[Lldb-commits] [PATCH] D53731: [NativePDB] Add the ability to display global variables

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
zturner added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h:46
+   // due to the debug magic at the beginning of the 
stream.
+  uint64_t global : 1; // True if this is from the globals stream.
+  uint64_t modi : 16;  // For non-global, this is the 0-based index of module.

lemo wrote:
> 30 + 1 != 32 - what's going on?
There's supposed to be a `uint64_t unused : 1;` here.  Thanks for noticing.



Comment at: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp:913
+
+  uint32_t section_idx = section - 1;
+  if (section_idx >= section_list->GetSize())

lemo wrote:
> comment explaining the - 1 ?
I'm going to be totally honest here.  I don't understand this code at all.  I 
copied it from the `SymbolFilePDB` implementation.  It seems to work :-/



Comment at: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp:936
+  lldb::ValueType scope = eValueTypeInvalid;
+  TypeIndex ti;
+  llvm::StringRef name;

lemo wrote:
> pls explicitly initialize all the locals
`TypeIndex` has a constructor, but I should definitely initialize the 
`lldb::addr_t`



Comment at: 
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp:1406
+  TypeSP type_sp = CreateAndCacheType(uid);
+  return &*type_sp;
 }

lemo wrote:
> type_sp->get() seems cleaner / more readable
You know, I kept trying to write that, and I was like "what silly person on the 
C++ standards committee forgot to put a `get()` method on `std::shared_ptr<>`.  
Did they really forget this or am I just going crazy?"  Turns out it's a bug in 
MSVC intellisense where it doesn't show it for some reason.  So I took that to 
mean it didn't exist.  Shame on me.


https://reviews.llvm.org/D53731



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


[Lldb-commits] [PATCH] D53731: [NativePDB] Add the ability to display global variables

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
zturner added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp:913
+
+  uint32_t section_idx = section - 1;
+  if (section_idx >= section_list->GetSize())

zturner wrote:
> lemo wrote:
> > comment explaining the - 1 ?
> I'm going to be totally honest here.  I don't understand this code at all.  I 
> copied it from the `SymbolFilePDB` implementation.  It seems to work :-/
Ok, I thought about this some, it's actually pretty simple.  I'll add a comment.


https://reviews.llvm.org/D53731



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


[Lldb-commits] [PATCH] D53368: [Symbol] Search symbols with name and type in a symbol file

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 171267.
aleksandr.urakov added a comment.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

That's done!


https://reviews.llvm.org/D53368

Files:
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Symbol/SymbolVendor.h
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  source/Symbol/SymbolVendor.cpp
  unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -616,3 +616,20 @@
   EXPECT_EQ(0u, num_results);
   EXPECT_EQ(0u, results.GetSize());
 }
+
+TEST_F(SymbolFilePDBTests, TestFindSymbolsWithNameAndType) {
+  FileSpec fspec(m_pdb_test_exe.c_str(), false);
+  ArchSpec aspec("i686-pc-windows");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+
+  SymbolContextList sc_list;
+  EXPECT_EQ(1u,
+module->FindSymbolsWithNameAndType(ConstString("?foo@@YAHH@Z"),
+   lldb::eSymbolTypeAny, sc_list));
+  EXPECT_EQ(1u, sc_list.GetSize());
+
+  SymbolContext sc;
+  EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+  EXPECT_STREQ("int foo(int)",
+   sc.GetFunctionName(Mangled::ePreferDemangled).AsCString());
+}
Index: source/Symbol/SymbolVendor.cpp
===
--- source/Symbol/SymbolVendor.cpp
+++ source/Symbol/SymbolVendor.cpp
@@ -61,7 +61,7 @@
 //--
 SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp)
 : ModuleChild(module_sp), m_type_list(), m_compile_units(),
-  m_sym_file_ap() {}
+  m_sym_file_ap(), m_symtab() {}
 
 //--
 // Destructor
@@ -438,14 +438,26 @@
 
 Symtab *SymbolVendor::GetSymtab() {
   ModuleSP module_sp(GetModule());
-  if (module_sp) {
-ObjectFile *objfile = module_sp->GetObjectFile();
-if (objfile) {
-  // Get symbol table from unified section list.
-  return objfile->GetSymtab();
-}
-  }
-  return nullptr;
+  if (!module_sp)
+return nullptr;
+
+  std::lock_guard guard(module_sp->GetMutex());
+
+  if (m_symtab)
+return m_symtab;
+
+  ObjectFile *objfile = module_sp->GetObjectFile();
+  if (!objfile)
+return nullptr;
+
+  m_symtab = objfile->GetSymtab();
+  if (m_symtab && m_sym_file_ap)
+m_sym_file_ap->AddSymbols(*m_symtab);
+
+  m_symtab->CalculateSymbolSizes();
+  m_symtab->Finalize();
+
+  return m_symtab;
 }
 
 void SymbolVendor::ClearSymtab() {
Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -133,6 +133,8 @@
   const std::string &scope_qualified_name,
   std::vector &mangled_names) override;
 
+  void AddSymbols(lldb_private::Symtab &symtab) override;
+
   uint32_t
   FindTypes(const lldb_private::SymbolContext &sc,
 const lldb_private::ConstString &name,
Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1331,6 +1331,55 @@
 const std::string &scope_qualified_name,
 std::vector &mangled_names) {}
 
+void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) {
+  std::set sym_addresses;
+  for (size_t i = 0; i < symtab.GetNumSymbols(); i++)
+sym_addresses.insert(symtab.SymbolAtIndex(i)->GetFileAddress());
+
+  auto results = m_global_scope_up->findAllChildren();
+  if (!results)
+return;
+
+  auto section_list = m_obj_file->GetSectionList();
+  if (!section_list)
+return;
+
+  while (auto pub_symbol = results->getNext()) {
+auto section_idx = pub_symbol->getAddressSection() - 1;
+if (section_idx >= section_list->GetSize())
+  continue;
+
+auto section = section_list->GetSectionAtIndex(section_idx);
+if (!section)
+  continue;
+
+auto offset = pub_symbol->getAddressOffset();
+
+auto file_addr = section->GetFileAddress() + offset;
+if (sym_addresses.find(file_addr) != sym_addresses.end())
+  continue;
+sym_addresses.insert(file_addr);
+
+auto size = pub_symbol->getLength();
+symtab.AddSymbol(
+Symbol(pub_symbol->getSymIndexId(),   // symID
+   pub_symbol->getName().c_str(), // name
+   true,  // name_is_mangled
+   pub_

[Lldb-commits] [lldb] r345373 - [NativePDB] Add the ability to dump dump global variables.

2018-10-26 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Fri Oct 26 02:06:38 2018
New Revision: 345373

URL: http://llvm.org/viewvc/llvm-project?rev=345373&view=rev
Log:
[NativePDB] Add the ability to dump dump global variables.

LLDB has the ability to display global variables, even without a running
process, via the target variable command. This is because global
variables are linker initialized, so their values are embedded directly
into the executables. This gives us great power for testing native PDB
functionality in a cross-platform manner, because we don't actually need
a running process. We can just create a target using an EXE file, and
display global variables. And global variables can have arbitrarily
complex types, so in theory we can fully exercise the type system,
record layout, and data formatters for native PDB files and PE/COFF
executables on any host platform, as long as our type does not require a
dynamic initializer.

This patch adds basic support for finding variables by name, and adds an
exhaustive test for fundamental data types and pointers / references to
fundamental data types.

Subsequent patches will extend this to typedefs, classes, pointers to
functions, and other cases.

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

Added:
lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit
lldb/trunk/lit/SymbolFile/NativePDB/globals-fundamental.cpp
Modified:
lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Added: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit?rev=345373&view=auto
==
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit 
(added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit Fri 
Oct 26 02:06:38 2018
@@ -0,0 +1,220 @@
+target variable BFalse
+target variable BTrue
+target variable CA
+target variable CZ
+target variable SCa
+target variable SCz
+target variable UC24
+target variable UC42
+target variable C16_24
+target variable C32_42
+target variable WC1
+target variable WCP
+target variable SMax
+target variable SMin
+target variable USMax
+target variable USMin
+target variable IMax
+target variable IMin
+target variable UIMax
+target variable UIMin
+target variable LMax
+target variable LMin
+target variable ULMax
+target variable ULMin
+target variable LLMax
+target variable LLMin
+target variable ULLMax
+target variable ULLMin
+target variable F
+target variable D
+
+target variable CBFalse
+target variable CBTrue
+target variable CCA
+target variable CCZ
+target variable CSCa
+target variable CSCz
+target variable CUC24
+target variable CUC42
+target variable CC16_24
+target variable CC32_42
+target variable CWC1
+target variable CWCP
+target variable CSMax
+target variable CSMin
+target variable CUSMax
+target variable CUSMin
+target variable CIMax
+target variable CIMin
+target variable CUIMax
+target variable CUIMin
+target variable CLMax
+target variable CLMin
+target variable CULMax
+target variable CULMin
+target variable CLLMax
+target variable CLLMin
+target variable CULLMax
+target variable CULLMin
+target variable CF
+target variable CD
+
+target variable ConstexprBFalse
+target variable ConstexprBTrue
+target variable ConstexprCA
+target variable ConstexprCZ
+target variable ConstexprSCa
+target variable ConstexprSCz
+target variable ConstexprUC24
+target variable ConstexprUC42
+target variable ConstexprC16_24
+target variable ConstexprC32_42
+target variable ConstexprWC1
+target variable ConstexprWCP
+target variable ConstexprSMax
+target variable ConstexprSMin
+target variable ConstexprUSMax
+target variable ConstexprUSMin
+target variable ConstexprIMax
+target variable ConstexprIMin
+target variable ConstexprUIMax
+target variable ConstexprUIMin
+target variable ConstexprLMax
+target variable ConstexprLMin
+target variable ConstexprULMax
+target variable ConstexprULMin
+target variable ConstexprLLMax
+target variable ConstexprLLMin
+target variable ConstexprULLMax
+target variable ConstexprULLMin
+target variable ConstexprF
+target variable ConstexprD
+
+target variable PBFalse
+target variable PBTrue
+target variable PCA
+target variable PCZ
+target variable PSCa
+target variable PSCz
+target variable PUC24
+target variable PUC42
+target variable PC16_24
+target variable PC32_42
+target variable PWC1
+target variable PWCP
+target variable PSMax
+target variable PSMin
+target variable PUSMax
+target variable PUSMin
+target variable PIMax
+target variable PIMin
+target variable PUIMax
+target variable PUIMin
+target variable PLMax
+target variable PLMin
+target variable PULMax
+target variable PULMin
+target variable PLLMax
+target 

[Lldb-commits] [PATCH] D53731: [NativePDB] Add the ability to display global variables

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345373: [NativePDB] Add the ability to dump dump global 
variables. (authored by zturner, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53731?vs=171189&id=171268#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53731

Files:
  lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit
  lldb/trunk/lit/SymbolFile/NativePDB/globals-fundamental.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Index: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -16,14 +16,17 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamBuffer.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTImporter.h"
 #include "lldb/Symbol/ClangExternalASTSourceCommon.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Variable.h"
+#include "lldb/Symbol/VariableList.h"
 
 #include "llvm/DebugInfo/CodeView/CVRecord.h"
 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
@@ -887,6 +890,131 @@
   return CreateAndCacheType(type_uid);
 }
 
+static DWARFExpression MakeGlobalLocationExpression(uint16_t section,
+uint32_t offset,
+ModuleSP module) {
+  assert(section > 0);
+  assert(module);
+
+  const ArchSpec &architecture = module->GetArchitecture();
+  ByteOrder byte_order = architecture.GetByteOrder();
+  uint32_t address_size = architecture.GetAddressByteSize();
+  uint32_t byte_size = architecture.GetDataByteSize();
+  assert(byte_order != eByteOrderInvalid && address_size != 0);
+
+  RegisterKind register_kind = eRegisterKindDWARF;
+  StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order);
+  stream.PutHex8(DW_OP_addr);
+
+  SectionList *section_list = module->GetSectionList();
+  assert(section_list);
+
+  // Section indices in PDB are 1-based, but in DWARF they are 0-based, so we
+  // need to subtract 1.
+  uint32_t section_idx = section - 1;
+  if (section_idx >= section_list->GetSize())
+return DWARFExpression(nullptr);
+
+  auto section_ptr = section_list->GetSectionAtIndex(section_idx);
+  if (!section_ptr)
+return DWARFExpression(nullptr);
+
+  stream.PutMaxHex64(section_ptr->GetFileAddress() + offset, address_size,
+ byte_order);
+  DataBufferSP buffer =
+  std::make_shared(stream.GetData(), stream.GetSize());
+  DataExtractor extractor(buffer, byte_order, address_size, byte_size);
+  DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize());
+  result.SetRegisterKind(register_kind);
+  return result;
+}
+
+VariableSP SymbolFileNativePDB::CreateGlobalVariable(PdbSymUid var_uid) {
+  const PdbCuSymId &cu_sym = var_uid.asCuSym();
+  lldbassert(cu_sym.global);
+  CVSymbol sym = m_index->symrecords().readRecord(cu_sym.offset);
+  lldb::ValueType scope = eValueTypeInvalid;
+  TypeIndex ti;
+  llvm::StringRef name;
+  lldb::addr_t addr = 0;
+  uint16_t section = 0;
+  uint32_t offset = 0;
+  bool is_external = false;
+  switch (sym.kind()) {
+  case S_GDATA32:
+is_external = true;
+LLVM_FALLTHROUGH;
+  case S_LDATA32: {
+DataSym ds(sym.kind());
+llvm::cantFail(SymbolDeserializer::deserializeAs(sym, ds));
+ti = ds.Type;
+scope = (sym.kind() == S_GDATA32) ? eValueTypeVariableGlobal
+  : eValueTypeVariableStatic;
+name = ds.Name;
+section = ds.Segment;
+offset = ds.DataOffset;
+addr = m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset);
+break;
+  }
+  case S_GTHREAD32:
+is_external = true;
+LLVM_FALLTHROUGH;
+  case S_LTHREAD32: {
+ThreadLocalDataSym tlds(sym.kind());
+llvm::cantFail(
+SymbolDeserializer::deserializeAs(sym, tlds));
+ti = tlds.Type;
+name = tlds.Name;
+section = tlds.Segment;
+offset = tlds.DataOffset;
+addr = m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset);
+scope = eValueTypeVariableThreadLocal;
+break;
+  }
+  default:
+llvm_unreachable("unreachable!");
+  }
+
+  CompUnitSP comp_unit;
+  llvm::Optional modi = m_index->GetModuleIndexForVa(addr);
+  if (modi) {
+PdbSymUid cuid = PdbSymUid::makeCompilandId(*modi);
+CompilandIndexItem &cci = m_index->compilands().GetOrCreateCompiland(cuid);
+comp_unit = Ge

[Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: zturner, stella.stamenova.
aleksandr.urakov added a project: LLDB.
Herald added a subscriber: lldb-commits.

This one fixes tests compilation preserving the type of the `scope` parameter.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53749

Files:
  unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp


Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -270,7 +270,7 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | 
lldb::eSymbolContextLineEntry;
+  auto scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   uint32_t count =
   symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
@@ -319,7 +319,7 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | 
lldb::eSymbolContextLineEntry;
+  auto scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   // First test with line 7, and verify that only line 7 entries are added.
   uint32_t count =


Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -270,7 +270,7 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+  auto scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   uint32_t count =
   symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
@@ -319,7 +319,7 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+  auto scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   // First test with line 7, and verify that only line 7 entries are added.
   uint32_t count =
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Zachary Turner via lldb-commits
Ahh, I meant to remind you, because I noticed this when I was looking
through the SymbolFilePDB code recently.  I think the LLVM guideline is not
to use so much auto.  The generally accepted rule is that we can use for
the result of make_shared, make_unique, and result of iterator types, but
otherwise we prefer to explicitly spell the types out.  You don't have to
go and submit another patch on top of this one to fix it again, it's just
something to keep in mind.

That said, thanks for fixing this for me.  Sorry for the break.

On Fri, Oct 26, 2018 at 2:11 AM Aleksandr Urakov via Phabricator <
revi...@reviews.llvm.org> wrote:

> aleksandr.urakov created this revision.
> aleksandr.urakov added reviewers: zturner, stella.stamenova.
> aleksandr.urakov added a project: LLDB.
> Herald added a subscriber: lldb-commits.
>
> This one fixes tests compilation preserving the type of the `scope`
> parameter.
>
>
> Repository:
>   rLLDB LLDB
>
> https://reviews.llvm.org/D53749
>
> Files:
>   unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
>
>
> Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
> ===
> --- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
> +++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
> @@ -270,7 +270,7 @@
>EXPECT_EQ(2u, cus);
>
>SymbolContextList sc_list;
> -  uint32_t scope = lldb::eSymbolContextCompUnit |
> lldb::eSymbolContextLineEntry;
> +  auto scope = lldb::eSymbolContextCompUnit |
> lldb::eSymbolContextLineEntry;
>
>uint32_t count =
>symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
> @@ -319,7 +319,7 @@
>EXPECT_EQ(2u, cus);
>
>SymbolContextList sc_list;
> -  uint32_t scope = lldb::eSymbolContextCompUnit |
> lldb::eSymbolContextLineEntry;
> +  auto scope = lldb::eSymbolContextCompUnit |
> lldb::eSymbolContextLineEntry;
>
>// First test with line 7, and verify that only line 7 entries are
> added.
>uint32_t count =
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a subscriber: aleksandr.urakov.
zturner added a comment.

Ahh, I meant to remind you, because I noticed this when I was looking
through the SymbolFilePDB code recently.  I think the LLVM guideline is not
to use so much auto.  The generally accepted rule is that we can use for
the result of make_shared, make_unique, and result of iterator types, but
otherwise we prefer to explicitly spell the types out.  You don't have to
go and submit another patch on top of this one to fix it again, it's just
something to keep in mind.

That said, thanks for fixing this for me.  Sorry for the break.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53749



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


[Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Ok, thanks! I didn't know about such rule. I'll reduce usages of auto :)

As for such an obvious changes, is it ok to commit them without a review? Or is 
it still preferable to create reviews for them?


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53749



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


[Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

For trivial changes it's ok to submit without review.  This is true for
cleanup and trivial refactor, but especially for build break like this
one., and even more so if you consider yourself code owner in the
corresponding code area.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53749



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


Re: [Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Zachary Turner via lldb-commits
For trivial changes it's ok to submit without review.  This is true for
cleanup and trivial refactor, but especially for build break like this
one., and even more so if you consider yourself code owner in the
corresponding code area.

On Fri, Oct 26, 2018 at 2:29 AM Aleksandr Urakov via Phabricator <
revi...@reviews.llvm.org> wrote:

> aleksandr.urakov added a comment.
>
> Ok, thanks! I didn't know about such rule. I'll reduce usages of auto :)
>
> As for such an obvious changes, is it ok to commit them without a review?
> Or is it still preferable to create reviews for them?
>
>
> Repository:
>   rLLDB LLDB
>
> https://reviews.llvm.org/D53749
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r345374 - [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Fri Oct 26 02:36:26 2018
New Revision: 345374

URL: http://llvm.org/viewvc/llvm-project?rev=345374&view=rev
Log:
[PDB] Fix `SymbolFilePDBTests` after r345313

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

Modified:
lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Modified: lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp?rev=345374&r1=345373&r2=345374&view=diff
==
--- lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp (original)
+++ lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp Fri Oct 26 
02:36:26 2018
@@ -270,7 +270,8 @@ TEST_F(SymbolFilePDBTests, TestLineTable
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | 
lldb::eSymbolContextLineEntry;
+  lldb::SymbolContextItem scope =
+  lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   uint32_t count =
   symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
@@ -319,7 +320,8 @@ TEST_F(SymbolFilePDBTests, TestLineTable
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | 
lldb::eSymbolContextLineEntry;
+  lldb::SymbolContextItem scope =
+  lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   // First test with line 7, and verify that only line 7 entries are added.
   uint32_t count =


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


[Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Ok, good!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53749



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


[Lldb-commits] [PATCH] D53749: [PDB] Fix `SymbolFilePDBTests` after r345313

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB345374: [PDB] Fix `SymbolFilePDBTests` after r345313 
(authored by aleksandr.urakov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53749?vs=171269&id=171275#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53749

Files:
  unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp


Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -270,7 +270,8 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | 
lldb::eSymbolContextLineEntry;
+  lldb::SymbolContextItem scope =
+  lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   uint32_t count =
   symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
@@ -319,7 +320,8 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | 
lldb::eSymbolContextLineEntry;
+  lldb::SymbolContextItem scope =
+  lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   // First test with line 7, and verify that only line 7 entries are added.
   uint32_t count =


Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -270,7 +270,8 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+  lldb::SymbolContextItem scope =
+  lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   uint32_t count =
   symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
@@ -319,7 +320,8 @@
   EXPECT_EQ(2u, cus);
 
   SymbolContextList sc_list;
-  uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+  lldb::SymbolContextItem scope =
+  lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
 
   // First test with line 7, and verify that only line 7 entries are added.
   uint32_t count =
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D53753: [Windows] Define generic arguments registers for Windows x64

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: zturner, stella.stamenova, labath.
aleksandr.urakov added a project: LLDB.
Herald added a subscriber: lldb-commits.

When evaluating expressions the generic arguments registers are required by 
ABI. This patch defines them.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53753

Files:
  source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp


Index: source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -74,12 +74,12 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(rcx, nullptr),
- {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG1,
   LLDB_INVALID_REGNUM, lldb_rcx_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(rdx, nullptr),
- {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG2,
   LLDB_INVALID_REGNUM, lldb_rdx_x86_64},
  nullptr,
  nullptr},
@@ -104,22 +104,22 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(r8, nullptr),
- {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG3,
   LLDB_INVALID_REGNUM, lldb_r8_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r9, nullptr),
- {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG4,
   LLDB_INVALID_REGNUM, lldb_r9_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr},


Index: source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -74,12 +74,12 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(rcx, nullptr),
- {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG1,
   LLDB_INVALID_REGNUM, lldb_rcx_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(rdx, nullptr),
- {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG2,
   LLDB_INVALID_REGNUM, lldb_rdx_x86_64},
  nullptr,
  nullptr},
@@ -104,22 +104,22 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(r8, nullptr),
- {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG3,
   LLDB_INVALID_REGNUM, lldb_r8_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r9, nullptr),
- {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG4,
   LLDB_INVALID_REGNUM, lldb_r9_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr},
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D53759: [PDB] Support PDB-backed expressions evaluation

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: zturner, asmith, stella.stamenova.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor, JDevlieghere, aprantl.

This patch contains several small fixes, which makes it possible to evaluate 
expressions on Windows using information from PDB. The changes are:

- several sanitize checks;
- make `IRExecutionUnit::MemoryManager::getSymbolAddress` to not return a magic 
value on a failure, because callers wait 0 in this case;
- entry point required to be a file address, not RVA, in the `ObjectFilePECOFF`;
- do not crash on a debuggee second chance exception - it may be an expression 
evaluation crash;
- create parameter declarations for functions in AST to make it possible to 
call debugee functions from expressions;
- relax name searching rules for variables, functions, namespaces and types. 
Now it works just like in the DWARF plugin;
- fix endless recursion in `SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc`.

Each change is small and it is hard to test each change separately, so I think 
that create one review for them all is not a bad idea, especially because they 
make together the test to work.

I remember about the new native PDB plugin, but these changes are old enough, 
for last two or three weeks I'm just releasing my stash :) And some of the 
changes may be useful for the new plugin too.

This review depends on https://reviews.llvm.org/D52461, 
https://reviews.llvm.org/D52618, https://reviews.llvm.org/D53368, x64 testing 
depends on https://reviews.llvm.org/D53753.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53759

Files:
  lit/SymbolFile/PDB/Inputs/ExpressionsTest.cpp
  lit/SymbolFile/PDB/Inputs/ExpressionsTest0.script
  lit/SymbolFile/PDB/Inputs/ExpressionsTest1.script
  lit/SymbolFile/PDB/Inputs/ExpressionsTest2.script
  lit/SymbolFile/PDB/expressions.test
  source/Core/RichManglingContext.cpp
  source/Expression/IRExecutionUnit.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  source/Plugins/SymbolFile/PDB/PDBASTParser.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
@@ -286,6 +286,10 @@
 const PDBSymbolFunc &pdb_func, const lldb_private::SymbolContext &sc) {
   lldbassert(sc.comp_unit && sc.module_sp.get());
 
+  if (FunctionSP result =
+  sc.comp_unit->FindFunctionByUID(pdb_func.getSymIndexId()))
+return result.get();
+
   auto file_vm_addr = pdb_func.getVirtualAddress();
   if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0)
 return nullptr;
@@ -1042,8 +1046,6 @@
 const lldb_private::ConstString &name,
 const lldb_private::CompilerDeclContext *parent_decl_ctx,
 uint32_t max_matches, lldb_private::VariableList &variables) {
-  if (!parent_decl_ctx)
-parent_decl_ctx = m_tu_decl_ctx_up.get();
   if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
 return 0;
   if (name.IsEmpty())
@@ -1073,9 +1075,8 @@
 if (sc.comp_unit == nullptr)
   continue;
 
-auto actual_parent_decl_ctx =
-GetDeclContextContainingUID(result->getSymIndexId());
-if (actual_parent_decl_ctx != *parent_decl_ctx)
+if (parent_decl_ctx && GetDeclContextContainingUID(
+   result->getSymIndexId()) != *parent_decl_ctx)
   continue;
 
 ParseVariables(sc, *pdb_data, &variables);
@@ -1266,20 +1267,28 @@
 CacheFunctionNames();
 
 std::set resolved_ids;
-auto ResolveFn = [include_inlines, &name, &sc_list, &resolved_ids,
-  this](UniqueCStringMap &Names) {
+auto ResolveFn = [this, &name, parent_decl_ctx, include_inlines, &sc_list,
+  &resolved_ids](UniqueCStringMap &Names) {
   std::vector ids;
-  if (Names.GetValues(name, ids)) {
-for (auto id : ids) {
-  if (resolved_ids.find(id) == resolved_ids.end()) {
-if (ResolveFunction(id, include_inlines, sc_list))
-  resolved_ids.insert(id);
-  }
-}
+  if (!Names.GetValues(name, ids))
+return;
+
+  for (uint32_t id : ids) {
+if (resolved_ids.find(id) != resolved_ids.end())
+  continue;
+
+if (parent_decl_ctx &&
+GetDeclContextContainingUID(id) != *parent_decl_ctx)
+  continue;
+
+if (ResolveFunction(id, include_inlines, sc_list))
+  resolved_ids.insert(id);
   }
 };
 if (name_type_mask & eFunctionNameTypeFull) {
   ResolveFn(m_func_full_names);
+  ResolveFn(m_func_base_names);
+  ResolveFn(m_func_method_names);
 }
 if (name_ty

[Lldb-commits] [PATCH] D53753: [Windows] Define generic arguments registers for Windows x64

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a subscriber: aleksandr.urakov.
zturner added a comment.

Lgtm


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53753



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


[Lldb-commits] [PATCH] D53761: [Target] Do not skip a stop on a breakpoint if a plan was completed

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: jingham, zturner, boris.ulasevich.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor.

This patch fixes the next situation. On Windows `clang-cl` makes no stub before 
the `main` function, so the `main` function is located exactly on module entry 
point. May be it is the same on other platforms. So consider the following 
sequence:

- set a breakpoint on `main` and stop there;
- try to evaluate expression, which requires a code execution on the debuggee 
side. Such an execution always returns to the module entry, and the plan waits 
for it there;
- the plan understands that it is complete now and removes its breakpoint. But 
the breakpoint site is still there, because we also have a breakpoint on entry;
- `StopInfo` analyzes a situation. It sees that we have stopped on the 
breakpoint site, and it sees that the breakpoint site has owners, and no one 
logical breakpoint is internal (because the plan is already completed and it 
have removed its breakpoint);
- `StopInfo` thinks that it's a user breakpoint and skips it to avoid recursive 
computations;
- the program continues.

So in this situation the program continues without a stop right after the 
expression evaluation. To avoid this I've added an additional check that the 
plan was completed.

The test is just the case I've caught, but it's Windows-only. It seems that the 
problem should exist on other platforms too, but I don't know how to test it in 
a cross-platform way (any tips are appreciated). The test depends on 
https://reviews.llvm.org/D53759.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53761

Files:
  lit/SymbolFile/PDB/Inputs/BPOnEntryTest.cpp
  lit/SymbolFile/PDB/Inputs/BPOnEntryTest.script
  lit/SymbolFile/PDB/bp-on-entry.test
  source/Target/StopInfo.cpp


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -333,6 +333,13 @@
 // commands when we see the same breakpoint hit a second time.
 
 m_should_stop_is_valid = true;
+
+if (thread_sp->CompletedPlanOverridesBreakpoint()) {
+  m_should_stop = true;
+  thread_sp->ResetStopInfo();
+  return;
+}
+
 if (log)
   log->Printf("StopInfoBreakpoint::PerformAction - Hit a "
   "breakpoint while running an expression,"
Index: lit/SymbolFile/PDB/bp-on-entry.test
===
--- /dev/null
+++ lit/SymbolFile/PDB/bp-on-entry.test
@@ -0,0 +1,7 @@
+REQUIRES: windows
+RUN: clang-cl /Zi /GS- /c %S/Inputs/BPOnEntryTest.cpp /Fo%t.obj
+RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
+RUN: %lldb -b -s %S/Inputs/BPOnEntryTest.script -- %t.exe | FileCheck %s
+
+CHECK: (lldb) print sum(3, 4)
+CHECK: (int) $0 = 7
Index: lit/SymbolFile/PDB/Inputs/BPOnEntryTest.script
===
--- /dev/null
+++ lit/SymbolFile/PDB/Inputs/BPOnEntryTest.script
@@ -0,0 +1,3 @@
+breakpoint set --file BPOnEntryTest.cpp --name main
+run
+print sum(3, 4)
Index: lit/SymbolFile/PDB/Inputs/BPOnEntryTest.cpp
===
--- /dev/null
+++ lit/SymbolFile/PDB/Inputs/BPOnEntryTest.cpp
@@ -0,0 +1,7 @@
+int sum(int a, int b) {
+  return a + b;
+}
+
+int main() {
+  return sum(-1, 1);
+}


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -333,6 +333,13 @@
 // commands when we see the same breakpoint hit a second time.
 
 m_should_stop_is_valid = true;
+
+if (thread_sp->CompletedPlanOverridesBreakpoint()) {
+  m_should_stop = true;
+  thread_sp->ResetStopInfo();
+  return;
+}
+
 if (log)
   log->Printf("StopInfoBreakpoint::PerformAction - Hit a "
   "breakpoint while running an expression,"
Index: lit/SymbolFile/PDB/bp-on-entry.test
===
--- /dev/null
+++ lit/SymbolFile/PDB/bp-on-entry.test
@@ -0,0 +1,7 @@
+REQUIRES: windows
+RUN: clang-cl /Zi /GS- /c %S/Inputs/BPOnEntryTest.cpp /Fo%t.obj
+RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
+RUN: %lldb -b -s %S/Inputs/BPOnEntryTest.script -- %t.exe | FileCheck %s
+
+CHECK: (lldb) print sum(3, 4)
+CHECK: (int) $0 = 7
Index: lit/SymbolFile/PDB/Inputs/BPOnEntryTest.script
===
--- /dev/null
+++ lit/SymbolFile/PDB/Inputs/BPOnEntryTest.script
@@ -0,0 +1,3 @@
+breakpoint set --file BPOnEntryTest.cpp --name main
+run
+print sum(3, 4)
Index: lit/SymbolFile/PDB/Inputs/BP

[Lldb-commits] [PATCH] D53753: [Windows] Define generic arguments registers for Windows x64

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Thanks!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53753



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


[Lldb-commits] [lldb] r345385 - [Windows] Define generic arguments registers for Windows x64

2018-10-26 Thread Aleksandr Urakov via lldb-commits
Author: aleksandr.urakov
Date: Fri Oct 26 07:15:34 2018
New Revision: 345385

URL: http://llvm.org/viewvc/llvm-project?rev=345385&view=rev
Log:
[Windows] Define generic arguments registers for Windows x64

Summary:
When evaluating expressions the generic arguments registers are required by ABI.
This patch defines them.

Reviewers: zturner, stella.stamenova, labath

Subscribers: aleksandr.urakov, lldb-commits

Tags: #lldb

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

Modified:

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

Modified: 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp?rev=345385&r1=345384&r2=345385&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
 Fri Oct 26 07:15:34 2018
@@ -74,12 +74,12 @@ RegisterInfo g_register_infos[] = {
  nullptr,
  nullptr},
 {DEFINE_GPR(rcx, nullptr),
- {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG1,
   LLDB_INVALID_REGNUM, lldb_rcx_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(rdx, nullptr),
- {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG2,
   LLDB_INVALID_REGNUM, lldb_rdx_x86_64},
  nullptr,
  nullptr},
@@ -104,22 +104,22 @@ RegisterInfo g_register_infos[] = {
  nullptr,
  nullptr},
 {DEFINE_GPR(r8, nullptr),
- {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG3,
   LLDB_INVALID_REGNUM, lldb_r8_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r9, nullptr),
- {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG4,
   LLDB_INVALID_REGNUM, lldb_r9_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr},


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


[Lldb-commits] [PATCH] D53753: [Windows] Define generic arguments registers for Windows x64

2018-10-26 Thread Aleksandr Urakov via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345385: [Windows] Define generic arguments registers for 
Windows x64 (authored by aleksandr.urakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53753?vs=171281&id=171299#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53753

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


Index: 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -74,12 +74,12 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(rcx, nullptr),
- {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG1,
   LLDB_INVALID_REGNUM, lldb_rcx_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(rdx, nullptr),
- {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG2,
   LLDB_INVALID_REGNUM, lldb_rdx_x86_64},
  nullptr,
  nullptr},
@@ -104,22 +104,22 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(r8, nullptr),
- {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG3,
   LLDB_INVALID_REGNUM, lldb_r8_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r9, nullptr),
- {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG4,
   LLDB_INVALID_REGNUM, lldb_r9_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr},


Index: lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -74,12 +74,12 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(rcx, nullptr),
- {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG1,
   LLDB_INVALID_REGNUM, lldb_rcx_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(rdx, nullptr),
- {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG2,
   LLDB_INVALID_REGNUM, lldb_rdx_x86_64},
  nullptr,
  nullptr},
@@ -104,22 +104,22 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(r8, nullptr),
- {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG3,
   LLDB_INVALID_REGNUM, lldb_r8_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r9, nullptr),
- {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG4,
   LLDB_INVALID_REGNUM, lldb_r9_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr},
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process

2018-10-26 Thread Hui Huang via Phabricator via lldb-commits
Hui added inline comments.



Comment at: source/Plugins/Process/Windows/Common/ProcessWindows.cpp:712
 
+lldb::addr_t ProcessWindows::DoAllocateMemory(size_t size, uint32_t 
permissions,
+  Status &error) {

Looks to me they are handlers to the GDB remote "__m" and "__M" packets.  If 
the remote is on Windows host, the debug inferior shall be responsible to 
handle memory allocation/deallocation for JITed codes. (There is a process 
utility for InferiorCall). Otherwise,  the requests will be answered by remote 
gdb server with memory region returned.


https://reviews.llvm.org/D52618



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


[Lldb-commits] [PATCH] D53759: [PDB] Support PDB-backed expressions evaluation

2018-10-26 Thread Hui Huang via Phabricator via lldb-commits
Hui added inline comments.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:819
   if (!section_list)
 m_entry_point_address.SetOffset(offset);
   else

This still needs to be the offset into the section.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53759



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


[Lldb-commits] [PATCH] D53662: Give the SymbolFile plugin enough information to efficiently do exact match lookups

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

My issue with adding "exact_match" is it renders a few of the arguments useless:

  size_t FindTypes(
const SymbolContext &sc, 
llvm::StringRef name,
const CompilerDeclContext *parent_decl_ctx, 
bool exact_match,
...);

With exact_match "parent_decl_ctx" is useless and possible the symbol context 
too. The FindTypes as written today was used for two cases which evolved over 
time:

- finding types for users without needing to be fully qualified
- finding types for the expression parser in a specific context

To fulfill these two cases, arguments have been added over time. As we keep 
adding arguments we make the function even harder to implement for SymbolFile 
subclasses. So as long as we are cleaning things up, it might be time to factor 
this out by making changes now.

Another complexity is that we can either search a single module or multiple 
modules when doing searches, and that is why we have 
Module::FindTypes_Impl(...) in since there is some work that needs to be done 
when we are searching by basename only (strip the context and search by 
basename, then filters matches afterward.

That is why I was thinking we might want to make changes. Seems like having:

  size_t FindTypesByBasename(
const SymbolContext &sc, 
llvm::StringRef name,
const CompilerDeclContext *parent_decl_ctx
...);
  
  size_t FindTypesByFullname(llvm::StringRef name, ...);

Clients of the first call must strip a typename to its identifier name prior to 
calling, and clients of the second can call with a fully qualified typename.


https://reviews.llvm.org/D53662



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


Re: [Lldb-commits] [PATCH] D53662: Give the SymbolFile plugin enough information to efficiently do exact match lookups

2018-10-26 Thread Zachary Turner via lldb-commits
Ok, that reasoning makes sense, I’ll see what i can do
On Fri, Oct 26, 2018 at 9:25 AM Greg Clayton via Phabricator <
revi...@reviews.llvm.org> wrote:

> clayborg added a comment.
>
> My issue with adding "exact_match" is it renders a few of the arguments
> useless:
>
>   size_t FindTypes(
> const SymbolContext &sc,
> llvm::StringRef name,
> const CompilerDeclContext *parent_decl_ctx,
> bool exact_match,
> ...);
>
> With exact_match "parent_decl_ctx" is useless and possible the symbol
> context too. The FindTypes as written today was used for two cases which
> evolved over time:
>
> - finding types for users without needing to be fully qualified
> - finding types for the expression parser in a specific context
>
> To fulfill these two cases, arguments have been added over time. As we
> keep adding arguments we make the function even harder to implement for
> SymbolFile subclasses. So as long as we are cleaning things up, it might be
> time to factor this out by making changes now.
>
> Another complexity is that we can either search a single module or
> multiple modules when doing searches, and that is why we have
> Module::FindTypes_Impl(...) in since there is some work that needs to be
> done when we are searching by basename only (strip the context and search
> by basename, then filters matches afterward.
>
> That is why I was thinking we might want to make changes. Seems like
> having:
>
>   size_t FindTypesByBasename(
> const SymbolContext &sc,
> llvm::StringRef name,
> const CompilerDeclContext *parent_decl_ctx
> ...);
>
>   size_t FindTypesByFullname(llvm::StringRef name, ...);
>
> Clients of the first call must strip a typename to its identifier name
> prior to calling, and clients of the second can call with a fully qualified
> typename.
>
>
> https://reviews.llvm.org/D53662
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D53662: Give the SymbolFile plugin enough information to efficiently do exact match lookups

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a subscriber: clayborg.
zturner added a comment.

Ok, that reasoning makes sense, I’ll see what i can do


https://reviews.llvm.org/D53662



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


[Lldb-commits] [lldb] r345402 - [DataFormatters] Adding formatters for libc++ std::u16string and std::u32string

2018-10-26 Thread Shafik Yaghmour via lldb-commits
Author: shafik
Date: Fri Oct 26 10:00:48 2018
New Revision: 345402

URL: http://llvm.org/viewvc/llvm-project?rev=345402&view=rev
Log:
[DataFormatters] Adding formatters for libc++ std::u16string and std::u32string

rdar://problem/41302849

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile?rev=345402&r1=345401&r2=345402&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
 Fri Oct 26 10:00:48 2018
@@ -4,4 +4,4 @@ CXX_SOURCES := main.cpp
 
 USE_LIBCPP := 1
 include $(LEVEL)/Makefile.rules
-CXXFLAGS += -O0
+CXXFLAGS += -std=c++11 -O0

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py?rev=345402&r1=345401&r2=345402&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 Fri Oct 26 10:00:48 2018
@@ -68,7 +68,9 @@ class LibcxxStringDataFormatterTestCase(
 '(%s::string) q = "hello world"'%ns,
 '(%s::string) Q = "quite a long std::strin with lots of info 
inside it"'%ns,
 '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
-'(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ 
ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns])
+'(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ 
ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns,
+'(%s::u16string) u16_string = u"ß水氶"'%ns,
+'(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns])
 
 self.runCmd("n")
 
@@ -98,4 +100,6 @@ class LibcxxStringDataFormatterTestCase(
 '(%s::string) q = "hello world"'%ns,
 '(%s::string) Q = "quite a long std::strin with lots of info 
inside it"'%ns,
 '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
-'(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ 
ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns])
+'(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ 
ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns,
+'(%s::u16string) u16_string = u"ß水氶"'%ns,
+'(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp?rev=345402&r1=345401&r2=345402&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
 Fri Oct 26 10:00:48 2018
@@ -10,6 +10,8 @@ int main()
 std::string 
TheVeryLongOne("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567

[Lldb-commits] [PATCH] D53656: Adding formatters for libc++ std::u16string and std::u32string

2018-10-26 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345402: [DataFormatters] Adding formatters for libc++ 
std::u16string and std::u32string (authored by shafik, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53656?vs=170921&id=171313#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53656

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile
@@ -4,4 +4,4 @@
 
 USE_LIBCPP := 1
 include $(LEVEL)/Makefile.rules
-CXXFLAGS += -O0
+CXXFLAGS += -std=c++11 -O0
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
@@ -10,6 +10,8 @@
 std::string TheVeryLongOne("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890someText123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901

[Lldb-commits] [PATCH] D53759: [PDB] Support PDB-backed expressions evaluation

2018-10-26 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova accepted this revision.
stella.stamenova added a comment.
This revision is now accepted and ready to land.

A couple of comments, but looks good otherwise. I'd wait for someone else to 
have a look as well.




Comment at: source/Plugins/Process/Windows/Common/ProcessWindows.cpp:959
+// It may be an expression evaluation crash.
+SetPrivateState(eStateStopped);
   }

Are we going to determine later whether it is supposed to be a crash or just 
never crash on second chance exceptions?



Comment at: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp:1085
+  } else
+set = &m_namespaces;
+  assert(set);

Nit: Maybe add curly braces here. Since the if statement has them, the code is 
easier to read if the else does as well.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53759



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


[Lldb-commits] [lldb] r345422 - Remove an early-return from Driver::ParseArgs that

2018-10-26 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Fri Oct 26 12:40:18 2018
New Revision: 345422

URL: http://llvm.org/viewvc/llvm-project?rev=345422&view=rev
Log:
Remove an early-return from Driver::ParseArgs that
was added as a part of D52604 / r343348.  If the
lldb driver is run without any arguments, .lldbinit 
file reading was not enabled.

 

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

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=345422&r1=345421&r2=345422&view=diff
==
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Oct 26 12:40:18 2018
@@ -578,10 +578,6 @@ SBError Driver::ParseArgs(int argc, cons
 
   ResetOptionValues();
 
-  // No arguments or just program name, nothing to parse.
-  if (argc <= 1)
-return SBError();
-
   SBError error;
   std::vector long_options_vector;
   BuildGetOptTable(long_options_vector);


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


[Lldb-commits] [PATCH] D53761: [Target] Do not skip a stop on a breakpoint if a plan was completed

2018-10-26 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

This seems safe, but you certainly want to add a comment explaining why you are 
doing this.

We find the expression breakpoint by calling ObjectFile::GetEntryPointAddress 
on the main executable.  So you should be able to test this everywhere by 
making that function result available somehow and then setting a user 
breakpoint there.

If you were making a dotest test I'd suggest adding 
SBTarget::GetEntryPointAddress and then use that.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53761



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


[Lldb-commits] [lldb] r345435 - Fix and rename broken test for `settings write`.

2018-10-26 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Fri Oct 26 16:01:25 2018
New Revision: 345435

URL: http://llvm.org/viewvc/llvm-project?rev=345435&view=rev
Log:
Fix and rename broken test for `settings write`.

I committed this test without updating the old `settings export` to
settings write. Since the functionality was renamed I also renamed the
test case.

Added:
lldb/trunk/lit/Settings/TestSettingsWrite.test
  - copied, changed from r345402, lldb/trunk/lit/Settings/TestExport.test
Removed:
lldb/trunk/lit/Settings/TestExport.test

Removed: lldb/trunk/lit/Settings/TestExport.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Settings/TestExport.test?rev=345434&view=auto
==
--- lldb/trunk/lit/Settings/TestExport.test (original)
+++ lldb/trunk/lit/Settings/TestExport.test (removed)
@@ -1,32 +0,0 @@
-# This tests writing and reading settings from LLDB.
-
-# Check that the settings can be written to file and read again without
-# altering the values.
-# RUN: %lldb -b -o 'settings write -f %t.foo' -o 'settings read -f %t.foo' -o 
'settings export %t.bar' -o 'settings read -f %t.bar' 2>&1 | FileCheck %s 
--check-prefix SUCCESS
-# RUN: diff -w %t.foo %t.bar
-# SUCCESS-NOT: error:
-
-# Check that exporting target settings only export target settings and nothing 
else.
-# RUN: %lldb -b -o 'settings write -f %t.target target' 2>&1 | FileCheck %s 
--check-prefix SUCCESS
-# RUN: cat %t.target | FileCheck %s --check-prefix TARGET
-# TARGET: settings set target
-# TARGET-NOT: settings set platform
-# TARGET-NOT: settings set symbols
-# TARGET-NOT: settings set interpreter
-# TARGET-NOT: settings set plugin
-
-# Check that settings appear twice when appending.
-# RUN: %lldb -b -o 'settings write -a -f %t.append target' -o 'settings write 
-a -f %t.append target' 2>&1 | FileCheck %s --check-prefix SUCCESS
-# RUN: cat %t.append | FileCheck %s --check-prefix APPEND
-# APPEND: settings set target.language
-# APPEND: settings set target.language
-
-# Check that an error is printed for non-existing setting.
-# RUN: echo "settings set bogus" > %t.bogus_setting
-# RUN: %lldb -b -o 'settings read -f %t.bogus_setting' 2>&1 | FileCheck %s 
--check-prefix BOGUS-SETTING
-# BOGUS-SETTING: error: invalid value path
-
-# Check that an error is printed for invalid value.
-# RUN: echo "settings set target.language bogus" > %t.bogus_value
-# RUN: %lldb -b -o 'settings read -f %t.bogus_value' 2>&1 | FileCheck %s 
--check-prefix BOGUS-VALUE
-# BOGUS-VALUE: error: invalid language type

Copied: lldb/trunk/lit/Settings/TestSettingsWrite.test (from r345402, 
lldb/trunk/lit/Settings/TestExport.test)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Settings/TestSettingsWrite.test?p2=lldb/trunk/lit/Settings/TestSettingsWrite.test&p1=lldb/trunk/lit/Settings/TestExport.test&r1=345402&r2=345435&rev=345435&view=diff
==
--- lldb/trunk/lit/Settings/TestExport.test (original)
+++ lldb/trunk/lit/Settings/TestSettingsWrite.test Fri Oct 26 16:01:25 2018
@@ -2,31 +2,31 @@
 
 # Check that the settings can be written to file and read again without
 # altering the values.
-# RUN: %lldb -b -o 'settings write -f %t.foo' -o 'settings read -f %t.foo' -o 
'settings export %t.bar' -o 'settings read -f %t.bar' 2>&1 | FileCheck %s 
--check-prefix SUCCESS
+# RUN: %lldb -b -o 'settings write -f %t.foo' -o 'settings read -f %t.foo' -o 
'settings write -f %t.bar' -o 'settings read -f %t.bar' 2>&1 | FileCheck %s 
--check-prefix SUCCESS
 # RUN: diff -w %t.foo %t.bar
 # SUCCESS-NOT: error:
 
 # Check that exporting target settings only export target settings and nothing 
else.
 # RUN: %lldb -b -o 'settings write -f %t.target target' 2>&1 | FileCheck %s 
--check-prefix SUCCESS
 # RUN: cat %t.target | FileCheck %s --check-prefix TARGET
-# TARGET: settings set target
-# TARGET-NOT: settings set platform
-# TARGET-NOT: settings set symbols
-# TARGET-NOT: settings set interpreter
-# TARGET-NOT: settings set plugin
+# TARGET: settings set -f target
+# TARGET-NOT: settings set -f platform
+# TARGET-NOT: settings set -f symbols
+# TARGET-NOT: settings set -f interpreter
+# TARGET-NOT: settings set -f plugin
 
 # Check that settings appear twice when appending.
 # RUN: %lldb -b -o 'settings write -a -f %t.append target' -o 'settings write 
-a -f %t.append target' 2>&1 | FileCheck %s --check-prefix SUCCESS
 # RUN: cat %t.append | FileCheck %s --check-prefix APPEND
-# APPEND: settings set target.language
-# APPEND: settings set target.language
+# APPEND: settings set -f target.language
+# APPEND: settings set -f target.language
 
 # Check that an error is printed for non-existing setting.
-# RUN: echo "settings set bogus" > %t.bogus_setting
+# RUN: echo "settings set -f bogus" > %t.bogus_setting
 # RUN: %lldb -b -o 'settings read -f %t.bogus_setting' 2>&1 | FileCheck %s 
--check-prefix BOGUS-SETTING
 # BOGUS-SETTING: error: i

[Lldb-commits] [PATCH] D53532: [FileSystem] Extend file system and have it use the VFS.

2018-10-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 171376.
JDevlieghere retitled this revision from "[FileSpec] Add VFS support to 
FileSpec convenience methods." to "[FileSystem] Extend file system and have it 
use the VFS.".
JDevlieghere edited the summary of this revision.
JDevlieghere added a comment.

I'll recycle this differential for the first patch that changes the FileSystem 
class.


https://reviews.llvm.org/D53532

Files:
  include/lldb/Host/FileSystem.h
  include/lldb/Utility/FileSpec.h
  source/Core/Disassembler.cpp
  source/Core/Module.cpp
  source/Core/ModuleList.cpp
  source/Core/SourceManager.cpp
  source/Host/common/FileSystem.cpp
  source/Host/common/HostInfoBase.cpp
  source/Host/common/Symbols.cpp
  source/Host/posix/HostProcessPosix.cpp
  source/Interpreter/OptionValueFileSpec.cpp
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  source/Plugins/Platform/Android/AdbClient.cpp
  source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  source/Target/Platform.cpp
  unittests/Host/FileSystemTest.cpp

Index: unittests/Host/FileSystemTest.cpp
===
--- unittests/Host/FileSystemTest.cpp
+++ unittests/Host/FileSystemTest.cpp
@@ -10,10 +10,150 @@
 #include "gtest/gtest.h"
 
 #include "lldb/Host/FileSystem.h"
+#include "llvm/Support/Errc.h"
 
 extern const char *TestMainArgv0;
 
 using namespace lldb_private;
+using namespace llvm;
+using llvm::sys::fs::UniqueID;
+
+// Modified from llvm/unittests/Support/VirtualFileSystemTest.cpp
+namespace {
+struct DummyFile : public vfs::File {
+  vfs::Status S;
+  explicit DummyFile(vfs::Status S) : S(S) {}
+  llvm::ErrorOr status() override { return S; }
+  llvm::ErrorOr>
+  getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
+bool IsVolatile) override {
+llvm_unreachable("unimplemented");
+  }
+  std::error_code close() override { return std::error_code(); }
+};
+
+class DummyFileSystem : public vfs::FileSystem {
+  int FSID;   // used to produce UniqueIDs
+  int FileID; // used to produce UniqueIDs
+  std::string cwd;
+  std::map FilesAndDirs;
+
+  static int getNextFSID() {
+static int Count = 0;
+return Count++;
+  }
+
+public:
+  DummyFileSystem() : FSID(getNextFSID()), FileID(0) {}
+
+  ErrorOr status(const Twine &Path) override {
+std::map::iterator I =
+FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+return I->second;
+  }
+  ErrorOr>
+  openFileForRead(const Twine &Path) override {
+auto S = status(Path);
+if (S)
+  return std::unique_ptr(new DummyFile{*S});
+return S.getError();
+  }
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return cwd;
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+cwd = Path.str();
+return std::error_code();
+  }
+  // Map any symlink to "/symlink".
+  std::error_code getRealPath(const Twine &Path,
+  SmallVectorImpl &Output) const override {
+auto I = FilesAndDirs.find(Path.str());
+if (I == FilesAndDirs.end())
+  return make_error_code(llvm::errc::no_such_file_or_directory);
+if (I->second.isSymlink()) {
+  Output.clear();
+  Twine("/symlink").toVector(Output);
+  return std::error_code();
+}
+Output.clear();
+Path.toVector(Output);
+return std::error_code();
+  }
+
+  struct DirIterImpl : public llvm::vfs::detail::DirIterImpl {
+std::map &FilesAndDirs;
+std::map::iterator I;
+std::string Path;
+bool isInPath(StringRef S) {
+  if (Path.size() < S.size() && S.find(Path) == 0) {
+auto LastSep = S.find_last_of('/');
+if (LastSep == Path.size() || LastSep == Path.size() - 1)
+  return true;
+  }
+  return false;
+}
+DirIterImpl(std::map &FilesAndDirs,
+const Twine &_Path)
+: FilesAndDirs(FilesAndDirs), I(FilesAndDirs.begin()),
+  Path(_Path.str()) {
+  for (; I != FilesAndDirs.end(); ++I) {
+if (isInPath(I->first)) {
+  CurrentEntry =
+  vfs::directory_entry(I->second.getName(), I->second.getType());
+  break;
+}
+  }
+}
+std::error_code increment() override {
+  ++I;
+  for (; I != FilesAndDirs.end(); ++I) {
+if (isInPath(I->first)) {
+  CurrentEntry =
+  vfs::directory_entry(I->second.getName(), I->second.getType());
+  break;
+}
+  }
+  if (I == FilesAndDirs.end())
+CurrentEntry = vfs::directory_entry();
+  return std::error_code();
+}
+  };
+
+  vfs::directory_iterator dir_

[Lldb-commits] [PATCH] D53785: [FileSystem] Move EnumerateDirectory from FileSpec to FileSystem.

2018-10-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: zturner, labath, jingham, clayborg.
JDevlieghere added a project: LLDB.

This patch moves the EnumerateDirectory functionality and related enums and 
typedefs from FileSpec to FileSystem. The long term goal is to remove this 
method and use the filesystem iterators without this indirection, but for 
introducing the VFS into LLDB this should be sufficient.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53785

Files:
  include/lldb/Utility/FileSpec.h
  source/Core/Debugger.cpp
  source/Core/PluginManager.cpp
  source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
  source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
  source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  source/Plugins/Platform/MacOSX/PlatformDarwin.h
  source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
  source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
  source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
  source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
  source/Target/Platform.cpp
  source/Utility/FileSpec.cpp

Index: source/Utility/FileSpec.cpp
===
--- source/Utility/FileSpec.cpp
+++ source/Utility/FileSpec.cpp
@@ -602,39 +602,6 @@
   return m_filename.MemorySize() + m_directory.MemorySize();
 }
 
-void FileSpec::EnumerateDirectory(llvm::StringRef dir_path,
-  bool find_directories, bool find_files,
-  bool find_other,
-  EnumerateDirectoryCallbackType callback,
-  void *callback_baton) {
-  namespace fs = llvm::sys::fs;
-  std::error_code EC;
-  fs::recursive_directory_iterator Iter(dir_path, EC);
-  fs::recursive_directory_iterator End;
-  for (; Iter != End && !EC; Iter.increment(EC)) {
-const auto &Item = *Iter;
-llvm::ErrorOr Status = Item.status();
-if (!Status)
-  break;
-if (!find_files && fs::is_regular_file(*Status))
-  continue;
-if (!find_directories && fs::is_directory(*Status))
-  continue;
-if (!find_other && fs::is_other(*Status))
-  continue;
-
-FileSpec Spec(Item.path(), false);
-auto Result = callback(callback_baton, Status->type(), Spec);
-if (Result == eEnumerateDirectoryResultQuit)
-  return;
-if (Result == eEnumerateDirectoryResultNext) {
-  // Default behavior is to recurse.  Opt out if the callback doesn't want
-  // this behavior.
-  Iter.no_push();
-}
-  }
-}
-
 FileSpec
 FileSpec::CopyByAppendingPathComponent(llvm::StringRef component) const {
   FileSpec ret = *this;
Index: source/Target/Platform.cpp
===
--- source/Target/Platform.cpp
+++ source/Target/Platform.cpp
@@ -552,16 +552,17 @@
   Status error;
 };
 
-static FileSpec::EnumerateDirectoryResult
+static FileSystem::EnumerateDirectoryResult
 RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
- const FileSpec &src) {
+ llvm::StringRef path) {
   RecurseCopyBaton *rc_baton = (RecurseCopyBaton *)baton;
+  FileSpec src(path, false);
   namespace fs = llvm::sys::fs;
   switch (ft) {
   case fs::file_type::fifo_file:
   case fs::file_type::socket_file:
 // we have no way to copy pipes and sockets - ignore them and continue
-return FileSpec::eEnumerateDirectoryResultNext;
+return FileSystem::eEnumerateDirectoryResultNext;
 break;
 
   case fs::file_type::directory_file: {
@@ -574,7 +575,7 @@
 if (error.Fail()) {
   rc_baton->error.SetErrorStringWithFormat(
   "unable to setup directory %s on remote end", dst_dir.GetCString());
-  return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+  return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out
 }
 
 // now recurse
@@ -586,13 +587,13 @@
 recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str());
 RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr,
   Status()};
-FileSpec::EnumerateDirectory(src_dir_path, true, true, true,
- RecurseCopy_Callback, &rc_baton2);
+FileSystem::Instance().EnumerateDirectory(src_dir_path, true, true, true,
+  RecurseCopy_Callback, &rc_baton2);
 if (rc_baton2.error.Fail()) {
   rc_baton->error.SetErrorString(rc_baton2.error.AsCString());
-  return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
+  return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out
 }
-return FileSpec::eEnumerateDirectoryResultNext;
+return FileSystem::eEnumerateDirectoryResultNext;
   } break;
 
   case fs::file_type::symlink_file: {
@@ -606,15 +607,15 @@
 rc_baton->er

[Lldb-commits] [PATCH] D53788: [FileSystem] Remove GetByteSize() from FileSpec

2018-10-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, zturner, jingham.
JDevlieghere added a project: LLDB.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

This patch removes the `GetByteSize` method from FileSpec and updates its uses 
with calls to the FileSystem.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53788

Files:
  include/lldb/Core/ModuleSpec.h
  include/lldb/Utility/FileSpec.h
  source/Core/Module.cpp
  source/Host/common/Host.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
  source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
  source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
  source/Symbol/ObjectFile.cpp
  source/Target/ModuleCache.cpp
  source/Utility/FileSpec.cpp

Index: source/Utility/FileSpec.cpp
===
--- source/Utility/FileSpec.cpp
+++ source/Utility/FileSpec.cpp
@@ -507,13 +507,6 @@
   return m_is_resolved;
 }
 
-uint64_t FileSpec::GetByteSize() const {
-  uint64_t Size = 0;
-  if (llvm::sys::fs::file_size(GetPath(), Size))
-return 0;
-  return Size;
-}
-
 FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
 
 uint32_t FileSpec::GetPermissions() const {
Index: source/Target/ModuleCache.cpp
===
--- source/Target/ModuleCache.cpp
+++ source/Target/ModuleCache.cpp
@@ -227,7 +227,8 @@
 
   if (!module_file_path.Exists())
 return Status("Module %s not found", module_file_path.GetPath().c_str());
-  if (module_file_path.GetByteSize() != module_spec.GetObjectSize())
+  if (FileSystem::Instance().GetByteSize(module_file_path) !=
+  module_spec.GetObjectSize())
 return Status("Module %s has invalid file size",
   module_file_path.GetPath().c_str());
 
Index: source/Symbol/ObjectFile.cpp
===
--- source/Symbol/ObjectFile.cpp
+++ source/Symbol/ObjectFile.cpp
@@ -91,7 +91,7 @@
 const bool must_exist = true;
 if (ObjectFile::SplitArchivePathWithObject(
 path_with_object, archive_file, archive_object, must_exist)) {
-  file_size = archive_file.GetByteSize();
+  file_size = FileSystem::Instance().GetByteSize(archive_file);
   if (file_size > 0) {
 file = &archive_file;
 module_sp->SetFileSpecAndObjectName(archive_file, archive_object);
@@ -212,7 +212,8 @@
   DataBufferSP data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(), 512, file_offset);
   if (data_sp) {
 if (file_size == 0) {
-  const lldb::offset_t actual_file_size = file.GetByteSize();
+  const lldb::offset_t actual_file_size =
+  FileSystem::Instance().GetByteSize(file);
   if (actual_file_size > file_offset)
 file_size = actual_file_size - file_offset;
 }
Index: source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
===
--- source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -153,9 +153,10 @@
 if (dsym_fspec) {
   DataBufferSP dsym_file_data_sp;
   lldb::offset_t dsym_file_data_offset = 0;
-  dsym_objfile_sp = ObjectFile::FindPlugin(
-  module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(),
-  dsym_file_data_sp, dsym_file_data_offset);
+  dsym_objfile_sp =
+  ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0,
+ FileSystem::Instance().GetByteSize(dsym_fspec),
+ dsym_file_data_sp, dsym_file_data_offset);
   if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get(), feedback_strm)) {
 // We need a XML parser if we hope to parse a plist...
 if (XMLDocument::XMLEnabled()) {
Index: source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
===
--- source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -108,9 +108,10 @@
 if (dsym_fspec) {
   DataBufferSP dsym_file_data_sp;
   lldb::offset_t dsym_file_data_offset = 0;
-  ObjectFileSP dsym_objfile_sp = ObjectFile::FindPlugin(
-  module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(),
-  dsym_file_data_sp, dsym_file_data_offset);
+  ObjectFileSP dsym_objfile_sp =
+  ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0,
+ FileSystem::Instance().GetByteSize(dsym_fspec),
+ dsym_file_data_sp, dsym_file_data_offset);
   if (dsym_objfile_sp) {
 // This objfile is for debugging purposes. Sadly, ObjectFileELF won't
 // be able to figure this out consistently as the symbol file may no

[Lldb-commits] [PATCH] D53788: [FileSystem] Remove GetByteSize() from FileSpec

2018-10-26 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53788



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


[Lldb-commits] [PATCH] D53788: [FileSystem] Remove GetByteSize() from FileSpec

2018-10-26 Thread Zachary Turner via Phabricator via lldb-commits
zturner accepted this revision.
zturner added a comment.

I always wondered if we actually even need methods like this in `FileSystem` 
given that they already exist in `llvm::sys::fs`.  Is it possible to just call 
the llvm methods directly, or is it still helpful to call the ones in 
`FileSystem` so we can more transparently interoperate with the VFS layer 
somehow?


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53788



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


[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off

2018-10-26 Thread Marc-Andre Laperle via Phabricator via lldb-commits
malaperle updated this revision to Diff 171388.
malaperle added a comment.

Convert to lit test, convert some code to an early return, clang-format.


https://reviews.llvm.org/D52953

Files:
  lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test
  lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c
  tools/lldb-mi/MICmdCmdBreak.cpp
  tools/lldb-mi/MICmdCmdGdbSet.cpp
  tools/lldb-mi/MICmdCmdGdbSet.h
  tools/lldb-mi/MICmdCmdGdbShow.cpp
  tools/lldb-mi/MICmdCmdGdbShow.h
  tools/lldb-mi/MICmnResources.cpp
  tools/lldb-mi/MICmnResources.h

Index: tools/lldb-mi/MICmnResources.h
===
--- tools/lldb-mi/MICmnResources.h
+++ tools/lldb-mi/MICmnResources.h
@@ -264,11 +264,14 @@
   IDS_CMD_ERR_INFO_PRINTFN_NOT_FOUND,
   IDS_CMD_ERR_INFO_PRINTFN_FAILED,
   IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC,
+  IDS_CMD_ERR_GDBSET_OPT_BREAKPOINT,
   IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH,
   IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS,
   IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION,
   IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS,
   IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION,
+  IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_BAD_ARGS,
+  IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_UNKNOWN_OPTION,
   IDS_CMD_ERR_EXPR_INVALID,
   IDS_CMD_ERR_ATTACH_FAILED,
   IDS_CMD_ERR_ATTACH_BAD_ARGS
Index: tools/lldb-mi/MICmnResources.cpp
===
--- tools/lldb-mi/MICmnResources.cpp
+++ tools/lldb-mi/MICmnResources.cpp
@@ -439,6 +439,8 @@
 {IDS_CMD_ERR_INFO_PRINTFN_FAILED, "The request '%s' failed."},
 {IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC,
  "'target-async' expects \"on\" or \"off\""},
+{IDS_CMD_ERR_GDBSET_OPT_BREAKPOINT,
+ "'breakpoint' expects \"pending on\" or \"pending off\""},
 {IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH,
  "'solib-search-path' requires at least one argument"},
 {IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS,
@@ -449,6 +451,10 @@
  "'print' expects option-name and \"on\" or \"off\""},
 {IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION,
  "'print' error. The option '%s' not found"},
+{IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_BAD_ARGS,
+"'breakpoint' expects option-name"},
+{IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_UNKNOWN_OPTION,
+"'breakpoint' error. The option '%s' not found"},
 {IDS_CMD_ERR_EXPR_INVALID, "Failed to evaluate expression: %s"},
 {IDS_CMD_ERR_ATTACH_FAILED,
  "Command '%s'. Attach to process failed: %s"},
Index: tools/lldb-mi/MICmdCmdGdbShow.h
===
--- tools/lldb-mi/MICmdCmdGdbShow.h
+++ tools/lldb-mi/MICmdCmdGdbShow.h
@@ -80,6 +80,7 @@
   bool OptionFnLanguage(const CMIUtilString::VecString_t &vrWords);
   bool OptionFnDisassemblyFlavor(const CMIUtilString::VecString_t &vrWords);
   bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
+  bool OptionFnBreakpoint(const CMIUtilString::VecString_t &vrWords);
 
   // Attributes:
 private:
Index: tools/lldb-mi/MICmdCmdGdbShow.cpp
===
--- tools/lldb-mi/MICmdCmdGdbShow.cpp
+++ tools/lldb-mi/MICmdCmdGdbShow.cpp
@@ -32,7 +32,8 @@
 {"print", &CMICmdCmdGdbShow::OptionFnPrint},
 {"language", &CMICmdCmdGdbShow::OptionFnLanguage},
 {"disassembly-flavor", &CMICmdCmdGdbShow::OptionFnDisassemblyFlavor},
-{"fallback", &CMICmdCmdGdbShow::OptionFnFallback}};
+{"fallback", &CMICmdCmdGdbShow::OptionFnFallback},
+{"breakpoint", &CMICmdCmdGdbShow::OptionFnBreakpoint}};
 
 //++
 //
@@ -347,6 +348,43 @@
   return MIstatus::success;
 }
 
+//++
+//
+// Details: Carry out work to complete the GDB show option 'breakpoint' to
+// prepare
+//  and send back the requested information.
+// Type:Method.
+// Args:vrWords - (R) List of additional parameters used by this option.
+// Return:  MIstatus::success - Function succeeded.
+//  MIstatus::failure - Function failed.
+// Throws:  None.
+//--
+bool CMICmdCmdGdbShow::OptionFnBreakpoint(
+const CMIUtilString::VecString_t &vrWords) {
+  if (vrWords.size() != 1) {
+m_bGbbOptionFnHasError = true;
+m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_BAD_ARGS);
+return MIstatus::failure;
+  }
+
+  const CMIUtilString strOption(vrWords[0]);
+  if (!CMIUtilString::Compare(strOption, "pending")) {
+m_bGbbOptionFnHasError = true;
+m_strGdbOptionFnError = CMIUtilString::Format(
+MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_UNKNOWN_OPTION),
+strOption.c_str());
+return MIstatus::failure;
+  }
+
+  if (!m_rLLDBDebugSessionInfo.SharedDataRetrieve("breakpoint.pending",
+