[Lldb-commits] [PATCH] D47021: Fix PathMappingList for relative and empty paths after recent FileSpec normalization changes

2018-05-18 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 147587.
clayborg added a comment.

- Fixed Pavel's issues
- If user specifies "" as the first directory in PathMappingList, it will match 
"."
- User can specify "/" as the first directory to remap all absolute paths
- Fixed FileSpec::IsAbsolute() and added tests for issues I discovered when 
adding tests for relative paths in PathMappingListTests
- Modified tests in PathMappingListTests to use a help function which 
simplifies code
- Added more tests to things that shouldn't get remapped


https://reviews.llvm.org/D47021

Files:
  include/lldb/Target/PathMappingList.h
  lldb.xcodeproj/project.pbxproj
  source/Target/PathMappingList.cpp
  source/Target/Target.cpp
  source/Utility/FileSpec.cpp
  unittests/Target/CMakeLists.txt
  unittests/Target/PathMappingListTest.cpp
  unittests/Utility/FileSpecTest.cpp

Index: unittests/Utility/FileSpecTest.cpp
===
--- unittests/Utility/FileSpecTest.cpp
+++ unittests/Utility/FileSpecTest.cpp
@@ -273,3 +273,50 @@
   EXPECT_EQ("(empty)", llvm::formatv("{0:D}", F).str());
 }
 
+TEST(FileSpecTest, IsRelative) {
+  llvm::StringRef not_relative[] = {
+"/",
+"/a",
+"/a/",
+"/a/b",
+"/a/b/",
+"//",
+"//a",
+"//a/",
+"//a/b",
+"//a/b/",
+"~",
+"~/",
+"~/a",
+"~/a/",
+"~/a/b"
+"~/a/b/",
+"/foo/.",
+"/foo/..",
+"/foo/../",
+"/foo/../.",
+  };
+  for (const auto : not_relative) {
+FileSpec spec(path, false, FileSpec::Style::posix);
+EXPECT_FALSE(spec.IsRelative());
+  }
+  llvm::StringRef is_relative[] = {
+".",
+"./",
+".///",
+"a",
+"./a",
+"./a/",
+"./a/",
+"./a/b",
+"./a/b/",
+"../foo",
+"foo/bar.c",
+"./foo/bar.c"
+  };
+  for (const auto : is_relative) {
+FileSpec spec(path, false, FileSpec::Style::posix);
+EXPECT_TRUE(spec.IsRelative());
+  }
+}
+
Index: unittests/Target/PathMappingListTest.cpp
===
--- unittests/Target/PathMappingListTest.cpp
+++ unittests/Target/PathMappingListTest.cpp
@@ -0,0 +1,109 @@
+//===-- PathMappingListTest.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "llvm/ADT/ArrayRef.h"
+#include "lldb/Target/PathMappingList.h"
+#include "lldb/Utility/FileSpec.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb_private;
+
+namespace {
+  struct Matches {
+ConstString original;
+ConstString remapped;
+Matches(const char *o, const char *r) : original(o),
+remapped(r) {}
+  };
+  
+  void TestPathMappings(const PathMappingList ,
+llvm::ArrayRef matches,
+llvm::ArrayRef fails) {
+ConstString actual_remapped;
+for (const auto : fails) {
+  EXPECT_FALSE(map.RemapPath(fail, actual_remapped));
+}
+for (const auto : matches) {
+  FileSpec orig_spec(match.original.GetStringRef(), false);
+  std::string orig_normalized = orig_spec.GetPath();
+  EXPECT_TRUE(map.RemapPath(match.original, actual_remapped));
+  EXPECT_EQ(actual_remapped, match.remapped);
+  FileSpec remapped_spec(match.remapped.GetStringRef(), false);
+  FileSpec unmapped_spec;
+  EXPECT_TRUE(map.ReverseRemapPath(remapped_spec, unmapped_spec));
+  std::string unmapped_path = unmapped_spec.GetPath();
+  EXPECT_EQ(unmapped_path, orig_normalized);
+}
+  }
+}
+
+TEST(PathMappingListTest, RelativeTests) {
+  Matches matches[] = {
+{".", "/tmp"},
+{"./", "/tmp"},
+{"./", "/tmp"},
+{"./foo.c", "/tmp/foo.c"},
+{"foo.c", "/tmp/foo.c"},
+{"./bar/foo.c", "/tmp/bar/foo.c"},
+{"bar/foo.c", "/tmp/bar/foo.c"},
+  };
+  ConstString fails[] = {
+ConstString("/a"),
+ConstString("/"),
+  };
+  PathMappingList map;
+  map.Append(ConstString("."), ConstString("/tmp"), false);
+  TestPathMappings(map, matches, fails);
+  PathMappingList map2;
+  map2.Append(ConstString(""), ConstString("/tmp"), false);
+  TestPathMappings(map, matches, fails);
+}
+
+TEST(PathMappingListTest, AbsoluteTests) {
+  PathMappingList map;
+  map.Append(ConstString("/old"), ConstString("/new"), false);
+  Matches matches[] = {
+{"/old", "/new"},
+{"/old/", "/new"},
+{"/old/foo/.", "/new/foo"},
+{"/old/foo.c", "/new/foo.c"},
+{"/old/foo.c/.", "/new/foo.c"},
+{"/old/./foo.c", "/new/foo.c"},
+  };
+  ConstString fails[] = {
+ConstString("/foo"),
+ConstString("/"),
+ConstString("foo.c"),
+ConstString("./foo.c"),
+ConstString("../foo.c"),
+ConstString("../bar/foo.c"),
+  };
+  TestPathMappings(map, matches, fails);
+}
+
+TEST(PathMappingListTest, 

[Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D46889#1104882, @aemerson wrote:

> In https://reviews.llvm.org/D46889#1104823, @aprantl wrote:
>
> > Thanks for jumping on this Amara — I just wanted to point out that we 
> > ususally don't revert lldb changes that only break the lldb-xcode bot if 
> > they pass on the lldb-cmake bot at the same time. When this happens it 
> > usually means that the lldb Xcode project must be updated and it's too much 
> > to ask from all open source contributors to get access to a machine running 
> > Xcode to do this. Instead one of the Apple LLDB developers usually goes in 
> > and updates the Xcode project for them.
> >
> > - adrian
>
>
> Ah ok. Does that include cases like this one with the link error:
>
>   Undefined symbols for architecture x86_64:
> "lldb_private::AppleDWARFIndex::Create(lldb_private::Module&, 
> lldb_private::DWARFDataExtractor, lldb_private::DWARFDataExtractor, 
> lldb_private::DWARFDataExtractor, lldb_private::DWARFDataExtractor, 
> lldb_private::DWARFDataExtractor)", referenced from:
> SymbolFileDWARF::InitializeObject() in 
> liblldb-core.a(SymbolFileDWARF.o)
> "vtable for lldb_private::ManualDWARFIndex", referenced from:
> SymbolFileDWARF::InitializeObject() in 
> liblldb-core.a(SymbolFileDWARF.o)
> NOTE: a missing vtable usually means the first non-inline virtual member 
> function has no definition.
>


A link error is the most common manifestation of a file not being added to the 
xcode project. the vtable in question would have been emitted if 
ManualDWARFIndex.cpp (created by this CL) was built with everything else.

I did verify that this patch builds (with cmake) and all tests pass on darwin, 
so I don't expect there to be any other problems.

I am going to try relanding this when I'm back at work on Monday, but until 
then, if someone knows how to add these files to the project, I'd appreciate it 
if he can submit those changes together with this patch, and we can avoid 
having the bot go red again.


Repository:
  rL LLVM

https://reviews.llvm.org/D46889



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


Re: [Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Adrian Prantl via lldb-commits


> On May 18, 2018, at 11:25 AM, Amara Emerson via Phabricator 
>  wrote:
> 
> aemerson added a comment.
> 
> In https://reviews.llvm.org/D46889#1104823, @aprantl wrote:
> 
>> Thanks for jumping on this Amara — I just wanted to point out that we 
>> ususally don't revert lldb changes that only break the lldb-xcode bot if 
>> they pass on the lldb-cmake bot at the same time. When this happens it 
>> usually means that the lldb Xcode project must be updated and it's too much 
>> to ask from all open source contributors to get access to a machine running 
>> Xcode to do this. Instead one of the Apple LLDB developers usually goes in 
>> and updates the Xcode project for them.
>> 
>> - adrian
> 
> 
> Ah ok. Does that include cases like this one with the link error:

Possibly not.. I just realized that the lldb-cmake bot was stuck. I changed the 
configuration to have a timeout and forced a clean rebuild.
-- adrian

> 
>  Undefined symbols for architecture x86_64:
>"lldb_private::AppleDWARFIndex::Create(lldb_private::Module&, 
> lldb_private::DWARFDataExtractor, lldb_private::DWARFDataExtractor, 
> lldb_private::DWARFDataExtractor, lldb_private::DWARFDataExtractor, 
> lldb_private::DWARFDataExtractor)", referenced from:
>SymbolFileDWARF::InitializeObject() in 
> liblldb-core.a(SymbolFileDWARF.o)
>"vtable for lldb_private::ManualDWARFIndex", referenced from:
>SymbolFileDWARF::InitializeObject() in 
> liblldb-core.a(SymbolFileDWARF.o)
>NOTE: a missing vtable usually means the first non-inline virtual member 
> function has no definition.
> 
> 
> Repository:
>  rL LLVM
> 
> https://reviews.llvm.org/D46889
> 
> 
> 

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


[Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Amara Emerson via Phabricator via lldb-commits
aemerson added a comment.

In https://reviews.llvm.org/D46889#1104823, @aprantl wrote:

> Thanks for jumping on this Amara — I just wanted to point out that we 
> ususally don't revert lldb changes that only break the lldb-xcode bot if they 
> pass on the lldb-cmake bot at the same time. When this happens it usually 
> means that the lldb Xcode project must be updated and it's too much to ask 
> from all open source contributors to get access to a machine running Xcode to 
> do this. Instead one of the Apple LLDB developers usually goes in and updates 
> the Xcode project for them.
>
> - adrian


Ah ok. Does that include cases like this one with the link error:

  Undefined symbols for architecture x86_64:
"lldb_private::AppleDWARFIndex::Create(lldb_private::Module&, 
lldb_private::DWARFDataExtractor, lldb_private::DWARFDataExtractor, 
lldb_private::DWARFDataExtractor, lldb_private::DWARFDataExtractor, 
lldb_private::DWARFDataExtractor)", referenced from:
SymbolFileDWARF::InitializeObject() in liblldb-core.a(SymbolFileDWARF.o)
"vtable for lldb_private::ManualDWARFIndex", referenced from:
SymbolFileDWARF::InitializeObject() in liblldb-core.a(SymbolFileDWARF.o)
NOTE: a missing vtable usually means the first non-inline virtual member 
function has no definition.


Repository:
  rL LLVM

https://reviews.llvm.org/D46889



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


Re: [Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Adrian Prantl via lldb-commits
Thanks for jumping on this Amara — I just wanted to point out that we ususally 
don't revert lldb changes that only break the lldb-xcode bot if they pass on 
the lldb-cmake bot at the same time. When this happens it usually means that 
the lldb Xcode project must be updated and it's too much to ask from all open 
source contributors to get access to a machine running Xcode to do this. 
Instead one of the Apple LLDB developers usually goes in and updates the Xcode 
project for them.

-- adrian

> On May 18, 2018, at 9:04 AM, Amara Emerson via Phabricator 
>  wrote:
> 
> aemerson reopened this revision.
> aemerson added a comment.
> This revision is now accepted and ready to land.
> 
> Hi Pavel,
> 
> I reverted this in r332730 due to the bot breaking. Please have a look and 
> commit again when ready.
> 
> Thanks,
> Amara
> 
> 
> Repository:
>  rL LLVM
> 
> https://reviews.llvm.org/D46889
> 
> 
> 

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


[Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added subscribers: jingham, jasonmolenda, labath.
aprantl added a comment.

Thanks for jumping on this Amara — I just wanted to point out that we ususally 
don't revert lldb changes that only break the lldb-xcode bot if they pass on 
the lldb-cmake bot at the same time. When this happens it usually means that 
the lldb Xcode project must be updated and it's too much to ask from all open 
source contributors to get access to a machine running Xcode to do this. 
Instead one of the Apple LLDB developers usually goes in and updates the Xcode 
project for them.

- adrian


Repository:
  rL LLVM

https://reviews.llvm.org/D46889



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


[Lldb-commits] [PATCH] D47062: Suggest lldb-dotest to reproduce a failure.

2018-05-18 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: packages/Python/lldbsuite/test/dosep.py:122
 print("[%s FAILED]%s" % (name, timeout_str), file=sys.stderr)
-print("Command invoked: %s" % ' '.join(command), file=sys.stderr)
+print("Reproduce with: lldb-dotest -f {}".format(name), 
file=sys.stderr)
 update_progress(name)

JDevlieghere wrote:
> aprantl wrote:
> > What do you think about adding the full path to lldb-dotest? I usually have 
> > at least three concurrent checkouts of lldb at any time.
> Me too, but how would we get that information here? On of `lldb-dotest`'s 
> goals is that you can execute it from anywhere, so you'd either have to pass 
> it explicitly to `dotest.py` (either using a custom argument and cmake 
> variable combo, or by assuming it lives in the same directory as the current 
> lldb and appending `-dotest`) but that feels like it might not be worth it. 
> Maybe there's another solution you had in mind?
The --executable option that dotest receives should point to an lldb that ought 
to have a matching lldb-dotest next to it. I don't think that that is 
particularly ugly.


Repository:
  rL LLVM

https://reviews.llvm.org/D47062



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


[Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Amara Emerson via Phabricator via lldb-commits
aemerson reopened this revision.
aemerson added a comment.
This revision is now accepted and ready to land.

Hi Pavel,

I reverted this in r332730 due to the bot breaking. Please have a look and 
commit again when ready.

Thanks,
Amara


Repository:
  rL LLVM

https://reviews.llvm.org/D46889



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


[Lldb-commits] [PATCH] D47062: Suggest lldb-dotest to reproduce a failure.

2018-05-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

In https://reviews.llvm.org/D47062#1104558, @davide wrote:

> Can you commit the whitespace fixes separately?


Sure.




Comment at: packages/Python/lldbsuite/test/dosep.py:122
 print("[%s FAILED]%s" % (name, timeout_str), file=sys.stderr)
-print("Command invoked: %s" % ' '.join(command), file=sys.stderr)
+print("Reproduce with: lldb-dotest -f {}".format(name), 
file=sys.stderr)
 update_progress(name)

aprantl wrote:
> What do you think about adding the full path to lldb-dotest? I usually have 
> at least three concurrent checkouts of lldb at any time.
Me too, but how would we get that information here? On of `lldb-dotest`'s goals 
is that you can execute it from anywhere, so you'd either have to pass it 
explicitly to `dotest.py` (either using a custom argument and cmake variable 
combo, or by assuming it lives in the same directory as the current lldb and 
appending `-dotest`) but that feels like it might not be worth it. Maybe 
there's another solution you had in mind?


Repository:
  rL LLVM

https://reviews.llvm.org/D47062



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


[Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Amara Emerson via Phabricator via lldb-commits
aemerson added a comment.

This caused a failure in green dragon: 
http://green.lab.llvm.org/green/job/lldb-xcode/6644

Can you please fix or revert this change, thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D46889



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


[Lldb-commits] [PATCH] D47062: Suggest lldb-dotest to reproduce a failure.

2018-05-18 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: packages/Python/lldbsuite/test/dosep.py:122
 print("[%s FAILED]%s" % (name, timeout_str), file=sys.stderr)
-print("Command invoked: %s" % ' '.join(command), file=sys.stderr)
+print("Reproduce with: lldb-dotest -f {}".format(name), 
file=sys.stderr)
 update_progress(name)

What do you think about adding the full path to lldb-dotest? I usually have at 
least three concurrent checkouts of lldb at any time.


Repository:
  rL LLVM

https://reviews.llvm.org/D47062



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


[Lldb-commits] [PATCH] D47062: Suggest lldb-dotest to reproduce a failure.

2018-05-18 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

Can you commit the whitespace fixes separately?


Repository:
  rL LLVM

https://reviews.llvm.org/D47062



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


[Lldb-commits] [PATCH] D46889: [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332719: [DWARF] Extract indexing code into a separate class 
hierarchy (authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46889?vs=147326=147505#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46889

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -10,6 +10,7 @@
 #include "DWARFCompileUnit.h"
 
 #include "SymbolFileDWARF.h"
+#include "lldb/Utility/Stream.h"
 
 using namespace lldb;
 using namespace lldb_private;
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -0,0 +1,71 @@
+//===-- DWARFIndex.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLDB_DWARFINDEX_H
+#define LLDB_DWARFINDEX_H
+
+#include "Plugins/SymbolFile/DWARF/DIERef.h"
+#include "Plugins/SymbolFile/DWARF/DWARFFormValue.h"
+
+class DWARFDebugInfo;
+class DWARFDeclContext;
+class DWARFDIE;
+
+namespace lldb_private {
+class DWARFIndex {
+public:
+  DWARFIndex(Module ) : m_module(module) {}
+  virtual ~DWARFIndex();
+
+  virtual void Preload() = 0;
+
+  virtual void GetGlobalVariables(ConstString name, DIEArray ) = 0;
+  virtual void GetGlobalVariables(const RegularExpression ,
+  DIEArray ) = 0;
+  virtual void GetGlobalVariables(const DWARFUnit , DIEArray ) = 0;
+  virtual void GetObjCMethods(ConstString class_name, DIEArray ) = 0;
+  virtual void GetCompleteObjCClass(ConstString class_name,
+bool must_be_implementation,
+DIEArray ) = 0;
+  virtual void GetTypes(ConstString name, DIEArray ) = 0;
+  virtual void GetTypes(const DWARFDeclContext , DIEArray ) = 0;
+  virtual void GetNamespaces(ConstString name, DIEArray ) = 0;
+  virtual void GetFunctions(
+  ConstString name, DWARFDebugInfo ,
+  llvm::function_ref
+  resolve_function,
+  llvm::function_ref
+  get_decl_context_containing_uid,
+  const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask,
+  bool include_inlines, SymbolContextList _list) = 0;
+  virtual void GetFunctions(
+  const RegularExpression , DWARFDebugInfo ,
+  llvm::function_ref
+  resolve_function,
+  bool include_inlines, SymbolContextList _list) = 0;
+
+  virtual void ReportInvalidDIEOffset(dw_offset_t offset,
+  llvm::StringRef name) = 0;
+  virtual void Dump(Stream ) = 0;
+
+protected:
+  Module _module;
+
+  void ParseFunctions(
+  const DIEArray , DWARFDebugInfo ,
+  llvm::function_ref
+  resolve_function,
+  bool include_inlines, SymbolContextList _list);
+};
+} // namespace lldb_private
+
+#endif // LLDB_DWARFINDEX_H
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
@@ -0,0 +1,71 @@
+//===-- ManulaDWARFIndex.h 

[Lldb-commits] [lldb] r332719 - [DWARF] Extract indexing code into a separate class hierarchy

2018-05-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri May 18 07:15:46 2018
New Revision: 332719

URL: http://llvm.org/viewvc/llvm-project?rev=332719=rev
Log:
[DWARF] Extract indexing code into a separate class hierarchy

Summary:
This places the `if(m_using_apple_tables)` branches inside the
SymbolFileDWARF class behind an abstract DWARFIndex class. The class
currently has two implementations:
- AppleIndex, which searches using .apple_names and friends
- ManualIndex, which searches using a manually built index

Most of the methods of the class are very simple, and simply extract the
list of DIEs for the given name from the appropriate sub-table. The main
exception are the two GetFunctions overloads, which take a couple of
extra paramenters, including some callbacks. It was not possible to
split these up the same way as other methods, as here we were doing a
lot of post-processing on the results. The post-processing is similar
for the two cases, but not identical. I hope to factor these further in
separate patches.

Other interesting methods are:
- Preload(): do any preprocessing to make lookups faster (noop for
  AppleIndex, forces a build of the lookup tables for ManualIndex).
- ReportInvalidDIEOffset(): Used to notify the users of an invalid index
  (prints a message for AppleIndex, noop for ManualIndex).
- Dump(): dumps the index state (noop for AppleIndex, prints the lookup
  tables for ManualIndex).

Reviewers: clayborg, JDevlieghere

Subscribers: mgorny, aprantl, lldb-commits

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

Added:
lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Added: lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp?rev=332719=auto
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp (added)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp Fri May 18 
07:15:46 2018
@@ -0,0 +1,306 @@
+//===-- AppleDWARFIndex.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Plugins/SymbolFile/DWARF/AppleDWARFIndex.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h"
+#include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
+#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
+
+#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/Function.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+std::unique_ptr AppleDWARFIndex::Create(
+Module , DWARFDataExtractor apple_names,
+DWARFDataExtractor apple_namespaces, DWARFDataExtractor apple_types,
+DWARFDataExtractor apple_objc, DWARFDataExtractor debug_str) {
+  auto apple_names_table_up = llvm::make_unique(
+  apple_names, debug_str, ".apple_names");
+  if (!apple_names_table_up->IsValid())
+apple_names_table_up.reset();
+
+  auto apple_namespaces_table_up =
+  llvm::make_unique(
+  apple_namespaces, debug_str, ".apple_namespaces");
+  if (!apple_namespaces_table_up->IsValid())
+apple_namespaces_table_up.reset();
+
+  auto apple_types_table_up = llvm::make_unique(
+  apple_types, debug_str, ".apple_types");
+  if (!apple_types_table_up->IsValid())
+apple_types_table_up.reset();
+
+  auto apple_objc_table_up = llvm::make_unique(
+  apple_objc, debug_str, ".apple_objc");
+  if (!apple_objc_table_up->IsValid())
+apple_objc_table_up.reset();
+
+  if (apple_names_table_up || apple_names_table_up || apple_types_table_up ||
+  apple_objc_table_up)
+return llvm::make_unique(
+module, std::move(apple_names_table_up),
+std::move(apple_namespaces_table_up), std::move(apple_types_table_up),
+std::move(apple_objc_table_up));
+
+  return nullptr;
+}
+
+void 

[Lldb-commits] [PATCH] D47064: Add some apple-tables lookup tests

2018-05-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: lit/SymbolFile/DWARF/find-basic-function.cpp:17
 // RUN:   FileCheck --check-prefix=EMPTY %s
+//
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx

`%t.o`?


https://reviews.llvm.org/D47064



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


[Lldb-commits] [PATCH] D47064: Add some apple-tables lookup tests

2018-05-18 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, clayborg.
Herald added subscribers: ioeric, ilya-biryukov, aprantl.

Now that we are able to parse MachO files everywhere, we can write some
cross-platform tests for handling of apple accelerator tables. This
reruns the same lookup tests we have for manual indexes on MachO files
which will use the accelerator tables instead. This makes sure we return
the same results regardless of the method we used to access the debug
info.

The tests confirm we return the same results for looking up types,
namespaces and variables, but have found an inconsistency in the
treatment of function lookup. In the function case we mis-classify the
method "foo" declared in the local struct sbar (inside function ffbar).
We classify it as a function whereas it really is a method. Preliminary
analysis suggests this is because
DWARFASTParserClang::GetClangDeclContextForDIE returns null when given
the local "struct sbar" DIE. This causes us to get the wrong
CompilerDeclContext when we ask for the context of the inner foo, which
means CompilerDeclContext::ISStructUnionOrClass returns false.

Until this is fixed, I do not include the darwin versions of the "base"
and "method" function lookup tests.


https://reviews.llvm.org/D47064

Files:
  lit/SymbolFile/DWARF/find-basic-function.cpp
  lit/SymbolFile/DWARF/find-basic-namespace.cpp
  lit/SymbolFile/DWARF/find-basic-type.cpp
  lit/SymbolFile/DWARF/find-basic-variable.cpp


Index: lit/SymbolFile/DWARF/find-basic-variable.cpp
===
--- lit/SymbolFile/DWARF/find-basic-variable.cpp
+++ lit/SymbolFile/DWARF/find-basic-variable.cpp
@@ -10,6 +10,16 @@
 // 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 -o %t --target=x86_64-apple-macosx
+// 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:
Index: lit/SymbolFile/DWARF/find-basic-type.cpp
===
--- lit/SymbolFile/DWARF/find-basic-type.cpp
+++ lit/SymbolFile/DWARF/find-basic-type.cpp
@@ -8,6 +8,14 @@
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
+//
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
+// 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:
Index: lit/SymbolFile/DWARF/find-basic-namespace.cpp
===
--- lit/SymbolFile/DWARF/find-basic-namespace.cpp
+++ lit/SymbolFile/DWARF/find-basic-namespace.cpp
@@ -8,6 +8,14 @@
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=namespace %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
+//
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
+// 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
 
Index: lit/SymbolFile/DWARF/find-basic-function.cpp
===
--- lit/SymbolFile/DWARF/find-basic-function.cpp
+++ lit/SymbolFile/DWARF/find-basic-function.cpp
@@ -14,6 +14,16 @@
 // RUN:   FileCheck --check-prefix=CONTEXT %s
 // RUN: lldb-test symbols --name=not_there --find=function %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
+//
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
+// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t 
| \
+// RUN:   FileCheck --check-prefix=FULL %s
+// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full 
%t | \
+// RUN:   FileCheck --check-prefix=FULL-MANGLED %s
+// RUN: lldb-test symbols --name=foo --context=context --find=function 
--function-flags=base %t | \
+// RUN:   FileCheck --check-prefix=CONTEXT 

[Lldb-commits] [PATCH] D47062: Suggest lldb-dotest to reproduce a failure.

2018-05-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, davide, aprantl.

Rather than trying to figure out what arguments to pass to `dotest.py`, suggest 
using `lldb-dotest`. Athough this obviously won't work for all invocations 
(i.e. when you're passing custom arguments to `lldb-dotest`) it will work in 
the most common case (which is unfortunately not true today).


Repository:
  rL LLVM

https://reviews.llvm.org/D47062

Files:
  packages/Python/lldbsuite/test/dosep.py
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/lldbtest.py

Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -700,21 +700,21 @@
 """Return the full path to the current test."""
 return os.path.join(os.environ["LLDB_BUILD"], self.mydir,
 self.getBuildDirBasename())
-
- 
+
+
 def makeBuildDir(self):
 """Create the test-specific working directory, deleting any previous
 contents."""
 # See also dotest.py which sets up ${LLDB_BUILD}.
 bdir = self.getBuildDir()
 if os.path.isdir(bdir):
 shutil.rmtree(bdir)
 lldbutil.mkdir_p(bdir)
- 
+
 def getBuildArtifact(self, name="a.out"):
 """Return absolute path to an artifact in the test's build directory."""
 return os.path.join(self.getBuildDir(), name)
- 
+
 def getSourcePath(self, name):
 """Return absolute path to a file in the test's source directory."""
 return os.path.join(self.getSourceDir(), name)
@@ -1089,7 +1089,7 @@
 file=sbuf)
 
 def getRerunArgs(self):
-return " -f %s.%s" % (self.__class__.__name__, self._testMethodName)
+return "-f %s.%s" % (self.__class__.__name__, self._testMethodName)
 
 def getLogBasenameForCurrentTest(self, prefix=None):
 """
@@ -1186,18 +1186,12 @@
 benchmarks = False
 
 import datetime
-print(
-"Session info generated @",
+print("Session info generated @",
 datetime.datetime.now().ctime(),
 file=self.session)
-print(
-"To rerun this test, issue the following command from the 'test' directory:\n",
+print("To rerun this test, issue the following command:\n",
 file=self.session)
-print(
-"./dotest.py %s -v %s %s" %
-(self.getRunOptions(),
- ('+b' if benchmarks else '-t'),
-self.getRerunArgs()),
+print("lldb-dotest {}".format(self.getRerunArgs()),
 file=self.session)
 self.session.close()
 del self.session
@@ -1373,18 +1367,6 @@
 
 return False
 
-def getRunOptions(self):
-"""Command line option for -A and -C to run this test again, called from
-self.dumpSessionInfo()."""
-arch = self.getArchitecture()
-comp = self.getCompiler()
-option_str = ""
-if arch:
-option_str = "-A " + arch
-if comp:
-option_str += " -C " + comp
-return option_str
-
 def getDebugInfo(self):
 method = getattr(self, self.testMethodName)
 return getattr(method, "debug_info", None)
@@ -1840,7 +1822,7 @@
 temp = os.path.join(self.getSourceDir(), template)
 with open(temp, 'r') as f:
 content = f.read()
-
+
 public_api_dir = os.path.join(
 os.environ["LLDB_SRC"], "include", "lldb", "API")
 
Index: packages/Python/lldbsuite/test/dotest.py
===
--- packages/Python/lldbsuite/test/dotest.py
+++ packages/Python/lldbsuite/test/dotest.py
@@ -991,10 +991,6 @@
 raise Exception(
 'log enable failed (check GDB_REMOTE_LOG env variable)')
 
-
-def getMyCommandLine():
-return ' '.join(sys.argv)
-
 #  #
 #  #
 # Execution of the test driver starts here #
@@ -1274,7 +1270,7 @@
 "\nSession logs for test failures/errors/unexpected successes"
 " will go into directory '%s'\n" %
 configuration.sdir_name)
-sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
+sys.stderr.write("Command invoked: %s\n" % ' '.join(sys.argv))
 
 if not os.path.isdir(configuration.sdir_name):
 try:
Index: packages/Python/lldbsuite/test/dosep.py
===
--- packages/Python/lldbsuite/test/dosep.py
+++ packages/Python/lldbsuite/test/dosep.py
@@ -119,7 +119,7 @@
 else:
 timeout_str = ""
 print("[%s FAILED]%s" % (name, timeout_str), file=sys.stderr)
-print("Command invoked: %s" % ' '.join(command), file=sys.stderr)
+  

[Lldb-commits] [lldb] r332710 - Add back #ifdef __APPLE__ to RegisterContextDarwin_xxx::NumSupportedHardwareWatchpoints

2018-05-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri May 18 05:54:21 2018
New Revision: 332710

URL: http://llvm.org/viewvc/llvm-project?rev=332710=rev
Log:
Add back #ifdef __APPLE__ to 
RegisterContextDarwin_xxx::NumSupportedHardwareWatchpoints

It turns out these class still contained some os-specific functionality,
but I did not notice that originally, as it was #ifdef arm(64). This
adds back the __APPLE__ condition to these particular functions,
unbreaking arm builds on other OSs.

Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp

Modified: 
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp?rev=332710=332709=332710=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp Fri 
May 18 05:54:21 2018
@@ -1505,7 +1505,7 @@ uint32_t RegisterContextDarwin_arm::Conv
 }
 
 uint32_t RegisterContextDarwin_arm::NumSupportedHardwareBreakpoints() {
-#if defined(__arm__)
+#if defined(__APPLE__) && defined(__arm__)
   // Set the init value to something that will let us know that we need to
   // autodetect how many breakpoints are supported dynamically...
   static uint32_t g_num_supported_hw_breakpoints = UINT32_MAX;
@@ -1637,7 +1637,7 @@ bool RegisterContextDarwin_arm::ClearHar
 }
 
 uint32_t RegisterContextDarwin_arm::NumSupportedHardwareWatchpoints() {
-#if defined(__arm__)
+#if defined(__APPLE__) && defined(__arm__)
   // Set the init value to something that will let us know that we need to
   // autodetect how many watchpoints are supported dynamically...
   static uint32_t g_num_supported_hw_watchpoints = UINT32_MAX;

Modified: 
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp?rev=332710=332709=332710=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp 
Fri May 18 05:54:21 2018
@@ -915,7 +915,7 @@ uint32_t RegisterContextDarwin_arm64::Co
 }
 
 uint32_t RegisterContextDarwin_arm64::NumSupportedHardwareWatchpoints() {
-#if defined(__arm64__) || defined(__aarch64__)
+#if defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__))
   // autodetect how many watchpoints are supported dynamically...
   static uint32_t g_num_supported_hw_watchpoints = UINT32_MAX;
   if (g_num_supported_hw_watchpoints == UINT32_MAX) {


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


[Lldb-commits] [lldb] r332702 - Make ObjectFileMachO work on non-darwin platforms

2018-05-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri May 18 04:35:46 2018
New Revision: 332702

URL: http://llvm.org/viewvc/llvm-project?rev=332702=rev
Log:
Make ObjectFileMachO work on non-darwin platforms

Summary:
Before this patch we were unable to write cross-platform MachO tests
because the parsing code did not compile on other platforms. The reason
for that was that ObjectFileMachO depended on
RegisterContextDarwin_arm(64)? (presumably for core file parsing) and
the two Register Context classes uses constants from the system headers
(KERN_SUCCESS, KERN_INVALID_ARGUMENT).

As far as I can tell, these two files don't actually interact with the
darwin kernel -- they are used only in ObjectFileMachO and MacOSX-Kernel
process plugin (even though it has "kernel" in the name, this one
communicates with it via network packets and not syscalls). For the time
being I have created OS-independent definitions of these constants and
made the register context classes use those. Long term, the error
handling in these classes should be probably changed to use more
standard mechanisms such as Status or Error classes.

This is the only change necessary (apart from build system glue) to make
ObjectFileMachO work on other platforms. To demonstrate that, I remove
REQUIRES:darwin from our (only) cross-platform mach-o test.

Reviewers: jasonmolenda, aprantl, clayborg, javed.absar

Subscribers: mgorny, lldb-commits, kristof.beyls

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

Added:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
Modified:
lldb/trunk/lit/Modules/lc_version_min.yaml
lldb/trunk/source/Initialization/CMakeLists.txt
lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp

Modified: lldb/trunk/lit/Modules/lc_version_min.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/lc_version_min.yaml?rev=332702=332701=332702=diff
==
--- lldb/trunk/lit/Modules/lc_version_min.yaml (original)
+++ lldb/trunk/lit/Modules/lc_version_min.yaml Fri May 18 04:35:46 2018
@@ -1,6 +1,6 @@
 # RUN: yaml2obj %s > %t.out
 # RUN: lldb-test symbols %t.out | FileCheck %s
-# REQUIRES: darwin
+
 # Test that the deployment target is parsed from the load commands.
 # CHECK: x86_64-apple-macosx10.9.0
 --- !mach-o

Modified: lldb/trunk/source/Initialization/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/CMakeLists.txt?rev=332702=332701=332702=diff
==
--- lldb/trunk/source/Initialization/CMakeLists.txt (original)
+++ lldb/trunk/source/Initialization/CMakeLists.txt Fri May 18 04:35:46 2018
@@ -1,7 +1,3 @@
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-  list(APPEND EXTRA_PLUGINS lldbPluginObjectFileMachO)
-endif()
-
 if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
   list(APPEND EXTRA_PLUGINS lldbPluginProcessPOSIX)
 endif()
@@ -24,6 +20,7 @@ add_lldb_library(lldbInitialization
 lldbPluginObjectContainerBSDArchive
 lldbPluginObjectContainerMachOArchive
 lldbPluginObjectFileELF
+lldbPluginObjectFileMachO
 lldbPluginObjectFilePECOFF
 lldbPluginProcessGDBRemote
 ${EXTRA_PLUGINS}

Modified: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializerCommon.cpp?rev=332702=332701=332702=diff
==
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp (original)
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp Fri May 18 
04:35:46 2018
@@ -21,10 +21,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Timer.h"
-
-#if defined(__APPLE__)
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#endif
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
@@ -82,6 +79,7 @@ void SystemInitializerCommon::Initialize
   // Initialize plug-ins
   ObjectContainerBSDArchive::Initialize();
   ObjectFileELF::Initialize();
+  ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
 
   EmulateInstructionARM::Initialize();
@@ -93,9 +91,6 @@ void SystemInitializerCommon::Initialize
   //--
   ObjectContainerUniversalMachO::Initialize();
 
-#if defined(__APPLE__)
-  ObjectFileMachO::Initialize();
-#endif
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
   ProcessPOSIXLog::Initialize();
 #endif
@@ -109,6 +104,7 @@ void SystemInitializerCommon::Terminate(
   Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
   

[Lldb-commits] [PATCH] D46934: Make ObjectFileMachO work on non-darwin platforms

2018-05-18 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332702: Make ObjectFileMachO work on non-darwin platforms 
(authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46934

Files:
  lldb/trunk/lit/Modules/lc_version_min.yaml
  lldb/trunk/source/Initialization/CMakeLists.txt
  lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp

Index: lldb/trunk/lit/Modules/lc_version_min.yaml
===
--- lldb/trunk/lit/Modules/lc_version_min.yaml
+++ lldb/trunk/lit/Modules/lc_version_min.yaml
@@ -1,6 +1,6 @@
 # RUN: yaml2obj %s > %t.out
 # RUN: lldb-test symbols %t.out | FileCheck %s
-# REQUIRES: darwin
+
 # Test that the deployment target is parsed from the load commands.
 # CHECK: x86_64-apple-macosx10.9.0
 --- !mach-o
Index: lldb/trunk/source/Initialization/CMakeLists.txt
===
--- lldb/trunk/source/Initialization/CMakeLists.txt
+++ lldb/trunk/source/Initialization/CMakeLists.txt
@@ -1,7 +1,3 @@
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-  list(APPEND EXTRA_PLUGINS lldbPluginObjectFileMachO)
-endif()
-
 if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
   list(APPEND EXTRA_PLUGINS lldbPluginProcessPOSIX)
 endif()
@@ -24,6 +20,7 @@
 lldbPluginObjectContainerBSDArchive
 lldbPluginObjectContainerMachOArchive
 lldbPluginObjectFileELF
+lldbPluginObjectFileMachO
 lldbPluginObjectFilePECOFF
 lldbPluginProcessGDBRemote
 ${EXTRA_PLUGINS}
Index: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
@@ -21,10 +21,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Timer.h"
-
-#if defined(__APPLE__)
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#endif
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
@@ -82,6 +79,7 @@
   // Initialize plug-ins
   ObjectContainerBSDArchive::Initialize();
   ObjectFileELF::Initialize();
+  ObjectFileMachO::Initialize();
   ObjectFilePECOFF::Initialize();
 
   EmulateInstructionARM::Initialize();
@@ -93,9 +91,6 @@
   //--
   ObjectContainerUniversalMachO::Initialize();
 
-#if defined(__APPLE__)
-  ObjectFileMachO::Initialize();
-#endif
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
   ProcessPOSIXLog::Initialize();
 #endif
@@ -109,16 +104,14 @@
   Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
   ObjectContainerBSDArchive::Terminate();
   ObjectFileELF::Terminate();
+  ObjectFileMachO::Terminate();
   ObjectFilePECOFF::Terminate();
 
   EmulateInstructionARM::Terminate();
   EmulateInstructionMIPS::Terminate();
   EmulateInstructionMIPS64::Terminate();
 
   ObjectContainerUniversalMachO::Terminate();
-#if defined(__APPLE__)
-  ObjectFileMachO::Terminate();
-#endif
 
 #if defined(_MSC_VER)
   ProcessWindowsLog::Terminate();
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -7,13 +7,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm.h"
-
-// C Includes
-#include 
-#include 
+#include "RegisterContextDarwinConstants.h"
 
 // C++ Includes
 // Other libraries and framework includes
@@ -1766,5 +1761,3 @@
   }
   return false;
 }
-
-#endif
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -8,14 +8,8 @@
 //
 //===--===//
 
-#if defined(__APPLE__)
-
 #include "RegisterContextDarwin_arm64.h"
-
-// C Includes
-#include 
-#include 
-#include 
+#include "RegisterContextDarwinConstants.h"
 
 // C++ Includes
 // Other libraries and framework includes
@@ -1043,5 +1037,3 @@
   }
   return false;
 }
-
-#endif
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h

[Lldb-commits] [PATCH] D47021: Fix PathMappingList for relative and empty paths after recent FileSpec normalization changes

2018-05-18 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Although it may not seem that way from the number of comments, the change looks 
good to me. The main thing is the moving of the test file, as that will fail in 
the cmake build. And it also looks like some code can be simplified if my 
assumption about not converting "" to "." is true.

Thank you for adding the test for this class.




Comment at: source/Target/PathMappingList.cpp:44
+// us. We then grab the string and turn it back into a ConstString.
+return ConstString(FileSpec(path.GetCString(), false).GetPath());
+  }

s/GetCString/GetStringRef



Comment at: source/Target/PathMappingList.cpp:101
 insert_iter = m_pairs.begin() + index;
-  m_pairs.insert(insert_iter, pair(path, replacement));
+  m_pairs.insert(insert_iter, pair(NormalizePath(path),
+   NormalizePath(replacement)));

s/insert/emplace



Comment at: source/Target/PathMappingList.cpp:161
+  if (RemapPath(path.GetStringRef(), remapped)) {
+new_path.SetCStringWithLength(remapped.c_str(), remapped.size());
+return true;

SetString(remapped)



Comment at: source/Target/PathMappingList.cpp:191-194
+  // If our original path was "", then the new path is just the suffix.
+  // If we call fixed.SetFile("", false) we will end up with "." as the
+  // path and any path we appended would end up being relative.
+  fixed.SetFile(path_ref, false);

Is this really true? Judging by the test you've had to remove in r332633, we 
shouldn't end up converting "" to ".".



Comment at: unittests/Utility/PathMappingListTest.cpp:1
+//===-- NameMatchesTest.cpp -*- C++ 
-*-===//
+//

This file should go to `unittests/Target/PathMappingListTest.cpp` to match 
where the class-under-test lives. (Also, please update the name in the header.)



Comment at: unittests/Utility/PathMappingListTest.cpp:39
+  for (const auto : tests) {
+FileSpec orig_spec(m.original.GetCString(), false);
+std::string orig_normalized = orig_spec.GetPath();

`s/GetCString/GetStringRef` (whole file)



Comment at: unittests/Utility/PathMappingListTest.cpp:42
+EXPECT_TRUE(map.RemapPath(m.original, actual_remapped));
+EXPECT_TRUE(actual_remapped == m.remapped);
+FileSpec remapped_spec(m.remapped.GetCString(), false);

It's better to use `EXPECT_EQ(expected, actual)` for equality comparison, as 
that will print out a more useful error message when things fail.



Comment at: unittests/Utility/PathMappingListTest.cpp:86
+{"/old/foo.c/.", "/new/old/foo.c"},
+{"/old/./foo.c", "/new/old/foo.c"},
+  };

How does this work for relative paths? I take it `foo.c` should be remapped to 
`/new/foo.c` ? Can you add a test for that?


https://reviews.llvm.org/D47021



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


[Lldb-commits] [lldb] r332700 - Fix _NSCFBoolean data formatter.

2018-05-18 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Fri May 18 02:14:45 2018
New Revision: 332700

URL: http://llvm.org/viewvc/llvm-project?rev=332700=rev
Log:
Fix _NSCFBoolean data formatter.

In r265181 the test for the NSCFBoolean data formatter was removed.
Later, in r279353 and r279446 a new implementation was provided for the
formatter, which I believe never worked (and this wasn't caught because
the test was never re-enabled).

This commit fixes the bug and re-enables the old test case.

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=332700=332699=332700=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
 Fri May 18 02:14:45 2018
@@ -186,16 +186,18 @@ class ObjCDataFormatterTestCase(TestBase
 
 def nsnumber_data_formatter_commands(self):
 # Now enable AppKit and check we are displaying Cocoa classes correctly
-self.expect('frame variable num1 num2 num3 num5 num6 num7 num9',
+self.expect('frame variable num1 num2 num3 num5 num6 num7 num8_Y 
num8_N num9',
 substrs=['(NSNumber *) num1 = ', ' (int)5',
  '(NSNumber *) num2 = ', ' (float)3.1',
  '(NSNumber *) num3 = ', ' (double)3.14',
  '(NSNumber *) num5 = ', ' (char)65',
  '(NSNumber *) num6 = ', ' (long)255',
  '(NSNumber *) num7 = ', '200',
+ '(NSNumber *) num8_Y = ', 'YES',
+ '(NSNumber *) num8_N = ', 'NO',
  '(NSNumber *) num9 = ', ' (short)-31616'])
 
-
+
 self.runCmd('frame variable num4', check=True)
 output = self.res.GetOutput()
 i128_handled_correctly = False

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=332700=332699=332700=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 Fri May 18 02:14:45 2018
@@ -2525,14 +2525,14 @@ bool AppleObjCRuntimeV2::GetCFBooleanVal
   if (m_CFBoolean_values)
 return true;
 
-  static ConstString g_kCFBooleanFalse("kCFBooleanFalse");
-  static ConstString g_kCFBooleanTrue("kCFBooleanTrue");
+  static ConstString g_kCFBooleanFalse("__kCFBooleanFalse");
+  static ConstString g_kCFBooleanTrue("__kCFBooleanTrue");
 
   std::function get_symbol =
   [this](ConstString sym) -> lldb::addr_t {
 SymbolContextList sc_list;
 if (GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(
-g_kCFBooleanFalse, lldb::eSymbolTypeData, sc_list) == 1) {
+sym, lldb::eSymbolTypeData, sc_list) == 1) {
   SymbolContext sc;
   sc_list.GetContextAtIndex(0, sc);
   if (sc.symbol)


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


[Lldb-commits] [PATCH] D47014: Fix _NSCFBoolean data formatter.

2018-05-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332700: Fix _NSCFBoolean data formatter. (authored by 
JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47014?vs=147312=147449#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47014

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
  
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp


Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
@@ -186,16 +186,18 @@
 
 def nsnumber_data_formatter_commands(self):
 # Now enable AppKit and check we are displaying Cocoa classes correctly
-self.expect('frame variable num1 num2 num3 num5 num6 num7 num9',
+self.expect('frame variable num1 num2 num3 num5 num6 num7 num8_Y 
num8_N num9',
 substrs=['(NSNumber *) num1 = ', ' (int)5',
  '(NSNumber *) num2 = ', ' (float)3.1',
  '(NSNumber *) num3 = ', ' (double)3.14',
  '(NSNumber *) num5 = ', ' (char)65',
  '(NSNumber *) num6 = ', ' (long)255',
  '(NSNumber *) num7 = ', '200',
+ '(NSNumber *) num8_Y = ', 'YES',
+ '(NSNumber *) num8_N = ', 'NO',
  '(NSNumber *) num9 = ', ' (short)-31616'])
 
-
+
 self.runCmd('frame variable num4', check=True)
 output = self.res.GetOutput()
 i128_handled_correctly = False
Index: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2525,14 +2525,14 @@
   if (m_CFBoolean_values)
 return true;
 
-  static ConstString g_kCFBooleanFalse("kCFBooleanFalse");
-  static ConstString g_kCFBooleanTrue("kCFBooleanTrue");
+  static ConstString g_kCFBooleanFalse("__kCFBooleanFalse");
+  static ConstString g_kCFBooleanTrue("__kCFBooleanTrue");
 
   std::function get_symbol =
   [this](ConstString sym) -> lldb::addr_t {
 SymbolContextList sc_list;
 if (GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(
-g_kCFBooleanFalse, lldb::eSymbolTypeData, sc_list) == 1) {
+sym, lldb::eSymbolTypeData, sc_list) == 1) {
   SymbolContext sc;
   sc_list.GetContextAtIndex(0, sc);
   if (sc.symbol)


Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
@@ -186,16 +186,18 @@
 
 def nsnumber_data_formatter_commands(self):
 # Now enable AppKit and check we are displaying Cocoa classes correctly
-self.expect('frame variable num1 num2 num3 num5 num6 num7 num9',
+self.expect('frame variable num1 num2 num3 num5 num6 num7 num8_Y num8_N num9',
 substrs=['(NSNumber *) num1 = ', ' (int)5',
  '(NSNumber *) num2 = ', ' (float)3.1',
  '(NSNumber *) num3 = ', ' (double)3.14',
  '(NSNumber *) num5 = ', ' (char)65',
  '(NSNumber *) num6 = ', ' (long)255',
  '(NSNumber *) num7 = ', '200',
+ '(NSNumber *) num8_Y = ', 'YES',
+ '(NSNumber *) num8_N = ', 'NO',
  '(NSNumber *) num9 = ', ' (short)-31616'])
 
-
+
 self.runCmd('frame variable num4', check=True)
 output = self.res.GetOutput()
 i128_handled_correctly = False
Index: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2525,14