[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lit/tools/lldb-mi/exec/exec-next.test:19
+
+-exec-next --thread 0
+# Check that exec-next can process the case of invalid thread ID.

aprantl wrote:
> 0 feels like it might actually be a valid thread id on some systems.. perhaps 
> use really high number instead?
I was surprised by that as well, so I tried a some experiments. I don't know 
how or why, but lldb-mi seems to use it's own notion of thread-ids, which are 
independent of os-level ids and always start with one. I guess they are just 
indexes into the list of threads. I don't know if that is intentional or what.



Comment at: tools/lldb-mi/MICmdCmdExec.cpp:384
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread = 
rSessionInfo.GetProcess().GetThreadByID(nThreadId);
+if (sbThread.IsValid())

polyakov.alex wrote:
> We can't test this branch until we have a way to get thread ID and then store 
> it in some variable.
Yes, that's the issue I was alluding to. I am not going to block this patch 
over it or anything, but I want to make sure you are aware that you're hitting 
the limitations of the FileCheck test approach already.

That said, if what I said above about the thread-id's always being numbered 
starting from one is true, then the thread ids may be predictable enough to 
test using `-exec-next --thread 1`  and avoid this problem for now.


https://reviews.llvm.org/D47797



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


[Lldb-commits] [lldb] r334177 - [LLDB] Unit tests / typo fix

2018-06-07 Thread David Carlier via lldb-commits
Author: devnexen
Date: Thu Jun  7 01:58:34 2018
New Revision: 334177

URL: http://llvm.org/viewvc/llvm-project?rev=334177&view=rev
Log:
[LLDB] Unit tests / typo fix

removing unnecessary comma.

Modified:
lldb/trunk/unittests/Symbol/TestType.cpp

Modified: lldb/trunk/unittests/Symbol/TestType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Symbol/TestType.cpp?rev=334177&r1=334176&r2=334177&view=diff
==
--- lldb/trunk/unittests/Symbol/TestType.cpp (original)
+++ lldb/trunk/unittests/Symbol/TestType.cpp Thu Jun  7 01:58:34 2018
@@ -30,7 +30,7 @@ void TestGetTypeScopeAndBasenameHelper(c
 EXPECT_EQ(name, expected_name);
   }
 }
-};
+}
 
 TEST(Type, GetTypeScopeAndBasename) {
   TestGetTypeScopeAndBasenameHelper("int", false, "", "");


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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D47708#1124429, @zturner wrote:

> Do you just need a pdb, or does it really need to be a vs pdb? lld can
>  generate high quality pdbs now. So it might be possible to use lld to link
>  and produce a pdb when you run the test.
>
> Pavel’s suggestion is equally viable, you can dump a pdb to yaml and
>  convert it back to a pdb at test time.
>
> The real problem is the exe. It’s harder to generate exes at test time
>  because we have to ensure that dependent libraries are present on the
>  system.
>
> If it has to be an msvc generated pdb, can you elaborate on why? Tbh I’m
>  not really against checking in pdbs. Exes I’d like to find a way to avoid
>  checking in wherever possible though. And even then, sometimes I don’t have
>  any better ideas other than compile and link before running the test


I guess that part that makes generating the exe during test tricky is the 
feedback loop needed for PGO. I don't know enough about the windows ecosystem 
to tell if there is a different way to generate these kinds of split line 
tables (on linux I can think of a several).

I suppose the reason you can't do the same yaml2obj trick on the .exe is 
because yaml2obj does not support serializing exe's yet?




Comment at: unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp:8-9
+
+#include 
+#include 
+

Could we shrink the size of these binaries by not using c and c++ standard 
library features?



Comment at: unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp:11-27
+int main()
+{
+auto b = false;
+for (auto i = 1; i <= 1024; i++)
+{
+if (b)
+{

Could you clang-format this patch?



Comment at: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp:375-398
+  uint32_t count =
+  symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
+  EXPECT_EQ(1u, count);
+
+  SymbolContext sc;
+  EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+

I think these kinds of checks would be a nice fit for a `lldb-test symbols 
--verify` option.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Yes, it does really need to be a VS PDB. Function-level linking is a linker's 
feature and I can't found support of this feature in lld, so I think module 
addresses inconsistency will not be reproducible with lld.

I've tried to convert a VS PDB to YAML and back in the next way:

> llvm-pdbutil.exe pdb2yaml -all test-pdb-function-level-linking.pdb > 
> test-pdb-function-level-linking.yaml
>  llvm-pdbutil.exe yaml2pdb test-pdb-function-level-linking.yaml

and I have put it near the executable, but it seems that the PDB was broken - 
nor lldb, nor IDA can load it, but I didn't investigated the problem in detail 
yet.

As for executable binaries, I think the key problem is that SymbolFilePDBTests 
has two responsibilities:

- Test the retrieving of data from PDB. All tests find a PDB location from the 
executable binary (e.g. TestAbilitiesForPDB checks that we have found a correct 
symbol file) and then somehow retrieve data from the PDB (e.g. via DIA 
interface). As far as I understand, this part is not tested somewhere else. 
This part requires original executable and PDB binaries.

- Test the processing of retrieved data (e.g. building the line table), and 
this is exactly our case. Now this part requires binaries only in 
VerifyLineEntry function. It uses a module object to convert a virtual address 
to an Address structure. The structure is used by the line table to a find 
corresponding entry, but I think that we can introduce a new function for this 
purpose, which would work with simple file address. So we can avoid using of 
the module object in VerifyLineEntry function, and make this part independent 
of binaries.

So if we will split testing of this parts and will find a way to load symbol 
information from some intermediate form, I think it will be possible to reduce 
binaries usage. But it requires some more time and investigation.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I don't know if there is any spec about what the gdb-mi protocol should use for 
thread identification, but I think the most important part is to be consistent. 
If you use indexes in one place and tid's in another you'll confuse the hell 
out of clients trying to talk to lldb-mi.


https://reviews.llvm.org/D47838



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

> I suppose the reason you can't do the same yaml2obj trick on the .exe is 
> because yaml2obj does not support serializing exe's yet?

Yes, it's so.

> Could we shrink the size of these binaries by not using c and c++ standard 
> library features?

The problem is that it is hard to reproduce splitting of a compiled source file 
on little executables, so I haven't found better way to reproduce it than using 
standard library.

> Could you clang-format this patch?

Yes, sure, I'll update patch.

> I think these kinds of checks would be a nice fit for a lldb-test symbols 
> --verify option.

Can you explain this in detail, please?


https://reviews.llvm.org/D47708



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


[Lldb-commits] [lldb] r334181 - DebugNamesDWARFIndex: Add ability to lookup variables

2018-06-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun  7 03:04:44 2018
New Revision: 334181

URL: http://llvm.org/viewvc/llvm-project?rev=334181&view=rev
Log:
DebugNamesDWARFIndex: Add ability to lookup variables

Summary:
This patch adds the ability to lookup variables to the DWARF v5 index
class.

During review we discovered an inconsistency between how the existing
two indexes handle looking up qualified names of the variables:
- manual index would return a value if the input string exactly matched
  the demangled name of some variable.
- apple index ignored the context and returned any variable with the
  same base name.

So, this patch also rectifies that situation:
- it removes all context handling from the index classes. The
  GetGlobalVariables functions now just take a base name. For manual
  index, this meant we can stop putting demangled names into the
  variable index (this matches the behavior for functions).
- context extraction is put into SymbolFileDWARF, so that it is common
  to all indexes.
- additional filtering based on the context is also done in
  SymbolFileDWARF. This is done via a simple substring search, which is
  not ideal, but it matches what we are doing for functions (cf.
  Module::LookupInfo::Prune).

Reviewers: clayborg, JDevlieghere

Subscribers: aprantl, lldb-commits

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

Added:
lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
lldb/trunk/lit/SymbolFile/DWARF/find-qualified-variable.cpp
Modified:
lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Added: lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp?rev=334181&view=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp Thu Jun  7 
03:04:44 2018
@@ -0,0 +1,14 @@
+// Test that we use the DWARF v5 name indexes.
+
+// REQUIRES: lld
+
+// RUN: clang %s -g -c -emit-llvm -o - --target=x86_64-pc-linux | \
+// RUN:   llc -accel-tables=Dwarf -filetype=obj -o %t.o
+// RUN: ld.lld %t.o -o %t
+// RUN: lldb-test symbols %t | FileCheck %s
+
+// CHECK: Name Index
+// CHECK: String: 0x{{.*}} "_start"
+// CHECK: Tag: DW_TAG_subprogram
+
+extern "C" void _start() {}

Modified: lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp?rev=334181&r1=334180&r2=334181&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp Thu Jun  7 03:04:44 
2018
@@ -20,6 +20,18 @@
 // RUN:   FileCheck --check-prefix=REGEX %s
 // RUN: lldb-test symbols --name=not_there --find=variable %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
+//
+// RUN: clang %s -g -c -emit-llvm -o - --target=x86_64-pc-linux | \
+// RUN:   llc -accel-tables=Dwarf -filetype=obj -o %t.o
+// RUN: ld.lld %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \
+// RUN:   FileCheck --check-prefix=CONTEXT %s
+// RUN: lldb-test symbols --name=foo --find=variable %t | \
+// RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \
+// RUN:   FileCheck --check-prefix=REGEX %s
+// RUN: lldb-test symbols --name=not_there --find=variable %t | \
+// RUN:   FileCheck --check-prefix=EMPTY %s
 
 // EMPTY: Found 0 variables:
 // NAME: Found 4 variables:

Added: lldb/trunk/lit/SymbolFile/DWARF/find-qualified-variable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-qualified-variable.cpp?rev=334181&view=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/find-qualified-variable.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-qualified-variable.cpp Thu Jun  7 
03:04:44 2018
@@ -0,0 +1,15 @@
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
+// RUN: lldb-test symbols --name=A::foo --find=variable %t | FileCheck %s
+
+// CHECK: Found 1 variables:
+
+struct A {
+  static int foo;
+};
+int A::foo;
+// NAME-DAG: name = "foo", {{.*}} decl = 
find-qualified-variable.cpp:[[@LINE-1]]
+
+struct B {
+  static int foo;
+}

[Lldb-commits] [PATCH] D47781: DebugNamesDWARFIndex: Add ability to lookup variables

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334181: DebugNamesDWARFIndex: Add ability to lookup 
variables (authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47781

Files:
  lldb/trunk/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
  lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp
  lldb/trunk/lit/SymbolFile/DWARF/find-qualified-variable.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -21,7 +21,7 @@
 
   void Preload() override { Index(); }
 
-  void GetGlobalVariables(ConstString name, DIEArray &offsets) override;
+  void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
   void GetGlobalVariables(const RegularExpression ®ex,
   DIEArray &offsets) override;
   void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override;
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -8,6 +8,8 @@
 //===--===//
 
 #include "Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
 
 using namespace lldb_private;
 using namespace lldb;
@@ -23,11 +25,68 @@
 DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names,
  DWARFDataExtractor debug_str,
  DWARFDebugInfo *debug_info) {
-  auto index_up = llvm::make_unique(ToLLVM(debug_names),
-   ToLLVM(debug_str));
+  auto index_up =
+  llvm::make_unique(ToLLVM(debug_names), ToLLVM(debug_str));
   if (llvm::Error E = index_up->extract())
 return std::move(E);
 
   return std::unique_ptr(new DebugNamesDWARFIndex(
   module, std::move(index_up), debug_names, debug_str, debug_info));
 }
+
+void DebugNamesDWARFIndex::Append(const DebugNames::Entry &entry,
+  DIEArray &offsets) {
+  llvm::Optional cu_offset = entry.getCUOffset();
+  llvm::Optional die_offset = entry.getDIESectionOffset();
+  if (cu_offset && die_offset)
+offsets.emplace_back(*cu_offset, *die_offset);
+}
+
+void DebugNamesDWARFIndex::MaybeLogLookupError(llvm::Error error,
+   const DebugNames::NameIndex &ni,
+   llvm::StringRef name) {
+  // Ignore SentinelErrors, log everything else.
+  LLDB_LOG_ERROR(
+  LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS),
+  handleErrors(std::move(error), [](const DebugNames::SentinelError &) {}),
+  "Failed to parse index entries for index at {1:x}, name {2}: {0}",
+  ni.getUnitOffset(), name);
+}
+
+void DebugNamesDWARFIndex::GetGlobalVariables(ConstString basename,
+  DIEArray &offsets) {
+  for (const DebugNames::Entry &entry :
+   m_debug_names_up->equal_range(basename.GetStringRef())) {
+if (entry.tag() != DW_TAG_variable)
+  continue;
+
+Append(entry, offsets);
+  }
+}
+
+void DebugNamesDWARFIndex::GetGlobalVariables(const RegularExpression ®ex,
+  DIEArray &offsets) {
+  for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
+for (DebugNames::NameTableEntry nte: ni) {
+  if (!regex.Execute(nte.getString()))
+continue;
+
+  uint32_t entry_offset = nte.getEntryOffset();
+  llvm::Expected entry_or = ni.getEntry(&entry_offset);
+  for (; entry_or; entry_or = ni.getEntry(&entry_offset)) {
+if (entry_or->tag() != DW_TAG_variable)
+  continue;
+
+Append(*entry_or, offsets);
+  }
+  MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
+}
+  }
+}
+
+void DebugNamesDWARFIndex::Dump(Stream &s) {
+  std::string data;
+  llvm::raw_string_ostream os(data);
+  m_debug_names_up->dump(os);
+  s.PutCString(os.str());
+}
Index: lldb/trunk/source/Plug

[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 150287.
aleksandr.urakov added a comment.

Formatted test sources corresponding to LLVM rules.


https://reviews.llvm.org/D47708

Files:
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  unittests/SymbolFile/PDB/CMakeLists.txt
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.exe
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.pdb
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.exe
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.pdb
  unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -56,6 +56,10 @@
 SymbolFilePDB::Initialize();
 
 m_pdb_test_exe = GetInputFilePath("test-pdb.exe");
+m_function_level_linking_test_exe =
+GetInputFilePath("test-pdb-function-level-linking.exe");
+m_splitted_function_test_exe =
+GetInputFilePath("test-pdb-splitted-function.exe");
 m_types_test_exe = GetInputFilePath("test-pdb-types.exe");
   }
 
@@ -73,6 +77,8 @@
 
 protected:
   std::string m_pdb_test_exe;
+  std::string m_function_level_linking_test_exe;
+  std::string m_splitted_function_test_exe;
   std::string m_types_test_exe;
 
   bool FileSpecMatchesAsBaseOrFull(const FileSpec &left,
@@ -354,6 +360,56 @@
   VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
 }
 
+void TestLineTableConsistency(llvm::StringRef exe_path, llvm::StringRef source_name)
+{
+  // All line entries of compile unit's line table must be consistent
+  // even if compiled sources are not continuous in the binary file.
+  FileSpec fspec(exe_path, false);
+  ArchSpec aspec("i686-pc-windows");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  FileSpec source_file(source_name, false);
+  uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+  SymbolContextList sc_list;
+  uint32_t count =
+  symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
+  EXPECT_EQ(1u, count);
+
+  SymbolContext sc;
+  EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+
+  LineTable *lt = sc.comp_unit->GetLineTable();
+  EXPECT_NE(nullptr, lt);
+
+  count = lt->GetSize();
+  EXPECT_LT(0u, count);
+
+  LineEntry le;
+  EXPECT_TRUE(lt->GetLineEntryAtIndex(0, le));
+  for (int i = 1; i < count; i++)
+  {
+lldb::addr_t curr_end =
+le.range.GetBaseAddress().GetFileAddress() + le.range.GetByteSize();
+
+EXPECT_TRUE(lt->GetLineEntryAtIndex(i, le));
+
+EXPECT_LE(curr_end, le.range.GetBaseAddress().GetFileAddress());
+  }
+}
+
+TEST_F(SymbolFilePDBTests, TestFunctionLevelLinking) {
+  TestLineTableConsistency(
+  m_function_level_linking_test_exe,
+  "test-pdb-function-level-linking.cpp");
+}
+
+TEST_F(SymbolFilePDBTests, TestSplittedFunction) {
+  TestLineTableConsistency(
+  m_splitted_function_test_exe,
+  "test-pdb-splitted-function.cpp");
+}
+
 TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
@@ -0,0 +1,24 @@
+// Compile with "cl /c /Zi /GL /O2 /EHsc /MTd test-pdb-splitted-function.cpp"
+// Link with "link /debug:full /LTCG /GENPROFILE
+//   test-pdb-splitted-function.obj"
+// Run several times
+// Link with "link /debug:full /LTCG /USEPROFILE
+//   test-pdb-splitted-function.obj"
+
+#include 
+#include 
+
+int main() {
+  auto b = false;
+  for (auto i = 1; i <= 1024; i++) {
+if (b) {
+  std::cout << "Unreachable code" << std::endl;
+  auto x = std::sin(i);
+  return x;
+}
+
+b = (i % 2 + (i - 1) % 2) != 1;
+  }
+
+  return 0;
+}
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.cpp
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.cpp
@@ -0,0 +1,15 @@
+// Compile with "cl /c /ZI /sdl /EHsc /MTd /permissive-
+// test-pdb-function-level-linking.cpp"
+// Link with "link /debug:full test-pdb-function-level-linking.obj"
+
+#include 
+#include 
+
+std::string foo() {
+  return "Hello!";
+}
+
+int main() {
+  auto x = foo();
+  return 0;
+}
Index: unittests/SymbolFile/PDB/CMakeLists.txt
===
--- unittests/SymbolFile/PDB/CMakeLists.txt
+++ unittests/SymbolFile/PDB/CMakeLists.txt
@@ -17,

[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D47708#1124733, @aleksandr.urakov wrote:

> > I think these kinds of checks would be a nice fit for a lldb-test symbols 
> > --verify option.
>
> Can you explain this in detail, please?


We have an lldb-test executable, which we use for writing tests (see tests in 
lit/SymbolFile). It's `symbols` subcommand currently just dumps their contents 
and then we match that.

Your checks don't have any assumptions about the input hardcoded in them. This 
may be both good and bad, but anyway, my idea was to add a `--verify` flag to 
lldb-test (similar to how `llvm-dwarfdump --verify` works) which would run 
these checks (and any other we can think of later). Then, the test would simply 
consist of running `lldb-test symbols --verify your.exe` and asserting that it 
returns success.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

In https://reviews.llvm.org/D47708#1124743, @labath wrote:

> We have an lldb-test executable, which we use for writing tests (see tests in 
> lit/SymbolFile). It's `symbols` subcommand currently just dumps their 
> contents and then we match that.
>
> Your checks don't have any assumptions about the input hardcoded in them. 
> This may be both good and bad, but anyway, my idea was to add a `--verify` 
> flag to lldb-test (similar to how `llvm-dwarfdump --verify` works) which 
> would run these checks (and any other we can think of later). Then, the test 
> would simply consist of running `lldb-test symbols --verify your.exe` and 
> asserting that it returns success.


Thank you, I'll implement this. Will be it better to create a different review 
for this?


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I don't think that's necessary. The actual fix is really simple and this whole 
discussion is just about figuring out what to do with tests.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Btw, would it be possible to use the `/order` directive to achive what you 
want? 
(/order:function_from_first_file,function_from_second_file,another_function_from_first_file)


https://reviews.llvm.org/D47708



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


[Lldb-commits] [lldb] r334185 - DebugNamesDWARFIndex: Add support for partial indexes

2018-06-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun  7 03:35:28 2018
New Revision: 334185

URL: http://llvm.org/viewvc/llvm-project?rev=334185&view=rev
Log:
DebugNamesDWARFIndex: Add support for partial indexes

Summary:
It possible that a single module has indexed and non-indexed compile
units. In this case, we can use the fast indexed lookup for the first
ones and fall back to the manual index for the others.

This patch implements this functionality by adding a units_to_avoid
argument to the ManualDWARFIndex constructor. Any units present in that
list will be ignored for the purposes of manual index. Individual
DebugNamesDWARFIndex then always consult both the manual fallback index
as well as the index in the .debug_names section.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, lldb-commits

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

Added:
lldb/trunk/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h

Added: lldb/trunk/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp?rev=334185&view=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp Thu Jun  7 
03:35:28 2018
@@ -0,0 +1,25 @@
+// Test that we return complete results when only a part of the binary is built
+// with an index.
+
+// REQUIRES: lld
+
+// RUN: clang %s -g -c -emit-llvm -o - --target=x86_64-pc-linux -DONE | \
+// RUN:   llc -accel-tables=Dwarf -filetype=obj -o %t-1.o
+// RUN: clang %s -g -c -emit-llvm -o - --target=x86_64-pc-linux -DTWO | \
+// RUN:   llc -accel-tables=Disable -filetype=obj -o %t-2.o
+// RUN: ld.lld %t-1.o %t-2.o -o %t
+// RUN: lldb-test symbols --find=variable --name=foo  %t | FileCheck %s
+
+// CHECK: Found 2 variables:
+#ifdef ONE
+namespace one {
+int foo;
+// CHECK-DAG: name = "foo", {{.*}} decl = dwarf5-partial-index.cpp:[[@LINE-1]]
+} // namespace one
+extern "C" void _start() {}
+#else
+namespace two {
+int foo;
+// CHECK-DAG: name = "foo", {{.*}} decl = dwarf5-partial-index.cpp:[[@LINE-1]]
+} // namespace two
+#endif

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp?rev=334185&r1=334184&r2=334185&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp Thu Jun 
 7 03:35:28 2018
@@ -34,6 +34,16 @@ DebugNamesDWARFIndex::Create(Module &mod
   module, std::move(index_up), debug_names, debug_str, debug_info));
 }
 
+llvm::DenseSet
+DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) {
+  llvm::DenseSet result;
+  for (const DebugNames::NameIndex &ni : debug_names) {
+for (uint32_t cu = 0; cu < ni.getCUCount(); ++cu)
+  result.insert(ni.getCUOffset(cu));
+  }
+  return result;
+}
+
 void DebugNamesDWARFIndex::Append(const DebugNames::Entry &entry,
   DIEArray &offsets) {
   llvm::Optional cu_offset = entry.getCUOffset();
@@ -55,6 +65,8 @@ void DebugNamesDWARFIndex::MaybeLogLooku
 
 void DebugNamesDWARFIndex::GetGlobalVariables(ConstString basename,
   DIEArray &offsets) {
+  m_fallback.GetGlobalVariables(basename, offsets);
+
   for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(basename.GetStringRef())) {
 if (entry.tag() != DW_TAG_variable)
@@ -66,6 +78,8 @@ void DebugNamesDWARFIndex::GetGlobalVari
 
 void DebugNamesDWARFIndex::GetGlobalVariables(const RegularExpression ®ex,
   DIEArray &offsets) {
+  m_fallback.GetGlobalVariables(regex, offsets);
+
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
   if (!regex.Execute(nte.getString()))
@@ -85,6 +99,8 @@ void DebugNamesDWARFIndex::GetGlobalVari
 }
 
 void DebugNamesDWARFIndex::Dump(Stream &s) {
+  m_fallback.Dump(s);
+
   std::string data;
   llvm::raw_string_ostream os(data);
   m_debug_names_up->dump(os);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h?rev=334185&r1=334184&r2=334185&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (original)

[Lldb-commits] [PATCH] D47832: DebugNamesDWARFIndex: Add support for partial indexes

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334185: DebugNamesDWARFIndex: Add support for partial 
indexes (authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47832?vs=150155&id=150289#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47832

Files:
  lldb/trunk/lit/SymbolFile/DWARF/dwarf5-partial-index.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -34,6 +34,16 @@
   module, std::move(index_up), debug_names, debug_str, debug_info));
 }
 
+llvm::DenseSet
+DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) {
+  llvm::DenseSet result;
+  for (const DebugNames::NameIndex &ni : debug_names) {
+for (uint32_t cu = 0; cu < ni.getCUCount(); ++cu)
+  result.insert(ni.getCUOffset(cu));
+  }
+  return result;
+}
+
 void DebugNamesDWARFIndex::Append(const DebugNames::Entry &entry,
   DIEArray &offsets) {
   llvm::Optional cu_offset = entry.getCUOffset();
@@ -55,6 +65,8 @@
 
 void DebugNamesDWARFIndex::GetGlobalVariables(ConstString basename,
   DIEArray &offsets) {
+  m_fallback.GetGlobalVariables(basename, offsets);
+
   for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(basename.GetStringRef())) {
 if (entry.tag() != DW_TAG_variable)
@@ -66,6 +78,8 @@
 
 void DebugNamesDWARFIndex::GetGlobalVariables(const RegularExpression ®ex,
   DIEArray &offsets) {
+  m_fallback.GetGlobalVariables(regex, offsets);
+
   for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
 for (DebugNames::NameTableEntry nte: ni) {
   if (!regex.Execute(nte.getString()))
@@ -85,6 +99,8 @@
 }
 
 void DebugNamesDWARFIndex::Dump(Stream &s) {
+  m_fallback.Dump(s);
+
   std::string data;
   llvm::raw_string_ostream os(data);
   m_debug_names_up->dump(os);
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -12,6 +12,7 @@
 
 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
 #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
+#include "Plugins/SymbolFile/DWARF/ManualDWARFIndex.h"
 #include "lldb/Utility/ConstString.h"
 #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
 
@@ -22,7 +23,7 @@
   Create(Module &module, DWARFDataExtractor debug_names,
  DWARFDataExtractor debug_str, DWARFDebugInfo *debug_info);
 
-  void Preload() override {}
+  void Preload() override { m_fallback.Preload(); }
 
   void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
   void GetGlobalVariables(const RegularExpression ®ex,
@@ -51,19 +52,23 @@
DWARFDataExtractor debug_names_data,
DWARFDataExtractor debug_str_data,
DWARFDebugInfo *debug_info)
-  : DWARFIndex(module), m_debug_names_up(std::move(debug_names_up)) {}
+  : DWARFIndex(module), m_debug_names_up(std::move(debug_names_up)),
+m_fallback(module, debug_info, GetUnits(*m_debug_names_up)) {}
 
   // LLVM DWARFDebugNames will hold a non-owning reference to this data, so keep
   // track of the ownership here.
   DWARFDataExtractor m_debug_names_data;
   DWARFDataExtractor m_debug_str_data;
 
   using DebugNames = llvm::DWARFDebugNames;
   std::unique_ptr m_debug_names_up;
+  ManualDWARFIndex m_fallback;
 
   void Append(const DebugNames::Entry &entry, DIEArray &offsets);
   void MaybeLogLookupError(llvm::Error error, const DebugNames::NameIndex &ni,
llvm::StringRef name);
+
+  static llvm::DenseSet GetUnits(const DebugNames &debug_names);
 };
 
 } // namespace lldb_private
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -32,28 +32,30 @@
   static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
   Timer scoped_timer(func_cat, "%p", static_cast(&debug_info));
 
-  const uint32_t num_compile_units = debug_info.GetNumCompileUnits();
-  if (num_compile_units == 0)
+  std::vector units_to_index;
+  units_to_in

[Lldb-commits] [lldb] r334186 - DebugNamesDWARFIndex: add namespace lookup support

2018-06-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun  7 03:56:16 2018
New Revision: 334186

URL: http://llvm.org/viewvc/llvm-project?rev=334186&view=rev
Log:
DebugNamesDWARFIndex: add namespace lookup support

Modified:
lldb/trunk/lit/SymbolFile/DWARF/find-basic-namespace.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

Modified: lldb/trunk/lit/SymbolFile/DWARF/find-basic-namespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-basic-namespace.cpp?rev=334186&r1=334185&r2=334186&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/find-basic-namespace.cpp (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-basic-namespace.cpp Thu Jun  7 
03:56:16 2018
@@ -17,6 +17,16 @@
 // RUN: lldb-test symbols --name=not_there --find=namespace %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
 
+// RUN: clang %s -g -c -emit-llvm -o - --target=x86_64-pc-linux | \
+// RUN:   llc -accel-tables=Dwarf -filetype=obj -o %t.o
+// RUN: ld.lld %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=namespace %t | \
+// RUN:   FileCheck --check-prefix=FOO %s
+// RUN: lldb-test symbols --name=foo --find=namespace --context=context %t | \
+// RUN:   FileCheck --check-prefix=CONTEXT %s
+// RUN: lldb-test symbols --name=not_there --find=namespace %t | \
+// RUN:   FileCheck --check-prefix=EMPTY %s
+
 // FOO: Found namespace: foo
 
 // CONTEXT: Found namespace: bar::foo

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp?rev=334186&r1=334185&r2=334186&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp Thu Jun 
 7 03:56:16 2018
@@ -98,6 +98,16 @@ void DebugNamesDWARFIndex::GetGlobalVari
   }
 }
 
+void DebugNamesDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
+  m_fallback.GetNamespaces(name, offsets);
+
+  for (const DebugNames::Entry &entry :
+   m_debug_names_up->equal_range(name.GetStringRef())) {
+if (entry.tag() == DW_TAG_namespace)
+  Append(entry, offsets);
+  }
+}
+
 void DebugNamesDWARFIndex::Dump(Stream &s) {
   m_fallback.Dump(s);
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h?rev=334186&r1=334185&r2=334186&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Thu Jun  
7 03:56:16 2018
@@ -34,7 +34,7 @@ public:
 DIEArray &offsets) override {}
   void GetTypes(ConstString name, DIEArray &offsets) override {}
   void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override {}
-  void GetNamespaces(ConstString name, DIEArray &offsets) override {}
+  void GetNamespaces(ConstString name, DIEArray &offsets) override;
   void GetFunctions(ConstString name, DWARFDebugInfo &info,
 const CompilerDeclContext &parent_decl_ctx,
 uint32_t name_type_mask,


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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

In https://reviews.llvm.org/D47708#1124749, @labath wrote:

> Btw, would it be possible to use the `/order` directive to achive what you 
> want? 
> (/order:function_from_first_file,function_from_second_file,another_function_from_first_file)


Yes, thanks for pointing to this!


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 150295.
aleksandr.urakov added a comment.

Use /ORDER switch to reduce test binaries size.


https://reviews.llvm.org/D47708

Files:
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  unittests/SymbolFile/PDB/CMakeLists.txt
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.exe
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.h
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.ord
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.pdb
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.exe
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.pdb
  unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -56,6 +56,10 @@
 SymbolFilePDB::Initialize();
 
 m_pdb_test_exe = GetInputFilePath("test-pdb.exe");
+m_function_level_linking_test_exe =
+GetInputFilePath("test-pdb-function-level-linking.exe");
+m_splitted_function_test_exe =
+GetInputFilePath("test-pdb-splitted-function.exe");
 m_types_test_exe = GetInputFilePath("test-pdb-types.exe");
   }
 
@@ -73,6 +77,8 @@
 
 protected:
   std::string m_pdb_test_exe;
+  std::string m_function_level_linking_test_exe;
+  std::string m_splitted_function_test_exe;
   std::string m_types_test_exe;
 
   bool FileSpecMatchesAsBaseOrFull(const FileSpec &left,
@@ -354,6 +360,56 @@
   VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
 }
 
+void TestLineTableConsistency(llvm::StringRef exe_path, llvm::StringRef source_name)
+{
+  // All line entries of compile unit's line table must be consistent
+  // even if compiled sources are not continuous in the binary file.
+  FileSpec fspec(exe_path, false);
+  ArchSpec aspec("i686-pc-windows");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  FileSpec source_file(source_name, false);
+  uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+  SymbolContextList sc_list;
+  uint32_t count =
+  symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
+  EXPECT_EQ(1u, count);
+
+  SymbolContext sc;
+  EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+
+  LineTable *lt = sc.comp_unit->GetLineTable();
+  EXPECT_NE(nullptr, lt);
+
+  count = lt->GetSize();
+  EXPECT_LT(0u, count);
+
+  LineEntry le;
+  EXPECT_TRUE(lt->GetLineEntryAtIndex(0, le));
+  for (int i = 1; i < count; i++)
+  {
+lldb::addr_t curr_end =
+le.range.GetBaseAddress().GetFileAddress() + le.range.GetByteSize();
+
+EXPECT_TRUE(lt->GetLineEntryAtIndex(i, le));
+
+EXPECT_LE(curr_end, le.range.GetBaseAddress().GetFileAddress());
+  }
+}
+
+TEST_F(SymbolFilePDBTests, TestFunctionLevelLinking) {
+  TestLineTableConsistency(
+  m_function_level_linking_test_exe,
+  "test-pdb-function-level-linking.cpp");
+}
+
+TEST_F(SymbolFilePDBTests, TestSplittedFunction) {
+  TestLineTableConsistency(
+  m_splitted_function_test_exe,
+  "test-pdb-splitted-function.cpp");
+}
+
 TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
@@ -0,0 +1,24 @@
+// Compile with "cl /c /Zi /GL /O2 /EHsc /MTd test-pdb-splitted-function.cpp"
+// Link with "link /debug:full /LTCG /GENPROFILE
+//   test-pdb-splitted-function.obj"
+// Run several times
+// Link with "link /debug:full /LTCG /USEPROFILE
+//   test-pdb-splitted-function.obj"
+
+#include 
+#include 
+
+int main() {
+  auto b = false;
+  for (auto i = 1; i <= 1024; i++) {
+if (b) {
+  std::cout << "Unreachable code" << std::endl;
+  auto x = std::sin(i);
+  return x;
+}
+
+b = (i % 2 + (i - 1) % 2) != 1;
+  }
+
+  return 0;
+}
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.ord
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.ord
@@ -0,0 +1,3 @@
+?foo@@YAHXZ
+?bar@@YAHXZ
+main
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.h
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.h
@@ -0,0 +1,5 @@
+#pragma once
+
+int bar() {
+  return 0;
+}
Index: unittests/SymbolFile/PDB/Inputs/test-pdb

[Lldb-commits] [lldb] r334190 - DebugNamesDWARFIndex: Add type lookup suport

2018-06-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun  7 05:26:18 2018
New Revision: 334190

URL: http://llvm.org/viewvc/llvm-project?rev=334190&view=rev
Log:
DebugNamesDWARFIndex: Add type lookup suport

This implements just one of the GetTypes overloads. The other is not
testable from lldb-test so I'm leaving it unimplemented until I figure
out what to do with testing.

Modified:
lldb/trunk/lit/SymbolFile/DWARF/find-basic-type.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

Modified: lldb/trunk/lit/SymbolFile/DWARF/find-basic-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-basic-type.cpp?rev=334190&r1=334189&r2=334190&view=diff
==
--- lldb/trunk/lit/SymbolFile/DWARF/find-basic-type.cpp (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-basic-type.cpp Thu Jun  7 05:26:18 2018
@@ -17,6 +17,16 @@
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
 
+// RUN: clang %s -g -c -emit-llvm -o - --target=x86_64-pc-linux | \
+// RUN:   llc -accel-tables=Dwarf -filetype=obj -o %t.o
+// RUN: ld.lld %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
+// RUN:   FileCheck --check-prefix=CONTEXT %s
+// RUN: lldb-test symbols --name=not_there --find=type %t | \
+// RUN:   FileCheck --check-prefix=EMPTY %s
+
 // EMPTY: Found 0 types:
 // NAME: Found 4 types:
 // CONTEXT: Found 1 types:

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp?rev=334190&r1=334189&r2=334190&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp Thu Jun 
 7 05:26:18 2018
@@ -98,6 +98,16 @@ void DebugNamesDWARFIndex::GetGlobalVari
   }
 }
 
+void DebugNamesDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
+  m_fallback.GetTypes(name, offsets);
+
+  for (const DebugNames::Entry &entry :
+   m_debug_names_up->equal_range(name.GetStringRef())) {
+if (isType(entry.tag()))
+  Append(entry, offsets);
+  }
+}
+
 void DebugNamesDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
   m_fallback.GetNamespaces(name, offsets);
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h?rev=334190&r1=334189&r2=334190&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Thu Jun  
7 05:26:18 2018
@@ -32,7 +32,7 @@ public:
   void GetObjCMethods(ConstString class_name, DIEArray &offsets) override {}
   void GetCompleteObjCClass(ConstString class_name, bool 
must_be_implementation,
 DIEArray &offsets) override {}
-  void GetTypes(ConstString name, DIEArray &offsets) override {}
+  void GetTypes(ConstString name, DIEArray &offsets) override;
   void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override {}
   void GetNamespaces(ConstString name, DIEArray &offsets) override;
   void GetFunctions(ConstString name, DWARFDebugInfo &info,


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


Re: [Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Zachary Turner via lldb-commits
On Thu, Jun 7, 2018 at 2:53 AM Aleksandr Urakov via Phabricator <
revi...@reviews.llvm.org> wrote:

> aleksandr.urakov added a comment.
>
> Yes, it does really need to be a VS PDB. Function-level linking is a
> linker's feature and I can't found support of this feature in lld, so I
> think module addresses inconsistency will not be reproducible with lld.
>

Function level linking is a compiler feature, not a linker feature.  It's
enabled via the /Gy option in the compiler and causes the compiler to put
each function into its own COMDAT.  The linker can then use this to discard
more functions (e.g. during /OPT:REF).

clang-cl also supports the /Gy option, right?
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 150322.
aleksandr.urakov added a comment.

The implementation of lldb-test symbols -verify option.


https://reviews.llvm.org/D47708

Files:
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  tools/lldb-test/lldb-test.cpp
  unittests/SymbolFile/PDB/CMakeLists.txt
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.exe
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.h
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.ord
  unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.pdb
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.exe
  unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.pdb
  unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -56,6 +56,10 @@
 SymbolFilePDB::Initialize();
 
 m_pdb_test_exe = GetInputFilePath("test-pdb.exe");
+m_function_level_linking_test_exe =
+GetInputFilePath("test-pdb-function-level-linking.exe");
+m_splitted_function_test_exe =
+GetInputFilePath("test-pdb-splitted-function.exe");
 m_types_test_exe = GetInputFilePath("test-pdb-types.exe");
   }
 
@@ -73,6 +77,8 @@
 
 protected:
   std::string m_pdb_test_exe;
+  std::string m_function_level_linking_test_exe;
+  std::string m_splitted_function_test_exe;
   std::string m_types_test_exe;
 
   bool FileSpecMatchesAsBaseOrFull(const FileSpec &left,
@@ -354,6 +360,56 @@
   VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
 }
 
+void TestLineTableConsistency(llvm::StringRef exe_path, llvm::StringRef source_name)
+{
+  // All line entries of compile unit's line table must be consistent
+  // even if compiled sources are not continuous in the binary file.
+  FileSpec fspec(exe_path, false);
+  ArchSpec aspec("i686-pc-windows");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  FileSpec source_file(source_name, false);
+  uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;
+  SymbolContextList sc_list;
+  uint32_t count =
+  symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
+  EXPECT_EQ(1u, count);
+
+  SymbolContext sc;
+  EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
+
+  LineTable *lt = sc.comp_unit->GetLineTable();
+  EXPECT_NE(nullptr, lt);
+
+  count = lt->GetSize();
+  EXPECT_LT(0u, count);
+
+  LineEntry le;
+  EXPECT_TRUE(lt->GetLineEntryAtIndex(0, le));
+  for (int i = 1; i < count; i++)
+  {
+lldb::addr_t curr_end =
+le.range.GetBaseAddress().GetFileAddress() + le.range.GetByteSize();
+
+EXPECT_TRUE(lt->GetLineEntryAtIndex(i, le));
+
+EXPECT_LE(curr_end, le.range.GetBaseAddress().GetFileAddress());
+  }
+}
+
+TEST_F(SymbolFilePDBTests, TestFunctionLevelLinking) {
+  TestLineTableConsistency(
+  m_function_level_linking_test_exe,
+  "test-pdb-function-level-linking.cpp");
+}
+
+TEST_F(SymbolFilePDBTests, TestSplittedFunction) {
+  TestLineTableConsistency(
+  m_splitted_function_test_exe,
+  "test-pdb-splitted-function.cpp");
+}
+
 TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
   FileSpec fspec(m_types_test_exe.c_str(), false);
   ArchSpec aspec("i686-pc-windows");
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-splitted-function.cpp
@@ -0,0 +1,24 @@
+// Compile with "cl /c /Zi /GL /O2 /EHsc /MTd test-pdb-splitted-function.cpp"
+// Link with "link /debug:full /LTCG /GENPROFILE
+//   test-pdb-splitted-function.obj"
+// Run several times
+// Link with "link /debug:full /LTCG /USEPROFILE
+//   test-pdb-splitted-function.obj"
+
+#include 
+#include 
+
+int main() {
+  auto b = false;
+  for (auto i = 1; i <= 1024; i++) {
+if (b) {
+  std::cout << "Unreachable code" << std::endl;
+  auto x = std::sin(i);
+  return x;
+}
+
+b = (i % 2 + (i - 1) % 2) != 1;
+  }
+
+  return 0;
+}
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.ord
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.ord
@@ -0,0 +1,4 @@
+?foo@@YAHXZ
+?bar@@YAHXZ
+main
+?baz@@YAHXZ
Index: unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.h
===
--- /dev/null
+++ unittests/SymbolFile/PDB/Inputs/test-pdb-function-level-linking.h
@@ -0,0 +1,12 @@
+#ifndef TEST_PDB_FUNCTION_LEVEL_LINKI

[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex added a comment.

In https://reviews.llvm.org/D47838#1124730, @labath wrote:

> I don't know if there is any spec about what the gdb-mi protocol should use 
> for thread identification, but I think the most important part is to be 
> consistent. If you use indexes in one place and tid's in another you'll 
> confuse the hell out of clients trying to talk to lldb-mi.


Due to https://sourceware.org/gdb/onlinedocs/gdb/Threads.html, gdb has its own 
thread numbers for each thread of an inferior.
So we should do the same, I guess.


https://reviews.llvm.org/D47838



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

> Function level linking is a compiler feature, not a linker feature.  It's 
> enabled via the /Gy option in the compiler and causes the compiler to put 
> each function into its own COMDAT.  The linker can then use this to discard 
> more functions (e.g. during /OPT:REF).
> 
> clang-cl also supports the /Gy option, right?

Yes, you are right. Sorry, I didn't know about such option in clang and 
googling by 'clang function-level linking' didn't show me any relevant 
information.

But Pavel have prompted me Microsoft linker's option '/ORDER', and it is always 
possible to reproduce the problem with it. Without that option it was very 
difficult to reproduce. Has lld some analog?


https://reviews.llvm.org/D47708



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


[Lldb-commits] [lldb] r334198 - DIERef: move trivial constructors into the header

2018-06-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jun  7 07:03:30 2018
New Revision: 334198

URL: http://llvm.org/viewvc/llvm-project?rev=334198&view=rev
Log:
DIERef: move trivial constructors into the header

This enables more inlining/optimization opportunities for a fairly
critical class.

NFCI

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp?rev=334198&r1=334197&r2=334198&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp Thu Jun  7 07:03:30 
2018
@@ -14,11 +14,6 @@
 #include "SymbolFileDWARF.h"
 #include "SymbolFileDWARFDebugMap.h"
 
-DIERef::DIERef()
-: cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) {}
-
-DIERef::DIERef(dw_offset_t c, dw_offset_t d) : cu_offset(c), die_offset(d) {}
-
 DIERef::DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf)
 : cu_offset(DW_INVALID_OFFSET), die_offset(uid & 0x) {
   SymbolFileDWARFDebugMap *debug_map = dwarf->GetDebugMapSymfile();

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h?rev=334198&r1=334197&r2=334198&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h Thu Jun  7 07:03:30 2018
@@ -17,9 +17,9 @@ class DWARFFormValue;
 class SymbolFileDWARF;
 
 struct DIERef {
-  DIERef();
+  DIERef() = default;
 
-  DIERef(dw_offset_t c, dw_offset_t d);
+  DIERef(dw_offset_t c, dw_offset_t d) : cu_offset(c), die_offset(d) {}
 
   //--
   // In order to properly decode a lldb::user_id_t back into a DIERef we
@@ -45,8 +45,8 @@ struct DIERef {
 
   bool operator<(const DIERef &ref) { return die_offset < ref.die_offset; }
 
-  dw_offset_t cu_offset;
-  dw_offset_t die_offset;
+  dw_offset_t cu_offset = DW_INVALID_OFFSET;
+  dw_offset_t die_offset = DW_INVALID_OFFSET;
 };
 
 typedef std::vector DIEArray;


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


[Lldb-commits] [PATCH] D47881: DebugNamesDWARFIndex: Implement GetFunctions method

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: clayborg, JDevlieghere.
Herald added a subscriber: aprantl.

This patch implements the non-regex variant of GetFunctions. To share
more code with the Apple implementation, I've extracted the common
filtering code from that class into a utility function on the DWARFIndex
base class.

The new implementation also searching the accelerator table multiple
times -- previously it could happen that the apple table would return
the same die more than once if one specified multiple search flags in
name_type_mask. This way, I separate table iteration from filtering, and
so we can be sure each die is inserted at most once.


https://reviews.llvm.org/D47881

Files:
  lit/SymbolFile/DWARF/find-basic-function.cpp
  source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/DIERef.h
  source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
===
--- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -38,7 +38,7 @@
   void GetFunctions(ConstString name, DWARFDebugInfo &info,
 const CompilerDeclContext &parent_decl_ctx,
 uint32_t name_type_mask,
-std::vector &dies) override {}
+std::vector &dies) override;
   void GetFunctions(const RegularExpression ®ex,
 DIEArray &offsets) override {}
 
@@ -64,9 +64,11 @@
   std::unique_ptr m_debug_names_up;
   ManualDWARFIndex m_fallback;
 
-  void Append(const DebugNames::Entry &entry, DIEArray &offsets);
-  void MaybeLogLookupError(llvm::Error error, const DebugNames::NameIndex &ni,
-   llvm::StringRef name);
+  static DIERef ToDIERef(const DebugNames::Entry &entry);
+  static void Append(const DebugNames::Entry &entry, DIEArray &offsets);
+  static void MaybeLogLookupError(llvm::Error error,
+  const DebugNames::NameIndex &ni,
+  llvm::StringRef name);
 
   static llvm::DenseSet GetUnits(const DebugNames &debug_names);
 };
Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
 
@@ -44,12 +45,18 @@
   return result;
 }
 
-void DebugNamesDWARFIndex::Append(const DebugNames::Entry &entry,
-  DIEArray &offsets) {
+DIERef DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
   llvm::Optional cu_offset = entry.getCUOffset();
   llvm::Optional die_offset = entry.getDIESectionOffset();
   if (cu_offset && die_offset)
-offsets.emplace_back(*cu_offset, *die_offset);
+return DIERef(*cu_offset, *die_offset);
+  return DIERef();
+}
+
+void DebugNamesDWARFIndex::Append(const DebugNames::Entry &entry,
+  DIEArray &offsets) {
+  if (DIERef ref = ToDIERef(entry))
+offsets.push_back(ref);
 }
 
 void DebugNamesDWARFIndex::MaybeLogLookupError(llvm::Error error,
@@ -118,6 +125,25 @@
   }
 }
 
+void DebugNamesDWARFIndex::GetFunctions(
+ConstString name, DWARFDebugInfo &info,
+const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
+std::vector &dies) {
+
+  m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, dies);
+
+  for (const DebugNames::Entry &entry :
+   m_debug_names_up->equal_range(name.GetStringRef())) {
+Tag tag = entry.tag();
+if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
+  continue;
+
+if (DIERef ref = ToDIERef(entry))
+  ProcessFunctionDIE(name.GetStringRef(), ref, info, parent_decl_ctx,
+ name_type_mask, dies);
+  }
+}
+
 void DebugNamesDWARFIndex::Dump(Stream &s) {
   m_fallback.Dump(s);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFIndex.h
===
--- source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -11,6 +11,7 @@
 #define LLDB_DWARFINDEX_H
 
 #include "Plugins/SymbolFile/DWARF/DIERef.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
 #include "Plugins/SymbolFile/DWARF/DWARFFormValue.h"
 
 class DWARFDebugInfo;
@@ -53,6 +54,15 @@
 
 protected:
   Module &m_module;
+
+  /// Helper function implementing 

[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex updated this revision to Diff 150328.
polyakov.alex added a comment.

Changes for using thread ids in a gdb way. Also added case of specified thread 
into test case.


https://reviews.llvm.org/D47797

Files:
  lit/tools/lldb-mi/exec/exec-next.test
  lit/tools/lldb-mi/exec/inputs/main.c
  tools/lldb-mi/MICmdCmdExec.cpp


Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -22,6 +22,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBThread.h"
 #include "lldb/lldb-enumerations.h"
 
 // In-house headers:
@@ -378,12 +379,17 @@
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
-  CMIUtilString strCmd("thread step-over");
-  if (nThreadId != UINT64_MAX)
-strCmd += CMIUtilString::Format(" %llu", nThreadId);
-  rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
-  false);
+
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread = 
rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
+if (!sbThread.IsValid()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+  return MIstatus::failure;
+}
+sbThread.StepOver();
+  } else rSessionInfo.GetProcess().GetSelectedThread().StepOver();
 
   return MIstatus::success;
 }
Index: lit/tools/lldb-mi/exec/inputs/main.c
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/inputs/main.c
@@ -0,0 +1,4 @@
+int main(void) {
+  int x = 0;
+  return x;
+}
Index: lit/tools/lldb-mi/exec/exec-next.test
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/exec-next.test
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-next command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-next --thread 0
+# Check that exec-next can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-next'. Thread ID invalid"
+
+-exec-next --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
+
+-exec-next
+# Check that exec-next can step over in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"


Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -22,6 +22,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBThread.h"
 #include "lldb/lldb-enumerations.h"
 
 // In-house headers:
@@ -378,12 +379,17 @@
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
-  CMIUtilString strCmd("thread step-over");
-  if (nThreadId != UINT64_MAX)
-strCmd += CMIUtilString::Format(" %llu", nThreadId);
-  rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
-  false);
+
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
+if (!sbThread.IsValid()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+  return MIstatus::failure;
+}
+sbThread.StepOver();
+  } else rSessionInfo.GetProcess().GetSelectedThread().StepOver();
 
   return MIstatus::success;
 }
Index: lit/tools/lldb-mi/exec/inputs/main.c
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/inputs/main.c
@@ -0,0 +1,4 @@
+int main(void) {
+  int x = 0;
+  return x;
+}
Index: lit/tools/lldb-mi/exec/exec-next.test
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/exec-next.test
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-next command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run

[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

As a general rule, lld-link is command line compatible with MSVC and
clang-cl is command line compatible with cl.  So, the /order option should
work exactly the same with lld-link as it does with link.


https://reviews.llvm.org/D47708



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


Re: [Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Zachary Turner via lldb-commits
As a general rule, lld-link is command line compatible with MSVC and
clang-cl is command line compatible with cl.  So, the /order option should
work exactly the same with lld-link as it does with link.

On Thu, Jun 7, 2018 at 7:00 AM Aleksandr Urakov via Phabricator <
revi...@reviews.llvm.org> wrote:

> aleksandr.urakov added a comment.
>
> > Function level linking is a compiler feature, not a linker feature.
> It's enabled via the /Gy option in the compiler and causes the compiler to
> put each function into its own COMDAT.  The linker can then use this to
> discard more functions (e.g. during /OPT:REF).
> >
> > clang-cl also supports the /Gy option, right?
>
> Yes, you are right. Sorry, I didn't know about such option in clang and
> googling by 'clang function-level linking' didn't show me any relevant
> information.
>
> But Pavel have prompted me Microsoft linker's option '/ORDER', and it is
> always possible to reproduce the problem with it. Without that option it
> was very difficult to reproduce. Has lld some analog?
>
>
> https://reviews.llvm.org/D47708
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thank you for implementing the lldb-test extension. Now that we have that, and 
the `/order`, we should be able to get rid of the binaries for the 
function-level-linking test. You should be able to rewrite it into something 
like this:

lit/SymbolFile/PDB/function-level-linking.cpp:

  // REQUIRES: windows lld
  // 
  // RUN: clang-cl /c /Zi /Gy %s /o %t
  // RUN: lld-link /debug:full /nodefaultlib /entry:main 
order:@%S/Inputs/function-level-linking.ord %t.obj /out:%t
  // RUN: lldb-test symbols -verify %t
  
  #include "function-level-linking.h" // You'll probably need to adjust the 
include path for this to work.
  
  int foo() {
return 0;
  }
  
  int main() {
return foo() + bar() + baz();
  }

As for the second test, does it actually bring anything new to the table? As 
far as I can tell, the line table parsing code does not actually use any 
information about functions. Combined with the fact that we don't know how to 
write the test without checked in binaries, maybe we could just drop it ?


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

In https://reviews.llvm.org/D47708#1124994, @zturner wrote:

> As a general rule, lld-link is command line compatible with MSVC and
>  clang-cl is command line compatible with cl.  So, the /order option should
>  work exactly the same with lld-link as it does with link.


It seeems that it is not implemented:

>>lld-link /debug /nodefaultlib /entry:main 
>>/order:@test-pdb-function-level-linking.ord 
>>test-pdb-function-level-linking.obj
>  C:\LLVM\bin\lld-link.EXE: error: could not open 
> /order:@test-pdb-function-level-linking.ord: no such file or directory

`lld-link /?` also don't list such option.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.

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

looks good to me


https://reviews.llvm.org/D47797



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D47708#1125030, @aleksandr.urakov wrote:

> In https://reviews.llvm.org/D47708#1124994, @zturner wrote:
>
> > As a general rule, lld-link is command line compatible with MSVC and
> >  clang-cl is command line compatible with cl.  So, the /order option should
> >  work exactly the same with lld-link as it does with link.
>
>
> It seeems that it is not implemented:
>
> >>lld-link /debug /nodefaultlib /entry:main 
> >>/order:@test-pdb-function-level-linking.ord 
> >>test-pdb-function-level-linking.obj
> >  C:\LLVM\bin\lld-link.EXE: error: could not open 
> > /order:@test-pdb-function-level-linking.ord: no such file or directory
>
> `lld-link /?` also don't list such option.


That's strange. I've learned of this option by browsing the lld-link /? output 
(I didn't check whether it works though). Are you sure you are on the latest 
master branch of llvm?


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

In https://reviews.llvm.org/D47708#1125029, @labath wrote:

> Thank you for implementing the lldb-test extension. Now that we have that, 
> and the `/order`, we should be able to get rid of the binaries for the 
> function-level-linking test. You should be able to rewrite it into something 
> like this:
>
> lit/SymbolFile/PDB/function-level-linking.cpp:
>
>   // REQUIRES: windows lld
>   // 
>   // RUN: clang-cl /c /Zi /Gy %s /o %t
>   // RUN: lld-link /debug:full /nodefaultlib /entry:main 
> order:@%S/Inputs/function-level-linking.ord %t.obj /out:%t
>   // RUN: lldb-test symbols -verify %t
>  
>   #include "function-level-linking.h" // You'll probably need to adjust the 
> include path for this to work.
>  
>   int foo() {
> return 0;
>   }
>  
>   int main() {
> return foo() + bar() + baz();
>   }
>
>
> As for the second test, does it actually bring anything new to the table? As 
> far as I can tell, the line table parsing code does not actually use any 
> information about functions. Combined with the fact that we don't know how to 
> write the test without checked in binaries, maybe we could just drop it ?


Yes, you are right, the second test does not bring anything new to the table. I 
have made it just by Leonard Mosescu suggestion. I think we can drop it.

As for `/ORDER` switch, I have tried it on the release version. Thanks for the 
point, I'll try the master version.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex updated this revision to Diff 150332.
polyakov.alex added a comment.

Changes for using thread ids in a gdb way. Also added case of specified thread 
into test case.


https://reviews.llvm.org/D47838

Files:
  lit/tools/lldb-mi/exec/exec-step.test
  tools/lldb-mi/MICmdCmdExec.cpp


Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -509,14 +509,28 @@
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
-  CMIUtilString strCmd("thread step-in");
-  if (nThreadId != UINT64_MAX)
-strCmd += CMIUtilString::Format(" %llu", nThreadId);
-  rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
-  false);
 
-  return MIstatus::success;
+  lldb::SBError error;
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread =
+rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
+if (!sbThread.IsValid()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+  return MIstatus::failure;
+}
+sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error);
+  } else rSessionInfo.GetProcess().GetSelectedThread().StepInto(
+ nullptr, LLDB_INVALID_LINE_NUMBER, error);
+
+  if (error.Success())
+return MIstatus::success;
+
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED),
+ m_cmdData.strMiCmd.c_str(),
+ error.GetCString()));
+  return MIstatus::failure;
 }
 
 //++
Index: lit/tools/lldb-mi/exec/exec-step.test
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/exec-step.test
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-step command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-step --thread 0
+# Check that exec-step can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-step'. Thread ID invalid"
+
+-exec-step --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
+
+-exec-step
+# Check that exec-step can step-in in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"


Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -509,14 +509,28 @@
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
-  CMIUtilString strCmd("thread step-in");
-  if (nThreadId != UINT64_MAX)
-strCmd += CMIUtilString::Format(" %llu", nThreadId);
-  rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
-  false);
 
-  return MIstatus::success;
+  lldb::SBError error;
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread =
+rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
+if (!sbThread.IsValid()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+  return MIstatus::failure;
+}
+sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error);
+  } else rSessionInfo.GetProcess().GetSelectedThread().StepInto(
+ nullptr, LLDB_INVALID_LINE_NUMBER, error);
+
+  if (error.Success())
+return MIstatus::success;
+
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED),
+ m_cmdData.strMiCmd.c_str(),
+ error.GetCString()));
+  return MIstatus::failure;
 }
 
 //++
Index: lit/tools/lldb-mi/exec/exec-step.test
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/exec-step.test
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-step command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-step --thread 0
+# Check that exec-step can process the case of inva

[Lldb-commits] [PATCH] D47889: Use llvm::VersionTuple instead of manual version marshalling

2018-06-07 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: zturner, friss, clayborg, jingham.
Herald added a subscriber: emaste.

This has multiple advantages:

- we need only one function argument/instance variable instead of three
- no need to default initialize variables
- no custom parsing code
- VersionTuple has comparison operators, which makes version comparisons much 
simpler

I think this touches a lot of code which is not very well tested, so I'd
appreciate it if you can double-check the transformations in the code that you
are familiar with.


https://reviews.llvm.org/D47889

Files:
  include/lldb/Core/Module.h
  include/lldb/Host/freebsd/HostInfoFreeBSD.h
  include/lldb/Host/linux/HostInfoLinux.h
  include/lldb/Host/macosx/HostInfoMacOSX.h
  include/lldb/Host/netbsd/HostInfoNetBSD.h
  include/lldb/Host/windows/HostInfoWindows.h
  include/lldb/Interpreter/OptionGroupPlatform.h
  include/lldb/Symbol/ObjectFile.h
  include/lldb/Target/Platform.h
  include/lldb/Target/Process.h
  include/lldb/Utility/Args.h
  source/API/SBModule.cpp
  source/API/SBPlatform.cpp
  source/Core/Module.cpp
  source/Host/freebsd/HostInfoFreeBSD.cpp
  source/Host/linux/HostInfoLinux.cpp
  source/Host/macosx/HostInfoMacOSX.mm
  source/Host/netbsd/HostInfoNetBSD.cpp
  source/Host/windows/HostInfoWindows.cpp
  source/Interpreter/OptionGroupPlatform.cpp
  source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  source/Plugins/Platform/Android/PlatformAndroid.cpp
  source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  source/Plugins/Platform/MacOSX/PlatformDarwin.h
  source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
  source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
  source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  source/Plugins/Platform/Windows/PlatformWindows.cpp
  source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  source/Target/Platform.cpp
  source/Utility/Args.cpp
  unittests/Platform/PlatformDarwinTest.cpp

Index: unittests/Platform/PlatformDarwinTest.cpp
===
--- unittests/Platform/PlatformDarwinTest.cpp
+++ unittests/Platform/PlatformDarwinTest.cpp
@@ -19,38 +19,29 @@
 using namespace lldb_private;
 
 TEST(PlatformDarwinTest, TestParseVersionBuildDir) {
-  uint32_t A, B, C;
+  llvm::VersionTuple V;
   llvm::StringRef D;
 
-  std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test1)");
-  EXPECT_EQ(1u, A);
-  EXPECT_EQ(2u, B);
-  EXPECT_EQ(3u, C);
+  std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test1)");
+  EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V);
   EXPECT_EQ("test1", D);
 
-  std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("2.3 (test2)");
-  EXPECT_EQ(2u, A);
-  EXPECT_EQ(3u, B);
+  std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("2.3 (test2)");
+  EXPECT_EQ(llvm::VersionTuple(2, 3), V);
   EXPECT_EQ("test2", D);
 
-  std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("3 (test3)");
-  EXPECT_EQ(3u, A);
+  std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3 (test3)");
+  EXPECT_EQ(llvm::VersionTuple(3), V);
   EXPECT_EQ("test3", D);
 
-  std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test");
-  EXPECT_EQ(1u, A);
-  EXPECT_EQ(2u, B);
-  EXPECT_EQ(3u, C);
+  std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test");
+  EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V);
   EXPECT_EQ("test", D);
 
-  std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test");
-  EXPECT_EQ(2u, A);
-  EXPECT_EQ(3u, B);
-  EXPECT_EQ(4u, C);
+  std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test");
+  EXPECT_EQ(llvm::VersionTuple(2, 3, 4), V);
   EXPECT_EQ("", D);
 
-  std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("3.4.5");
-  EXPECT_EQ(3u, A);
-  EXPECT_EQ(4u, B);
-  EXPECT_EQ(5u, C);
+  std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3.4.5");
+  EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V);
 }
Index: source/Utility/Args.cpp
===
--- source/Utility/Args.cpp
+++ source/Utility/Args.cpp
@@ -409,29 +409,6 @@
   return s.c_str();
 }
 
-bool Args::StringToVersion(llvm::StringRef string, uint32_t &major,
-   uint32_t &minor, uint32_t &update) {
-  major = UINT32_MAX;
-  minor = UINT32_MAX;
-  update = UINT32_MAX;
-
-  if (string.empty())
-return false;
-
-  llvm

[Lldb-commits] [lldb] r334205 - [Platform] Accept arbitrary kext variants

2018-06-07 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Jun  7 09:10:42 2018
New Revision: 334205

URL: http://llvm.org/viewvc/llvm-project?rev=334205&view=rev
Log:
[Platform] Accept arbitrary kext variants

When loading kexts in PlatformDarwinKernel, we use the BundleID as the
filename to to create shared modules. In GetSharedModule we call
ExamineKextForMatchingUUID for any BundleID it finds that is a match, to
see if the UUID is also a match. Until now we were using
Host::ResolveExecutableInBundle which calls a CoreFoundation API to
obtain the executable. However, it's possible that the executable has a
variant suffix (e.g. foo_development) and these files were ignored.

This patch replaces that call with logic that looks for all the binaries
in the bundle. Because of the way ExamineKextForMatchingUUID works, it's
fine to try to load executables that are not valid and we can just
iterate over the list until we found a match.

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

Modified:
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp?rev=334205&r1=334204&r2=334205&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp 
(original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp Thu Jun  
7 09:10:42 2018
@@ -779,35 +779,53 @@ Status PlatformDarwinKernel::GetSharedMo
   return error;
 }
 
+std::vector
+PlatformDarwinKernel::SearchForExecutablesRecursively(const ConstString &dir) {
+  std::vector executables;
+  std::error_code EC;
+  for (llvm::sys::fs::recursive_directory_iterator it(dir.GetStringRef(), EC),
+   end;
+   it != end && !EC; it.increment(EC)) {
+auto status = it->status();
+if (!status)
+  break;
+if (llvm::sys::fs::is_regular_file(*status) &&
+llvm::sys::fs::can_execute(it->path()))
+  executables.emplace_back(it->path(), false);
+  }
+  return executables;
+}
+
 Status PlatformDarwinKernel::ExamineKextForMatchingUUID(
 const FileSpec &kext_bundle_path, const lldb_private::UUID &uuid,
 const ArchSpec &arch, ModuleSP &exe_module_sp) {
-  Status error;
-  FileSpec exe_file = kext_bundle_path;
-  Host::ResolveExecutableInBundle(exe_file);
-  if (exe_file.Exists()) {
-ModuleSpec exe_spec(exe_file);
-exe_spec.GetUUID() = uuid;
-if (!uuid.IsValid()) {
-  exe_spec.GetArchitecture() = arch;
-}
+  for (const auto &exe_file :
+   SearchForExecutablesRecursively(kext_bundle_path.GetDirectory())) {
+if (exe_file.Exists()) {
+  ModuleSpec exe_spec(exe_file);
+  exe_spec.GetUUID() = uuid;
+  if (!uuid.IsValid()) {
+exe_spec.GetArchitecture() = arch;
+  }
 
-// First try to create a ModuleSP with the file / arch and see if the UUID
-// matches. If that fails (this exec file doesn't have the correct uuid),
-// don't call GetSharedModule (which may call in to the DebugSymbols
-// framework and therefore can be slow.)
-ModuleSP module_sp(new Module(exe_spec));
-if (module_sp && module_sp->GetObjectFile() &&
-module_sp->MatchesModuleSpec(exe_spec)) {
-  error = ModuleList::GetSharedModule(exe_spec, exe_module_sp, NULL, NULL,
-  NULL);
-  if (exe_module_sp && exe_module_sp->GetObjectFile()) {
-return error;
+  // First try to create a ModuleSP with the file / arch and see if the 
UUID
+  // matches. If that fails (this exec file doesn't have the correct uuid),
+  // don't call GetSharedModule (which may call in to the DebugSymbols
+  // framework and therefore can be slow.)
+  ModuleSP module_sp(new Module(exe_spec));
+  if (module_sp && module_sp->GetObjectFile() &&
+  module_sp->MatchesModuleSpec(exe_spec)) {
+Status error = ModuleList::GetSharedModule(exe_spec, exe_module_sp,
+   NULL, NULL, NULL);
+if (exe_module_sp && exe_module_sp->GetObjectFile()) {
+  return error;
+}
   }
+  exe_module_sp.reset();
 }
-exe_module_sp.reset();
   }
-  return error;
+
+  return {};
 }
 
 bool PlatformDarwinKernel::GetSupportedArchitectureAtIndex(uint32_t idx,

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h?rev=334205&r1=334204&r2=334205&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h Thu Jun  7 
09:10:42 2018
@@ -127,6

[Lldb-commits] [PATCH] D47539: [Platform] Accept arbitrary kext variants

2018-06-07 Thread Jonas Devlieghere 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 rL334205: [Platform] Accept arbitrary kext variants (authored 
by JDevlieghere, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47539?vs=149143&id=150348#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47539

Files:
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h


Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -779,35 +779,53 @@
   return error;
 }
 
+std::vector
+PlatformDarwinKernel::SearchForExecutablesRecursively(const ConstString &dir) {
+  std::vector executables;
+  std::error_code EC;
+  for (llvm::sys::fs::recursive_directory_iterator it(dir.GetStringRef(), EC),
+   end;
+   it != end && !EC; it.increment(EC)) {
+auto status = it->status();
+if (!status)
+  break;
+if (llvm::sys::fs::is_regular_file(*status) &&
+llvm::sys::fs::can_execute(it->path()))
+  executables.emplace_back(it->path(), false);
+  }
+  return executables;
+}
+
 Status PlatformDarwinKernel::ExamineKextForMatchingUUID(
 const FileSpec &kext_bundle_path, const lldb_private::UUID &uuid,
 const ArchSpec &arch, ModuleSP &exe_module_sp) {
-  Status error;
-  FileSpec exe_file = kext_bundle_path;
-  Host::ResolveExecutableInBundle(exe_file);
-  if (exe_file.Exists()) {
-ModuleSpec exe_spec(exe_file);
-exe_spec.GetUUID() = uuid;
-if (!uuid.IsValid()) {
-  exe_spec.GetArchitecture() = arch;
-}
-
-// First try to create a ModuleSP with the file / arch and see if the UUID
-// matches. If that fails (this exec file doesn't have the correct uuid),
-// don't call GetSharedModule (which may call in to the DebugSymbols
-// framework and therefore can be slow.)
-ModuleSP module_sp(new Module(exe_spec));
-if (module_sp && module_sp->GetObjectFile() &&
-module_sp->MatchesModuleSpec(exe_spec)) {
-  error = ModuleList::GetSharedModule(exe_spec, exe_module_sp, NULL, NULL,
-  NULL);
-  if (exe_module_sp && exe_module_sp->GetObjectFile()) {
-return error;
+  for (const auto &exe_file :
+   SearchForExecutablesRecursively(kext_bundle_path.GetDirectory())) {
+if (exe_file.Exists()) {
+  ModuleSpec exe_spec(exe_file);
+  exe_spec.GetUUID() = uuid;
+  if (!uuid.IsValid()) {
+exe_spec.GetArchitecture() = arch;
+  }
+
+  // First try to create a ModuleSP with the file / arch and see if the 
UUID
+  // matches. If that fails (this exec file doesn't have the correct uuid),
+  // don't call GetSharedModule (which may call in to the DebugSymbols
+  // framework and therefore can be slow.)
+  ModuleSP module_sp(new Module(exe_spec));
+  if (module_sp && module_sp->GetObjectFile() &&
+  module_sp->MatchesModuleSpec(exe_spec)) {
+Status error = ModuleList::GetSharedModule(exe_spec, exe_module_sp,
+   NULL, NULL, NULL);
+if (exe_module_sp && exe_module_sp->GetObjectFile()) {
+  return error;
+}
   }
+  exe_module_sp.reset();
 }
-exe_module_sp.reset();
   }
-  return error;
+
+  return {};
 }
 
 bool PlatformDarwinKernel::GetSupportedArchitectureAtIndex(uint32_t idx,
Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
@@ -127,6 +127,9 @@
   const lldb_private::FileSpec &file_spec,
   bool recurse);
 
+  static std::vector
+  SearchForExecutablesRecursively(const lldb_private::ConstString &dir);
+
   static void AddKextToMap(PlatformDarwinKernel *thisp,
const lldb_private::FileSpec &file_spec);
 


Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -779,35 +779,53 @@
   return error;
 }
 
+std::vector
+PlatformDarwinKernel::SearchForExecutablesRecursively(const ConstString &dir) {
+  std::vector executables;
+  std::error_code EC;
+  for (llvm::sys::fs::recursive_directory_iterator it(dir.GetStringRef(), EC),
+   end;
+   it != end && !EC; i

[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov updated this revision to Diff 150356.
aleksandr.urakov added a comment.

Avoid binaries in tests.


https://reviews.llvm.org/D47708

Files:
  lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp
  lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h
  lit/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord
  lit/SymbolFile/PDB/function-level-linking.test
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  tools/lldb-test/lldb-test.cpp

Index: tools/lldb-test/lldb-test.cpp
===
--- tools/lldb-test/lldb-test.cpp
+++ tools/lldb-test/lldb-test.cpp
@@ -21,6 +21,8 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTImporter.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/VariableList.h"
@@ -143,6 +145,9 @@
   return Result;
 }
 
+static cl::opt Verify("verify", cl::desc("Verify symbol information."),
+cl::sub(SymbolsSubcommand));
+
 static Expected getDeclContext(SymbolVendor &Vendor);
 
 static Error findFunctions(lldb_private::Module &Module);
@@ -150,6 +155,7 @@
 static Error findTypes(lldb_private::Module &Module);
 static Error findVariables(lldb_private::Module &Module);
 static Error dumpModule(lldb_private::Module &Module);
+static Error verify(lldb_private::Module &Module);
 
 static int dumpSymbols(Debugger &Dbg);
 }
@@ -412,7 +418,75 @@
   return Error::success();
 }
 
+Error opts::symbols::verify(lldb_private::Module &Module) {
+  SymbolVendor *plugin = Module.GetSymbolVendor();
+  if (!plugin)
+return make_error("Can't get a symbol vendor.",
+   inconvertibleErrorCode());
+
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  if (!symfile)
+return make_error("Can't get a symbol file.",
+   inconvertibleErrorCode());
+
+  uint32_t comp_units_count = symfile->GetNumCompileUnits();
+
+  outs() << "Found " << comp_units_count << " compile units.\n";
+
+  for (uint32_t i = 0; i < comp_units_count; i++) {
+lldb::CompUnitSP comp_unit = symfile->ParseCompileUnitAtIndex(i);
+if (!comp_unit)
+  return make_error("Can't get a compile unit.",
+ inconvertibleErrorCode());
+
+outs() << "Processing '" << comp_unit->GetFilename().AsCString() <<
+  "' compile unit.\n";
+
+LineTable *lt = comp_unit->GetLineTable();
+if (!lt)
+  return make_error(
+"Can't get a line table of a compile unit.",
+inconvertibleErrorCode());
+
+uint32_t count = lt->GetSize();
+
+outs() << "The line table contains " << count << " entries.\n";
+
+if (count == 0)
+  continue;
+
+LineEntry le;
+if (!lt->GetLineEntryAtIndex(0, le))
+  return make_error(
+  "Can't get a line entry of a compile unit",
+  inconvertibleErrorCode());
+
+for (uint32_t i = 1; i < count; i++) {
+  lldb::addr_t curr_end =
+le.range.GetBaseAddress().GetFileAddress() + le.range.GetByteSize();
+
+  if (!lt->GetLineEntryAtIndex(i, le))
+return make_error(
+"Can't get a line entry of a compile unit",
+inconvertibleErrorCode());
+
+  if (curr_end > le.range.GetBaseAddress().GetFileAddress())
+return make_error(
+"Line table of a compile unit is inconsistent",
+inconvertibleErrorCode());
+}
+  }
+
+  outs() << "The symbol information is verified.\n";
+
+  return Error::success();
+}
+
 int opts::symbols::dumpSymbols(Debugger &Dbg) {
+  if (Verify && Find != FindType::None) {
+WithColor::error() << "Cannot both search and verify symbol information.\n";
+return 1;
+  }
   if (Find != FindType::None && Regex && !Context.empty()) {
 WithColor::error()
 << "Cannot search using both regular expressions and context.\n";
@@ -435,23 +509,26 @@
   }
 
   Error (*Action)(lldb_private::Module &);
-  switch (Find) {
-  case FindType::Function:
-Action = findFunctions;
-break;
-  case FindType::Namespace:
-Action = findNamespaces;
-break;
-  case FindType::Type:
-Action = findTypes;
-break;
-  case FindType::Variable:
-Action = findVariables;
-break;
-  case FindType::None:
-Action = dumpModule;
-break;
-  }
+  if (!Verify) {
+switch (Find) {
+case FindType::Function:
+  Action = findFunctions;
+  break;
+case FindType::Namespace:
+  Action = findNamespaces;
+  break;
+case FindType::Type:
+  Action = findTypes;
+  break;
+case FindType::Variable:
+  Action = findVariables;
+  break;
+case FindType::None:
+  Action = dumpModule;
+  break;
+}
+  } else
+Action = verify;
 
   int HadErrors = 0;
   for (const auto &File : InputFilenames) {
Index: source/Plugins/SymbolFile/P

[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

I replaced all binaries by a lit-based test, as you told. The only thing, I 
have made it more like other PDB tests.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [lldb] r334210 - [lit, windows] Disable a number of tests that are failing on Windows

2018-06-07 Thread Stella Stamenova via lldb-commits
Author: stella.stamenova
Date: Thu Jun  7 10:49:22 2018
New Revision: 334210

URL: http://llvm.org/viewvc/llvm-project?rev=334210&view=rev
Log:
[lit, windows] Disable a number of tests that are failing on Windows

Summary: They all correspond to bugs that are already logged and I've added the 
appropriate (or most appropriate) bug numbers. This leaves only a handful of 
failing tests.

Reviewers: asmith, zturner, labath

Reviewed By: zturner

Subscribers: eraman, llvm-commits

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

Modified:
lldb/trunk/lit/Breakpoint/case-insensitive.test

lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py

lldb/trunk/packages/Python/lldbsuite/test/lang/c/conflicting-symbol/TestConflictingSymbol.py

lldb/trunk/packages/Python/lldbsuite/test/lang/c/step-target/TestStepTarget.py

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/class_static/TestStaticVariables.py

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespace.py

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/signed_types/TestSignedTypes.py

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/template/TestTemplateArgs.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py

lldb/trunk/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py
lldb/trunk/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
lldb/trunk/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py

Modified: lldb/trunk/lit/Breakpoint/case-insensitive.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/case-insensitive.test?rev=334210&r1=334209&r2=334210&view=diff
==
--- lldb/trunk/lit/Breakpoint/case-insensitive.test (original)
+++ lldb/trunk/lit/Breakpoint/case-insensitive.test Thu Jun  7 10:49:22 2018
@@ -1,4 +1,6 @@
 # REQUIRES: windows
+# XFAIL: windows
+# -> llvm.org/pr24528
 #
 # RUN: %cc %p/Inputs/case-sensitive.c -g -o %t
 # RUN: lldb-test breakpoints %t %s | FileCheck %s

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py?rev=334210&r1=334209&r2=334210&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py
 Thu Jun  7 10:49:22 2018
@@ -8,6 +8,7 @@ from __future__ import print_function
 import os
 import time
 import lldb
+from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
 
@@ -15,6 +16,7 @@ class CmdPythonTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
 def test(self):
 self.build()
 self.pycmd_tests()

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py?rev=334210&r1=334209&r2=334210&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py
 Thu Jun  7 10:49:22 2018
@@ -10,6 +10,7 @@ import time
 import re
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
 
@@ -22,6 +23,7 @@ class TestFrameGuessLanguage(TestBase):
 # each debug info format.
 NO_DEBUG_INFO_TESTCASE = True
 
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37658")
 def test_guess_language(self):
 

[Lldb-commits] [PATCH] D47897: Check for process_vm_readv using CheckSymbolExists

2018-06-07 Thread Alex Langford via Phabricator via lldb-commits
xiaobai created this revision.
xiaobai added reviewers: eugene, labath, beanz.
Herald added a subscriber: mgorny.

Instead of checking if code compiles, I think it is a better to check
if the symbol exists. This is simpler and should do the same thing.


https://reviews.llvm.org/D47897

Files:
  cmake/modules/LLDBGenerateConfig.cmake


Index: cmake/modules/LLDBGenerateConfig.cmake
===
--- cmake/modules/LLDBGenerateConfig.cmake
+++ cmake/modules/LLDBGenerateConfig.cmake
@@ -14,14 +14,8 @@
 check_include_file(termios.h HAVE_TERMIOS_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
-check_cxx_source_compiles("
-  #include 
-  int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
-  HAVE_PROCESS_VM_READV)
-check_cxx_source_compiles("
-#include 
-int main() { return __NR_process_vm_readv; }"
-HAVE_NR_PROCESS_VM_READV)
+check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
+check_cxx_symbol_exists(__NR_process_vm_readv "sys/syscall.h" 
HAVE_NR_PROCESS_VM_READV)
 
 check_library_exists(compression compression_encode_buffer "" 
HAVE_LIBCOMPRESSION)
 


Index: cmake/modules/LLDBGenerateConfig.cmake
===
--- cmake/modules/LLDBGenerateConfig.cmake
+++ cmake/modules/LLDBGenerateConfig.cmake
@@ -14,14 +14,8 @@
 check_include_file(termios.h HAVE_TERMIOS_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
-check_cxx_source_compiles("
-  #include 
-  int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
-  HAVE_PROCESS_VM_READV)
-check_cxx_source_compiles("
-#include 
-int main() { return __NR_process_vm_readv; }"
-HAVE_NR_PROCESS_VM_READV)
+check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
+check_cxx_symbol_exists(__NR_process_vm_readv "sys/syscall.h" HAVE_NR_PROCESS_VM_READV)
 
 check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSION)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r334215 - [lldb-mi] Re-implement MI -exec-next command.

2018-06-07 Thread Alexander Polyakov via lldb-commits
Author: apolyakov
Date: Thu Jun  7 12:09:01 2018
New Revision: 334215

URL: http://llvm.org/viewvc/llvm-project?rev=334215&view=rev
Log:
[lldb-mi] Re-implement MI -exec-next command.

Summary: Now -exec-next command uses SB API for stepping over.

Reviewers: aprantl, clayborg, stella.stamenova, labath

Reviewed By: aprantl, clayborg, labath

Subscribers: labath, ki.stfu, lldb-commits

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

Added:
lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test
lldb/trunk/lit/tools/lldb-mi/exec/inputs/
lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
Modified:
lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp

Added: lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test?rev=334215&view=auto
==
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test (added)
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test Thu Jun  7 12:09:01 2018
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-next command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-next --thread 0
+# Check that exec-next can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-next'. Thread ID invalid"
+
+-exec-next --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
+
+-exec-next
+# Check that exec-next can step over in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"

Added: lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c?rev=334215&view=auto
==
--- lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c (added)
+++ lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c Thu Jun  7 12:09:01 2018
@@ -0,0 +1,4 @@
+int main(void) {
+  int x = 0;
+  return x;
+}

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp?rev=334215&r1=334214&r2=334215&view=diff
==
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp Thu Jun  7 12:09:01 2018
@@ -22,6 +22,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBThread.h"
 #include "lldb/lldb-enumerations.h"
 
 // In-house headers:
@@ -378,12 +379,17 @@ bool CMICmdCmdExecNext::Execute() {
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
-  CMIUtilString strCmd("thread step-over");
-  if (nThreadId != UINT64_MAX)
-strCmd += CMIUtilString::Format(" %llu", nThreadId);
-  rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
-  false);
+
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread = 
rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
+if (!sbThread.IsValid()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+  return MIstatus::failure;
+}
+sbThread.StepOver();
+  } else rSessionInfo.GetProcess().GetSelectedThread().StepOver();
 
   return MIstatus::success;
 }


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


[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334215: [lldb-mi] Re-implement MI -exec-next command. 
(authored by apolyakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47797?vs=150328&id=150381#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47797

Files:
  lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test
  lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
  lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp


Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
@@ -22,6 +22,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBThread.h"
 #include "lldb/lldb-enumerations.h"
 
 // In-house headers:
@@ -378,12 +379,17 @@
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
-  CMIUtilString strCmd("thread step-over");
-  if (nThreadId != UINT64_MAX)
-strCmd += CMIUtilString::Format(" %llu", nThreadId);
-  rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
-  false);
+
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread = 
rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
+if (!sbThread.IsValid()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+  return MIstatus::failure;
+}
+sbThread.StepOver();
+  } else rSessionInfo.GetProcess().GetSelectedThread().StepOver();
 
   return MIstatus::success;
 }
Index: lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
===
--- lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
+++ lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
@@ -0,0 +1,4 @@
+int main(void) {
+  int x = 0;
+  return x;
+}
Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test
===
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-next command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-next --thread 0
+# Check that exec-next can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-next'. Thread ID invalid"
+
+-exec-next --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
+
+-exec-next
+# Check that exec-next can step over in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"


Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
@@ -22,6 +22,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
+#include "lldb/API/SBThread.h"
 #include "lldb/lldb-enumerations.h"
 
 // In-house headers:
@@ -378,12 +379,17 @@
 
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
-  CMIUtilString strCmd("thread step-over");
-  if (nThreadId != UINT64_MAX)
-strCmd += CMIUtilString::Format(" %llu", nThreadId);
-  rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
-  false);
+
+  if (nThreadId != UINT64_MAX) {
+lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId);
+if (!sbThread.IsValid()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+  return MIstatus::failure;
+}
+sbThread.StepOver();
+  } else rSessionInfo.GetProcess().GetSelectedThread().StepOver();
 
   return MIstatus::success;
 }
Index: lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
===
--- lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
+++ lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
@@ -0,0 +1,4 @@
+int main(void) {
+  int x = 0;
+  return x;
+}
Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test
==

[Lldb-commits] [PATCH] D47625: [cmake] Detect presence of wide-char libedit at build time

2018-06-07 Thread Christos Zoulas via Phabricator via lldb-commits
christos added inline comments.



Comment at: include/lldb/Host/Editline.h:72-76
 #ifdef EL_CLIENTDATA   /* editline with wide support + wide char read function 
*/
 using EditLineGetCharType = wchar_t;
 #else
 using EditLineGetCharType = char;
 #endif

labath wrote:
> christos wrote:
> > labath wrote:
> > > It's not fully clear to me whether this part is still correct. My 
> > > understanding is that if we use `el_wset` to set the getchar callback, we 
> > > should always use wchar_t, regardless of libedit version. This is only 
> > > true if all wide-char capable libedit versions also define EL_CLIENTDATA.
> > > 
> > > Is this the case?
> > I believe that you are correct: If you use el_wset, you should use wchar_t. 
> > The problem is that for libedit versions prior to 2016-04-19 the getchar 
> > function used char * for narrow and wchar_t * for wide. Versions after that 
> > use wchar_t * for both. This was an accident due to some code refactoring. 
> > If you are checking if that's the case or not, perhaps you can determine 
> > this if el_rfunc_t is defined in histedit.h or not. Unfortunately there is 
> > no compile time way to determine if that's the case or not.
> Thank, I can do that. Just to double-check, the condition you say here should 
> be is:
> ```
> #if LLDB_EDITLINE_USE_WCHAR || defined(EL_CLIENTDATA) || 
> LLDB_LIBEDIT_HAVE_EL_RFUNC_T
> using EditLineGetCharType = wchar_t;
> #else
> using EditLineGetCharType = char;
> #endif
> ```
> Is that right ?
I think that's right. In any case it will probably fix cases that are currently 
broken.


https://reviews.llvm.org/D47625



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


[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex updated this revision to Diff 150391.
polyakov.alex added a comment.

Updated because of commited -exec-next and -exec-step commands.


https://reviews.llvm.org/D47415

Files:
  lit/tools/lldb-mi/exec/exec-continue.test
  tools/lldb-mi/MICmdCmdExec.cpp


Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -233,33 +233,19 @@
 // Throws:  None.
 //--
 bool CMICmdCmdExecContinue::Execute() {
-  const char *pCmd = "continue";
-  CMICmnLLDBDebugSessionInfo &rSessionInfo(
-  CMICmnLLDBDebugSessionInfo::Instance());
-  const lldb::ReturnStatus rtn =
-  rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(
-  pCmd, m_lldbResult);
-  MIunused(rtn);
-
-  if (m_lldbResult.GetErrorSize() == 0) {
+  lldb::SBError error =
+  CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue();
+ 
+  if (error.Success()) {
 // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
 if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
   const CMIUtilString 
&rErrMsg(CMIDriver::Instance().GetErrorDescription());
   SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
  m_cmdData.strMiCmd.c_str(),
  rErrMsg.c_str()));
   return MIstatus::failure;
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 
   return MIstatus::success;
 }
Index: lit/tools/lldb-mi/exec/exec-continue.test
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/exec-continue.test
@@ -0,0 +1,20 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-continue command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-continue
+# CHECK: ^running


Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -233,33 +233,19 @@
 // Throws:  None.
 //--
 bool CMICmdCmdExecContinue::Execute() {
-  const char *pCmd = "continue";
-  CMICmnLLDBDebugSessionInfo &rSessionInfo(
-  CMICmnLLDBDebugSessionInfo::Instance());
-  const lldb::ReturnStatus rtn =
-  rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(
-  pCmd, m_lldbResult);
-  MIunused(rtn);
-
-  if (m_lldbResult.GetErrorSize() == 0) {
+  lldb::SBError error =
+  CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue();
+ 
+  if (error.Success()) {
 // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
 if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
   const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
   SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
  m_cmdData.strMiCmd.c_str(),
  rErrMsg.c_str()));
   return MIstatus::failure;
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 
   return MIstatus::success;
 }
Index: lit/tools/lldb-mi/exec/exec-continue.test
===
--- /dev/null
+++ lit/tools/lldb-mi/exec/exec-continue.test
@@ -0,0 +1,20 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-continue command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-continue
+# CHECK: ^running
___
lldb-commits mailing list
lldb-

[Lldb-commits] [PATCH] D47897: Check for process_vm_readv using CheckSymbolExists

2018-06-07 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

This should be functionally identical and is much cleaner.  Thanks!


https://reviews.llvm.org/D47897



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


[Lldb-commits] [PATCH] D47897: Check for process_vm_readv using CheckSymbolExists

2018-06-07 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334219: Check for process_vm_readv using CheckSymbolExists 
(authored by xiaobai, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47897

Files:
  lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake


Index: lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
@@ -14,14 +14,8 @@
 check_include_file(termios.h HAVE_TERMIOS_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
-check_cxx_source_compiles("
-  #include 
-  int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
-  HAVE_PROCESS_VM_READV)
-check_cxx_source_compiles("
-#include 
-int main() { return __NR_process_vm_readv; }"
-HAVE_NR_PROCESS_VM_READV)
+check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
+check_cxx_symbol_exists(__NR_process_vm_readv "sys/syscall.h" 
HAVE_NR_PROCESS_VM_READV)
 
 check_library_exists(compression compression_encode_buffer "" 
HAVE_LIBCOMPRESSION)
 


Index: lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
@@ -14,14 +14,8 @@
 check_include_file(termios.h HAVE_TERMIOS_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
-check_cxx_source_compiles("
-  #include 
-  int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
-  HAVE_PROCESS_VM_READV)
-check_cxx_source_compiles("
-#include 
-int main() { return __NR_process_vm_readv; }"
-HAVE_NR_PROCESS_VM_READV)
+check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
+check_cxx_symbol_exists(__NR_process_vm_readv "sys/syscall.h" HAVE_NR_PROCESS_VM_READV)
 
 check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSION)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r334219 - Check for process_vm_readv using CheckSymbolExists

2018-06-07 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Thu Jun  7 12:53:25 2018
New Revision: 334219

URL: http://llvm.org/viewvc/llvm-project?rev=334219&view=rev
Log:
Check for process_vm_readv using CheckSymbolExists

Instead of checking if code compiles, I think it is a better to check
if the symbol exists. This is simpler and should do the same thing.

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

Modified:
lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake

Modified: lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake?rev=334219&r1=334218&r2=334219&view=diff
==
--- lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake Thu Jun  7 12:53:25 2018
@@ -14,14 +14,8 @@ check_cxx_symbol_exists(accept4 "sys/soc
 check_include_file(termios.h HAVE_TERMIOS_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
-check_cxx_source_compiles("
-  #include 
-  int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
-  HAVE_PROCESS_VM_READV)
-check_cxx_source_compiles("
-#include 
-int main() { return __NR_process_vm_readv; }"
-HAVE_NR_PROCESS_VM_READV)
+check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
+check_cxx_symbol_exists(__NR_process_vm_readv "sys/syscall.h" 
HAVE_NR_PROCESS_VM_READV)
 
 check_library_exists(compression compression_encode_buffer "" 
HAVE_LIBCOMPRESSION)
 


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


[Lldb-commits] [lldb] r334221 - [FileSystem] Split up the OpenFlags enumeration.

2018-06-07 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Jun  7 12:58:58 2018
New Revision: 334221

URL: http://llvm.org/viewvc/llvm-project?rev=334221&view=rev
Log:
[FileSystem] Split up the OpenFlags enumeration.

This breaks the OpenFlags enumeration into two separate
enumerations: OpenFlags and CreationDisposition.  The first
controls the behavior of the API depending on whether or not
the target file already exists, and is not a flags-based
enum.  The second controls more flags-like values.

This yields a more easy to understand API, while also allowing
flags to be passed to the openForRead api, where most of the
values didn't make sense before.  This also makes the apis more
testable as it becomes easy to enumerate all the configurations
which make sense, so I've added many new tests to exercise all
the different values.

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

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=334221&r1=334220&r2=334221&view=diff
==
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Jun  7 12:58:58 2018
@@ -1241,8 +1241,8 @@ bool Debugger::EnableLog(llvm::StringRef
   if (log_options & LLDB_LOG_OPTION_APPEND)
 flags |= llvm::sys::fs::F_Append;
   int FD;
-  if (std::error_code ec =
-  llvm::sys::fs::openFileForWrite(log_file, FD, flags)) {
+  if (std::error_code ec = llvm::sys::fs::openFileForWrite(
+  log_file, FD, llvm::sys::fs::CD_CreateAlways, flags)) {
 error_stream << "Unable to open log file: " << ec.message();
 return false;
   }


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


[Lldb-commits] [lldb] r334225 - Remove commented out line from top-level CMakeLists.txt

2018-06-07 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Thu Jun  7 13:17:46 2018
New Revision: 334225

URL: http://llvm.org/viewvc/llvm-project?rev=334225&view=rev
Log:
Remove commented out line from top-level CMakeLists.txt

Modified:
lldb/trunk/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=334225&r1=334224&r2=334225&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Thu Jun  7 13:17:46 2018
@@ -42,7 +42,6 @@ if(LLDB_BUILD_FRAMEWORK)
 ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
 endif()
 
-# add_subdirectory(include)
 add_subdirectory(docs)
 if (NOT LLDB_DISABLE_PYTHON)
   if(LLDB_USE_SYSTEM_SIX)


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


[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

2018-06-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 

An error can claim to fail but not have an error string set. It might be nice 
to have a helper function that checks to make sure there is an error string on 
error cases and if there is no error string when error.Success() is false or 
error.Fail() is true, then set the error string to "unknown error". 


https://reviews.llvm.org/D47415



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


[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex added inline comments.



Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 

clayborg wrote:
> An error can claim to fail but not have an error string set. It might be nice 
> to have a helper function that checks to make sure there is an error string 
> on error cases and if there is no error string when error.Success() is false 
> or error.Fail() is true, then set the error string to "unknown error". 
This functionality might be useful in all lldb-mi commands. So do you know 
where to place this function? Maybe inside SBError class?


https://reviews.llvm.org/D47415



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


[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

2018-06-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 

polyakov.alex wrote:
> clayborg wrote:
> > An error can claim to fail but not have an error string set. It might be 
> > nice to have a helper function that checks to make sure there is an error 
> > string on error cases and if there is no error string when error.Success() 
> > is false or error.Fail() is true, then set the error string to "unknown 
> > error". 
> This functionality might be useful in all lldb-mi commands. So do you know 
> where to place this function? Maybe inside SBError class?
I would put it somewhere in lldb-mi in a static function that is something like:
```
static void SetErrorString(lldb::SBError &error, T &lldbResult) {
  const char *error_cstr = error.GetCString();
  if (error_cstr)
lldbResult.SetError(error.GetCString());
  else
lldbResult.SetError("unknown error");
}
```
Where the T is the type of m_lldbResult. 


https://reviews.llvm.org/D47415



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


[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

2018-06-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 

clayborg wrote:
> polyakov.alex wrote:
> > clayborg wrote:
> > > An error can claim to fail but not have an error string set. It might be 
> > > nice to have a helper function that checks to make sure there is an error 
> > > string on error cases and if there is no error string when 
> > > error.Success() is false or error.Fail() is true, then set the error 
> > > string to "unknown error". 
> > This functionality might be useful in all lldb-mi commands. So do you know 
> > where to place this function? Maybe inside SBError class?
> I would put it somewhere in lldb-mi in a static function that is something 
> like:
> ```
> static void SetErrorString(lldb::SBError &error, T &lldbResult) {
>   const char *error_cstr = error.GetCString();
>   if (error_cstr)
> lldbResult.SetError(error.GetCString());
>   else
> lldbResult.SetError("unknown error");
> }
> ```
> Where the T is the type of m_lldbResult. 
Actually, are we using m_lldbResult now? I didn't realize its type was 
lldb::SBCommandReturnObject. That was only needed if we were calling:
```
rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, 
m_lldbResult);
```

So we can get rid of all "lldb::SBCommandReturnObject m_lldbResult" member 
variables in any lldb-mi functions where we switch to using the API.


https://reviews.llvm.org/D47415



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


[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

2018-06-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Also need to remove m_lldbResult from the CMICmdCmdExecContinue class.




Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 

clayborg wrote:
> clayborg wrote:
> > polyakov.alex wrote:
> > > clayborg wrote:
> > > > An error can claim to fail but not have an error string set. It might 
> > > > be nice to have a helper function that checks to make sure there is an 
> > > > error string on error cases and if there is no error string when 
> > > > error.Success() is false or error.Fail() is true, then set the error 
> > > > string to "unknown error". 
> > > This functionality might be useful in all lldb-mi commands. So do you 
> > > know where to place this function? Maybe inside SBError class?
> > I would put it somewhere in lldb-mi in a static function that is something 
> > like:
> > ```
> > static void SetErrorString(lldb::SBError &error, T &lldbResult) {
> >   const char *error_cstr = error.GetCString();
> >   if (error_cstr)
> > lldbResult.SetError(error.GetCString());
> >   else
> > lldbResult.SetError("unknown error");
> > }
> > ```
> > Where the T is the type of m_lldbResult. 
> Actually, are we using m_lldbResult now? I didn't realize its type was 
> lldb::SBCommandReturnObject. That was only needed if we were calling:
> ```
> rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, 
> m_lldbResult);
> ```
> 
> So we can get rid of all "lldb::SBCommandReturnObject m_lldbResult" member 
> variables in any lldb-mi functions where we switch to using the API.
Since we can get rid of m_lldbResult, this should be:

```
} else return MIstatus::failure;
```


https://reviews.llvm.org/D47415



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


[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
polyakov.alex added inline comments.



Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248
 }
-  } else {
-// ToDo: Re-evaluate if this is required when application near finished as
-// this is parsing LLDB error message
-// which seems a hack and is code brittle
-const char *pLldbErr = m_lldbResult.GetError();
-const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
-if (strLldbMsg == "error: Process must be launched.") {
-  CMIDriver::Instance().SetExitApplicationFlag(true);
-}
-  }
+  } else m_lldbResult.SetError(error.GetCString());
 

clayborg wrote:
> clayborg wrote:
> > clayborg wrote:
> > > polyakov.alex wrote:
> > > > clayborg wrote:
> > > > > An error can claim to fail but not have an error string set. It might 
> > > > > be nice to have a helper function that checks to make sure there is 
> > > > > an error string on error cases and if there is no error string when 
> > > > > error.Success() is false or error.Fail() is true, then set the error 
> > > > > string to "unknown error". 
> > > > This functionality might be useful in all lldb-mi commands. So do you 
> > > > know where to place this function? Maybe inside SBError class?
> > > I would put it somewhere in lldb-mi in a static function that is 
> > > something like:
> > > ```
> > > static void SetErrorString(lldb::SBError &error, T &lldbResult) {
> > >   const char *error_cstr = error.GetCString();
> > >   if (error_cstr)
> > > lldbResult.SetError(error.GetCString());
> > >   else
> > > lldbResult.SetError("unknown error");
> > > }
> > > ```
> > > Where the T is the type of m_lldbResult. 
> > Actually, are we using m_lldbResult now? I didn't realize its type was 
> > lldb::SBCommandReturnObject. That was only needed if we were calling:
> > ```
> > rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, 
> > m_lldbResult);
> > ```
> > 
> > So we can get rid of all "lldb::SBCommandReturnObject m_lldbResult" member 
> > variables in any lldb-mi functions where we switch to using the API.
> Since we can get rid of m_lldbResult, this should be:
> 
> ```
> } else return MIstatus::failure;
> ```
It should be:
```
else {
  SetError(CMIUtilString::Format(..., error.GetCString()));
  return MIstatus::failure;
}
```
So, we anyway need a C-style error string.


https://reviews.llvm.org/D47415



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


[Lldb-commits] [PATCH] D47914: [lldb-mi] Add overloaded method for setting an error.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov created this revision.
apolyakov added reviewers: aprantl, clayborg.
Herald added a subscriber: ki.stfu.

https://reviews.llvm.org/D47914

Files:
  tools/lldb-mi/MICmdBase.cpp
  tools/lldb-mi/MICmdBase.h


Index: tools/lldb-mi/MICmdBase.h
===
--- tools/lldb-mi/MICmdBase.h
+++ tools/lldb-mi/MICmdBase.h
@@ -12,6 +12,8 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "lldb/API/SBError.h"
+
 // Project includes
 #include "MICmdArgSet.h"
 #include "MICmdData.h"
@@ -80,6 +82,7 @@
   // Methods:
 protected:
   void SetError(const CMIUtilString &rErrMsg);
+  void SetError(const lldb::SBError &error);
   template  T *GetOption(const CMIUtilString &vStrOptionName);
   bool ParseValidateCmdOptions();
 
Index: tools/lldb-mi/MICmdBase.cpp
===
--- tools/lldb-mi/MICmdBase.cpp
+++ tools/lldb-mi/MICmdBase.cpp
@@ -214,6 +214,23 @@
 
 //++
 
//
+// Details: Short cut function to enter error information into the command's
+//  metadata object and set the command's error status.
+// Type:Method.
+// Args:error - (R) Command result description.
+// Return:  None.
+// Throws:  None.
+//--
+void CMICmdBase::SetError(const lldb::SBError &error) {
+  const char *error_cstr = error.GetCString();
+  if (error_cstr)
+SetError(error_cstr);
+  else
+SetError("unknown error");
+}
+
+//++
+//
 // Details: Ask a command to provide its unique identifier.
 // Type:Method.
 // Args:A unique identifier for this command class.


Index: tools/lldb-mi/MICmdBase.h
===
--- tools/lldb-mi/MICmdBase.h
+++ tools/lldb-mi/MICmdBase.h
@@ -12,6 +12,8 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "lldb/API/SBError.h"
+
 // Project includes
 #include "MICmdArgSet.h"
 #include "MICmdData.h"
@@ -80,6 +82,7 @@
   // Methods:
 protected:
   void SetError(const CMIUtilString &rErrMsg);
+  void SetError(const lldb::SBError &error);
   template  T *GetOption(const CMIUtilString &vStrOptionName);
   bool ParseValidateCmdOptions();
 
Index: tools/lldb-mi/MICmdBase.cpp
===
--- tools/lldb-mi/MICmdBase.cpp
+++ tools/lldb-mi/MICmdBase.cpp
@@ -214,6 +214,23 @@
 
 //++
 //
+// Details: Short cut function to enter error information into the command's
+//  metadata object and set the command's error status.
+// Type:Method.
+// Args:error - (R) Command result description.
+// Return:  None.
+// Throws:  None.
+//--
+void CMICmdBase::SetError(const lldb::SBError &error) {
+  const char *error_cstr = error.GetCString();
+  if (error_cstr)
+SetError(error_cstr);
+  else
+SetError("unknown error");
+}
+
+//++
+//
 // Details: Ask a command to provide its unique identifier.
 // Type:Method.
 // Args:A unique identifier for this command class.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r334245 - [lldb-mi] Add overloaded method for setting an error.

2018-06-07 Thread Alexander Polyakov via lldb-commits
Author: apolyakov
Date: Thu Jun  7 16:03:49 2018
New Revision: 334245

URL: http://llvm.org/viewvc/llvm-project?rev=334245&view=rev
Log:
[lldb-mi] Add overloaded method for setting an error.

Reviewers: aprantl, clayborg

Reviewed By: clayborg

Subscribers: ki.stfu, lldb-commits

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

Modified:
lldb/trunk/tools/lldb-mi/MICmdBase.cpp
lldb/trunk/tools/lldb-mi/MICmdBase.h

Modified: lldb/trunk/tools/lldb-mi/MICmdBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdBase.cpp?rev=334245&r1=334244&r2=334245&view=diff
==
--- lldb/trunk/tools/lldb-mi/MICmdBase.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp Thu Jun  7 16:03:49 2018
@@ -214,6 +214,23 @@ void CMICmdBase::SetError(const CMIUtilS
 
 //++
 
//
+// Details: Short cut function to enter error information into the command's
+//  metadata object and set the command's error status.
+// Type:Method.
+// Args:error - (R) Command result description.
+// Return:  None.
+// Throws:  None.
+//--
+void CMICmdBase::SetError(const lldb::SBError &error) {
+  const char *error_cstr = error.GetCString();
+  if (error_cstr)
+SetError(error_cstr);
+  else
+SetError("unknown error");
+}
+
+//++
+//
 // Details: Ask a command to provide its unique identifier.
 // Type:Method.
 // Args:A unique identifier for this command class.

Modified: lldb/trunk/tools/lldb-mi/MICmdBase.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdBase.h?rev=334245&r1=334244&r2=334245&view=diff
==
--- lldb/trunk/tools/lldb-mi/MICmdBase.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdBase.h Thu Jun  7 16:03:49 2018
@@ -12,6 +12,8 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "lldb/API/SBError.h"
+
 // Project includes
 #include "MICmdArgSet.h"
 #include "MICmdData.h"
@@ -80,6 +82,7 @@ public:
   // Methods:
 protected:
   void SetError(const CMIUtilString &rErrMsg);
+  void SetError(const lldb::SBError &error);
   template  T *GetOption(const CMIUtilString &vStrOptionName);
   bool ParseValidateCmdOptions();
 


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


[Lldb-commits] [PATCH] D47914: [lldb-mi] Add overloaded method for setting an error.

2018-06-07 Thread Alexander Polyakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334245: [lldb-mi] Add overloaded method for setting an 
error. (authored by apolyakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47914?vs=150421&id=150428#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47914

Files:
  lldb/trunk/tools/lldb-mi/MICmdBase.cpp
  lldb/trunk/tools/lldb-mi/MICmdBase.h


Index: lldb/trunk/tools/lldb-mi/MICmdBase.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdBase.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp
@@ -214,6 +214,23 @@
 
 //++
 
//
+// Details: Short cut function to enter error information into the command's
+//  metadata object and set the command's error status.
+// Type:Method.
+// Args:error - (R) Command result description.
+// Return:  None.
+// Throws:  None.
+//--
+void CMICmdBase::SetError(const lldb::SBError &error) {
+  const char *error_cstr = error.GetCString();
+  if (error_cstr)
+SetError(error_cstr);
+  else
+SetError("unknown error");
+}
+
+//++
+//
 // Details: Ask a command to provide its unique identifier.
 // Type:Method.
 // Args:A unique identifier for this command class.
Index: lldb/trunk/tools/lldb-mi/MICmdBase.h
===
--- lldb/trunk/tools/lldb-mi/MICmdBase.h
+++ lldb/trunk/tools/lldb-mi/MICmdBase.h
@@ -12,6 +12,8 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "lldb/API/SBError.h"
+
 // Project includes
 #include "MICmdArgSet.h"
 #include "MICmdData.h"
@@ -80,6 +82,7 @@
   // Methods:
 protected:
   void SetError(const CMIUtilString &rErrMsg);
+  void SetError(const lldb::SBError &error);
   template  T *GetOption(const CMIUtilString &vStrOptionName);
   bool ParseValidateCmdOptions();
 


Index: lldb/trunk/tools/lldb-mi/MICmdBase.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdBase.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp
@@ -214,6 +214,23 @@
 
 //++
 //
+// Details: Short cut function to enter error information into the command's
+//  metadata object and set the command's error status.
+// Type:Method.
+// Args:error - (R) Command result description.
+// Return:  None.
+// Throws:  None.
+//--
+void CMICmdBase::SetError(const lldb::SBError &error) {
+  const char *error_cstr = error.GetCString();
+  if (error_cstr)
+SetError(error_cstr);
+  else
+SetError("unknown error");
+}
+
+//++
+//
 // Details: Ask a command to provide its unique identifier.
 // Type:Method.
 // Args:A unique identifier for this command class.
Index: lldb/trunk/tools/lldb-mi/MICmdBase.h
===
--- lldb/trunk/tools/lldb-mi/MICmdBase.h
+++ lldb/trunk/tools/lldb-mi/MICmdBase.h
@@ -12,6 +12,8 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "lldb/API/SBError.h"
+
 // Project includes
 #include "MICmdArgSet.h"
 #include "MICmdData.h"
@@ -80,6 +82,7 @@
   // Methods:
 protected:
   void SetError(const CMIUtilString &rErrMsg);
+  void SetError(const lldb::SBError &error);
   template  T *GetOption(const CMIUtilString &vStrOptionName);
   bool ParseValidateCmdOptions();
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47923: Added missing include to LoadedModuleInfoList.h

2018-06-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

https://reviews.llvm.org/D47923

Files:
  include/lldb/Core/LoadedModuleInfoList.h


Index: include/lldb/Core/LoadedModuleInfoList.h
===
--- include/lldb/Core/LoadedModuleInfoList.h
+++ include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes


Index: include/lldb/Core/LoadedModuleInfoList.h
===
--- include/lldb/Core/LoadedModuleInfoList.h
+++ include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r334259 - Added missing include to LoadedModuleInfoList.h

2018-06-07 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Jun  7 19:00:27 2018
New Revision: 334259

URL: http://llvm.org/viewvc/llvm-project?rev=334259&view=rev
Log:
Added missing include to LoadedModuleInfoList.h

Subscribers: lldb-commits

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

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

Modified: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h?rev=334259&r1=334258&r2=334259&view=diff
==
--- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h (original)
+++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h Thu Jun  7 19:00:27 2018
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes


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


[Lldb-commits] [PATCH] D47923: Added missing include to LoadedModuleInfoList.h

2018-06-07 Thread Raphael Isemann 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 rL334259: Added missing include to LoadedModuleInfoList.h 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47923?vs=150441&id=150442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47923

Files:
  lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h


Index: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
===
--- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
+++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes


Index: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
===
--- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
+++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aaron Smith via Phabricator via lldb-commits
asmith added a comment.

Thanks! Much better without the binaries.


https://reviews.llvm.org/D47708



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


[Lldb-commits] [PATCH] D47929: Add modulemap to lldb include directory

2018-06-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: aprantl.

This patch adds a modulemap which allows compiling the lldb headers into C++ 
modules
(for example in builds with LLVM_ENABLE_MODULES=On).

Even though most of the affected code has been cleaned up to work with the more 
strict
C++ module semantics, there are still some workarounds left in the current 
modulemap
(the most obvious one is the big `lldb` wrapper module).

Note: With the latest clang and libstdc++ it seems necessary to have a STL C++ 
module
to get a working LLVM_ENABLE_MODULES build for lldb. Otherwise clang will 
falsely
detect ODR violations in the textually included STL code inside the lldb 
modules.


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap

Index: include/lldb/module.modulemap
===
--- /dev/null
+++ include/lldb/module.modulemap
@@ -0,0 +1,139 @@
+
+module lldb_API {
+  requires cplusplus
+
+  umbrella "API"
+  module * { export * }
+}
+
+module lldb_Host {
+  requires cplusplus
+
+  // Because we have OS-specific headers in Host, we just list
+  // all OS-independent headers here that will include the correct
+  // OS-specific header for us.
+  module ConnectionFileDescriptor { header "Host/ConnectionFileDescriptor.h" export * }
+  module Debug { header "Host/Debug.h" export * }
+  module Editline { header "Host/Editline.h" export * }
+  module FileCache { header "Host/FileCache.h" export * }
+  module File { header "Host/File.h" export * }
+  module FileSystem { header "Host/FileSystem.h" export * }
+  module HostGetOpt { header "Host/HostGetOpt.h" export * }
+  module Host { header "Host/Host.h" export * }
+  module HostInfoBase { header "Host/HostInfoBase.h" export * }
+  module HostInfo { header "Host/HostInfo.h" export * }
+  module HostNativeProcessBase { header "Host/HostNativeProcessBase.h" export * }
+  module HostNativeProcess { header "Host/HostNativeProcess.h" export * }
+  module HostNativeThreadBase { header "Host/HostNativeThreadBase.h" export * }
+  module HostNativeThreadForward { header "Host/HostNativeThreadForward.h" export * }
+  module HostNativeThread { header "Host/HostNativeThread.h" export * }
+  module HostProcess { header "Host/HostProcess.h" export * }
+  module HostThread { header "Host/HostThread.h" export * }
+  module LockFileBase { header "Host/LockFileBase.h" export * }
+  module LockFile { header "Host/LockFile.h" export * }
+  module MainLoopBase { header "Host/MainLoopBase.h" export * }
+  module MainLoop { header "Host/MainLoop.h" export * }
+  module MonitoringProcessLauncher { header "Host/MonitoringProcessLauncher.h" export * }
+  module OptionParser { header "Host/OptionParser.h" export * }
+  module PipeBase { header "Host/PipeBase.h" export * }
+  module Pipe { header "Host/Pipe.h" export * }
+  module PosixApi { header "Host/PosixApi.h" export * }
+  module Predicate { header "Host/Predicate.h" export * }
+  module ProcessLauncher { header "Host/ProcessLauncher.h" export * }
+  module ProcessRunLock { header "Host/ProcessRunLock.h" export * }
+  module PseudoTerminal { header "Host/PseudoTerminal.h" export * }
+  module SocketAddress { header "Host/SocketAddress.h" export * }
+  module Socket { header "Host/Socket.h" export * }
+  module StringConvert { header "Host/StringConvert.h" export * }
+  module Symbols { header "Host/Symbols.h" export * }
+  module TaskPool { header "Host/TaskPool.h" export * }
+  module Terminal { header "Host/Terminal.h" export * }
+  module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
+  module Time { header "Host/Time.h" export * }
+  module XML { header "Host/XML.h" export * }
+
+  export *
+}
+
+module lldb_Initialization {
+  requires cplusplus
+
+  umbrella "Initialization"
+  module * { export * }
+}
+
+// This big module is necessary to work around the cyclic dependencies
+// between its submodules.
+module lldb {
+  module Breakpoint {
+requires cplusplus
+
+umbrella "Breakpoint"
+module * { export * }
+  }
+
+  module Core {
+requires cplusplus
+
+umbrella "Core"
+module * { export * }
+  }
+
+
+  module DataFormatters {
+requires cplusplus
+
+umbrella "DataFormatters"
+module * { export * }
+  }
+
+  module Expression {
+requires cplusplus
+
+umbrella "Expression"
+module * { export * }
+// TODO: This file includes a non-public header.
+exclude header "Expression/REPL.h"
+  }
+
+  module Interpreter {
+requires cplusplus
+
+umbrella "Interpreter"
+module * { export * }
+  }
+
+  module Symbol {
+requires cplusplus
+
+umbrella "Symbol"
+module * { export * }
+  }
+  module Target {
+requires cplusplus
+
+umbrella "Target"
+module * { export * }
+  }
+}
+
+
+module lldb_Utility {
+  requires cplusplus
+
+  umbrella "Utility"
+  module * { export * }
+
+  module defines { header "lldb-defines.h" export * }
+  module enumerations { header "

[Lldb-commits] [PATCH] D47929: Add modulemap to lldb include directory

2018-06-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I generated a report for the remaining cyclic dependencies in the `lldb` module 
here .

Note that I'll provide a modulemap for the `source/` headers in another patch, 
so this is out of scope for this review. The reason is that this modulemap 
seems to barely affect compilation time and is quite verbose (as I can't use 
umbrellas with the mixed source/header files in the same directory).


https://reviews.llvm.org/D47929



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


[Lldb-commits] [PATCH] D47708: PDB support of function-level linking and splitted functions

2018-06-07 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Thank you for explanations!


https://reviews.llvm.org/D47708



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