[Lldb-commits] [PATCH] D60817: [NativePDB] Add anonymous namespaces support

2019-04-22 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358873: [NativePDB] Add anonymous namespaces support 
(authored by aleksandr.urakov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60817?vs=195863&id=196037#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60817

Files:
  lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
  lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp
  lldb/trunk/lit/SymbolFile/NativePDB/typedefs.cpp
  lldb/trunk/lit/SymbolFile/PDB/ast-restore.test
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h

Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
@@ -59,8 +59,6 @@
   clang::DeclContext *GetOrCreateDeclContextForUid(PdbSymUid uid);
   clang::DeclContext *GetParentDeclContext(PdbSymUid uid);
 
-  clang::NamespaceDecl *GetOrCreateNamespaceDecl(llvm::StringRef name,
- clang::DeclContext &context);
   clang::FunctionDecl *GetOrCreateFunctionDecl(PdbCompilandSymId func_id);
   clang::BlockDecl *GetOrCreateBlockDecl(PdbCompilandSymId block_id);
   clang::VarDecl *GetOrCreateVariableDecl(PdbCompilandSymId scope_id,
@@ -114,6 +112,9 @@
   clang::DeclContext *
   GetParentDeclContextForSymbol(const llvm::codeview::CVSymbol &sym);
 
+  clang::NamespaceDecl *GetOrCreateNamespaceDecl(const char *name,
+ clang::DeclContext &context);
+
   void ParseAllNamespacesPlusChildrenOf(llvm::Optional parent);
   void ParseDeclsForSimpleContext(clang::DeclContext &context);
   void ParseBlockChildren(PdbCompilandSymId block_id);
Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -205,6 +205,10 @@
   return std::move(child);
 }
 
+static bool IsAnonymousNamespaceName(llvm::StringRef name) {
+  return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
+}
+
 PdbAstBuilder::PdbAstBuilder(ObjectFile &obj, PdbIndex &index)
 : m_index(index), m_clang(GetClangASTContext(obj)) {
   BuildParentMap();
@@ -256,7 +260,7 @@
 for (llvm::ms_demangle::Node *scope : scopes) {
   auto *nii = static_cast(scope);
   std::string str = nii->toString();
-  context = m_clang.GetUniqueNamespaceDeclaration(str.c_str(), context);
+  context = GetOrCreateNamespaceDecl(str.c_str(), *context);
 }
 return {context, uname};
   }
@@ -525,7 +529,7 @@
   // If that fails, treat it as a series of namespaces.
   for (const MSVCUndecoratedNameSpecifier &spec : specs) {
 std::string ns_name = spec.GetBaseName().str();
-context = m_clang.GetUniqueNamespaceDeclaration(ns_name.c_str(), context);
+context = GetOrCreateNamespaceDecl(ns_name.c_str(), *context);
   }
   return {context, uname};
 }
@@ -568,7 +572,7 @@
   clang::DeclContext *context = &GetTranslationUnitDecl();
   while (!name_components.empty()) {
 std::string ns = name_components.front()->toString();
-context = m_clang.GetUniqueNamespaceDeclaration(ns.c_str(), context);
+context = GetOrCreateNamespaceDecl(ns.c_str(), *context);
 name_components = name_components.drop_front();
   }
   return context;
@@ -805,9 +809,10 @@
 }
 
 clang::NamespaceDecl *
-PdbAstBuilder::GetOrCreateNamespaceDecl(llvm::StringRef name,
+PdbAstBuilder::GetOrCreateNamespaceDecl(const char *name,
 clang::DeclContext &context) {
-  return m_clang.GetUniqueNamespaceDeclaration(name.str().c_str(), &context);
+  return m_clang.GetUniqueNamespaceDeclaration(
+  IsAnonymousNamespaceName(name) ? nullptr : name, &context);
 }
 
 clang::BlockDecl *
Index: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
===
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
@@ -10,11 +10,16 @@
 target variable AC0
 target variable ACNeg1
 
+target variable AC1D
 target variable AC0D
 target variable ACNeg1D
 target variable AD
 target variable ADE
 
+target variable AnonInt
+target variable AnonABCVoid
+target variable AnonABCVoidD
+
 target modules dump ast
 
 quit
Index: lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp
===
--- lldb/trunk/lit/SymbolFile/NativePDB/ast-ty

[Lldb-commits] [lldb] r358873 - [NativePDB] Add anonymous namespaces support

2019-04-22 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Mon Apr 22 00:14:40 2019
New Revision: 358873

URL: http://llvm.org/viewvc/llvm-project?rev=358873&view=rev
Log:
[NativePDB] Add anonymous namespaces support

Summary:
This patch adds anonymous namespaces support to the native PDB plugin.

I had to reference from the main function variables of the types that are inside
of the anonymous namespace to include them in debug info. Without the references
they are not included. I think it's because they are static, then are visible
only in the current translation unit, so they are not needed without any
references to them.

There is also the problem case with variables of types that are nested in
template structs. For now I've left FIXME in the test because this case is not
related to the change.

Reviewers: zturner, asmith, labath, stella.stamenova, amccarth

Reviewed By: amccarth

Subscribers: zloyrobot, aprantl, teemperor, lldb-commits, leonid.mashinskiy

Tags: #lldb

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

Modified:
lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp
lldb/trunk/lit/SymbolFile/NativePDB/typedefs.cpp
lldb/trunk/lit/SymbolFile/PDB/ast-restore.test
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h

Modified: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit?rev=358873&r1=358872&r2=358873&view=diff
==
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit (original)
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/ast-types.lldbinit Mon Apr 22 
00:14:40 2019
@@ -10,11 +10,16 @@ target variable ABCVoid
 target variable AC0
 target variable ACNeg1
 
+target variable AC1D
 target variable AC0D
 target variable ACNeg1D
 target variable AD
 target variable ADE
 
+target variable AnonInt
+target variable AnonABCVoid
+target variable AnonABCVoidD
+
 target modules dump ast
 
 quit

Modified: lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp?rev=358873&r1=358872&r2=358873&view=diff
==
--- lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp (original)
+++ lldb/trunk/lit/SymbolFile/NativePDB/ast-types.cpp Mon Apr 22 00:14:40 2019
@@ -72,15 +72,18 @@ A::B::C ABCVoid;
 A::C<0> AC0;
 A::C<-1> ACNeg1;
 
+// FIXME: The type `D` is located now at the level of the translation unit.
+// FIXME: Should be located in the namespace `A`, in the struct `C<1>`.
+A::C<1>::D AC1D;
+
 A::C<0>::D AC0D;
 A::C<-1>::D ACNeg1D;
 A::D AD;
 A::D::E ADE;
 
-// FIXME: Anonymous namespaces aren't working correctly.
 Anonymous AnonInt;
 Anonymous> AnonABCVoid;
-Anonymous>::D AnonABCVoidD;
+Anonymous>::D AnonABCVoidD;
 
 // FIXME: Enum size isn't being correctly determined.
 // FIXME: Can't read memory for variable values.
@@ -94,10 +97,14 @@ Anonymous>::D AnonABCVoidD;
 // CHECK: (A::B::C) ABCVoid = (ABCSpecializationMember = 0x{{0+}})
 // CHECK: (A::C<0>) AC0 = {}
 // CHECK: (A::C<-1>) ACNeg1 = {}
+// CHECK: (A::C<1>::D) AC1D = (ACDMember = 0, CPtr = 0x{{0+}})
 // CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x{{0+}})
 // CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x{{0+}})
 // CHECK: (A::D) AD = {}
 // CHECK: (A::D::E) ADE = (ADDMember = 0)
+// CHECK: ((anonymous namespace)::Anonymous) AnonInt = (AnonymousMember = 
0)
+// CHECK: ((anonymous namespace)::Anonymous>) AnonABCVoid = 
(AnonymousMember = 0)
+// CHECK: ((anonymous namespace)::Anonymous>::D) AnonABCVoidD = 
(AnonymousDMember = 0)
 // CHECK: Dumping clang ast for 1 modules.
 // CHECK: TranslationUnitDecl {{.*}}
 // CHECK: |-CXXRecordDecl {{.*}} class TrivialC definition
@@ -113,6 +120,10 @@ Anonymous>::D AnonABCVoidD;
 // CHECK: | | | `-FieldDecl {{.*}} ABCMember 'float'
 // CHECK: | | `-CXXRecordDecl {{.*}} struct C definition
 // CHECK: | |   `-FieldDecl {{.*}} ABCSpecializationMember 'void *'
+// FIXME: | |-CXXRecordDecl {{.*}} struct C<1> definition
+// FIXME: | | `-CXXRecordDecl {{.*}} class D definition
+// FIXME: | |   |-FieldDecl {{.*}} ACDMember 'int'
+// FIXME: | |   `-FieldDecl {{.*}} CPtr 'A::C<1> *'
 // CHECK: | |-CXXRecordDecl {{.*}} struct C<0> definition
 // CHECK: | | `-CXXRecordDecl {{.*}} class D definition
 // CHECK: | |   |-FieldDecl {{.*}} ACDMember 'int'
@@ -125,7 +136,18 @@ Anonymous>::D AnonABCVoidD;
 // CHECK: | `-CXXRecordDecl {{.*}} struct D definition
 // CHECK: |   `-CXXRecordDecl {{.*}} struct E definition
 // CHECK: | `-FieldDecl {{.*}} ADDMember 'int'
+// CHECK: |-NamespaceDecl
+// CHECK: | |-CXXRecordDecl {{.*}} struct Anonymous definition
+// CHECK: | | `-FieldDecl {{.*}} AnonymousMember 'int'
+// CHECK: | `

[Lldb-commits] [PATCH] D59015: [lldb-mi] Include full path in the -data-disassemble response

2019-04-22 Thread Anton Kolesov via Phabricator via lldb-commits
anton.kolesov added inline comments.



Comment at: lldb/tools/lldb-mi/MICmdCmdData.cpp:419
+  // Get a full path to the file.
+  std::unique_ptr pPathBuffer(new char[PATH_MAX]);
+  lineEntry.GetFileSpec().GetPath(pPathBuffer.get(), PATH_MAX);

clayborg wrote:
> Confused as to why we are calling malloc and free here for pPathBuffer? Why 
> not just:
> ```
> char pPathBuffer[PATH_MAX];
> ```
I don't have a strong opinion on this, so to maintain consistency in the code 
I'm trying to use what other code in lldb-mi uses in similar situations - which 
is either unique_ptr or static local variable, but I presume it was decided 
that second approach is not good. FWIW, If I were to write code without regard 
of what is being done in the same project, then I would never ever had a 
variable named "miValueConst5".


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59015



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


[Lldb-commits] [PATCH] D60962: [NativePDB] Extend .pdb files search folders

2019-04-22 Thread Mikhail Senkov via Phabricator via lldb-commits
zloyrobot created this revision.
zloyrobot added reviewers: amccarth, asmith, stella.stamenova.
zloyrobot added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor.

This patch adds ability to find .pdb files in NT_SYMBOL_PATH folders and in 
.exe file folder


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D60962

Files:
  lldb/lit/SymbolFile/NativePDB/Inputs/pdb-file-lookup.lldbinit
  lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -106,6 +106,43 @@
   return File;
 }
 
+
+static std::string findPdbFile(const llvm::StringRef exe_path, const llvm::StringRef pdb_file, llvm::file_magic &magic) {
+  auto ec = llvm::identify_magic(pdb_file, magic);
+  if (!ec)
+return pdb_file;
+
+  auto pdb_file_name = llvm::sys::path::filename(pdb_file);
+
+  llvm::SmallString<128> path = exe_path;
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, pdb_file_name);
+
+  ec = llvm::identify_magic(path, magic);
+  if (!ec)
+return path.str();
+
+  llvm::StringRef nt_symbol_path = ::getenv("_NT_SYMBOL_PATH");
+  llvm::SmallVector parts;
+  nt_symbol_path.split(parts, ';', -1, false);
+
+  for (auto part_ref : parts)  {
+if (part_ref.startswith_lower("srv*")) {
+  //Symbol servers is not supported yet
+  continue;
+}
+
+path = part_ref;
+llvm::sys::path::append(path, pdb_file_name);
+
+ec = llvm::identify_magic(path, magic);
+if (!ec) {
+  return path.str();
+}
+  }
+
+  return {};
+}
 static std::unique_ptr
 loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
   // Try to find a matching PDB for an EXE.
@@ -130,13 +167,14 @@
   if (ec)
 return nullptr;
 
+  llvm::file_magic magic;
+  auto pdb_full_path = findPdbFile(exe_path, pdb_file, magic);
+
   // if the file doesn't exist, is not a pdb, or doesn't have a matching guid,
   // fail.
-  llvm::file_magic magic;
-  ec = llvm::identify_magic(pdb_file, magic);
-  if (ec || magic != llvm::file_magic::pdb)
+  if (pdb_full_path.empty() || magic != llvm::file_magic::pdb)
 return nullptr;
-  std::unique_ptr pdb = loadPDBFile(pdb_file, allocator);
+  std::unique_ptr pdb = loadPDBFile(pdb_full_path, allocator);
   if (!pdb)
 return nullptr;
 
Index: lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
===
--- /dev/null
+++ lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
@@ -0,0 +1,24 @@
+// clang-format off
+// REQUIRES: lld
+
+// Test that we can find .pdb file in folder containing .exe file.
+// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
+// RUN: mkdir -p %t
+// RUN: mv %t.pdb %t/pdb-file-lookup.cpp.tmp.pdb
+// RUN: env _NT_SYMBOL_PATH=%t LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
+// RUN: %p/Inputs/pdb-file-lookup.lldbinit | FileCheck %s
+
+
+int main(int argc, char **argv) {
+  // Here are some comments.
+  return 0;
+}
+
+// CHECK: (lldb) source list -n main
+// CHECK: File: {{.*}}pdb-file-lookup.cpp
+// CHECK:11
+// CHECK:12   int main(int argc, char **argv) {
+// CHECK:13 // Here are some comments.
+// CHECK:14 return 0;
+// CHECK:15   }
+// CHECK:16
Index: lldb/lit/SymbolFile/NativePDB/Inputs/pdb-file-lookup.lldbinit
===
--- /dev/null
+++ lldb/lit/SymbolFile/NativePDB/Inputs/pdb-file-lookup.lldbinit
@@ -0,0 +1,2 @@
+source list -n main
+quit
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D60963: Fix dereferencing null pointer

2019-04-22 Thread Mikhail Senkov via Phabricator via lldb-commits
zloyrobot created this revision.
zloyrobot added reviewers: amccarth, thakis.
zloyrobot added a project: LLDB.
Herald added subscribers: llvm-commits, lldb-commits, erik.pilkington, 
hiraditya.
Herald added a project: LLVM.

All callers of Demangler::parseTagUniqueName check 'Demangler.Error' and assume 
that 'Error is false' means 'return value is not null'


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D60963

Files:
  llvm/lib/Demangle/MicrosoftDemangle.cpp


Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -735,11 +735,15 @@
 }
 
 TagTypeNode *Demangler::parseTagUniqueName(StringView &MangledName) {
-  if (!MangledName.consumeFront(".?A"))
+  if (!MangledName.consumeFront(".?A")) {
+Error = true;
 return nullptr;
+  }
   MangledName.consumeFront(".?A");
-  if (MangledName.empty())
+  if (MangledName.empty()) {
+Error = true;
 return nullptr;
+  }
 
   return demangleClassType(MangledName);
 }


Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -735,11 +735,15 @@
 }
 
 TagTypeNode *Demangler::parseTagUniqueName(StringView &MangledName) {
-  if (!MangledName.consumeFront(".?A"))
+  if (!MangledName.consumeFront(".?A")) {
+Error = true;
 return nullptr;
+  }
   MangledName.consumeFront(".?A");
-  if (MangledName.empty())
+  if (MangledName.empty()) {
+Error = true;
 return nullptr;
+  }
 
   return demangleClassType(MangledName);
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59015: [lldb-mi] Include full path in the -data-disassemble response

2019-04-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/tools/lldb-mi/MICmdCmdData.cpp:419
+  // Get a full path to the file.
+  std::unique_ptr pPathBuffer(new char[PATH_MAX]);
+  lineEntry.GetFileSpec().GetPath(pPathBuffer.get(), PATH_MAX);

anton.kolesov wrote:
> clayborg wrote:
> > Confused as to why we are calling malloc and free here for pPathBuffer? Why 
> > not just:
> > ```
> > char pPathBuffer[PATH_MAX];
> > ```
> I don't have a strong opinion on this, so to maintain consistency in the code 
> I'm trying to use what other code in lldb-mi uses in similar situations - 
> which is either unique_ptr or static local variable, but I presume it was 
> decided that second approach is not good. FWIW, If I were to write code 
> without regard of what is being done in the same project, then I would never 
> ever had a variable named "miValueConst5".
I would just use a local variable on the stack as I suggested. static variables 
are not correct and should never be used in cases like this, so if you see 
other errors, might be a good idea to submit a patch and improve lldb-mi. I am 
all for consistency where it makes sense, but I am also for fixing issues when 
we see them. 


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59015



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


[Lldb-commits] [PATCH] D60948: yamlify TestMiniDumpUUID binaries

2019-04-22 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added inline comments.
This revision is now accepted and ready to land.



Comment at: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-zero-uuids.yaml:5
+Processor Arch:  AMD64
+Platform ID: MacOSX
+CSD Version: '15E216'

labath wrote:
> @clayborg: The OS in this minidump is inconsistent with the file name. Do you 
> want me to rename the file, or change the OS in the minidump?
Lets change the OS


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

https://reviews.llvm.org/D60948



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


[Lldb-commits] [PATCH] D60968: WIP, RFC: Add an example of how LLDB python plug-in could look like

2019-04-22 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov created this revision.
apolyakov added reviewers: jingham, aprantl, labath.
Herald added a project: LLDB.

This commit shows how LLDB python plug-in could look like.

Such an approach allows users to use LLDB for OS kernel debugging, for doing 
that they only need to implement two interfaces: `OperatingSystemInterface` and 
`OSThread`.  As an example, this patch contains `zephyr.py` file with simple 
plug-in implementation for Zephyr OS, OS-specific files could live in OS' 
repository and evolve alongside it.

In the future, arch-specific code, e.g. `arc.py`, can be eliminated since LLDB 
already implements that functionality.

Remaining code can be upstreamed to LLDB with or without significant changes, 
the main idea of the review is to discuss these changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60968

Files:
  lldb/examples/python/lldb-os-plugin/arch/__init__.py
  lldb/examples/python/lldb-os-plugin/arch/arc.py
  lldb/examples/python/lldb-os-plugin/arch/common.py
  lldb/examples/python/lldb-os-plugin/core/__init__.py
  lldb/examples/python/lldb-os-plugin/core/cvalue.py
  lldb/examples/python/lldb-os-plugin/core/operating_system.py
  lldb/examples/python/lldb-os-plugin/core/osplugin_common.py
  lldb/examples/python/lldb-os-plugin/core/register_set_common.py
  lldb/examples/python/lldb-os-plugin/core/thread.py
  lldb/examples/python/lldb-os-plugin/logging.yaml
  lldb/examples/python/lldb-os-plugin/logs/.gitkeep
  lldb/examples/python/lldb-os-plugin/utilities/helpers.py
  lldb/examples/python/lldb-os-plugin/utilities/tracing.py
  lldb/examples/python/lldb-os-plugin/zephyr.py

Index: lldb/examples/python/lldb-os-plugin/zephyr.py
===
--- /dev/null
+++ lldb/examples/python/lldb-os-plugin/zephyr.py
@@ -0,0 +1,156 @@
+import logging
+
+from typing import Iterator
+
+import lldb
+
+from core.operating_system import *
+from core.osplugin_common import *
+from core.cvalue import *
+from arch.common import *
+from utilities.helpers import *
+
+# Common defines.
+ZEPHYR_THREAD_TYPE = 'struct k_thread'
+
+# ARC-related defines.
+ARC_CALLEE_SAVED_TYPE = 'struct _callee_saved_stack'
+ARC_IRQ_STACK_FRAME_TYPE = 'struct _irq_stack_frame'
+ARC_REGISTER_TYPE = 'u32_t'
+ARC_CAUSE_NONE = 0
+ARC_CAUSE_COOP = 1
+ARC_CAUSE_RIRQ = 2
+ARC_CAUSE_FIRQ = 3
+
+logger = logging.getLogger(__name__)
+
+
+def create_k_thread(target: lldb.SBTarget, address: int) -> value:
+return create_value_from_address(target, ZEPHYR_THREAD_TYPE, address)
+
+
+class ZephyrThread(OSThread):
+
+def __init__(self, target: lldb.SBTarget, arch: str, address: int, is_active: bool = False):
+self._k_thread = create_k_thread(target, address)
+
+# Zephyr thread has 'name' attribute only if CONFIG_THREAD_NAME option is enabled.
+try:
+th_name = self._k_thread.name
+except AttributeError:
+super().__init__(target, arch, address, address, is_active=is_active)
+return
+
+super().__init__(target, arch, address, address, name=str(th_name), is_active=is_active)
+
+def _arc_register_context_create(self) -> Dict[str, int]:
+stack_ptr = unsigned(self._callee_saved.sp)
+
+registers = register_value_to_dict(
+create_value_from_address(self.target, ARC_CALLEE_SAVED_TYPE, stack_ptr))
+
+callee_saved_size = self.target.FindFirstType(ARC_CALLEE_SAVED_TYPE).GetByteSize()
+
+relinquish_cause = self._thread_arch.relinquish_cause
+if relinquish_cause == ARC_CAUSE_NONE:
+logger.warning(f'Bad relinquish cause for thread {hex(self.id)}')
+elif relinquish_cause == ARC_CAUSE_COOP:
+stack_ptr += callee_saved_size + 4
+# TODO: check status32' AE bit
+status32 = register_value_to_dict(create_value_from_address(
+self.target, ARC_REGISTER_TYPE, stack_ptr, 'status32'))
+pc = register_value_to_dict(create_value_from_address(
+self.target, ARC_REGISTER_TYPE, stack_ptr + 4, 'pc'))
+
+registers = {**registers, **status32, **pc}
+# In case of returning from coop, we should also copy BLINK to PC, STATUS32 to R3, and restore SP.
+registers['blink'] = registers['pc']
+registers['r3'] = registers['status32']
+registers['sp'] = stack_ptr + 8
+elif relinquish_cause == ARC_CAUSE_RIRQ or relinquish_cause == ARC_CAUSE_FIRQ:
+irq_stack_frame_ptr = stack_ptr + callee_saved_size
+irq_stack_frame = register_value_to_dict(create_value_from_address(
+self.target, ARC_IRQ_STACK_FRAME_TYPE, irq_stack_frame_ptr))
+# Restore SP.
+irq_stack_frame_size = self.target.FindFirstType(ARC_IRQ_STACK_FRAME_TYPE).GetByteSize()
+irq_stack_frame['sp'] = irq_stack_frame_ptr + irq_stack_frame_size + 4
+
+registers = {**registers, **irq_s

[Lldb-commits] [PATCH] D60968: WIP, RFC: Add an example of how LLDB python plug-in could look like

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

Not sure what functionality this really adds? It seems to just wrap the OS 
plug-in python class in a different way?




Comment at: lldb/examples/python/lldb-os-plugin/arch/arc.py:15
+# Find the location of registers description file.
+_interp = lldb.debugger.GetCommandInterpreter()
+_result = lldb.SBCommandReturnObject()

We really shouldn't be using the "lldb.debugger" in the script, we would want 
this to be supplied to a function call. Top level code isn't always a great 
idea. If you import this module before the process is loaded 
"plugin.process.icd.hardware.registers" might not be available.



Comment at: lldb/examples/python/lldb-os-plugin/core/cvalue.py:1-7
+from typing import Any
+
+from utilities.tracing import traced
+
+import lldb
+
+

this is already in lldb.value in the lldb module. did you make additions to it? 
If so, modify that and remove this file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60968



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


[Lldb-commits] [PATCH] D60608: Make TestVSCode_step pass reliably

2019-04-22 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe added a comment.

Thanks for the fix!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60608



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


[Lldb-commits] [PATCH] D60968: WIP, RFC: Add an example of how LLDB python plug-in could look like

2019-04-22 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov marked an inline comment as done.
apolyakov added a comment.

In D60968#1474470 , @clayborg wrote:

> Not sure what functionality this really adds? It seems to just wrap the OS 
> plug-in python class in a different way?


You are right, for now the patch doesn't add new functionality, but this 
approach allows us to extend LLDB in a more flexible way, for example, if 
someday LLDB supports `CPU ID`, we will be able to fetch it from OS threads 
without modifying client's code.




Comment at: lldb/examples/python/lldb-os-plugin/arch/arc.py:15
+# Find the location of registers description file.
+_interp = lldb.debugger.GetCommandInterpreter()
+_result = lldb.SBCommandReturnObject()

clayborg wrote:
> We really shouldn't be using the "lldb.debugger" in the script, we would want 
> this to be supplied to a function call. Top level code isn't always a great 
> idea. If you import this module before the process is loaded 
> "plugin.process.icd.hardware.registers" might not be available.
Thanks, I will consider it.



Comment at: lldb/examples/python/lldb-os-plugin/core/cvalue.py:1-7
+from typing import Any
+
+from utilities.tracing import traced
+
+import lldb
+
+

clayborg wrote:
> this is already in lldb.value in the lldb module. did you make additions to 
> it? If so, modify that and remove this file
Yes I did. For now it's here just for example of how it could be modified in 
comparison to lldb.value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60968



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


[Lldb-commits] [lldb] r358916 - [Reproducers] Fix lifetime issue

2019-04-22 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Mon Apr 22 13:05:02 2019
New Revision: 358916

URL: http://llvm.org/viewvc/llvm-project?rev=358916&view=rev
Log:
[Reproducers] Fix lifetime issue

Deallocating the data recorder in during the ::Keep() operation causes
problems down the line when exiting the debugger. The command
interpreter still holds a pointer to the now deallocated object and has
no way to know it no longer exists. This is exactly what the m_record
flag was meant for, although it wasn't hooked up properly either.

Modified:
lldb/trunk/include/lldb/Utility/Reproducer.h
lldb/trunk/source/Utility/Reproducer.cpp

Modified: lldb/trunk/include/lldb/Utility/Reproducer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Reproducer.h?rev=358916&r1=358915&r2=358916&view=diff
==
--- lldb/trunk/include/lldb/Utility/Reproducer.h (original)
+++ lldb/trunk/include/lldb/Utility/Reproducer.h Mon Apr 22 13:05:02 2019
@@ -121,6 +121,8 @@ public:
   Create(FileSpec filename);
 
   template  void Record(const T &t, bool newline = false) {
+if (!m_record)
+  return;
 m_os << t;
 if (newline)
   m_os << '\n';

Modified: lldb/trunk/source/Utility/Reproducer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Reproducer.cpp?rev=358916&r1=358915&r2=358916&view=diff
==
--- lldb/trunk/source/Utility/Reproducer.cpp (original)
+++ lldb/trunk/source/Utility/Reproducer.cpp Mon Apr 22 13:05:02 2019
@@ -259,8 +259,6 @@ void CommandProvider::Keep() {
 return;
   yaml::Output yout(os);
   yout << files;
-
-  m_data_recorders.clear();
 }
 
 void CommandProvider::Discard() { m_data_recorders.clear(); }


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


[Lldb-commits] [lldb] r358918 - [EditLineTest] Not always TERM is available, e.g. on some bots.

2019-04-22 Thread Davide Italiano via lldb-commits
Author: davide
Date: Mon Apr 22 13:27:10 2019
New Revision: 358918

URL: http://llvm.org/viewvc/llvm-project?rev=358918&view=rev
Log:
[EditLineTest] Not always TERM is available, e.g. on some bots.

Modified:
lldb/trunk/unittests/Editline/EditlineTest.cpp

Modified: lldb/trunk/unittests/Editline/EditlineTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Editline/EditlineTest.cpp?rev=358918&r1=358917&r2=358918&view=diff
==
--- lldb/trunk/unittests/Editline/EditlineTest.cpp (original)
+++ lldb/trunk/unittests/Editline/EditlineTest.cpp Mon Apr 22 13:27:10 2019
@@ -244,17 +244,19 @@ private:
   EditlineAdapter _el_adapter;
   std::shared_ptr _sp_output_thread;
 
+protected:
+  bool _has_term = true;
+
 public:
   void SetUp() {
 FileSystem::Initialize();
 
 // We need a TERM set properly for editline to work as expected.
-setenv("TERM", "vt100", 1);
+if (setenv("TERM", "vt100", 1) != 0)
+  _has_term = false;
 
 // Validate the editline adapter.
 EXPECT_TRUE(_el_adapter.IsValid());
-if (!_el_adapter.IsValid())
-  return;
 
 // Dump output.
 _sp_output_thread =
@@ -273,6 +275,10 @@ public:
 };
 
 TEST_F(EditlineTestFixture, EditlineReceivesSingleLineText) {
+  // Skip if we don't have a TERM.
+  if (!_has_term)
+return;
+
   // Send it some text via our virtual keyboard.
   const std::string input_text("Hello, world");
   EXPECT_TRUE(GetEditlineAdapter().SendLine(input_text));
@@ -289,6 +295,10 @@ TEST_F(EditlineTestFixture, EditlineRece
 }
 
 TEST_F(EditlineTestFixture, EditlineReceivesMultiLineText) {
+  // Skip if we don't have a TERM.
+  if (!_has_term)
+return;
+
   // Send it some text via our virtual keyboard.
   std::vector input_lines;
   input_lines.push_back("int foo()");


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


[Lldb-commits] [PATCH] D60962: [NativePDB] Extend .pdb files search folders

2019-04-22 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added inline comments.



Comment at: lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp:4
+
+// Test that we can find .pdb file in folder containing .exe file.
+// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 

Is this not testing finding the PDB file in the _NT_SYMBOL_PATH?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60962



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


[Lldb-commits] [PATCH] D60829: FuncUnwinders: remove "current_offset" from function arguments

2019-04-22 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

Sorry for the delay in looking at this.  It looks like a good change, an 
improvement on the original for sure.  I've never seen multiple eh_frame FDEs 
for a single function, so that's fine.  The .ARM.exidx format and Apple's 
compact unwind format can theoretically have multiple different unwind plans 
for a single function - but I've never seen it done in practice.  More 
commonly, a single unwind plan will be used for multiple functions that have 
the same unwind state.  (these two formats don't describe prologue/epilogues - 
they only describe the unwind state in the middle of the function where 
exceptions can be thrown)


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

https://reviews.llvm.org/D60829



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


[Lldb-commits] [lldb] r358924 - Rename C++ TestGlobalVariables.py to have a distinct name from C version.

2019-04-22 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Mon Apr 22 15:16:33 2019
New Revision: 358924

URL: http://llvm.org/viewvc/llvm-project?rev=358924&view=rev
Log:
Rename C++ TestGlobalVariables.py to have a distinct name from C version.

Added:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestCPPGlobalVariables.py
Removed:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestCPPGlobalVariables.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestCPPGlobalVariables.py?rev=358924&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestCPPGlobalVariables.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestCPPGlobalVariables.py
 Mon Apr 22 15:16:33 2019
@@ -0,0 +1,41 @@
+"""Test that C++ global variables can be inspected by name and also their 
mangled name."""
+
+from __future__ import print_function
+
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class GlobalVariablesCppTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.source = lldb.SBFileSpec('main.cpp')
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+def test(self):
+self.build()
+
+(target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set 
break point at this line.", self.source)
+
+# Check that we can access g_file_global_int by its name
+self.expect("target variable g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable abc::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+self.expect("target variable xyz::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
+error=True, substrs=['can\'t find global variable'])
+
+# Check that we can access g_file_global_int by its mangled name
+addr = 
target.EvaluateExpression("&abc::g_file_global_int").GetValueAsUnsigned()
+self.assertTrue(addr != 0)
+mangled = lldb.SBAddress(addr, target).GetSymbol().GetMangledName()
+self.assertTrue(mangled != None)
+gv = target.FindFirstGlobalVariable(mangled)
+self.assertTrue(gv.IsValid())
+self.assertEqual(gv.GetName(), "abc::g_file_global_int")
+self.assertEqual(gv.GetValueAsUnsigned(), 42)

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py?rev=358923&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/global_variables/TestGlobalVariables.py
 (removed)
@@ -1,41 +0,0 @@
-"""Test that C++ global variables can be inspected by name and also their 
mangled name."""
-
-from __future__ import print_function
-
-
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class GlobalVariablesCppTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-TestBase.setUp(self)
-self.source = lldb.SBFileSpec('main.cpp')
-
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-def test(self):
-self.build()
-
-(target, _, _, _) = lldbutil.run_to_source_breakpoint(self, "// Set 
break point at this line.", self.source)
-
-# Check that we can access g_file_global_int by its name
-self.expect("target variable g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['42'])
-self.expect("target variable abc::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
-substrs=['42'])
-self.expect("target variable xyz::g_file_global_int", 
VARIABLES_DISPLAYED_CORRECTLY,
-error=True, substrs=['can\'t find global variable'])
-
-# Check that we can access g_file_global_int by its mangled name
-addr = 
target.EvaluateExpression("&abc::g_file_global_int").GetValueAsUnsigned()
-self.assertTrue(addr != 0)
-mangled = lldb.SBAddress(addr, target).GetSymbol().GetMangledName()
-self.assertTrue(mangled != None)
-gv = target.FindFirstGlobalVariable(mangled)
-self.assertTrue(gv.IsValid())
-self.assertEqual(gv.GetName(), "abc::g_file_global_int")
- 

[Lldb-commits] [PATCH] D60984: [Reproducers] Limit logging to calls that cross the API boundary.

2019-04-22 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: jasonmolenda, jingham, labath.
Herald added a project: LLDB.

We recently moved API logging into the instrumentation macros. This made that 
logging is now consistent and abstracted behind a macro for every API 
functions, independent of the reproducers. It also means we have a lot more 
output. While this is a good thing, it also meant a lot more noise in the log, 
from things that aren't always equally interesting, such as the copy 
constructor for example.

To improve usability, we should increase the signal-to-noise ratio. I propose 
to achieve this by only logging API functions that cross the API boundary. This 
is a divergence of what we had before, where a select number of functions were 
logged, irregardless of the API boundary, a concept that was introduced for the 
reproducers. However, I believe this is in line with the purpose of the API log.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D60984

Files:
  lldb/include/lldb/Utility/ReproducerInstrumentation.h
  lldb/source/Utility/ReproducerInstrumentation.cpp

Index: lldb/source/Utility/ReproducerInstrumentation.cpp
===
--- lldb/source/Utility/ReproducerInstrumentation.cpp
+++ lldb/source/Utility/ReproducerInstrumentation.cpp
@@ -101,14 +101,16 @@
   return m_mapping[object];
 }
 
-Recorder::Recorder(Serializer &serializer, Registry ®istry,
-   llvm::StringRef pretty_func)
-: m_serializer(serializer), m_registry(registry),
-  m_pretty_func(pretty_func), m_local_boundary(false),
+Recorder::Recorder(llvm::StringRef pretty_func, std::string &&pretty_args)
+: m_serializer(nullptr), m_pretty_func(pretty_func),
+  m_pretty_args(pretty_args), m_local_boundary(false),
   m_result_recorded(true) {
   if (!g_global_boundary) {
 g_global_boundary = true;
 m_local_boundary = true;
+
+LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "{0} ({1})",
+ m_pretty_func, m_pretty_args);
   }
 }
 
@@ -117,13 +119,4 @@
   UpdateBoundary();
 }
 
-void Recorder::Log(unsigned id) {
-#ifndef LLDB_REPRO_INSTR_TRACE
-  LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "Recording {0}: {1}", id,
-   m_pretty_func);
-#else
-  llvm::errs() << "Recording " << id << ": " << m_pretty_func << "\n";
-#endif
-}
-
 bool lldb_private::repro::Recorder::g_global_boundary;
Index: lldb/include/lldb/Utility/ReproducerInstrumentation.h
===
--- lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -22,43 +22,44 @@
 
 template ::value, int>::type = 0>
-inline void log_append(llvm::raw_string_ostream &ss, const T &t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
   ss << t;
 }
 
 template ::value,
   int>::type = 0>
-inline void log_append(llvm::raw_string_ostream &ss, const T &t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
   ss << &t;
 }
 
 template 
-inline void log_append(llvm::raw_string_ostream &ss, const T *t) {
+inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) {
   ss << reinterpret_cast(t);
 }
 
 template <>
-inline void log_append(llvm::raw_string_ostream &ss, const char *t) {
+inline void stringify_append(llvm::raw_string_ostream &ss,
+   const char *t) {
   ss << t;
 }
 
 template 
-inline void log_helper(llvm::raw_string_ostream &ss, const Head &head) {
-  log_append(ss, head);
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) {
+  stringify_append(ss, head);
 }
 
 template 
-inline void log_helper(llvm::raw_string_ostream &ss, const Head &head,
-   const Tail &... tail) {
-  log_append(ss, head);
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head,
+ const Tail &... tail) {
+  stringify_append(ss, head);
   ss << ", ";
-  log_helper(ss, tail...);
+  stringify_helper(ss, tail...);
 }
 
-template  inline std::string log_args(const Ts &... ts) {
+template  inline std::string stringify_args(const Ts &... ts) {
   std::string buffer;
   llvm::raw_string_ostream ss(buffer);
-  log_helper(ss, ts...);
+  stringify_helper(ss, ts...);
   return ss.str();
 }
 
@@ -69,131 +70,111 @@
 
 #define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)\
   R.Register(&construct::doit, "", #Class, \
-  #Class, #Signature)
+#Class, #Signature)
 #define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) \
   R.Register(  \
   &invoke::method<(&Class::Method)>::doit, \
   #Result, #Class, #Method, #Signature)
 #define LLDB_REGISTER_METHOD_CONST(Res

[Lldb-commits] [lldb] r358928 - [Docs] Move API docs to the front page

2019-04-22 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Mon Apr 22 15:41:55 2019
New Revision: 358928

URL: http://llvm.org/viewvc/llvm-project?rev=358928&view=rev
Log:
[Docs] Move API docs to the front page

This moves the links to the C++ and Python API docs up to the main page.
As of now the links are still broken [1], but at least this will prevent
the additional frustration of searching for the links only to find out
they're broken.

[1] http://lists.llvm.org/pipermail/lldb-dev/2019-April/014992.html

Modified:
lldb/trunk/docs/index.rst
lldb/trunk/docs/resources/external.rst

Modified: lldb/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/index.rst?rev=358928&r1=358927&r2=358928&view=diff
==
--- lldb/trunk/docs/index.rst (original)
+++ lldb/trunk/docs/index.rst Mon Apr 22 15:41:55 2019
@@ -58,6 +58,13 @@ Resources
resources/sbapi
resources/external
 
+API Documentation
+=
+
+* `Python API Documentation 
`_
+* `C++ API Documentation 
`_
+
+
 Indices and tables
 ==
 

Modified: lldb/trunk/docs/resources/external.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/resources/external.rst?rev=358928&r1=358927&r2=358928&view=diff
==
--- lldb/trunk/docs/resources/external.rst (original)
+++ lldb/trunk/docs/resources/external.rst Mon Apr 22 15:41:55 2019
@@ -1,12 +1,6 @@
 External Resources
 ==
 
-Documentation
--
-
-* `Python API Documentation 
`_
-* `C++ API Documentation 
`_
-
 Bugs
 
 


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


[Lldb-commits] [PATCH] D60963: Fix dereferencing null pointer

2019-04-22 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

test?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60963



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


[Lldb-commits] [lldb] r358929 - Fix a bug in my change to ModulesDidLoad in r357955.

2019-04-22 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Mon Apr 22 15:42:29 2019
New Revision: 358929

URL: http://llvm.org/viewvc/llvm-project?rev=358929&view=rev
Log:
Fix a bug in my change to ModulesDidLoad in r357955.
In the process of hoisting the LoadScriptingResourceForModule
out of Target::ModuleAdded and into Target::ModulesDidLoad,
I had ModulesDidLoad fetching the Target's entire image list
and look for scripting resources in those -- instead of only
looking for scripting resources in the modules that had
been added to the target's image list.

 


Modified:
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/Target/Target.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=358929&r1=358928&r2=358929&view=diff
==
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Apr 22 15:42:29 2019
@@ -1651,12 +1651,10 @@ void Target::NotifyModulesRemoved(lldb_p
 
 
 void Target::ModulesDidLoad(ModuleList &module_list) {
-  if (m_valid && module_list.GetSize()) {
-
-const ModuleList &modules = GetImages();
-const size_t num_images = modules.GetSize();
+  const size_t num_images = module_list.GetSize();
+  if (m_valid && num_images) {
 for (size_t idx = 0; idx < num_images; ++idx) {
-  ModuleSP module_sp(modules.GetModuleAtIndex(idx));
+  ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
   LoadScriptingResourceForModule(module_sp, this);
 }
 m_breakpoint_list.UpdateBreakpoints(module_list, true, false);


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


[Lldb-commits] [lldb] r358938 - Add a small check to PlatformDarwin::LoadScriptingResourceForModule

2019-04-22 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Mon Apr 22 18:02:51 2019
New Revision: 358938

URL: http://llvm.org/viewvc/llvm-project?rev=358938&view=rev
Log:
Add a small check to PlatformDarwin::LoadScriptingResourceForModule
which reads the python files in a dSYM bundle, to check that the
SymbolFile is actually a dSYM bundle filepath; delay any fetching
of the ScriptInterpreter until after we've done that check.

When debugging a binary without a dSYM on darwin systems, the
SymbolFile we fetch is actually the ObjectFile -- so we would do
an unnecessary trip into Python land and stat around the filesystem
looking for a python file to read in.  There's no reason to do any
of this unless the SymbolFile's file path includes the .dSYM bundle
telltale path components.

 

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

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=358938&r1=358937&r2=358938&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Apr 22 
18:02:51 2019
@@ -68,8 +68,6 @@ FileSpecList PlatformDarwin::LocateExecu
 // precisely that. Ideally, we should have a per-platform list of
 // extensions (".exe", ".app", ".dSYM", ".framework") which should be
 // stripped while leaving "this.binary.file" as-is.
-ScriptInterpreter *script_interpreter =
-target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
 
 FileSpec module_spec = module.GetFileSpec();
 
@@ -81,7 +79,10 @@ FileSpecList PlatformDarwin::LocateExecu
   ObjectFile *objfile = symfile->GetObjectFile();
   if (objfile) {
 FileSpec symfile_spec(objfile->GetFileSpec());
-if (symfile_spec && FileSystem::Instance().Exists(symfile_spec)) {
+if (symfile_spec && 
+FileSystem::Instance().Exists(symfile_spec) && 
+strcasestr (symfile_spec.GetPath().c_str(), 
+".dSYM/Contents/Resources/DWARF") != nullptr) {
   while (module_spec.GetFilename()) {
 std::string module_basename(
 module_spec.GetFilename().GetCString());
@@ -103,6 +104,8 @@ FileSpecList PlatformDarwin::LocateExecu
  ' ', '_');
 std::replace(module_basename.begin(), module_basename.end(),
  '-', '_');
+ScriptInterpreter *script_interpreter =
+  
target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
 if (script_interpreter &&
 script_interpreter->IsReservedWord(
 module_basename.c_str())) {


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


[Lldb-commits] [lldb] r358939 - One small tweak to LocateExecutableScriptingResources - I

2019-04-22 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Mon Apr 22 18:13:27 2019
New Revision: 358939

URL: http://llvm.org/viewvc/llvm-project?rev=358939&view=rev
Log:
One small tweak to LocateExecutableScriptingResources - I
was still stat'ing the possibly-dSYM FileSpec before I
(more cheaply) checked the filepath for telltale dSYM
components.
 

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

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=358939&r1=358938&r2=358939&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Apr 22 
18:13:27 2019
@@ -80,9 +80,9 @@ FileSpecList PlatformDarwin::LocateExecu
   if (objfile) {
 FileSpec symfile_spec(objfile->GetFileSpec());
 if (symfile_spec && 
-FileSystem::Instance().Exists(symfile_spec) && 
 strcasestr (symfile_spec.GetPath().c_str(), 
-".dSYM/Contents/Resources/DWARF") != nullptr) {
+".dSYM/Contents/Resources/DWARF") != nullptr &&
+FileSystem::Instance().Exists(symfile_spec)) {
   while (module_spec.GetFilename()) {
 std::string module_basename(
 module_spec.GetFilename().GetCString());


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


[Lldb-commits] [PATCH] D60962: [NativePDB] Extend .pdb files search folders

2019-04-22 Thread Mikhail Senkov via Phabricator via lldb-commits
zloyrobot added inline comments.



Comment at: lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp:4
+
+// Test that we can find .pdb file in folder containing .exe file.
+// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 

stella.stamenova wrote:
> Is this not testing finding the PDB file in the _NT_SYMBOL_PATH?
Thanks for feedback, this description is wrong and test checks that we can find 
PDB file in the _NT_SYMBOL_PATH and doesn't check PDB file in folder containing 
EXE file.

I'll update test and make it test both cases.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D60962



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