[Lldb-commits] [lldb] r372815 - [lldb][NFC] Refactor TestCallBuiltinFunction

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 00:11:37 2019
New Revision: 372815

URL: http://llvm.org/viewvc/llvm-project?rev=372815&view=rev
Log:
[lldb][NFC] Refactor TestCallBuiltinFunction

Using asserts doesn't print a useful error message in case this test fails.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py?rev=372815&r1=372814&r2=372815&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/call-function/TestCallBuiltinFunction.py
 Wed Sep 25 00:11:37 2019
@@ -40,14 +40,7 @@ class ExprCommandCallBuiltinFunction(Tes
 
 # Test different builtin functions.
 
-interp.HandleCommand("expr __builtin_isinf(0.0f)", result)
-self.assertEqual(result.GetOutput(), "(int) $0 = 0\n")
-
-interp.HandleCommand("expr __builtin_isnormal(0.0f)", result)
-self.assertEqual(result.GetOutput(), "(int) $1 = 0\n")
-
-interp.HandleCommand("expr __builtin_constant_p(1)", result)
-self.assertEqual(result.GetOutput(), "(int) $2 = 1\n")
-
-interp.HandleCommand("expr __builtin_abs(-14)", result)
-self.assertEqual(result.GetOutput(), "(int) $3 = 14\n")
+self.expect("expr __builtin_isinf(0.0f)", substrs=["(int) $", " = 
0\n"])
+self.expect("expr __builtin_isnormal(0.0f)", substrs=["(int) $", " = 
0\n"])
+self.expect("expr __builtin_constant_p(1)", substrs=["(int) $", " = 
1\n"])
+self.expect("expr __builtin_abs(-14)", substrs=["(int) $", " = 14\n"])


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


[Lldb-commits] [lldb] r372817 - [lldb] Fix undefined behavior when having fixits in undefined top level exprs

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 00:34:56 2019
New Revision: 372817

URL: http://llvm.org/viewvc/llvm-project?rev=372817&view=rev
Log:
[lldb] Fix undefined behavior when having fixits in undefined top level exprs

In top level expressions, we don't have a m_source_code and we don't need to 
change
the source bounds (as no wrapping happend there). Fixes the test on the
sanitizer bot.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=372817&r1=372816&r2=372817&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
Wed Sep 25 00:34:56 2019
@@ -600,7 +600,10 @@ bool ClangUserExpression::Parse(Diagnost
 size_t fixed_end;
 const std::string &fixed_expression =
 diagnostic_manager.GetFixedExpression();
-if (m_source_code->GetOriginalBodyBounds(fixed_expression, m_expr_lang,
+// Retrieve the original expression in case we don't have a top level
+// expression (which has no surrounding source code).
+if (m_source_code &&
+m_source_code->GetOriginalBodyBounds(fixed_expression, m_expr_lang,
  fixed_start, fixed_end))
   m_fixed_text =
   fixed_expression.substr(fixed_start, fixed_end - fixed_start);


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


[Lldb-commits] [PATCH] D68010: [lldb] Fix string summary of an empty NSPathStore2

2019-09-25 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: aprantl, JDevlieghere, shafik.
Herald added subscribers: lldb-commits, abidh, christof.
Herald added a project: LLDB.

Printing a summary for an empty NSPathStore2 string currently prints random 
bytes behind the empty string pointer from memory (rdar://55575888).

It seems the reason for this is that the SourceSize parameter in the 
`ReadStringAndDumpToStreamOptions` - which is supposed to contain the string
length - actually uses the length 0 as a magic value for saying "read as much 
as possible from the buffer" which is clearly wrong for empty strings.

This patch adds another flag that indicates if we have know the string length 
or not and makes this behaviour dependent on that (which seemingly
was the original purpose of this magic value). As this code is shared between 
all string reading, this patch also adds tests for printing empty strings
to all string type tests that seem to use this code path.

Note that I'm aware that some of the surrounding code that I touch here is 
spaghetti which should be refactored. However, I would prefer if we could
backport this patch without also having to backport a series of refactoring 
patches, so let's just add sauce to that pasta for now and I'll do the 
refactoring
once this has landed.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68010

Files:
  lldb/include/lldb/DataFormatters/StringPrinter.h
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp

Index: lldb/source/Plugins/Language/ObjC/NSString.cpp
===
--- lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -171,6 +171,7 @@
   options.SetStream(&stream);
   options.SetQuote('"');
   options.SetSourceSize(explicit_length);
+  options.SetHasSourceSize(has_explicit_length);
   options.SetNeedsZeroTermination(false);
   options.SetIgnoreMaxLength(summary_options.GetCapping() ==
  TypeSummaryCapping::eTypeSummaryUncapped);
@@ -183,6 +184,7 @@
   options.SetProcessSP(process_sp);
   options.SetStream(&stream);
   options.SetSourceSize(explicit_length);
+  options.SetHasSourceSize(has_explicit_length);
   options.SetNeedsZeroTermination(false);
   options.SetIgnoreMaxLength(summary_options.GetCapping() ==
  TypeSummaryCapping::eTypeSummaryUncapped);
@@ -200,6 +202,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
 options.SetLanguage(summary_options.GetLanguage());
@@ -222,6 +225,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -242,6 +246,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -264,6 +269,7 @@
 options.SetProcessSP(process_sp);
 options.SetStream(&stream);
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -287,6 +293,7 @@
 options.SetProcessSP(process_sp);
 options.SetStream(&stream);
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetIgnoreMaxLength(summary_opt

[Lldb-commits] [lldb] r372827 - [lldb] Remove -nostdlib++ flag from import-std-module/sysroot test

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 01:32:25 2019
New Revision: 372827

URL: http://llvm.org/viewvc/llvm-project?rev=372827&view=rev
Log:
[lldb] Remove -nostdlib++ flag from import-std-module/sysroot test

That flag was introduced in Clang 6.0, so this made the test fail
with Clang <= 5.0. As it only influences linking builtin libraries
like -m which aren't relevant for this test, we can drop this flag.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile?rev=372827&r1=372826&r2=372827&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
 Wed Sep 25 01:32:25 2019
@@ -3,7 +3,7 @@
 # system headers.
 NO_TEST_COMMON_H := 1
 
-CXXFLAGS += -I $(SRCDIR)/root/usr/include/c++/include/ -I 
$(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++ -nostdlib++
+CXXFLAGS += -I $(SRCDIR)/root/usr/include/c++/include/ -I 
$(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
 CXX_SOURCES := main.cpp
 
 include Makefile.rules


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


[Lldb-commits] [PATCH] D67994: [WIP] Modify lldb-test to print out ASTs from symbol file

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

For dumping a specific type something like this could be right, but for 
"indiscriminately dumping" everything, this seems to be a bit fragile.

Would it be possible to make this use the `SymbolFile::DumpClangAST` method 
(this is what the "image dump ast" lldb command uses), and then possibly change 
that method to include any extra information you need? I already see the 
`DefinitionData` line when i do a "image dump clang ast", so it's possible you 
wouldn't need to change anything there...

FTR, this is what i get from image dump ast:

  Dumping clang ast for 1 modules.
  TranslationUnitDecl 0x561fa5fd9128 <>  

  `-NamespaceDecl 0x561fa5fd99e8 <>  Q
`-CXXRecordDecl 0x561fa5fd9a70 <>  struct A 
definition
  |-DefinitionData pass_in_registers empty standard_layout 
trivially_copyable has_user_declared_ctor can_const_default_init
  | |-DefaultConstructor exists non_trivial user_provided 
defaulted_is_constexpr
  | |-CopyConstructor simple trivial has_const_param needs_implicit 
implicit_has_const_param
  | |-MoveConstructor exists simple trivial needs_implicit
  | |-CopyAssignment trivial has_const_param needs_implicit 
implicit_has_const_param
  | |-MoveAssignment exists simple trivial needs_implicit
  | `-Destructor simple irrelevant trivial needs_implicit
  `-CXXConstructorDecl 0x561fa5fd9bf0 <>  A 
'void ()'


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

https://reviews.llvm.org/D67994



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


[Lldb-commits] [PATCH] D68003: [dotest] Support specifying a version for skipIfOutOfTreeDebugserver

2019-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py:18
 @expectedFailureNetBSD
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<=', ''])
 def test(self):

JDevlieghere wrote:
> I used  here because that's commonly the placeholder until the next 
> release. 
I haven't looked at the code in detail, but given that you are removing the 
explicit notion of an "out of tree" debug server, it seems to be that this will 
kick in even if you are testing against the in-tree debug server, which doesn't 
seem right. Or am I missing something?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68003



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


[Lldb-commits] [PATCH] D67984: Canonicalize variable usage in testsuite Makefiles

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

Cool stuff. I wanted to do this for a while. Thanks.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67984



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


[Lldb-commits] [lldb] r372830 - [lldb][NFC] Use default member initializers in ReadBufferAndDumpToStreamOptions

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 01:55:55 2019
New Revision: 372830

URL: http://llvm.org/viewvc/llvm-project?rev=372830&view=rev
Log:
[lldb][NFC] Use default member initializers in ReadBufferAndDumpToStreamOptions

Modified:
lldb/trunk/include/lldb/DataFormatters/StringPrinter.h

Modified: lldb/trunk/include/lldb/DataFormatters/StringPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/StringPrinter.h?rev=372830&r1=372829&r2=372830&view=diff
==
--- lldb/trunk/include/lldb/DataFormatters/StringPrinter.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/StringPrinter.h Wed Sep 25 01:55:55 
2019
@@ -144,11 +144,7 @@ public:
 
   class ReadBufferAndDumpToStreamOptions {
   public:
-ReadBufferAndDumpToStreamOptions()
-: m_data(), m_stream(nullptr), m_prefix_token(), m_suffix_token(),
-  m_quote('"'), m_source_size(0), m_escape_non_printables(true),
-  m_zero_is_terminator(true), m_is_truncated(false),
-  m_language_type(lldb::eLanguageTypeUnknown) {}
+ReadBufferAndDumpToStreamOptions() = default;
 
 ReadBufferAndDumpToStreamOptions(ValueObject &valobj);
 
@@ -241,15 +237,15 @@ public:
 
   private:
 DataExtractor m_data;
-Stream *m_stream;
+Stream *m_stream = nullptr;
 std::string m_prefix_token;
 std::string m_suffix_token;
-char m_quote;
-uint32_t m_source_size;
-bool m_escape_non_printables;
-bool m_zero_is_terminator;
-bool m_is_truncated;
-lldb::LanguageType m_language_type;
+char m_quote = '"';
+uint32_t m_source_size = 0;
+bool m_escape_non_printables = true;
+bool m_zero_is_terminator = true;
+bool m_is_truncated = false;
+lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
   };
 
   // I can't use a std::unique_ptr for this because the Deleter is a template


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


[Lldb-commits] [PATCH] D67390: [LLDB][ELF] Load both, .symtab and .dynsym sections

2019-09-25 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 221689.
kwk added a comment.

- [LLDB][ELF] Fixup for comments in D67390 
- Change test expectation to find 2 instead of 1 symbol
- symbol uniqueness by using elf::ELFSymbol


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/Inputs/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/Inputs/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/load-from-dynsym-alone.test
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.test
  lldb/lit/helper/toolchain.py
  
lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/unittests/Target/ModuleCacheTest.cpp

Index: lldb/unittests/Target/ModuleCacheTest.cpp
===
--- lldb/unittests/Target/ModuleCacheTest.cpp
+++ lldb/unittests/Target/ModuleCacheTest.cpp
@@ -129,7 +129,7 @@
   ASSERT_TRUE(bool(module_sp));
 
   SymbolContextList sc_list;
-  EXPECT_EQ(1u, module_sp->FindFunctionSymbols(ConstString("boom"),
+  EXPECT_EQ(2u, module_sp->FindFunctionSymbols(ConstString("boom"),
eFunctionNameTypeFull, sc_list));
   EXPECT_STREQ(GetDummyRemotePath().GetCString(),
module_sp->GetPlatformFileSpec().GetCString());
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -221,6 +222,9 @@
   /// The address class for each symbol in the elf file
   FileAddressToAddressClassMap m_address_class_map;
 
+  /// A unique set of (mangled symbol name, type, address, size) tuple  
+  std::vector m_unique_symbol_set;
+
   /// Returns the index of the given section header.
   size_t SectionIndex(const SectionHeaderCollIter &I);
 
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MipsABIFlags.h"
+#include "lldb/Utility/StreamString.h"
 
 #define CASE_AND_STREAM(s, def, width) \
   case def:\
@@ -2196,7 +2197,12 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+if (std::find(m_unique_symbol_set.begin(), m_unique_symbol_set.end(),
+  symbol) == m_unique_symbol_set.end()) {
+  symtab->AddSymbol(dc_symbol);
+  m_unique_symbol_set.push_back(symbol);
+}
   }
   return i;
 }
@@ -2644,24 +2650,33 @@
 
 // Sharable objects and dynamic executables usually have 2 distinct symbol
 // tables, one named ".symtab", and the other ".dynsym". The dynsym is a
-// smaller version of the symtab that only contains global symbols. The
-// information found in the dynsym is therefore also found in the symtab,
-// while the reverse is not necessarily true.
+// smaller version of the symtab that only contains global symbols.
+// Information in the dynsym section is *usually* also found in the symtab,
+// but this is not required as symtab entries can be removed after linking.
+// The minidebuginfo format makes use of this facility to create smaller
+// symbol tables.
 Section *symtab =
 section_list->FindSectionByType(eSectionTypeELFSymbolTable, true).get();
-if (!symtab) {
-  // The symtab section is non-allocable and can be stripped, so if it
-  // doesn't exist then use the dynsym section which should always be
-  // there.
-  symtab =
-  section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
-  .get();
-}
 if (symtab) {
   m_symtab_up.reset(new Symtab(symtab->GetObjectFile()));
   symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, symtab);
 }
 
+// The symtab section is non-allocable and can be stripped, while the dynsym
+// section which should always be always be there. If both exist we load
+// both to support the minidebuginfo case. Otherwise we just load the dynsym
+// section.
+Section *dynsym =
+section_list->FindSectionByType(eSectio

[Lldb-commits] [PATCH] D68005: Make dw_tag_t a llvm::dwarf::Tag

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

Makes sense to me.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68005



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


[Lldb-commits] [PATCH] D67774: [Mangle] Add flag to asm labels to disable '\01' prefixing

2019-09-25 Thread John McCall via Phabricator via lldb-commits
rjmccall added a comment.

Thanks. One last and minor request: please mention in the comment on 
IsLiteralLabel that non-literal labels are used by some external AST sources 
like LLDB.


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

https://reviews.llvm.org/D67774



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


[Lldb-commits] [PATCH] D67390: [LLDB][ELF] Load both, .symtab and .dynsym sections

2019-09-25 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk updated this revision to Diff 221690.
kwk added a comment.

- Revert "Change test expectation to find 2 instead of 1 symbol"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390

Files:
  lldb/lit/Modules/ELF/Inputs/load-from-dynsym-alone.c
  lldb/lit/Modules/ELF/Inputs/load-symtab-and-dynsym.c
  lldb/lit/Modules/ELF/load-from-dynsym-alone.test
  lldb/lit/Modules/ELF/load-symtab-and-dynsym.test
  lldb/lit/helper/toolchain.py
  lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -221,6 +222,9 @@
   /// The address class for each symbol in the elf file
   FileAddressToAddressClassMap m_address_class_map;
 
+  /// A unique set of (mangled symbol name, type, address, size) tuple  
+  std::vector m_unique_symbol_set;
+
   /// Returns the index of the given section header.
   size_t SectionIndex(const SectionHeaderCollIter &I);
 
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MipsABIFlags.h"
+#include "lldb/Utility/StreamString.h"
 
 #define CASE_AND_STREAM(s, def, width) \
   case def:\
@@ -2196,7 +2197,12 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-symtab->AddSymbol(dc_symbol);
+
+if (std::find(m_unique_symbol_set.begin(), m_unique_symbol_set.end(),
+  symbol) == m_unique_symbol_set.end()) {
+  symtab->AddSymbol(dc_symbol);
+  m_unique_symbol_set.push_back(symbol);
+}
   }
   return i;
 }
@@ -2644,24 +2650,33 @@
 
 // Sharable objects and dynamic executables usually have 2 distinct symbol
 // tables, one named ".symtab", and the other ".dynsym". The dynsym is a
-// smaller version of the symtab that only contains global symbols. The
-// information found in the dynsym is therefore also found in the symtab,
-// while the reverse is not necessarily true.
+// smaller version of the symtab that only contains global symbols.
+// Information in the dynsym section is *usually* also found in the symtab,
+// but this is not required as symtab entries can be removed after linking.
+// The minidebuginfo format makes use of this facility to create smaller
+// symbol tables.
 Section *symtab =
 section_list->FindSectionByType(eSectionTypeELFSymbolTable, true).get();
-if (!symtab) {
-  // The symtab section is non-allocable and can be stripped, so if it
-  // doesn't exist then use the dynsym section which should always be
-  // there.
-  symtab =
-  section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
-  .get();
-}
 if (symtab) {
   m_symtab_up.reset(new Symtab(symtab->GetObjectFile()));
   symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, symtab);
 }
 
+// The symtab section is non-allocable and can be stripped, while the dynsym
+// section which should always be always be there. If both exist we load
+// both to support the minidebuginfo case. Otherwise we just load the dynsym
+// section.
+Section *dynsym =
+section_list->FindSectionByType(eSectionTypeELFDynamicSymbols, true)
+.get();
+if (dynsym) {
+  if (!m_symtab_up) {
+auto sec = symtab ? symtab : dynsym;
+m_symtab_up.reset(new Symtab(sec->GetObjectFile()));
+  }
+  symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, dynsym);
+}
+
 // DT_JMPREL
 //  If present, this entry's d_ptr member holds the address of
 //  relocation
Index: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
===
--- lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
+++ lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
@@ -269,6 +269,12 @@
   void Dump(lldb_private::Stream *s, uint32_t idx,
 const lldb_private::DataExtractor *strtab_data,
 const lldb_private::SectionList *section_list);
+  
+  bool operator==(const ELFSymbol

[Lldb-commits] [PATCH] D67988: [lldb] clean up lldb/scripts a little bit

2019-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a subscriber: sgraenitz.
labath added a comment.

I don't think this is fully right. We did have a separate xcode build, but it 
was removed a couple of months ago. Instead the regular cmake build supports 
building a macos-style framework (and I believe it does that regardless of 
which generator is used). So all that's needed here is to replace references to 
xcode with some blurb about "frameworks", and instead of "built by llvm" we 
should just say that we're building with a traditional unix layout. @sgraenitz  
might know more details here...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67988



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


[Lldb-commits] [PATCH] D67774: [Mangle] Add flag to asm labels to disable '\01' prefixing

2019-09-25 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor resigned from this revision.
teemperor added a comment.

This LGTM modulo rjmccall's comment.


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

https://reviews.llvm.org/D67774



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


[Lldb-commits] [PATCH] D67390: [LLDB][ELF] Load both, .symtab and .dynsym sections

2019-09-25 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h:276
+   st_size == rhs.st_size && st_other == rhs.st_other &&
+   st_shndx == rhs.st_shndx && st_value == rhs.st_value;
+  }

It could be in the same order as `ELFSymbol` fields as otherwise it is 
difficult to verify all the fields are matched here.



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:42
 #include "llvm/Support/MipsABIFlags.h"
+#include "lldb/Utility/StreamString.h"
 

Is it really needed?



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:2205
+  m_unique_symbol_set.push_back(symbol);
+}
   }

What if the symbol is ignored, the function will then incorrectly return a 
number of added symbols even when they were not added, wouldn't it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390



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


[Lldb-commits] [lldb] r372834 - [lldb][NFC] Remove unused method chaining from Read[Buffer/String]AndDumpToStreamOptions

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 02:21:00 2019
New Revision: 372834

URL: http://llvm.org/viewvc/llvm-project?rev=372834&view=rev
Log:
[lldb][NFC] Remove unused method chaining from 
Read[Buffer/String]AndDumpToStreamOptions

All this code isn't used anywhere and method chaining isn't really useful for 
some
option struct.

Modified:
lldb/trunk/include/lldb/DataFormatters/StringPrinter.h

Modified: lldb/trunk/include/lldb/DataFormatters/StringPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/StringPrinter.h?rev=372834&r1=372833&r2=372834&view=diff
==
--- lldb/trunk/include/lldb/DataFormatters/StringPrinter.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/StringPrinter.h Wed Sep 25 02:21:00 
2019
@@ -30,97 +30,55 @@ public:
 
 ReadStringAndDumpToStreamOptions(ValueObject &valobj);
 
-ReadStringAndDumpToStreamOptions &SetLocation(uint64_t l) {
-  m_location = l;
-  return *this;
-}
+void SetLocation(uint64_t l) { m_location = l; }
 
 uint64_t GetLocation() const { return m_location; }
 
-ReadStringAndDumpToStreamOptions &SetProcessSP(lldb::ProcessSP p) {
-  m_process_sp = p;
-  return *this;
-}
+void SetProcessSP(lldb::ProcessSP p) { m_process_sp = p; }
 
 lldb::ProcessSP GetProcessSP() const { return m_process_sp; }
 
-ReadStringAndDumpToStreamOptions &SetStream(Stream *s) {
-  m_stream = s;
-  return *this;
-}
+void SetStream(Stream *s) { m_stream = s; }
 
 Stream *GetStream() const { return m_stream; }
 
-ReadStringAndDumpToStreamOptions &SetPrefixToken(const std::string &p) {
-  m_prefix_token = p;
-  return *this;
-}
+void SetPrefixToken(const std::string &p) { m_prefix_token = p; }
 
-ReadStringAndDumpToStreamOptions &SetPrefixToken(std::nullptr_t) {
-  m_prefix_token.clear();
-  return *this;
-}
+void SetPrefixToken(std::nullptr_t) { m_prefix_token.clear(); }
 
 const char *GetPrefixToken() const { return m_prefix_token.c_str(); }
 
-ReadStringAndDumpToStreamOptions &SetSuffixToken(const std::string &p) {
-  m_suffix_token = p;
-  return *this;
-}
+void SetSuffixToken(const std::string &p) { m_suffix_token = p; }
 
-ReadStringAndDumpToStreamOptions &SetSuffixToken(std::nullptr_t) {
-  m_suffix_token.clear();
-  return *this;
-}
+void SetSuffixToken(std::nullptr_t) { m_suffix_token.clear(); }
 
 const char *GetSuffixToken() const { return m_suffix_token.c_str(); }
 
-ReadStringAndDumpToStreamOptions &SetQuote(char q) {
-  m_quote = q;
-  return *this;
-}
+void SetQuote(char q) { m_quote = q; }
 
 char GetQuote() const { return m_quote; }
 
-ReadStringAndDumpToStreamOptions &SetSourceSize(uint32_t s) {
-  m_source_size = s;
-  return *this;
-}
+void SetSourceSize(uint32_t s) { m_source_size = s; }
 
 uint32_t GetSourceSize() const { return m_source_size; }
 
-ReadStringAndDumpToStreamOptions &SetNeedsZeroTermination(bool z) {
-  m_needs_zero_termination = z;
-  return *this;
-}
+void SetNeedsZeroTermination(bool z) { m_needs_zero_termination = z; }
 
 bool GetNeedsZeroTermination() const { return m_needs_zero_termination; }
 
-ReadStringAndDumpToStreamOptions &SetBinaryZeroIsTerminator(bool e) {
-  m_zero_is_terminator = e;
-  return *this;
-}
+void SetBinaryZeroIsTerminator(bool e) { m_zero_is_terminator = e; }
 
 bool GetBinaryZeroIsTerminator() const { return m_zero_is_terminator; }
 
-ReadStringAndDumpToStreamOptions &SetEscapeNonPrintables(bool e) {
-  m_escape_non_printables = e;
-  return *this;
-}
+void SetEscapeNonPrintables(bool e) { m_escape_non_printables = e; }
 
 bool GetEscapeNonPrintables() const { return m_escape_non_printables; }
 
-ReadStringAndDumpToStreamOptions &SetIgnoreMaxLength(bool e) {
-  m_ignore_max_length = e;
-  return *this;
-}
+void SetIgnoreMaxLength(bool e) { m_ignore_max_length = e; }
 
 bool GetIgnoreMaxLength() const { return m_ignore_max_length; }
 
-ReadStringAndDumpToStreamOptions &SetLanguage(lldb::LanguageType l) {
-  m_language_type = l;
-  return *this;
-}
+void SetLanguage(lldb::LanguageType l) { m_language_type = l; }
 
 lldb::LanguageType GetLanguage() const
 {
@@ -151,89 +109,49 @@ public:
 ReadBufferAndDumpToStreamOptions(
 const ReadStringAndDumpToStreamOptions &options);
 
-ReadBufferAndDumpToStreamOptions &SetData(DataExtractor d) {
-  m_data = d;
-  return *this;
-}
+void SetData(DataExtractor d) { m_data = d; }
 
 lldb_private::DataExtractor GetData() const { return m_data; }
 
-ReadBufferAndDumpToStreamOptions &SetStream(Stream *s) {
-  m_stream = s;
-  return *this;
-}
+void SetStream(Stream *s) { m_stream = s; }
 
 Stream *GetStre

[Lldb-commits] [PATCH] D67993: [lldb] Calculate relative path for symbol links

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

This looks fine.

There is no xcode build. If you want to test building the framework, you just 
need to set LLDB_BUILD_FRAMEWORK cmake variable. I don't know if there's any 
other var than needs setting, but we have a cache file 
(cmake/caches/Apple-lldb-Xcode.cmake), which should build things the same way 
as the apple folks are building, so you could just use that.




Comment at: lldb/scripts/Python/finishSwigPythonLLDB.py:383
 bMakeFileCalled = "-m" in vDictArgs
 eOSType = utilsOsType.determine_os_type()
 

I guess this is unused now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67993



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


[Lldb-commits] [PATCH] D68007: [lldb] Move swig call from python code to cmake

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

Yay, tons of nasty python code going down the drain. This looks fine, but 
please take it slowly when landing these patches. Waiting a day or two before 
proceeding with the next patch will make it easier to fix things up if any of 
them cause problems for some people.

In D68007#1681908 , @mgorny wrote:

> Thanks! That's a great job, and certainly saves me some trouble in pushing my 
> patch forward, though I'm kinda surprised we don't need site-packages path 
> there after all.


I guess that's because this script puts its output in a temporary location, and 
the "finish" script then copies it to the site-packages folder. I think this 
was mainly done because we were doing some post-processing of the 
swig-generated code, which we don't do any more thankfully, so it may be 
possible to have this put the code straight into the final location, but it's 
better to take things one slowly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68007



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


[Lldb-commits] [lldb] r372835 - [lldb] [cmake] Fix installing Python modules on systems using /usr/lib

2019-09-25 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Wed Sep 25 02:47:35 2019
New Revision: 372835

URL: http://llvm.org/viewvc/llvm-project?rev=372835&view=rev
Log:
[lldb] [cmake] Fix installing Python modules on systems using /usr/lib

Fix installing Python modules on systems that use /usr/lib for Python
while installing other libraries in /usr/lib64.  Rewrite CMake logic
to query correct directories from Python, similarly to how
prepare_binding_Python.py does it.  Furthermore, change the regex used
in get_relative_lib_dir.py to allow 'lib' without suffix.

I think that the code can be further improved but I'd like to take
this enterprise in smaller steps in case one of them breaks something.

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

Modified:
lldb/trunk/scripts/CMakeLists.txt
lldb/trunk/scripts/get_relative_lib_dir.py

Modified: lldb/trunk/scripts/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/CMakeLists.txt?rev=372835&r1=372834&r2=372835&view=diff
==
--- lldb/trunk/scripts/CMakeLists.txt (original)
+++ lldb/trunk/scripts/CMakeLists.txt Wed Sep 25 02:47:35 2019
@@ -42,15 +42,18 @@ add_custom_target(swig_wrapper ALL DEPEN
 )
 
 if(NOT LLDB_BUILD_FRAMEWORK)
-  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-set(swig_python_subdir site-packages)
-  else()
-set(swig_python_subdir 
python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-  endif()
-
-  set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir})
-  set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
+  execute_process(
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig, sys; 
print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
+${CMAKE_BINARY_DIR}
+OUTPUT_VARIABLE SWIG_PYTHON_DIR
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  execute_process(
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig; 
print(distutils.sysconfig.get_python_lib(True, False, ''))"
+OUTPUT_VARIABLE SWIG_INSTALL_DIR
+OUTPUT_STRIP_TRAILING_WHITESPACE)
 
   # Install the LLDB python module
-  install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})
+  install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
 endif()

Modified: lldb/trunk/scripts/get_relative_lib_dir.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/get_relative_lib_dir.py?rev=372835&r1=372834&r2=372835&view=diff
==
--- lldb/trunk/scripts/get_relative_lib_dir.py (original)
+++ lldb/trunk/scripts/get_relative_lib_dir.py Wed Sep 25 02:47:35 2019
@@ -23,7 +23,7 @@ def get_python_relative_libdir():
 # right answer always.
 arch_specific_libdir = distutils.sysconfig.get_python_lib(True, False)
 split_libdir = arch_specific_libdir.split(os.sep)
-lib_re = re.compile(r"^lib.+$")
+lib_re = re.compile(r"^lib.*$")
 
 for i in range(len(split_libdir)):
 match = lib_re.match(split_libdir[i])


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


[Lldb-commits] [PATCH] D67890: [lldb] [cmake] Fix installing Python modules on systems using /usr/lib

2019-09-25 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372835: [lldb] [cmake] Fix installing Python modules on 
systems using /usr/lib (authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67890?vs=221555&id=221696#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67890

Files:
  lldb/trunk/scripts/CMakeLists.txt
  lldb/trunk/scripts/get_relative_lib_dir.py


Index: lldb/trunk/scripts/get_relative_lib_dir.py
===
--- lldb/trunk/scripts/get_relative_lib_dir.py
+++ lldb/trunk/scripts/get_relative_lib_dir.py
@@ -23,7 +23,7 @@
 # right answer always.
 arch_specific_libdir = distutils.sysconfig.get_python_lib(True, False)
 split_libdir = arch_specific_libdir.split(os.sep)
-lib_re = re.compile(r"^lib.+$")
+lib_re = re.compile(r"^lib.*$")
 
 for i in range(len(split_libdir)):
 match = lib_re.match(split_libdir[i])
Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -42,15 +42,18 @@
 )
 
 if(NOT LLDB_BUILD_FRAMEWORK)
-  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-set(swig_python_subdir site-packages)
-  else()
-set(swig_python_subdir 
python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-  endif()
-
-  set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir})
-  set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
+  execute_process(
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig, sys; 
print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
+${CMAKE_BINARY_DIR}
+OUTPUT_VARIABLE SWIG_PYTHON_DIR
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  execute_process(
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig; 
print(distutils.sysconfig.get_python_lib(True, False, ''))"
+OUTPUT_VARIABLE SWIG_INSTALL_DIR
+OUTPUT_STRIP_TRAILING_WHITESPACE)
 
   # Install the LLDB python module
-  install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})
+  install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
 endif()


Index: lldb/trunk/scripts/get_relative_lib_dir.py
===
--- lldb/trunk/scripts/get_relative_lib_dir.py
+++ lldb/trunk/scripts/get_relative_lib_dir.py
@@ -23,7 +23,7 @@
 # right answer always.
 arch_specific_libdir = distutils.sysconfig.get_python_lib(True, False)
 split_libdir = arch_specific_libdir.split(os.sep)
-lib_re = re.compile(r"^lib.+$")
+lib_re = re.compile(r"^lib.*$")
 
 for i in range(len(split_libdir)):
 match = lib_re.match(split_libdir[i])
Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -42,15 +42,18 @@
 )
 
 if(NOT LLDB_BUILD_FRAMEWORK)
-  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-set(swig_python_subdir site-packages)
-  else()
-set(swig_python_subdir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-  endif()
-
-  set(SWIG_PYTHON_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${swig_python_subdir})
-  set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
+  execute_process(
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig, sys; print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
+${CMAKE_BINARY_DIR}
+OUTPUT_VARIABLE SWIG_PYTHON_DIR
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  execute_process(
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
+OUTPUT_VARIABLE SWIG_INSTALL_DIR
+OUTPUT_STRIP_TRAILING_WHITESPACE)
 
   # Install the LLDB python module
-  install(DIRECTORY ${SWIG_PYTHON_DIR} DESTINATION ${SWIG_INSTALL_DIR})
+  install(DIRECTORY ${SWIG_PYTHON_DIR}/ DESTINATION ${SWIG_INSTALL_DIR})
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r372836 - [lldb][NFC] Refactor and document *DumpToStreamOptions

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 02:56:23 2019
New Revision: 372836

URL: http://llvm.org/viewvc/llvm-project?rev=372836&view=rev
Log:
[lldb][NFC] Refactor and document *DumpToStreamOptions

Those two classes were mostly copy-pasted.

Modified:
lldb/trunk/include/lldb/DataFormatters/StringPrinter.h

Modified: lldb/trunk/include/lldb/DataFormatters/StringPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/StringPrinter.h?rev=372836&r1=372835&r2=372836&view=diff
==
--- lldb/trunk/include/lldb/DataFormatters/StringPrinter.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/StringPrinter.h Wed Sep 25 02:56:23 
2019
@@ -24,19 +24,9 @@ public:
 
   enum class GetPrintableElementType { ASCII, UTF8 };
 
-  class ReadStringAndDumpToStreamOptions {
+  class DumpToStreamOptions {
   public:
-ReadStringAndDumpToStreamOptions() = default;
-
-ReadStringAndDumpToStreamOptions(ValueObject &valobj);
-
-void SetLocation(uint64_t l) { m_location = l; }
-
-uint64_t GetLocation() const { return m_location; }
-
-void SetProcessSP(lldb::ProcessSP p) { m_process_sp = p; }
-
-lldb::ProcessSP GetProcessSP() const { return m_process_sp; }
+DumpToStreamOptions() = default;
 
 void SetStream(Stream *s) { m_stream = s; }
 
@@ -80,90 +70,75 @@ public:
 
 void SetLanguage(lldb::LanguageType l) { m_language_type = l; }
 
-lldb::LanguageType GetLanguage() const
-{
-  return m_language_type;
-}
+lldb::LanguageType GetLanguage() const { return m_language_type; }
 
   private:
-uint64_t m_location = 0;
-lldb::ProcessSP m_process_sp;
+/// The used output stream.
 Stream *m_stream = nullptr;
+/// String that should be printed before the heading quote character.
 std::string m_prefix_token;
+/// String that should be printed after the trailing quote character.
 std::string m_suffix_token;
+/// The quote character that should surround the string.
 char m_quote = '"';
+/// The length of the memory region that should be dumped in bytes.
 uint32_t m_source_size = 0;
 bool m_needs_zero_termination = true;
+/// True iff non-printable characters should be escaped when dumping
+/// them to the stream.
 bool m_escape_non_printables = true;
+/// True iff the max-string-summary-length setting of the target should
+/// be ignored.
 bool m_ignore_max_length = false;
+/// True iff a zero bytes ('\0') should terminate the memory region that
+/// is being dumped.
 bool m_zero_is_terminator = true;
+/// The language that the generated string literal is supposed to be valid
+/// for. This changes for example what and how certain characters are
+/// escaped.
+/// For example, printing the a string containing only a quote (") char
+/// with eLanguageTypeC would escape the quote character.
 lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
   };
 
-  class ReadBufferAndDumpToStreamOptions {
+  class ReadStringAndDumpToStreamOptions : public DumpToStreamOptions {
   public:
-ReadBufferAndDumpToStreamOptions() = default;
-
-ReadBufferAndDumpToStreamOptions(ValueObject &valobj);
-
-ReadBufferAndDumpToStreamOptions(
-const ReadStringAndDumpToStreamOptions &options);
-
-void SetData(DataExtractor d) { m_data = d; }
-
-lldb_private::DataExtractor GetData() const { return m_data; }
-
-void SetStream(Stream *s) { m_stream = s; }
-
-Stream *GetStream() const { return m_stream; }
-
-void SetPrefixToken(const std::string &p) { m_prefix_token = p; }
-
-void SetPrefixToken(std::nullptr_t) { m_prefix_token.clear(); }
-
-const char *GetPrefixToken() const { return m_prefix_token.c_str(); }
+ReadStringAndDumpToStreamOptions() = default;
 
-void SetSuffixToken(const std::string &p) { m_suffix_token = p; }
+ReadStringAndDumpToStreamOptions(ValueObject &valobj);
 
-void SetSuffixToken(std::nullptr_t) { m_suffix_token.clear(); }
+void SetLocation(uint64_t l) { m_location = l; }
 
-const char *GetSuffixToken() const { return m_suffix_token.c_str(); }
+uint64_t GetLocation() const { return m_location; }
 
-void SetQuote(char q) { m_quote = q; }
+void SetProcessSP(lldb::ProcessSP p) { m_process_sp = p; }
 
-char GetQuote() const { return m_quote; }
+lldb::ProcessSP GetProcessSP() const { return m_process_sp; }
 
-void SetSourceSize(uint32_t s) { m_source_size = s; }
+  private:
+uint64_t m_location = 0;
+lldb::ProcessSP m_process_sp;
+  };
 
-uint32_t GetSourceSize() const { return m_source_size; }
+  class ReadBufferAndDumpToStreamOptions : public DumpToStreamOptions {
+  public:
+ReadBufferAndDumpToStreamOptions() = default;
 
-void SetEscapeNonPrintables(bool e) { m_escape_non_printables = e; }
+ReadBufferAndDumpToStreamOptions(ValueObject &valobj);
 
-bool GetE

[Lldb-commits] [lldb] r372837 - [lldb] Test data formatters for empty strings

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 03:07:23 2019
New Revision: 372837

URL: http://llvm.org/viewvc/llvm-project?rev=372837&view=rev
Log:
[lldb] Test data formatters for empty strings

Modified:

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

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py?rev=372837&r1=372836&r2=372837&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 Wed Sep 25 03:07:23 2019
@@ -59,16 +59,23 @@ class LibcxxStringDataFormatterTestCase(
 self.expect(
 "frame variable",
 substrs=[
+'(%s::wstring) wempty = L""'%ns,
 '(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
 '(%s::wstring) S = L""'%ns,
 '(const wchar_t *) mazeltov = 0x',
 'L"מזל טוב"',
+'(%s::string) empty = ""'%ns,
 '(%s::string) q = "hello world"'%ns,
 '(%s::string) Q = "quite a long std::strin with lots of info 
inside it"'%ns,
 '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
 '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ 
ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns,
 '(%s::u16string) u16_string = u"ß水氶"'%ns,
-'(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns])
+# FIXME: This should have a 'u' prefix.
+'(%s::u16string) u16_empty = ""'%ns,
+'(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns,
+# FIXME: This should have a 'U' prefix.
+'(%s::u32string) u32_empty = ""'%ns
+])
 
 self.runCmd("n")
 

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp?rev=372837&r1=372836&r2=372837&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
 Wed Sep 25 03:07:23 2019
@@ -2,16 +2,20 @@
 
 int main()
 {
+std::wstring wempty(L"");
 std::wstring s(L"hello world! מזל טוב!");
 std::wstring S(L"");
 const wchar_t *mazeltov = L"מזל טוב";
+std::string empty("");
 std::string q("hello world");
 std::string Q("quite a long std::strin with lots of info inside it");
 std::string 
TheVeryLongOne("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456

[Lldb-commits] [lldb] r372840 - [lldb] [test] Add NetBSD to XFAIL list for thread_local test

2019-09-25 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Wed Sep 25 03:18:38 2019
New Revision: 372840

URL: http://llvm.org/viewvc/llvm-project?rev=372840&view=rev
Log:
[lldb] [test] Add NetBSD to XFAIL list for thread_local test

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py?rev=372840&r1=372839&r2=372840&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/thread_local/TestThreadLocal.py
 Wed Sep 25 03:18:38 2019
@@ -2,4 +2,5 @@ from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
 lldbinline.MakeInlineTest(__file__, globals(),
-  lldbinline.expectedFailureAll(oslist=["windows", 
"linux"]))
+  lldbinline.expectedFailureAll(oslist=[
+  "windows", "linux", "netbsd"]))


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


[Lldb-commits] [PATCH] D68010: [lldb] Fix string summary of an empty NSPathStore2

2019-09-25 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 221702.
teemperor edited the summary of this revision.
teemperor added a comment.

- Land the NFC test additions to other string classes as separate NFC commits.
- Rebase on the already landed refactoring.


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

https://reviews.llvm.org/D68010

Files:
  lldb/include/lldb/DataFormatters/StringPrinter.h
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
  
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp

Index: lldb/source/Plugins/Language/ObjC/NSString.cpp
===
--- lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -171,6 +171,7 @@
   options.SetStream(&stream);
   options.SetQuote('"');
   options.SetSourceSize(explicit_length);
+  options.SetHasSourceSize(has_explicit_length);
   options.SetNeedsZeroTermination(false);
   options.SetIgnoreMaxLength(summary_options.GetCapping() ==
  TypeSummaryCapping::eTypeSummaryUncapped);
@@ -183,6 +184,7 @@
   options.SetProcessSP(process_sp);
   options.SetStream(&stream);
   options.SetSourceSize(explicit_length);
+  options.SetHasSourceSize(has_explicit_length);
   options.SetNeedsZeroTermination(false);
   options.SetIgnoreMaxLength(summary_options.GetCapping() ==
  TypeSummaryCapping::eTypeSummaryUncapped);
@@ -200,6 +202,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
 options.SetLanguage(summary_options.GetLanguage());
@@ -222,6 +225,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -242,6 +246,7 @@
 options.SetStream(&stream);
 options.SetQuote('"');
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -264,6 +269,7 @@
 options.SetProcessSP(process_sp);
 options.SetStream(&stream);
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetNeedsZeroTermination(!has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@@ -287,6 +293,7 @@
 options.SetProcessSP(process_sp);
 options.SetStream(&stream);
 options.SetSourceSize(explicit_length);
+options.SetHasSourceSize(has_explicit_length);
 options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
 options.SetLanguage(summary_options.GetLanguage());
Index: lldb/source/DataFormatters/StringPrinter.cpp
===
--- lldb/source/DataFormatters/StringPrinter.cpp
+++ lldb/source/DataFormatters/StringPrinter.cpp
@@ -543,7 +543,7 @@
   bool is_truncated = false;
   const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
 
-  if (!sourceSize) {
+  if (!options.GetHasSourceSize()) {
 sourceSize = max_size;
 needs_zero_terminator = true;
   } else if (!options.GetIgnoreMaxLength()) {
@@ -557,7 +557,10 @@
 
   lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize, 0));
 
-  if (!buffer_sp->GetBytes())
+  // Check if we got bytes. We never get any bytes if we have an empty
+  // string, but we still continue so that we end up actually printing
+  // an empty string ("").
+  if (!buffer_sp->GetBytes() && sourceSize != 0)
 return false;
 
   Status error;
Index: lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
===
--- lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
+++ lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
@@ -24,7 +24,7 @@
 {
 
 NSAutoreleasePool * pool = [[NSAutoreleaseP

[Lldb-commits] [lldb] r372847 - Revert r372788 "Host: use the platform identifiers from LLVM (NFC)"

2019-09-25 Thread Hans Wennborg via lldb-commits
Author: hans
Date: Wed Sep 25 04:55:16 2019
New Revision: 372847

URL: http://llvm.org/viewvc/llvm-project?rev=372847&view=rev
Log:
Revert r372788 "Host: use the platform identifiers from LLVM (NFC)"

> Use symbolic constants for the platform identifiers rather than replicating 
> them
> locally.

This broke the build of LLDB on Windows, see
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9182 which
fails with e.g.

  
E:\build_slave\lldb-x64-windows-ninja\llvm\include\llvm/BinaryFormat/COFF.h(96):
 error C2059: syntax error: 'constant'
  
E:\build_slave\lldb-x64-windows-ninja\llvm\include\llvm/BinaryFormat/COFF.h(96):
 error C3805: 'constant': unexpected token, expected either '}' or a ','
  
E:\build_slave\lldb-x64-windows-ninja\llvm\include\llvm/BinaryFormat/COFF.h(128):
 error C2059: syntax error: 'constant'
  ...

Modified:
lldb/trunk/source/Host/windows/Host.cpp

Modified: lldb/trunk/source/Host/windows/Host.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=372847&r1=372846&r2=372847&view=diff
==
--- lldb/trunk/source/Host/windows/Host.cpp (original)
+++ lldb/trunk/source/Host/windows/Host.cpp Wed Sep 25 04:55:16 2019
@@ -22,7 +22,6 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/StructuredData.h"
 
-#include "llvm/BinaryFormat/COFF.h"
 #include "llvm/Support/ConvertUTF.h"
 
 // Windows includes
@@ -53,13 +52,13 @@ bool GetTripleForProcess(const FileSpec
   triple.setVendor(llvm::Triple::PC);
   triple.setOS(llvm::Triple::Win32);
   triple.setArch(llvm::Triple::UnknownArch);
-  if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
+  if (machineType == 0x8664)
 triple.setArch(llvm::Triple::x86_64);
-  else if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_I386)
+  else if (machineType == 0x14c)
 triple.setArch(llvm::Triple::x86);
-  else if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_ARMNT)
+  else if (machineType == 0x1c4)
 triple.setArch(llvm::Triple::arm);
-  else if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_ARM64)
+  else if (machineType == 0xaa64)
 triple.setArch(llvm::Triple::aarch64);
 
   return true;


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


Re: [Lldb-commits] [lldb] r372788 - Host: use the platform identifiers from LLVM (NFC)

2019-09-25 Thread Hans Wennborg via lldb-commits
This seems to have broken the build:
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9182

I've reverted in r372847.

On Wed, Sep 25, 2019 at 12:53 AM Saleem Abdulrasool via lldb-commits
 wrote:
>
> Author: compnerd
> Date: Tue Sep 24 15:55:44 2019
> New Revision: 372788
>
> URL: http://llvm.org/viewvc/llvm-project?rev=372788&view=rev
> Log:
> Host: use the platform identifiers from LLVM (NFC)
>
> Use symbolic constants for the platform identifiers rather than replicating 
> them
> locally.
>
> Modified:
> lldb/trunk/source/Host/windows/Host.cpp
>
> Modified: lldb/trunk/source/Host/windows/Host.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=372788&r1=372787&r2=372788&view=diff
> ==
> --- lldb/trunk/source/Host/windows/Host.cpp (original)
> +++ lldb/trunk/source/Host/windows/Host.cpp Tue Sep 24 15:55:44 2019
> @@ -22,6 +22,7 @@
>  #include "lldb/Utility/StreamString.h"
>  #include "lldb/Utility/StructuredData.h"
>
> +#include "llvm/BinaryFormat/COFF.h"
>  #include "llvm/Support/ConvertUTF.h"
>
>  // Windows includes
> @@ -52,13 +53,13 @@ bool GetTripleForProcess(const FileSpec
>triple.setVendor(llvm::Triple::PC);
>triple.setOS(llvm::Triple::Win32);
>triple.setArch(llvm::Triple::UnknownArch);
> -  if (machineType == 0x8664)
> +  if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
>  triple.setArch(llvm::Triple::x86_64);
> -  else if (machineType == 0x14c)
> +  else if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_I386)
>  triple.setArch(llvm::Triple::x86);
> -  else if (machineType == 0x1c4)
> +  else if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_ARMNT)
>  triple.setArch(llvm::Triple::arm);
> -  else if (machineType == 0xaa64)
> +  else if (machineType == llvm::COFF::IMAGE_FILE_MACHINE_ARM64)
>  triple.setArch(llvm::Triple::aarch64);
>
>return true;
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r372851 - [lldb][NFC] Remove useless cursor shifting in Options::HandleOptionCompletion

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 05:04:48 2019
New Revision: 372851

URL: http://llvm.org/viewvc/llvm-project?rev=372851&view=rev
Log:
[lldb][NFC] Remove useless cursor shifting in Options::HandleOptionCompletion

The cursor position is always at the end of the current argument (as the
argument cut off after the cursor position). So this code is a no-op and
can be removed.

Modified:
lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=372851&r1=372850&r2=372851&view=diff
==
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Wed Sep 25 05:04:48 2019
@@ -720,11 +720,8 @@ bool Options::HandleOptionCompletion(Com
 } else if (opt_arg_pos == request.GetCursorIndex()) {
   // Okay the cursor is on the completion of an argument. See if it has a
   // completion, otherwise return no matches.
-
-  CompletionRequest subrequest = request;
-  subrequest.SetCursorCharPosition(subrequest.GetCursorArgument().size());
   if (opt_defs_index != -1) {
-HandleOptionArgumentCompletion(subrequest, opt_element_vector, i,
+HandleOptionArgumentCompletion(request, opt_element_vector, i,
interpreter);
 return true;
   } else {


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


[Lldb-commits] [PATCH] D67996: Convert FileSystem::Open() to return Expected

2019-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added a comment.

Thanks for splitting this up. Despite the number of comments, I think this is 
looking pretty good. The main theme of the comments is making sure that we 
satisfy the contract of the Expected class, which is a bit... unexpected. This 
is something that every new contributor gets burned by so don't worry about 
that. I've tried to annotate each place and suggest the possible way to handle 
it.

Additionally, I think it would be good to remove the ability to swap the file 
from underneath the stream if it is not too difficult.




Comment at: lldb/include/lldb/Core/StreamFile.h:48-53
+  void SetFile(std::shared_ptr file) {
+if (file)
+  m_file_sp = file;
+else
+  m_file_sp = std::make_shared();
+  }

Could we remove this method? It would make things easier to reason about if we 
could disallow swapping of a File object backing a stream midway through its 
lifetime. Looking at the existing callers, it does not seem it should be hard 
to do that -- this is always called immediately after a stream is constructed 
via patterns like:
```
auto *stream = new StreamFile();
auto file = create_a_file();
if (file.is_ok()) {
  stream->SetFile(file);
  use(stream);
}
```
It should be easy to change that so that the stream is constructed only after 
we have a valid File object. It would also avoid the need to construct a fake 
File object just to guarantee it is always initialized.



Comment at: lldb/source/API/SBStream.cpp:93
+  FileSystem::Instance().Open(FileSpec(path), open_options);
+  if (file) {
+StreamFile *newStream = new StreamFile(std::move(file.get()));

This is the trickiest thing about the Expected class. The idea behind it is it 
forces you to do something with the error. This means that this code would 
trigger an assertion if the opening of the file ever fails, as you don't 
"handle" the error in any way.
Unfortunately, here there is nothing we can do with the error (this is probably 
a deficiency of this API, but that's also another thing we can't change here), 
so we need to either explicitly throw it away (`else 
consumeError(file.takeError())`), or log it `else 
LLDB_LOG_ERROR(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), file.takeError(), 
"Cannot open {1}: {0}", path)`



Comment at: lldb/source/API/SBStream.cpp:120
   }
-  m_opaque_up.reset(new StreamFile(fh, transfer_fh_ownership));
+  StreamFile *newStream = new StreamFile(fh, transfer_fh_ownership);
 

why not assign this to the `m_opaque_up` (and avoid having an unowned pointer 
floating around)?



Comment at: lldb/source/API/SBStream.cpp:143
 
-  m_opaque_up.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership));
-  if (m_opaque_up) {
-m_is_file = true;
+  StreamFile *newStream = new StreamFile(fd, transfer_fh_ownership);
 

same here.



Comment at: lldb/source/Commands/CommandObjectMemory.cpp:807-808
   } else {
 result.AppendErrorWithFormat("Failed to open file '%s' for %s.\n",
  path.c_str(), append ? "append" : 
"write");
 result.SetStatus(eReturnStatusFailed);

Include the error message here, which will also set the "checked" flag inside 
the expected object.



Comment at: lldb/source/Core/StreamFile.cpp:40
+m_file_sp = std::move(file.get());
+  else
+m_file_sp = std::make_shared();

We'll need to ignore/log the error here. Maybe leave a TODO to refactor this so 
that the caller is able to know whether the file was successfully created or 
not.



Comment at: lldb/source/Core/StreamFile.cpp:49
+m_file_sp = std::move(file.get());
+  else
+m_file_sp = std::make_shared();

same here.



Comment at: lldb/source/Expression/REPL.cpp:412
+  file.get()->Close();
+}
 

I guess the error can be written to `error_sp` here.



Comment at: lldb/source/Host/common/FileCache.cpp:33
+  auto file = FileSystem::Instance().Open(file_spec, flags, mode);
+  if (!file)
 return UINT64_MAX;

add: `error = std::move(file.takeError());`



Comment at: lldb/source/Host/windows/Host.cpp:40
+  if (!imageBinaryP)
+return false;
+  File &imageBinary = *imageBinaryP.get();

`return errorToBool(imageBinaryUP.takeError())`



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2326-2329
+std::string error = llvm::toString(file.takeError());
 result.AppendErrorWithFormat(
 "error: an error occurred read file '%s': %s\n", cmd_file_path.c_str(),
+error.c_str());

You could change this into something like 
`result.AppendErrorWithFormatv("error: an error occurred read file '{0}': 
{1}\n", cmd_file

[Lldb-commits] [PATCH] D67891: remove File::SetStream(), make new files instead.

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

Thanks for splitting these up. It makes it much more obvious what is going on.

I see now that you're making use of this SetFile method which I wanted to 
remove in the previous patch. I kind of like that, because it pushes the `Set` 
one level up (so it now happens on the Stream instead of the File), but I do 
wonder if we shouldn't remove it completely. It seems like we could have 
Debugger::SetXXXFileHandle just create a fresh stream instead of twiddling with 
the existing one. This has the potential to change behavior as this change will 
not propagate to anybody who has fetched the stream_sp previously. However, I'm 
not sure if this is a change we care about because if anybody was writing to a 
stream while we were in the process of changing it, then he would likely 
trigger a race condition anyway. This way, we risk some code not immediately 
noticing the stream change, but at least we're thread safe. @jingham, what do 
you think about that?

Other than that, I am pretty happy with how this looks, and I think you've 
convinced me that the shared pointer inside the StreamFile object is really 
needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67891



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


[Lldb-commits] [PATCH] D67793: new api class: SBFile

2019-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/API/SBFile.cpp:20-26
+void SBFile::SetStream(FILE *file, bool transfer_ownership) {
+m_opaque_up = std::make_unique(file, transfer_ownership);
+}
+
+void SBFile::SetDescriptor(int fd, bool transfer_owndership) {
+m_opaque_up = std::make_unique(fd, transfer_owndership);
+}

lawrence_danna wrote:
> labath wrote:
> > I think it would be better if these were constructors instead of member 
> > functions. That way you might be able to get rid of the all the `if 
> > (!m_opaque_up) {` checks as the File member will always be initialized.
> Unfortunately, SWIG does not allow return types that don't have default 
> constructors.
> 
> https://github.com/swig/swig/issues/1062
Hmm.. that is unfortunate. I guess that means we still need the validity 
checks, but you should still be able to replace these with constructors, right? 
(you've guessed by now that I am not a fan of `Set` methods :) ).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67793



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


[Lldb-commits] [lldb] r372858 - [lldb][NFC] Add CompletionRequest::AppendEmptyArgument

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 05:40:01 2019
New Revision: 372858

URL: http://llvm.org/viewvc/llvm-project?rev=372858&view=rev
Log:
[lldb][NFC] Add CompletionRequest::AppendEmptyArgument

This is the only legitimate use we currently have for modifying
a CompletionRequest. Add a utility function for this purpose
and remove the remaining setters which go against the idea of
having an immutable CompletionRequest.

Modified:
lldb/trunk/include/lldb/Utility/CompletionRequest.h
lldb/trunk/source/Commands/CommandObjectMultiword.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
lldb/trunk/unittests/Utility/CompletionRequestTest.cpp

Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CompletionRequest.h?rev=372858&r1=372857&r2=372858&view=diff
==
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h (original)
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h Wed Sep 25 05:40:01 2019
@@ -123,11 +123,15 @@ public:
 m_parsed_line.Shift();
   }
 
-  void SetCursorIndex(size_t i) { m_cursor_index = i; }
-  size_t GetCursorIndex() const { return m_cursor_index; }
+  /// Adds an empty argument at the end of the argument list and moves
+  /// the cursor to this new argument.
+  void AppendEmptyArgument() {
+m_parsed_line.AppendArgument(llvm::StringRef());
+m_cursor_index++;
+m_cursor_char_position = 0;
+  }
 
-  void SetCursorCharPosition(size_t pos) { m_cursor_char_position = pos; }
-  size_t GetCursorCharPosition() const { return m_cursor_char_position; }
+  size_t GetCursorIndex() const { return m_cursor_index; }
 
   /// Adds a possible completion string. If the completion was already
   /// suggested before, it will not be added to the list of results. A copy of
@@ -193,7 +197,7 @@ public:
   }
 
   llvm::StringRef GetCursorArgumentPrefix() const {
-return GetCursorArgument().substr(0, GetCursorCharPosition());
+return GetCursorArgument().substr(0, m_cursor_char_position);
   }
 
 private:

Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=372858&r1=372857&r2=372858&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Wed Sep 25 05:40:01 
2019
@@ -195,8 +195,7 @@ void CommandObjectMultiword::HandleCompl
   if (cmd_obj != nullptr) {
 if (request.GetParsedLine().GetArgumentCount() != 1) {
   request.GetParsedLine().Shift();
-  request.SetCursorCharPosition(0);
-  request.GetParsedLine().AppendArgument(llvm::StringRef());
+  request.AppendEmptyArgument();
   cmd_obj->HandleCompletion(request);
 }
   }

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=372858&r1=372857&r2=372858&view=diff
==
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed Sep 25 05:40:01 
2019
@@ -1779,9 +1779,7 @@ void CommandInterpreter::HandleCompletio
 look_for_subcommand = true;
 new_matches.DeleteStringAtIndex(0);
 new_descriptions.DeleteStringAtIndex(0);
-request.GetParsedLine().AppendArgument(llvm::StringRef());
-request.SetCursorIndex(request.GetCursorIndex() + 1U);
-request.SetCursorCharPosition(0);
+request.AppendEmptyArgument();
   }
 }
 request.AddCompletions(new_matches, new_descriptions);

Modified: lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CompletionRequestTest.cpp?rev=372858&r1=372857&r2=372858&view=diff
==
--- lldb/trunk/unittests/Utility/CompletionRequestTest.cpp (original)
+++ lldb/trunk/unittests/Utility/CompletionRequestTest.cpp Wed Sep 25 05:40:01 
2019
@@ -15,7 +15,6 @@ TEST(CompletionRequest, Constructor) {
   std::string command = "a bad c";
   const unsigned cursor_pos = 3;
   const size_t arg_index = 1;
-  const size_t arg_cursor_pos = 1;
   StringList matches;
   CompletionResult result;
 
@@ -25,10 +24,9 @@ TEST(CompletionRequest, Constructor) {
   EXPECT_STREQ(request.GetRawLine().str().c_str(), command.c_str());
   EXPECT_EQ(request.GetRawCursorPos(), cursor_pos);
   EXPECT_EQ(request.GetCursorIndex(), arg_index);
-  EXPECT_EQ(request.GetCursorCharPosition(), arg_cursor_pos);
 
   EXPECT_EQ(request.GetParsedLine().GetArgumentCount(), 2u);
-  EXPECT_STREQ(request.GetParsedLine().GetArg

[Lldb-commits] [PATCH] D67965: Have ABI plugins vend llvm MCRegisterInfo data

2019-09-25 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 3 inline comments as done.
labath added inline comments.



Comment at: include/lldb/Target/ABI.h:141
 protected:
-  // Classes that inherit from ABI can see and modify these
-  ABI(lldb::ProcessSP process_sp) {
-if (process_sp.get())
-m_process_wp = process_sp;
+  ABI(lldb::ProcessSP process_sp, std::unique_ptr 
info_up)
+  : m_process_wp(process_sp), m_mc_register_info_up(std::move(info_up)) {

tatyana-krasnukha wrote:
> Since this and derived class's constructors are protected/private it can make 
> sense to make their parameters r-value and not rely on copy elision.
Technically, this is not copy elision, since std::move supresses that. :)
But anyway, I generally try to avoid overusing rvalue references as they tend 
to make one wonder whether there is something funny going on (and in particular 
with std::unique_ptr, a rvalue reference can have subtly different behavior 
than a plain object). I also believe the advice given (by some experts at 
least) since c++11 is to prefer plain objects where that makes sense.


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

https://reviews.llvm.org/D67965



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


[Lldb-commits] [lldb] r372861 - [lldb][NFC] Remove CompletionRequest::GetCursorArgument and GetRawLineUntilCursor

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 05:55:30 2019
New Revision: 372861

URL: http://llvm.org/viewvc/llvm-project?rev=372861&view=rev
Log:
[lldb][NFC] Remove CompletionRequest::GetCursorArgument and 
GetRawLineUntilCursor

They both return the same result as another function (GetCursorArgumentPrefix
and GetRawLine). They were only added because the old API allowed to look
(in theory) behind the cursor position which is no longer possible.

Modified:
lldb/trunk/include/lldb/Utility/CompletionRequest.h
lldb/trunk/source/Expression/REPL.cpp
lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CompletionRequest.h?rev=372861&r1=372860&r2=372861&view=diff
==
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h (original)
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h Wed Sep 25 05:55:30 2019
@@ -103,9 +103,6 @@ public:
 CompletionResult &result);
 
   llvm::StringRef GetRawLine() const { return m_command; }
-  llvm::StringRef GetRawLineUntilCursor() const {
-return m_command.substr(0, m_cursor_index);
-  }
 
   unsigned GetRawCursorPos() const { return m_raw_cursor_pos; }
 
@@ -192,12 +189,8 @@ public:
 descriptions.GetStringAtIndex(i));
   }
 
-  llvm::StringRef GetCursorArgument() const {
-return GetParsedLine().GetArgumentAtIndex(GetCursorIndex());
-  }
-
   llvm::StringRef GetCursorArgumentPrefix() const {
-return GetCursorArgument().substr(0, m_cursor_char_position);
+return GetParsedLine().GetArgumentAtIndex(GetCursorIndex());
   }
 
 private:

Modified: lldb/trunk/source/Expression/REPL.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/REPL.cpp?rev=372861&r1=372860&r2=372861&view=diff
==
--- lldb/trunk/source/Expression/REPL.cpp (original)
+++ lldb/trunk/source/Expression/REPL.cpp Wed Sep 25 05:55:30 2019
@@ -453,7 +453,7 @@ void REPL::IOHandlerComplete(IOHandler &
   }
 
   // Strip spaces from the line and see if we had only spaces
-  if (request.GetRawLineUntilCursor().trim().empty()) {
+  if (request.GetRawLine().trim().empty()) {
 // Only spaces on this line, so just indent
 request.AddCompletion(m_indent_str);
 return;
@@ -479,7 +479,7 @@ void REPL::IOHandlerComplete(IOHandler &
   }
 
   current_code.append("\n");
-  current_code += request.GetRawLineUntilCursor();
+  current_code += request.GetRawLine();
 
   StringList matches;
   int result = CompleteCode(current_code, matches);

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=372861&r1=372860&r2=372861&view=diff
==
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Wed Sep 25 05:55:30 2019
@@ -698,7 +698,7 @@ bool Options::HandleOptionCompletion(Com
   request.AddCompletion("--" + long_option.str(), opt.usage_text);
   return true;
 } else
-  request.AddCompletion(request.GetCursorArgument());
+  request.AddCompletion(request.GetCursorArgumentPrefix());
 return true;
   } else {
 // FIXME - not handling wrong options yet:


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


[Lldb-commits] [lldb] r372862 - Have ABI plugins vend llvm MCRegisterInfo data

2019-09-25 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Sep 25 06:03:04 2019
New Revision: 372862

URL: http://llvm.org/viewvc/llvm-project?rev=372862&view=rev
Log:
Have ABI plugins vend llvm MCRegisterInfo data

Summary:
I was recently surprised to learn that there is a total of 2 (two) users
of the register info definitions contained in the ABI plugins. Yet, the
defitions themselves span nearly 10kLOC.
The two users are:
 - dwarf expression pretty printer
 - the mechanism for augmenting the register info definitions obtained
   over gdb-remote protocol (AugmentRegisterInfoViaABI)

Both of these uses need the DWARF an EH register numbers, which is
information that is already available in LLVM. This patch makes it
possible to do so.

It adds a GetMCRegisterInfo method to the ABI class, which every class
is expected to implement. Normally, it should be sufficient to obtain
the definitions from the appropriate llvm::Target object (for which I
provide a utility function), but the subclasses are free to construct it
in any way they deem fit.

We should be able to always get the MCRegisterInfo object from llvm,
with one important exception: if the relevant llvm target was disabled
at compile time. To handle this, I add a mechanism to disable the
compilation of ABI plugins based on the value of LLVM_TARGETS_TO_BUILD
cmake setting. This ensures all our existing are able to create their
MCRegisterInfo objects.

The new MCRegisterInfo api is not used yet, but the intention is to make
use of it in follow-up patches.

Reviewers: jasonmolenda, aprantl, JDevlieghere, tatyana-krasnukha

Subscribers: wuzish, nemanjai, mgorny, kbarton, atanasyan, lldb-commits

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

Modified:
lldb/trunk/include/lldb/Target/ABI.h
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/ABI/CMakeLists.txt
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
lldb/trunk/source/Target/ABI.cpp
lldb/trunk/tools/lldb-test/CMakeLists.txt
lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp

Modified: lldb/trunk/include/lldb/Target/ABI.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=372862&r1=372861&r2=372862&view=diff
==
--- lldb/trunk/include/lldb/Target/ABI.h (original)
+++ lldb/trunk/include/lldb/Target/ABI.h Wed Sep 25 06:03:04 2019
@@ -15,8 +15,8 @@
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/MC/MCRegisterInfo.h"
 
-// forward define the llvm::Type class
 namespace llvm {
 class Type;
 }
@@ -124,6 +124,8 @@ public:
 return pc;
   }
 
+  llvm::MCRegisterInfo &GetMCRegisterInfo() { return *m_mc_register_info_up; }
+
   virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
 
   bool GetRegisterInfoByName(ConstString name, RegisterInfo &info);
@@ -136,13 +138,19 @@ public:
   static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec 
&arch);
 
 protected:
-  // Classes that inherit from ABI can see and modify these
-  ABI(lldb::ProcessSP process_sp) {
-if (process_sp.get())
-m_process_wp = process_sp;
+  ABI(lldb::ProcessSP process_sp, std::unique_ptr 
info_up)
+  : m_process_wp

[Lldb-commits] [PATCH] D67965: Have ABI plugins vend llvm MCRegisterInfo data

2019-09-25 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rL372862: Have ABI plugins vend llvm MCRegisterInfo data 
(authored by labath, committed by ).
Herald added subscribers: llvm-commits, jrtc27.
Herald added a project: LLVM.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67965

Files:
  lldb/trunk/include/lldb/Target/ABI.h
  lldb/trunk/source/API/CMakeLists.txt
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Plugins/ABI/CMakeLists.txt
  lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
  lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
  lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
  lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
  lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
  lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
  lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
  lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
  lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
  lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
  lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
  lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
  lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
  lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
  lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
  lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
  lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
  lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
  lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
  lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
  lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
  lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
  lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
  lldb/trunk/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
  lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
  lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/trunk/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/trunk/source/Target/ABI.cpp
  lldb/trunk/tools/lldb-test/CMakeLists.txt
  lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp

Index: lldb/trunk/include/lldb/Target/ABI.h
===
--- lldb/trunk/include/lldb/Target/ABI.h
+++ lldb/trunk/include/lldb/Target/ABI.h
@@ -15,8 +15,8 @@
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/MC/MCRegisterInfo.h"
 
-// forward define the llvm::Type class
 namespace llvm {
 class Type;
 }
@@ -124,6 +124,8 @@
 return pc;
   }
 
+  llvm::MCRegisterInfo &GetMCRegisterInfo() { return *m_mc_register_info_up; }
+
   virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
 
   bool GetRegisterInfoByName(ConstString name, RegisterInfo &info);
@@ -136,13 +138,19 @@
   static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch);
 
 protected:
-  // Classes that inherit from ABI can see and modify these
-  ABI(lldb::ProcessSP process_sp) {
-if (process_sp.get())
-m_process_wp = process_sp;
+  ABI(lldb::ProcessSP process_sp, std::unique_ptr info_up)
+  : m_process_wp(process_sp), m_mc_register_info_up(std::move(info_up)) {
+assert(m_mc_register_info_up && "ABI must have MCRegisterInfo");
   }
 
+  /// Utility function to construct a MCRegisterInfo using the ArchSpec triple.
+  /// Plugins wishing to customize the construction can construct the
+  /// MCRegisterInfo themselves.
+  static std::unique_ptr
+  MakeMCRegisterInfo(const ArchSpec &arch);
+
   lldb::ProcessWP m_process_wp;
+  std::unique_ptr m_mc_register_info_up;
 
 private:
   DISALLOW_COPY_AND_ASSIGN(ABI);
Index: lldb/trunk/tools/lldb-test/CMakeLists.txt
===
--- lldb/trunk/tools/lldb-test/CMakeLists.txt
+++ lldb/trunk/tools/lldb-test/CMakeLists.txt
@@ -24,4 +24,9 @@
 Support
   )
   
+foreach (t ${LLVM_TARGETS_TO_BUILD})
+  set_property(SOURCE SystemInitializerTest.cpp APPEND PROPERTY
+COMPILE_DEFINITIONS "LLVM_TARGET_${t}_BUILT")
+endforeach()
+
 include_directories(${LLDB_SOURCE_DIR}/source)
Index: lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
@@ -28,6 +28,7 @@
 #include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
 #include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
 #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
+#include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h"
 #include "Plugins/Architecture/Arm/ArchitectureArm.h"
 #include "Plugins/A

[Lldb-commits] [PATCH] D67776: Use UnixSignals::ShouldSuppress to filter out signals a process expects

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

To Pavel: this problem is not only about the behavior of process attach, but 
for process launch too (and possibly something else). That's why I'm trying to 
move this logic out of specific commands.

Now I see that there are too many different usages of SIGTRAP and most of them 
are architecture-dependent (like `__builtin_trap` which can send SIGTRAP for 
one processor and SIGILL for another). So, a process cannot know how to 
distinguish the signal sender's intention. The problem is common to gdb.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67776



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


[Lldb-commits] [lldb] r372869 - [lldb][modern-type-lookup] Add two basic tests for modern-type-lookup

2019-09-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Sep 25 06:33:50 2019
New Revision: 372869

URL: http://llvm.org/viewvc/llvm-project?rev=372869&view=rev
Log:
[lldb][modern-type-lookup] Add two basic tests for modern-type-lookup

The story so far: LLDB's modern type lookup mode has no (as in, 0%) test
coverage. It was supposed to be tested by hardcoding the default to 'true' and 
then running
the normal LLDB tests, but to my knowledge no one is doing that. As a around 
130 tests
seem to fail with this mode enabled, we also can't just enable it globally for 
now.

As we touch the surrounding code all the time and also want to refactor parts 
of it, we
should be a bit more ambitious with our testing efforts.

So this patch adds two basic tests that enable this mode and do some
basic expression parsing which should hopefully be basic enough to not
break anywhere but still lets us know if this mode works at all (i.e. setting 
up the
ExternalASTMerger in LLDB, using its basic import functionality to move 
declarations
around and do some lookups).

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/TestBasicModernTypeLookup.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/main.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile?rev=372869&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/Makefile
 Wed Sep 25 06:33:50 2019
@@ -0,0 +1,4 @@
+OBJC_SOURCES := main.m
+LD_EXTRAS := -lobjc -framework Foundation
+
+include Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py?rev=372869&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/TestBasicObjcModernTypeLookup.py
 Wed Sep 25 06:33:50 2019
@@ -0,0 +1,18 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestBasicObjcModernTypeLookup(TestBase):
+  mydir = TestBase.compute_mydir(__file__)
+
+  @skipUnlessDarwin
+  def test(self):
+self.build()
+# Activate modern-type-lookup.
+# FIXME: This has to happen before we create any target otherwise we 
crash...
+self.runCmd("settings set target.experimental.use-modern-type-lookup true")
+(target, process, thread, main_breakpoint) = 
lldbutil.run_to_source_breakpoint(self,
+  "break here", lldb.SBFileSpec("main.m"))
+self.expect("expr 1", substrs=["(int) ", " = 1"])
+self.expect("expr (int)[Foo bar:22]", substrs=["(int) ", " = 44"])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m?rev=372869&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic-objc/main.m
 Wed Sep 25 06:33:50 2019
@@ -0,0 +1,17 @@
+#import 
+
+@interface Foo : NSObject
++(int) bar: (int) string;
+@end
+
+@implementation Foo
++(int) bar: (int) x
+{
+  return x + x;
+}
+@end
+
+int main() {
+  NSLog(@"Hello World");
+  return 0; // break here
+}

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/modern-type-lookup/basic/Mak

[Lldb-commits] [PATCH] D67776: Don't stop execution in batch mode when process stops with SIGINT or SIGSTOP

2019-09-25 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 221744.
tatyana-krasnukha retitled this revision from "Use UnixSignals::ShouldSuppress 
to filter out signals a process expects" to "Don't stop execution in batch mode 
when process stops with SIGINT or SIGSTOP".
tatyana-krasnukha edited the summary of this revision.
tatyana-krasnukha added a comment.

Removed using UnixSignals::ShouldSuppress, just check if a signal is either 
SIGINT or SIGSTOP.

Fixed header of the test.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67776

Files:
  include/lldb/Interpreter/CommandInterpreter.h
  include/lldb/Interpreter/CommandReturnObject.h
  packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
  source/Commands/CommandObjectProcess.cpp
  source/Interpreter/CommandInterpreter.cpp
  source/Interpreter/CommandReturnObject.cpp

Index: source/Interpreter/CommandReturnObject.cpp
===
--- source/Interpreter/CommandReturnObject.cpp
+++ source/Interpreter/CommandReturnObject.cpp
@@ -33,8 +33,7 @@
 
 CommandReturnObject::CommandReturnObject()
 : m_out_stream(), m_err_stream(), m_status(eReturnStatusStarted),
-  m_did_change_process_state(false), m_interactive(true),
-  m_abnormal_stop_was_expected(false) {}
+  m_did_change_process_state(false), m_interactive(true) {}
 
 CommandReturnObject::~CommandReturnObject() {}
 
Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -63,8 +63,10 @@
 #include "lldb/Utility/Args.h"
 
 #include "lldb/Target/Process.h"
+#include "lldb/Target/StopInfo.h"
 #include "lldb/Target/TargetList.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Target/UnixSignals.h"
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
@@ -2141,6 +2143,45 @@
   return platform_sp;
 }
 
+bool CommandInterpreter::DidProcessStopAbnormally() const {
+  TargetSP target_sp = m_debugger.GetTargetList().GetSelectedTarget();
+  if (!target_sp)
+return false;
+
+  ProcessSP process_sp(target_sp->GetProcessSP());
+  if (!process_sp)
+return false;
+
+  if (eStateStopped != process_sp->GetState())
+return false;
+
+  for (const auto &thread_sp : process_sp->GetThreadList().Threads()) {
+StopInfoSP stop_info = thread_sp->GetStopInfo();
+if (!stop_info)
+  return false;
+
+const StopReason reason = stop_info->GetStopReason();
+if (reason == eStopReasonException || reason == eStopReasonInstrumentation)
+  return true;
+
+if (reason == eStopReasonSignal) {
+  const auto stop_signal = static_cast(stop_info->GetValue());
+  UnixSignalsSP signals_sp = process_sp->GetUnixSignals();
+  if (!signals_sp || !signals_sp->SignalIsValid(stop_signal))
+// The signal is unknown, treat it as abnormal.
+return true;
+
+  const auto sigint_num = signals_sp->GetSignalNumberFromName("SIGINT");
+  const auto sigstop_num = signals_sp->GetSignalNumberFromName("SIGSTOP");
+  if ((stop_signal != sigint_num) && (stop_signal != sigstop_num))
+// The signal very likely implies a crash.
+return true;
+}
+  }
+
+  return false;
+}
+
 void CommandInterpreter::HandleCommands(const StringList &commands,
 ExecutionContext *override_context,
 CommandInterpreterRunOptions &options,
@@ -2251,38 +2292,22 @@
 }
 
 // Also check for "stop on crash here:
-bool should_stop = false;
-if (tmp_result.GetDidChangeProcessState() && options.GetStopOnCrash()) {
-  TargetSP target_sp(m_debugger.GetTargetList().GetSelectedTarget());
-  if (target_sp) {
-ProcessSP process_sp(target_sp->GetProcessSP());
-if (process_sp) {
-  for (ThreadSP thread_sp : process_sp->GetThreadList().Threads()) {
-StopReason reason = thread_sp->GetStopReason();
-if (reason == eStopReasonSignal || reason == eStopReasonException ||
-reason == eStopReasonInstrumentation) {
-  should_stop = true;
-  break;
-}
-  }
-}
-  }
-  if (should_stop) {
-if (idx != num_lines - 1)
-  result.AppendErrorWithFormat(
-  "Aborting reading of commands after command #%" PRIu64
-  ": '%s' stopped with a signal or exception.\n",
-  (uint64_t)idx + 1, cmd);
-else
-  result.AppendMessageWithFormat(
-  "Command #%" PRIu64 " '%s' stopped with a signal or exception.\n",
-  (uint64_t)idx + 1, cmd);
+if (tmp_result.GetDidChangeProcessState() && options.GetStopOnCrash() &&
+DidProcessStopAbnormally()) {
+  if (idx != num_lines - 1)
+result.AppendErrorWithFormat(
+

[Lldb-commits] [lldb] r372890 - Modernize Makefile.

2019-09-25 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Sep 25 08:48:30 2019
New Revision: 372890

URL: http://llvm.org/viewvc/llvm-project?rev=372890&view=rev
Log:
Modernize Makefile.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile?rev=372890&r1=372889&r2=372890&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/commands/expression/import-std-module/sysroot/Makefile
 Wed Sep 25 08:48:30 2019
@@ -3,7 +3,7 @@
 # system headers.
 NO_TEST_COMMON_H := 1
 
-CXXFLAGS += -I $(SRCDIR)/root/usr/include/c++/include/ -I 
$(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
+CXXFLAGS_EXTRAS = -I $(SRCDIR)/root/usr/include/c++/include/ -I 
$(SRCDIR)/root/usr/include/ -nostdinc -nostdinc++
 CXX_SOURCES := main.cpp
 
 include Makefile.rules


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


[Lldb-commits] [lldb] r372891 - [Dwarf] Make dw_tag_t a typedef for llvm::dwarf::Tag instead of uint16_t.

2019-09-25 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep 25 09:04:38 2019
New Revision: 372891

URL: http://llvm.org/viewvc/llvm-project?rev=372891&view=rev
Log:
[Dwarf] Make dw_tag_t a typedef for llvm::dwarf::Tag instead of uint16_t.

Currently dw_tag_t is a typedef for uint16_t. This patch changes makes
dw_tag_t a typedef for llvm::dwarf::Tag. This enables us to use the full
power of the DWARF utilities in LLVM without having to do the cast every
time. With this approach, we only have to do the cast when reading the
ULEB value.

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

Modified:
lldb/trunk/include/lldb/Core/dwarf.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h

Modified: lldb/trunk/include/lldb/Core/dwarf.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/dwarf.h?rev=372891&r1=372890&r2=372891&view=diff
==
--- lldb/trunk/include/lldb/Core/dwarf.h (original)
+++ lldb/trunk/include/lldb/Core/dwarf.h Wed Sep 25 09:04:38 2019
@@ -22,7 +22,7 @@ typedef uint32_t dw_uleb128_t;
 typedef int32_t dw_sleb128_t;
 typedef uint16_t dw_attr_t;
 typedef uint16_t dw_form_t;
-typedef uint16_t dw_tag_t;
+typedef llvm::dwarf::Tag dw_tag_t;
 typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for
 // any addresses in the compile units that get
 // parsed

Modified: 
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp?rev=372891&r1=372890&r2=372891&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp 
Wed Sep 25 09:04:38 2019
@@ -18,7 +18,8 @@
 using namespace lldb_private;
 
 DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration()
-: m_code(InvalidCode), m_tag(0), m_has_children(0), m_attributes() {}
+: m_code(InvalidCode), m_tag(llvm::dwarf::DW_TAG_null), m_has_children(0),
+  m_attributes() {}
 
 DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag,
uint8_t 
has_children)
@@ -33,7 +34,7 @@ DWARFAbbreviationDeclaration::extract(co
 return DWARFEnumState::Complete;
 
   m_attributes.clear();
-  m_tag = data.GetULEB128(offset_ptr);
+  m_tag = static_cast(data.GetULEB128(offset_ptr));
   if (m_tag == DW_TAG_null)
 return llvm::make_error(
 "abbrev decl requires non-null tag.");
@@ -68,7 +69,7 @@ DWARFAbbreviationDeclaration::extract(co
 }
 
 bool DWARFAbbreviationDeclaration::IsValid() {
-  return m_code != 0 && m_tag != 0;
+  return m_code != 0 && m_tag != llvm::dwarf::DW_TAG_null;
 }
 
 uint32_t

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp?rev=372891&r1=372890&r2=372891&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp Wed Sep 25 
09:04:38 2019
@@ -30,7 +30,7 @@ dw_tag_t DWARFBaseDIE::Tag() const {
   if (m_die)
 return m_die->Tag();
   else
-return 0;
+return llvm::dwarf::DW_TAG_null;
 }
 
 const char *DWARFBaseDIE::GetTagAsCString() const {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=372891&r1=372890&r2=372891&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Wed Sep 
25 09:04:38 2019
@@ -192,7 +192,7 @@ bool DWARFDebugInfoEntry::Extract(const
 *offset_ptr = offset;
 return true;
   } else {
-m_tag = 0;
+m_tag = llvm::dwarf::DW_TAG_null;
 m_has_children = false;
 return true; // NULL debug tag entry
   }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=372891&r1=372890&r2=372891&view=diff
===

[Lldb-commits] [PATCH] D68005: Make dw_tag_t a llvm::dwarf::Tag

2019-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372891: [Dwarf] Make dw_tag_t a typedef for llvm::dwarf::Tag 
instead of uint16_t. (authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68005?vs=221654&id=221783#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68005

Files:
  lldb/trunk/include/lldb/Core/dwarf.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h

Index: lldb/trunk/include/lldb/Core/dwarf.h
===
--- lldb/trunk/include/lldb/Core/dwarf.h
+++ lldb/trunk/include/lldb/Core/dwarf.h
@@ -22,7 +22,7 @@
 typedef int32_t dw_sleb128_t;
 typedef uint16_t dw_attr_t;
 typedef uint16_t dw_form_t;
-typedef uint16_t dw_tag_t;
+typedef llvm::dwarf::Tag dw_tag_t;
 typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for
 // any addresses in the compile units that get
 // parsed
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -31,7 +31,7 @@
 
   DWARFDebugInfoEntry()
   : m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0),
-m_has_children(false), m_abbr_idx(0), m_tag(0) {}
+m_has_children(false), m_abbr_idx(0), m_tag(llvm::dwarf::DW_TAG_null) {}
 
   explicit operator bool() const { return m_offset != DW_INVALID_OFFSET; }
   bool operator==(const DWARFDebugInfoEntry &rhs) const;
@@ -178,8 +178,9 @@
   // a single NULL terminating child.
   m_has_children : 1;
   uint16_t m_abbr_idx;
-  uint16_t m_tag; // A copy of the DW_TAG value so we don't have to go through
-  // the compile unit abbrev table
+  /// A copy of the DW_TAG value so we don't have to go through the compile
+  /// unit abbrev table
+  dw_tag_t m_tag = llvm::dwarf::DW_TAG_null;
 };
 
 #endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
@@ -18,7 +18,8 @@
 using namespace lldb_private;
 
 DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration()
-: m_code(InvalidCode), m_tag(0), m_has_children(0), m_attributes() {}
+: m_code(InvalidCode), m_tag(llvm::dwarf::DW_TAG_null), m_has_children(0),
+  m_attributes() {}
 
 DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag,
uint8_t has_children)
@@ -33,7 +34,7 @@
 return DWARFEnumState::Complete;
 
   m_attributes.clear();
-  m_tag = data.GetULEB128(offset_ptr);
+  m_tag = static_cast(data.GetULEB128(offset_ptr));
   if (m_tag == DW_TAG_null)
 return llvm::make_error(
 "abbrev decl requires non-null tag.");
@@ -68,7 +69,7 @@
 }
 
 bool DWARFAbbreviationDeclaration::IsValid() {
-  return m_code != 0 && m_tag != 0;
+  return m_code != 0 && m_tag != llvm::dwarf::DW_TAG_null;
 }
 
 uint32_t
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
@@ -30,7 +30,7 @@
   if (m_die)
 return m_die->Tag();
   else
-return 0;
+return llvm::dwarf::DW_TAG_null;
 }
 
 const char *DWARFBaseDIE::GetTagAsCString() const {
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -23,7 +23,7 @@
 class DWARFDeclContext {
 public:
   struct Entry {
-Entry() : tag(0), name(nullptr) {}
+Entry() : tag(llvm::dwarf::DW_TAG_null), name(nullptr) {}
 Entry(dw_tag_t t, const char *n) : tag(t), name(n) {}
 
 bool NameMatches(const Entry &rhs) const {
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/tru

[Lldb-commits] [lldb] r372894 - [Docs] Document forwarding arguments with lit

2019-09-25 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep 25 09:14:26 2019
New Revision: 372894

URL: http://llvm.org/viewvc/llvm-project?rev=372894&view=rev
Log:
[Docs] Document forwarding arguments with lit

Explain how to forward arguments to dotest.py from lit.

Modified:
lldb/trunk/docs/resources/test.rst

Modified: lldb/trunk/docs/resources/test.rst
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/resources/test.rst?rev=372894&r1=372893&r2=372894&view=diff
==
--- lldb/trunk/docs/resources/test.rst (original)
+++ lldb/trunk/docs/resources/test.rst Wed Sep 25 09:14:26 2019
@@ -133,6 +133,14 @@ LIT can also filter based on test name.
> ./bin/llvm-lit -sv tools/lldb/lit --filter CommandScriptImmediateOutput
 
 
+It is also possible to forward arguments to dotest.py by passing ``--param`` to
+lit and setting a value for ``dotest-args``.
+
+::
+
+   > ./bin/llvm-lit -sv tools/lldb/lit --param dotest-args='-C gcc'
+
+
 Running the Test Suite Remotely
 ---
 


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


[Lldb-commits] [PATCH] D68005: Make dw_tag_t a llvm::dwarf::Tag

2019-09-25 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/trunk/include/lldb/Core/dwarf.h:23
 typedef int32_t dw_sleb128_t;
 typedef uint16_t dw_attr_t;
 typedef uint16_t dw_form_t;

so should this be `llvm::dwarf::Attribute`?



Comment at: lldb/trunk/include/lldb/Core/dwarf.h:24
 typedef uint16_t dw_attr_t;
 typedef uint16_t dw_form_t;
+typedef llvm::dwarf::Tag dw_tag_t;

`llvm::dwarf::Form`?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68005



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


[Lldb-commits] [PATCH] D68003: [dotest] Support specifying a version for skipIfOutOfTreeDebugserver

2019-09-25 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/register/register/register_command/TestRegisters.py:73
 @skipIf(archs=no_match(['amd64', 'i386', 'x86_64']))
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<', '1100'])
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")

This will not skip the test for an in-tree llvm.org debugserver, right?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68003



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


[Lldb-commits] [PATCH] D68003: [dotest] Support specifying a version for skipIfOutOfTreeDebugserver

2019-09-25 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/commands/register/register/register_command/TestRegisters.py:73
 @skipIf(archs=no_match(['amd64', 'i386', 'x86_64']))
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<', '1100'])
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")

aprantl wrote:
> This will not skip the test for an in-tree llvm.org debugserver, right?
(with a version number of 10)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68003



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


[Lldb-commits] [PATCH] D68005: Make dw_tag_t a llvm::dwarf::Tag

2019-09-25 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

Thanks for doing this! I spent a bunch of time trying to understand that 
relationship yesterday.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68005



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


[Lldb-commits] [PATCH] D68007: [lldb] Move swig call from python code to cmake

2019-09-25 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372895: [lldb] Move swig call from python code to cmake 
(authored by hhb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68007?vs=221667&id=221790#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68007

Files:
  lldb/trunk/scripts/CMakeLists.txt
  lldb/trunk/scripts/Python/prepare_binding_Python.py
  lldb/trunk/scripts/prepare_bindings.py

Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -1,12 +1,8 @@
 file(GLOB SWIG_INTERFACES interface/*.i)
 file(GLOB_RECURSE SWIG_SOURCES *.swig)
-set(SWIG_HEADERS
-  ${LLDB_SOURCE_DIR}/include/lldb/API/SBDefines.h
-  ${LLDB_SOURCE_DIR}/include/lldb/lldb-defines.h
-  ${LLDB_SOURCE_DIR}/include/lldb/lldb-enumerations.h
-  ${LLDB_SOURCE_DIR}/include/lldb/lldb-forward.h
-  ${LLDB_SOURCE_DIR}/include/lldb/lldb-types.h
-  ${LLDB_SOURCE_DIR}/include/lldb/lldb-versioning.h
+file(GLOB SWIG_HEADERS
+  ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
+  ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )
 
 if(LLDB_BUILD_FRAMEWORK)
@@ -19,22 +15,34 @@
   message(FATAL_ERROR "LLDB requires swig ${SWIG_MIN_VERSION}, your version is ${SWIG_VERSION}.")
 endif()
 
+if(APPLE)
+  set(DARWIN_EXTRAS "-D__APPLE__")
+else()
+  set(DARWIN_EXTRAS "")
+endif()
+
 add_custom_command(
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
   DEPENDS ${SWIG_SOURCES}
   DEPENDS ${SWIG_INTERFACES}
   DEPENDS ${SWIG_HEADERS}
-  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Python/prepare_binding_Python.py
-  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/prepare_bindings.py
-  ${framework_arg}
-  --srcRoot=${LLDB_SOURCE_DIR}
-  --targetDir=${CMAKE_CURRENT_BINARY_DIR}
-  --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}
-  --prefix=${CMAKE_BINARY_DIR}
-  --swigExecutable=${SWIG_EXECUTABLE}
+  COMMAND ${SWIG_EXECUTABLE} 
+  -c++
+  -shadow
+  -python
+  -features autodoc
+  -threads
+  -I${LLDB_SOURCE_DIR}/include
+  -I${CMAKE_CURRENT_SOURCE_DIR}
+  -D__STDC_LIMIT_MACROS
+  -D__STDC_CONSTANT_MACROS
+  ${DARWIN_EXTRAS}
+  -outdir ${CMAKE_CURRENT_BINARY_DIR}
+  -o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
+  ${LLDB_SOURCE_DIR}/scripts/lldb.swig
   VERBATIM
-  COMMENT "Python script building LLDB Python wrapper")
+  COMMENT "Builds LLDB Python wrapper")
 
 add_custom_target(swig_wrapper ALL DEPENDS
   ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
Index: lldb/trunk/scripts/Python/prepare_binding_Python.py
===
--- lldb/trunk/scripts/Python/prepare_binding_Python.py
+++ lldb/trunk/scripts/Python/prepare_binding_Python.py
@@ -1,396 +0,0 @@
-"""
-Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-See https://llvm.org/LICENSE.txt for license information.
-SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-Python binding preparation script.
-"""
-
-# Python modules:
-from __future__ import print_function
-
-import logging
-import os
-import re
-import shutil
-import subprocess
-import sys
-import platform
-
-
-class SwigSettings(object):
-"""Provides a single object to represent swig files and settings."""
-
-def __init__(self):
-self.extensions_file = None
-self.header_files = None
-self.input_file = None
-self.interface_files = None
-self.output_file = None
-self.safecast_file = None
-self.typemaps_file = None
-self.wrapper_file = None
-
-@classmethod
-def _any_files_newer(cls, files, check_mtime):
-"""Returns if any of the given files has a newer modified time.
-
-@param cls the class
-@param files a list of zero or more file paths to check
-@param check_mtime the modification time to use as a reference.
-
-@return True if any file's modified time is newer than check_mtime.
-"""
-for path in files:
-path_mtime = os.path.getmtime(path)
-if path_mtime > check_mtime:
-# This path was modified more recently than the
-# check_mtime.
-return True
-# If we made it here, nothing was newer than the check_mtime
-return False
-
-@classmethod
-def _file_newer(cls, path, check_mtime):
-"""Tests how recently a file has been modified.
-
-@param cls the class
-@param path a file path to check
-@param check_mtime the modification time to use as a reference.
-
-@return True if the file's modified time is newer than check_mtime.
-"""
-path_mtime = os.path.getmti

[Lldb-commits] [PATCH] D68003: [dotest] Support specifying a version for skipIfOutOfTreeDebugserver

2019-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 221791.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68003

Files:
  
lldb/packages/Python/lldbsuite/test/commands/register/register/register_command/TestRegisters.py
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyCrash.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py
  
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
  lldb/test/CMakeLists.txt

Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -108,7 +108,7 @@
   set(LLVM_DISTRIBUTION_COMPONENTS ${LLVM_DISTRIBUTION_COMPONENTS} PARENT_SCOPE)
 endif()
 message(STATUS "LLDB tests use out-of-tree debugserver: ${system_debugserver_path}")
-list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
+list(APPEND LLDB_TEST_COMMON_ARGS --server ${system_debugserver_path})
   elseif(TARGET debugserver)
 set(debugserver_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver)
 message(STATUS "LLDB Tests use just-built debugserver: ${debugserver_path}")
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/register-reading/TestGdbRemoteGPacket.py
@@ -51,7 +51,7 @@
 context = self.expect_gdbremote_sequence()
 self.assertTrue(context.get("G_reply")[0] != 'E')
 
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<', '1100'])
 @debugserver_test
 @skipIfDarwinEmbedded
 def test_g_packet_debugserver(self):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1293,6 +1293,20 @@
 version = m.group(1)
 return version
 
+def getDebugserverVersion(self):
+""" Returns a string that represents the debugserver version. """
+if not configuration.debugserver:
+return '0'
+try:
+version_output = check_output([configuration.debugserver, "-v"], stderr=STDOUT)
+except CalledProcessError as e:
+version_output = e.output
+for line in version_output.split(os.linesep):
+m = re.search('PROJECT:lldb-([0-9\.]+)', line)
+if m:
+return m.group(1)
+return '0'
+
 def getDwarfVersion(self):
 """ Returns the dwarf version generated by clang or '0'. """
 if configuration.dwarf_version:
Index: lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py
@@ -16,7 +16,7 @@
 @skipIf(triple='^mips')
 @expectedFailureNetBSD
 @add_test_categories(["watchpoint"])
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<=', ''])
 def test(self):
 """Test 100 watchpoints from 100 threads."""
 self.build(dictionary=self.getBuildFlags())
Index: lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManySignals.py
@@ -17,7 +17,7 @@
 # This test is flaky on Darwin.
 @skipIfDarwin
 @expectedFailureNetBSD
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<=', ''])
 def test(self):
 """Test 100 signals from 100 threads."""
 self.build(dictionary=self.getBuildFlags())
Index: lldb/packages/Python/lldbsuite/test/functionalities/thre

[Lldb-commits] [PATCH] D68003: [dotest] Support specifying a version for skipIfOutOfTreeDebugserver

2019-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 2 inline comments as done.
JDevlieghere added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py:18
 @expectedFailureNetBSD
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<=', ''])
 def test(self):

labath wrote:
> JDevlieghere wrote:
> > I used  here because that's commonly the placeholder until the next 
> > release. 
> I haven't looked at the code in detail, but given that you are removing the 
> explicit notion of an "out of tree" debug server, it seems to be that this 
> will kick in even if you are testing against the in-tree debug server, which 
> doesn't seem right. Or am I missing something?
Yeah, I was just going to check for version numbers below a hundred, but then 
forgot to add it before I uploaded the patch. 


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68003



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


[Lldb-commits] [PATCH] D68010: [lldb] Fix string summary of an empty NSPathStore2

2019-09-25 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/include/lldb/DataFormatters/StringPrinter.h:120
+
+bool GetHasSourceSize() const { return m_has_source_size; }
+

I don't know the LLDB rules that well: is the convention really `GetHas` 
instead of `Has`?



Comment at: lldb/source/DataFormatters/StringPrinter.cpp:546
 
-  if (!sourceSize) {
+  if (!options.GetHasSourceSize()) {
 sourceSize = max_size;

why unconditionally call GetSourceSize? Should we move it into the else?



Comment at: lldb/source/DataFormatters/StringPrinter.cpp:563
+  // an empty string ("").
+  if (!buffer_sp->GetBytes() && sourceSize != 0)
 return false;

Why call GetBytes() if sourceSize is 0? Should we reverse the two conditions?


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

https://reviews.llvm.org/D68010



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


[Lldb-commits] [PATCH] D68003: [dotest] Support specifying a version for skipIfOutOfTreeDebugserver

2019-09-25 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/packages/Python/lldbsuite/test/decorators.py:513
+debugserver_version[0], debugserver_version[1],
+actual_debugserver_version) else None
+return skipTestIfFn(is_older_out_of_tree_debugserver)

IMHO the expression if-else is only good for readability if the expression fits 
on one line :-)



Comment at: 
lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyCrash.py:18
 @expectedFailureNetBSD
-@skipIfOutOfTreeDebugserver
+@skipIfOutOfTreeDebugserver(['<=', ''])
 def test(self):

Did you file a radar to update these tests once the version number is known?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68003



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


[Lldb-commits] [lldb] r372900 - [CMake] Run the lldb-server tests with system debugserver.

2019-09-25 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep 25 10:12:59 2019
New Revision: 372900

URL: http://llvm.org/viewvc/llvm-project?rev=372900&view=rev
Log:
[CMake] Run the lldb-server tests with system debugserver.

Now that we no longer build debugserver when LLDB_USE_SYSTEM_DEBUGSERVER
is set, we have to change the logic for testing lldb-server.

Modified:
lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt

Modified: lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt?rev=372900&r1=372899&r2=372900&view=diff
==
--- lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt Wed Sep 25 10:12:59 
2019
@@ -13,7 +13,7 @@ endfunction()
 add_lldb_test_executable(thread_inferior inferior/thread_inferior.cpp)
 add_lldb_test_executable(environment_check inferior/environment_check.cpp)
 
-if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD)
+if(LLDB_CAN_USE_DEBUGSERVER AND (LLDB_TOOL_DEBUGSERVER_BUILD OR 
LLDB_USE_SYSTEM_DEBUGSERVER))
   if(LLDB_USE_SYSTEM_DEBUGSERVER)
 lldb_find_system_debugserver(debugserver_path)
   else()


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


[Lldb-commits] [lldb] r372901 - [CMake] Add the system debugserver to lldb-test-deps.

2019-09-25 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep 25 10:13:02 2019
New Revision: 372901

URL: http://llvm.org/viewvc/llvm-project?rev=372901&view=rev
Log:
[CMake] Add the system debugserver to lldb-test-deps.

When using the system debugserver we create a target to copy it over.
This target has to be added to lldb-test-deps.

Modified:
lldb/trunk/test/CMakeLists.txt

Modified: lldb/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=372901&r1=372900&r2=372901&view=diff
==
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Wed Sep 25 10:13:02 2019
@@ -109,6 +109,7 @@ if(CMAKE_HOST_APPLE)
 endif()
 message(STATUS "LLDB tests use out-of-tree debugserver: 
${system_debugserver_path}")
 list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
+add_dependencies(lldb-test-deps debugserver)
   elseif(TARGET debugserver)
 set(debugserver_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver)
 message(STATUS "LLDB Tests use just-built debugserver: 
${debugserver_path}")


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


[Lldb-commits] [PATCH] D67774: [Mangle] Add flag to asm labels to disable '\01' prefixing

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

- Add a comment describing where non-literal labels are used.


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

https://reviews.llvm.org/D67774

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/AST/Mangle.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/unittests/AST/DeclTest.cpp
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -8301,8 +8301,8 @@
 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
 
   if (mangled_name != nullptr) {
-cxx_method_decl->addAttr(
-clang::AsmLabelAttr::CreateImplicit(*getASTContext(), mangled_name));
+cxx_method_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
+*getASTContext(), mangled_name, /*literal=*/false));
   }
 
   // Populate the method decl with parameter decls
Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -10,12 +10,16 @@
 //
 //===--===//
 
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Mangle.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
 
 using namespace clang::ast_matchers;
 using namespace clang::tooling;
+using namespace clang;
 
 TEST(Decl, CleansUpAPValues) {
   MatchFinder Finder;
@@ -56,3 +60,48 @@
   "constexpr _Complex __uint128_t c = 0x;",
   Args));
 }
+
+TEST(Decl, AsmLabelAttr) {
+  // Create two method decls: `f` and `g`.
+  StringRef Code = R"(
+struct S {
+  void f() {}
+  void g() {}
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
+  ASTContext &Ctx = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine &Diags = AST->getDiagnostics();
+  SourceManager &SM = AST->getSourceManager();
+  FileID MainFileID = SM.getMainFileID();
+
+  // Find the method decls within the AST.
+  SmallVector Decls;
+  AST->findFileRegionDecls(MainFileID, Code.find('{'), 0, Decls);
+  ASSERT_TRUE(Decls.size() == 1);
+  CXXRecordDecl *DeclS = cast(Decls[0]);
+  NamedDecl *DeclF = *DeclS->method_begin();
+  NamedDecl *DeclG = *(++DeclS->method_begin());
+
+  // Attach asm labels to the decls: one literal, and one not.
+  DeclF->addAttr(::new (Ctx) AsmLabelAttr(Ctx, SourceLocation(), "foo",
+  /*LiteralLabel=*/true));
+  DeclG->addAttr(::new (Ctx) AsmLabelAttr(Ctx, SourceLocation(), "goo",
+  /*LiteralLabel=*/false));
+
+  // Mangle the decl names.
+  std::string MangleF, MangleG;
+  MangleContext *MC = ItaniumMangleContext::create(Ctx, Diags);
+  {
+llvm::raw_string_ostream OS_F(MangleF);
+llvm::raw_string_ostream OS_G(MangleG);
+MC->mangleName(DeclF, OS_F);
+MC->mangleName(DeclG, OS_G);
+  }
+
+  ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
+  ASSERT_TRUE(0 == MangleG.compare("goo"));
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2766,7 +2766,7 @@
 
   if (AsmLabelAttr *NewA = New->getAttr()) {
 if (AsmLabelAttr *OldA = Old->getAttr()) {
-  if (OldA->getLabel() != NewA->getLabel()) {
+  if (!OldA->isEquivalent(NewA)) {
 // This redeclaration changes __asm__ label.
 Diag(New->getLocation(), diag::err_different_asm_label);
 Diag(OldA->getLocation(), diag::note_previous_declaration);
@@ -6983,8 +6983,8 @@
   }
 }
 
-NewVD->addAttr(::new (Context)
-   AsmLabelAttr(Context, SE->getStrTokenLoc(0), Label));
+NewVD->addAttr(::new (Context) AsmLabelAttr(
+Context, SE->getStrTokenLoc(0), Label, /*IsLiteralLabel=*/true));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier());
@@ -8882,8 +8882,9 @@
   if (Expr *E = (Expr*) D.getAsmLabel()) {
 // The parser guarantees this is a string.
 StringLiteral *SE = cast(E);
-NewFD->addAttr(::new (Context) AsmLabelAttr(Context, SE->getStrTokenLoc(0),
-SE->getString()));
+NewFD->addAttr(::new (Context)
+   AsmLabelAttr(Context, SE->getStrTokenLoc(0),
+SE->getString(), /*IsLiteralLabel=*/true));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 

[Lldb-commits] [PATCH] D67774: [Mangle] Add flag to asm labels to disable '\01' prefixing

2019-09-25 Thread John McCall via Phabricator via lldb-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


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

https://reviews.llvm.org/D67774



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


[Lldb-commits] [PATCH] D68007: [lldb] Move swig call from python code to cmake

2019-09-25 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added inline comments.



Comment at: lldb/trunk/scripts/CMakeLists.txt:5
+  ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
+  ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )

Doesn't this now include the `lldb-private` headers now? Is that intended?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68007



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


[Lldb-commits] [PATCH] D68007: [lldb] Move swig call from python code to cmake

2019-09-25 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked an inline comment as done.
hhb added inline comments.



Comment at: lldb/trunk/scripts/CMakeLists.txt:5
+  ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
+  ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )

xiaobai wrote:
> Doesn't this now include the `lldb-private` headers now? Is that intended?
Oh sorry. Will send a change to fix. Is there an easy way to exclude a pattern 
in file() call?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68007



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


[Lldb-commits] [lldb] r372903 - [Mangle] Add flag to asm labels to disable '\01' prefixing

2019-09-25 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Sep 25 11:00:31 2019
New Revision: 372903

URL: http://llvm.org/viewvc/llvm-project?rev=372903&view=rev
Log:
[Mangle] Add flag to asm labels to disable '\01' prefixing

LLDB synthesizes decls using asm labels. These decls cannot have a mangle
different than the one specified in the label name. I.e., the '\01' prefix
should not be added.

Fixes an expression evaluation failure in lldb's TestVirtual.py on iOS.

rdar://45827323

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

Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=372903&r1=372902&r2=372903&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Sep 25 11:00:31 2019
@@ -8301,8 +8301,8 @@ clang::CXXMethodDecl *ClangASTContext::A
 
cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
 
   if (mangled_name != nullptr) {
-cxx_method_decl->addAttr(
-clang::AsmLabelAttr::CreateImplicit(*getASTContext(), mangled_name));
+cxx_method_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
+*getASTContext(), mangled_name, /*literal=*/false));
   }
 
   // Populate the method decl with parameter decls


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


[Lldb-commits] [PATCH] D67774: [Mangle] Add flag to asm labels to disable '\01' prefixing

2019-09-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372903: [Mangle] Add flag to asm labels to disable 
'\01' prefixing (authored by vedantk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67774?vs=221801&id=221805#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67774

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/lib/AST/Mangle.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/unittests/AST/DeclTest.cpp
  lldb/trunk/source/Symbol/ClangASTContext.cpp

Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -722,9 +722,25 @@
 
 def AsmLabel : InheritableAttr {
   let Spellings = [Keyword<"asm">, Keyword<"__asm__">];
-  let Args = [StringArgument<"Label">];
+  let Args = [
+// Label specifies the mangled name for the decl.
+StringArgument<"Label">,
+
+// IsLiteralLabel specifies whether the label is literal (i.e. suppresses
+// the global C symbol prefix) or not. If not, the mangle-suppression prefix
+// ('\01') is omitted from the decl name at the LLVM IR level.
+//
+// Non-literal labels are used by some external AST sources like LLDB.
+BoolArgument<"IsLiteralLabel", /*optional=*/0, /*fake=*/1>
+  ];
   let SemaHandler = 0;
-  let Documentation = [Undocumented];
+  let Documentation = [AsmLabelDocs];
+  let AdditionalMembers =
+[{
+bool isEquivalent(AsmLabelAttr *Other) const {
+  return getLabel() == Other->getLabel() && getIsLiteralLabel() == Other->getIsLiteralLabel();
+}
+}];
 }
 
 def Availability : InheritableAttr {
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -2558,6 +2558,30 @@
   }];
 }
 
+def AsmLabelDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+This attribute can be used on a function or variable to specify its symbol name.
+
+On some targets, all C symbols are prefixed by default with a single character, typically ``_``.  This was done historically to distinguish them from symbols used by other languages.  (This prefix is also added to the standard Itanium C++ ABI prefix on "mangled" symbol names, so that e.g. on such targets the true symbol name for a C++ variable declared as ``int cppvar;`` would be ``__Z6cppvar``; note the two underscores.)  This prefix is *not* added to the symbol names specified by the ``asm`` attribute; programmers wishing to match a C symbol name must compensate for this.
+
+For example, consider the following C code:
+
+.. code-block:: c
+
+  int var1 asm("altvar") = 1;  // "altvar" in symbol table.
+  int var2 = 1; // "_var2" in symbol table.
+
+  void func1(void) asm("altfunc");
+  void func1(void) {} // "altfunc" in symbol table.
+  void func2(void) {} // "_func2" in symbol table.
+
+Clang's implementation of this attribute is compatible with GCC's, `documented here `_.
+
+While it is possible to use this attribute to name a special symbol used internally by the compiler, such as an LLVM intrinsic, this is neither recommended nor supported and may cause the compiler to crash or miscompile.  Users who wish to gain access to intrinsic behavior are strongly encouraged to request new builtin functions.
+  }];
+}
+
 def EnumExtensibilityDocs : Documentation {
   let Category = DocCatDecl;
   let Content = [{
Index: cfe/trunk/lib/AST/Mangle.cpp
===
--- cfe/trunk/lib/AST/Mangle.cpp
+++ cfe/trunk/lib/AST/Mangle.cpp
@@ -122,15 +122,21 @@
   if (const AsmLabelAttr *ALA = D->getAttr()) {
 // If we have an asm name, then we use it as the mangling.
 
+// If the label isn't literal, or if this is an alias for an LLVM intrinsic,
+// do not add a "\01" prefix.
+if (!ALA->getIsLiteralLabel() || ALA->getLabel().startswith("llvm.")) {
+  Out << ALA->getLabel();
+  return;
+}
+
 // Adding the prefix can cause problems when one file has a "foo" and
 // another has a "\01foo". That is known to happen on ELF with the
 // tricks normally used for producing aliases (PR9177). Fortunately the
 // llvm mangler on ELF is a nop, so we can just avoid adding the \01
-// marker.  We also avoid adding the marker if this is an alias for an
-// LLVM intrinsic.
+// marker.
 char GlobalPrefix =
 getASTContext().getTargetInfo().getDataLayout().getGlobalPrefix();
-if (GlobalPrefix && !ALA->getLabel().startswith("llvm."))
+if (GlobalPrefix)
   Out << '\01'; // LLVM IR Marker for __asm("foo")

[Lldb-commits] [PATCH] D68007: [lldb] Move swig call from python code to cmake

2019-09-25 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added inline comments.



Comment at: lldb/trunk/scripts/CMakeLists.txt:5
+  ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
+  ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )

hhb wrote:
> xiaobai wrote:
> > Doesn't this now include the `lldb-private` headers now? Is that intended?
> Oh sorry. Will send a change to fix. Is there an easy way to exclude a 
> pattern in file() call?
You can use `EXCLUDE` but I'm not sure that works with `file(GLOB)`. It might 
be better just to enumerate all the headers you want to use instead of globbing.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68007



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


[Lldb-commits] [PATCH] D68039: [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, labath, jingham, xiaobai.
Herald added a project: LLDB.

When all the tests run by dotest are unsupported, it still reports `RESULT: 
PASSED` which we translate to success for lit. We can better report the status 
as unsupported when we see that there are unsupported tests but no passing 
tests. This will not affect the situation where there are failures or 
unexpected passes, because those report a non-zero exit code.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68039

Files:
  lldb/lit/Suite/lldbtest.py


Index: lldb/lit/Suite/lldbtest.py
===
--- lldb/lit/Suite/lldbtest.py
+++ lldb/lit/Suite/lldbtest.py
@@ -102,6 +102,11 @@
 if 'XPASS:' in out or 'XPASS:' in err:
 return lit.Test.XPASS, out + err
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err
+if has_unsupported_tests and not has_passing_tests:
+return lit.Test.UNSUPPORTED, out + err
+
 passing_test_line = 'RESULT: PASSED'
 if passing_test_line not in out and passing_test_line not in err:
 msg = ('Unable to find %r in dotest output (exit code %d):\n\n%s%s'


Index: lldb/lit/Suite/lldbtest.py
===
--- lldb/lit/Suite/lldbtest.py
+++ lldb/lit/Suite/lldbtest.py
@@ -102,6 +102,11 @@
 if 'XPASS:' in out or 'XPASS:' in err:
 return lit.Test.XPASS, out + err
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err
+if has_unsupported_tests and not has_passing_tests:
+return lit.Test.UNSUPPORTED, out + err
+
 passing_test_line = 'RESULT: PASSED'
 if passing_test_line not in out and passing_test_line not in err:
 msg = ('Unable to find %r in dotest output (exit code %d):\n\n%s%s'
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68039: [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Alex Langford via Phabricator via lldb-commits
xiaobai accepted this revision.
xiaobai added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68039



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


[Lldb-commits] [PATCH] D68040: [lldb] Excludes private headers from SWIG dependency.

2019-09-25 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: xiaobai.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68040

Files:
  lldb/scripts/CMakeLists.txt


Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -4,6 +4,12 @@
   ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
   ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )
+file(GLOB SWIG_PRIVATE_HEADERS
+  ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
+)
+foreach(private_header ${SWIG_PRIVATE_HEADERS})
+  list(REMOVE_ITEM SWIG_HEADERS ${private_header})
+endforeach()
 
 if(LLDB_BUILD_FRAMEWORK)
   set(framework_arg --framework --target-platform Darwin)


Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -4,6 +4,12 @@
   ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
   ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )
+file(GLOB SWIG_PRIVATE_HEADERS
+  ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
+)
+foreach(private_header ${SWIG_PRIVATE_HEADERS})
+  list(REMOVE_ITEM SWIG_HEADERS ${private_header})
+endforeach()
 
 if(LLDB_BUILD_FRAMEWORK)
   set(framework_arg --framework --target-platform Darwin)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68039: [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/lit/Suite/lldbtest.py:105
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err

`'UNSUPPORTED:' in out + err` ?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68039



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


[Lldb-commits] [PATCH] D68040: [lldb] Excludes private headers from SWIG dependency.

2019-09-25 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372905: [lldb] Excludes private headers from SWIG 
dependency. (authored by hhb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68040?vs=221807&id=221809#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68040

Files:
  lldb/trunk/scripts/CMakeLists.txt


Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -4,6 +4,12 @@
   ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
   ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )
+file(GLOB SWIG_PRIVATE_HEADERS
+  ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
+)
+foreach(private_header ${SWIG_PRIVATE_HEADERS})
+  list(REMOVE_ITEM SWIG_HEADERS ${private_header})
+endforeach()
 
 if(LLDB_BUILD_FRAMEWORK)
   set(framework_arg --framework --target-platform Darwin)


Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -4,6 +4,12 @@
   ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
   ${LLDB_SOURCE_DIR}/include/lldb/*.h
 )
+file(GLOB SWIG_PRIVATE_HEADERS
+  ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
+)
+foreach(private_header ${SWIG_PRIVATE_HEADERS})
+  list(REMOVE_ITEM SWIG_HEADERS ${private_header})
+endforeach()
 
 if(LLDB_BUILD_FRAMEWORK)
   set(framework_arg --framework --target-platform Darwin)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68039: [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 2 inline comments as done.
JDevlieghere added inline comments.



Comment at: lldb/lit/Suite/lldbtest.py:105
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err

aprantl wrote:
> `'UNSUPPORTED:' in out + err` ?
Is that actually faster? If not I'd like to keep things consistent with the 
rest of the code above and below it. 


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68039



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


Re: [Lldb-commits] [lldb] r372891 - [Dwarf] Make dw_tag_t a typedef for llvm::dwarf::Tag instead of uint16_t.

2019-09-25 Thread Rumeet Dhindsa via lldb-commits
Hi Jonas,

Since dw_tag_t is an enum now, in the switch statement at following
mentioned location, default case needs to be added as well. It generates a
warning that some enumeration values are not handled in switch.
https://github.com/llvm-mirror/lldb/blob/master/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp#L35

On Wed, Sep 25, 2019 at 9:02 AM Jonas Devlieghere via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: jdevlieghere
> Date: Wed Sep 25 09:04:38 2019
> New Revision: 372891
>
> URL: http://llvm.org/viewvc/llvm-project?rev=372891&view=rev
> Log:
> [Dwarf] Make dw_tag_t a typedef for llvm::dwarf::Tag instead of uint16_t.
>
> Currently dw_tag_t is a typedef for uint16_t. This patch changes makes
> dw_tag_t a typedef for llvm::dwarf::Tag. This enables us to use the full
> power of the DWARF utilities in LLVM without having to do the cast every
> time. With this approach, we only have to do the cast when reading the
> ULEB value.
>
> Differential revision: https://reviews.llvm.org/D68005
>
> Modified:
> lldb/trunk/include/lldb/Core/dwarf.h
>
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
> lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
>
> Modified: lldb/trunk/include/lldb/Core/dwarf.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/dwarf.h?rev=372891&r1=372890&r2=372891&view=diff
>
> ==
> --- lldb/trunk/include/lldb/Core/dwarf.h (original)
> +++ lldb/trunk/include/lldb/Core/dwarf.h Wed Sep 25 09:04:38 2019
> @@ -22,7 +22,7 @@ typedef uint32_t dw_uleb128_t;
>  typedef int32_t dw_sleb128_t;
>  typedef uint16_t dw_attr_t;
>  typedef uint16_t dw_form_t;
> -typedef uint16_t dw_tag_t;
> +typedef llvm::dwarf::Tag dw_tag_t;
>  typedef uint64_t dw_addr_t; // Dwarf address define that must be big
> enough for
>  // any addresses in the compile units that get
>  // parsed
>
> Modified:
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp?rev=372891&r1=372890&r2=372891&view=diff
>
> ==
> ---
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
> Wed Sep 25 09:04:38 2019
> @@ -18,7 +18,8 @@
>  using namespace lldb_private;
>
>  DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration()
> -: m_code(InvalidCode), m_tag(0), m_has_children(0), m_attributes() {}
> +: m_code(InvalidCode), m_tag(llvm::dwarf::DW_TAG_null),
> m_has_children(0),
> +  m_attributes() {}
>
>  DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag,
> uint8_t
> has_children)
> @@ -33,7 +34,7 @@ DWARFAbbreviationDeclaration::extract(co
>  return DWARFEnumState::Complete;
>
>m_attributes.clear();
> -  m_tag = data.GetULEB128(offset_ptr);
> +  m_tag = static_cast(data.GetULEB128(offset_ptr));
>if (m_tag == DW_TAG_null)
>  return llvm::make_error(
>  "abbrev decl requires non-null tag.");
> @@ -68,7 +69,7 @@ DWARFAbbreviationDeclaration::extract(co
>  }
>
>  bool DWARFAbbreviationDeclaration::IsValid() {
> -  return m_code != 0 && m_tag != 0;
> +  return m_code != 0 && m_tag != llvm::dwarf::DW_TAG_null;
>  }
>
>  uint32_t
>
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp?rev=372891&r1=372890&r2=372891&view=diff
>
> ==
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp Wed Sep 25
> 09:04:38 2019
> @@ -30,7 +30,7 @@ dw_tag_t DWARFBaseDIE::Tag() const {
>if (m_die)
>  return m_die->Tag();
>else
> -return 0;
> +return llvm::dwarf::DW_TAG_null;
>  }
>
>  const char *DWARFBaseDIE::GetTagAsCString() const {
>
> Modified:
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=372891&r1=372890&r2=372891&view=diff
>
> ==
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
>

[Lldb-commits] [PATCH] D68039: [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/lit/Suite/lldbtest.py:105
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err

JDevlieghere wrote:
> aprantl wrote:
> > `'UNSUPPORTED:' in out + err` ?
> Is that actually faster? If not I'd like to keep things consistent with the 
> rest of the code above and below it. 
I was optimizing for readability, not speed :-)
The principled solution would be to emit the same kind of junit XML output that 
lit produces or some other machine-readable format.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68039



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


[Lldb-commits] [PATCH] D68039: [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 3 inline comments as done.
JDevlieghere added inline comments.



Comment at: lldb/lit/Suite/lldbtest.py:105
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err

aprantl wrote:
> JDevlieghere wrote:
> > aprantl wrote:
> > > `'UNSUPPORTED:' in out + err` ?
> > Is that actually faster? If not I'd like to keep things consistent with the 
> > rest of the code above and below it. 
> I was optimizing for readability, not speed :-)
> The principled solution would be to emit the same kind of junit XML output 
> that lit produces or some other machine-readable format.
I agree. It's on my todo list :-) 


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68039



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


[Lldb-commits] [lldb] r372914 - [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep 25 12:31:54 2019
New Revision: 372914

URL: http://llvm.org/viewvc/llvm-project?rev=372914&view=rev
Log:
[lit] Do a better job at parsing unsupported tests.

When all the tests run by dotest are unsupported, it still reports
RESULT: PASSED which we translate to success for lit. We can better
report the status as unsupported when we see that there are unsupported
tests but no passing tests. This will not affect the situation where
there are failures or unexpected passes, because those report a non-zero
exit code.

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

Modified:
lldb/trunk/lit/Suite/lldbtest.py

Modified: lldb/trunk/lit/Suite/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Suite/lldbtest.py?rev=372914&r1=372913&r2=372914&view=diff
==
--- lldb/trunk/lit/Suite/lldbtest.py (original)
+++ lldb/trunk/lit/Suite/lldbtest.py Wed Sep 25 12:31:54 2019
@@ -102,6 +102,11 @@ class LLDBTest(TestFormat):
 if 'XPASS:' in out or 'XPASS:' in err:
 return lit.Test.XPASS, out + err
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err
+if has_unsupported_tests and not has_passing_tests:
+return lit.Test.UNSUPPORTED, out + err
+
 passing_test_line = 'RESULT: PASSED'
 if passing_test_line not in out and passing_test_line not in err:
 msg = ('Unable to find %r in dotest output (exit code %d):\n\n%s%s'


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


[Lldb-commits] [PATCH] D68039: [lit] Do a better job at parsing unsupported tests.

2019-09-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
Closed by commit rL372914: [lit] Do a better job at parsing unsupported tests. 
(authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68039?vs=221806&id=221819#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68039

Files:
  lldb/trunk/lit/Suite/lldbtest.py


Index: lldb/trunk/lit/Suite/lldbtest.py
===
--- lldb/trunk/lit/Suite/lldbtest.py
+++ lldb/trunk/lit/Suite/lldbtest.py
@@ -102,6 +102,11 @@
 if 'XPASS:' in out or 'XPASS:' in err:
 return lit.Test.XPASS, out + err
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err
+if has_unsupported_tests and not has_passing_tests:
+return lit.Test.UNSUPPORTED, out + err
+
 passing_test_line = 'RESULT: PASSED'
 if passing_test_line not in out and passing_test_line not in err:
 msg = ('Unable to find %r in dotest output (exit code %d):\n\n%s%s'


Index: lldb/trunk/lit/Suite/lldbtest.py
===
--- lldb/trunk/lit/Suite/lldbtest.py
+++ lldb/trunk/lit/Suite/lldbtest.py
@@ -102,6 +102,11 @@
 if 'XPASS:' in out or 'XPASS:' in err:
 return lit.Test.XPASS, out + err
 
+has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
+has_passing_tests = 'PASS:' in out or 'PASS:' in err
+if has_unsupported_tests and not has_passing_tests:
+return lit.Test.UNSUPPORTED, out + err
+
 passing_test_line = 'RESULT: PASSED'
 if passing_test_line not in out and passing_test_line not in err:
 msg = ('Unable to find %r in dotest output (exit code %d):\n\n%s%s'
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68048: adbps

2019-09-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace created this revision.
Herald added subscribers: lldb-commits, srhines.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68048

Files:
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -610,9 +610,9 @@
   if (m_supports_jLoadedDynamicLibrariesInfos == eLazyBoolCalculate) {
 StringExtractorGDBRemote response;
 m_supports_jLoadedDynamicLibrariesInfos = eLazyBoolNo;
-if (SendPacketAndWaitForResponse("jGetLoadedDynamicLibrariesInfos:",
- response,
- false) == PacketResult::Success) {
+if (SendPacketAndWaitForResponse(
+"jGetLoadedDynamicLibrariesInfos:", response, false) ==
+PacketResult::Success) {
   if (response.IsOKResponse()) {
 m_supports_jLoadedDynamicLibrariesInfos = eLazyBoolYes;
   }
@@ -1124,8 +1124,8 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS));
 
   if (force || m_qHostInfo_is_valid == eLazyBoolCalculate) {
-// host info computation can require DNS traffic and shelling out to external processes.
-// Increase the timeout to account for that.
+// host info computation can require DNS traffic and shelling out to
+// external processes. Increase the timeout to account for that.
 ScopedTimeout timeout(*this, seconds(10));
 m_qHostInfo_is_valid = eLazyBoolNo;
 StringExtractorGDBRemote response;
@@ -1199,10 +1199,9 @@
 if (!value.getAsInteger(0, pointer_byte_size))
   ++num_keys_decoded;
   } else if (name.equals("os_version") ||
- name.equals(
- "version")) // Older debugserver binaries used the
- // "version" key instead of
- // "os_version"...
+ name.equals("version")) // Older debugserver binaries used
+ // the "version" key instead of
+ // "os_version"...
   {
 if (!m_os_version.tryParse(value))
   ++num_keys_decoded;
@@ -2067,7 +2066,7 @@
  !vendor_name.empty()) {
 llvm::Triple triple(llvm::Twine("-") + vendor_name + "-" + os_name);
 if (!environment.empty())
-triple.setEnvironmentName(environment);
+  triple.setEnvironmentName(environment);
 
 assert(triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat);
 assert(triple.getObjectFormat() != llvm::Triple::Wasm);
@@ -2099,10 +2098,12 @@
 }
 m_process_arch.GetTriple().setVendorName(llvm::StringRef(vendor_name));
 m_process_arch.GetTriple().setOSName(llvm::StringRef(os_name));
-m_process_arch.GetTriple().setEnvironmentName(llvm::StringRef(environment));
+m_process_arch.GetTriple().setEnvironmentName(
+llvm::StringRef(environment));
 m_host_arch.GetTriple().setVendorName(llvm::StringRef(vendor_name));
 m_host_arch.GetTriple().setOSName(llvm::StringRef(os_name));
-m_host_arch.GetTriple().setEnvironmentName(llvm::StringRef(environment));
+m_host_arch.GetTriple().setEnvironmentName(
+llvm::StringRef(environment));
   }
   return true;
 }
@@ -2581,7 +2582,7 @@
  * The reply from '?' packet could be as simple as 'S05'. There is no packet
  * which can
  * give us pid and/or tid. Assume pid=tid=1 in such cases.
-*/
+ */
 if (response.IsUnsupportedResponse() && IsConnected()) {
   m_curr_tid = 1;
   return true;
@@ -2617,7 +2618,7 @@
  * The reply from '?' packet could be as simple as 'S05'. There is no packet
  * which can
  * give us pid and/or tid. Assume pid=tid=1 in such cases.
-*/
+ */
 if (response.IsUnsupportedResponse() && IsConnected()) {
   m_curr_tid_run = 1;
   return true;
@@ -2754,7 +2755,7 @@
  * be as simple as 'S05'. There is no packet which can give us pid and/or
  * tid.
  * Assume pid=tid=1 in such cases.
-*/
+ */
 if ((response.IsUnsupportedResponse() || response.IsNormalResponse()) &&
 thread_ids.size() == 0 && IsConnected()) {
   thread_ids.push_back(1);
Index: lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
===
--- lldb/sourc

[Lldb-commits] [lldb] r372920 - [Dwarf] Fix switch cases that take an dw_tag_t.

2019-09-25 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Sep 25 13:59:56 2019
New Revision: 372920

URL: http://llvm.org/viewvc/llvm-project?rev=372920&view=rev
Log:
[Dwarf] Fix switch cases that take an dw_tag_t.

Now that dw_tag_t is an enum, a default case is required.

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=372920&r1=372919&r2=372920&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Wed Sep 
25 13:59:56 2019
@@ -3277,6 +3277,8 @@ DWARFASTParser::ParseChildArrayInfo(cons
 array_info.element_orders.push_back(num_elements);
   }
 } break;
+default:
+  break;
 }
   }
   return array_info;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=372920&r1=372919&r2=372920&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 25 
13:59:56 2019
@@ -314,6 +314,8 @@ void SymbolFileDWARF::GetTypes(const DWA
   case DW_TAG_ptr_to_member_type:
 add_type = (type_mask & eTypeClassMemberPointer) != 0;
 break;
+  default:
+break;
   }
 
   if (add_type) {
@@ -392,6 +394,8 @@ SymbolFileDWARF::GetParentSymbolContextD
 case DW_TAG_inlined_subroutine:
 case DW_TAG_lexical_block:
   return die;
+default:
+  break;
 }
   }
   return DWARFDIE();
@@ -3583,6 +3587,8 @@ SymbolFileDWARF::FindBlockContainingSpec
   spec_block_die_offset)
 return die;
 } break;
+default:
+  break;
 }
 
 // Give the concrete function die specified by "func_die_offset", find the

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp?rev=372920&r1=372919&r2=372920&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Wed Sep 
25 13:59:56 2019
@@ -55,6 +55,8 @@ bool UniqueDWARFASTTypeList::Find(const
   case DW_TAG_partial_unit:
 done = true;
 break;
+  default:
+break;
   }
 }
 parent_arg_die = parent_arg_die.GetParent();


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


Re: [Lldb-commits] [lldb] r372891 - [Dwarf] Make dw_tag_t a typedef for llvm::dwarf::Tag instead of uint16_t.

2019-09-25 Thread Jonas Devlieghere via lldb-commits
Thanks, fixed in r372920.

On Wed, Sep 25, 2019 at 11:51 AM Rumeet Dhindsa  wrote:
>
> Hi Jonas,
>
> Since dw_tag_t is an enum now, in the switch statement at following mentioned 
> location, default case needs to be added as well. It generates a warning that 
> some enumeration values are not handled in switch. 
> https://github.com/llvm-mirror/lldb/blob/master/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp#L35
>
> On Wed, Sep 25, 2019 at 9:02 AM Jonas Devlieghere via lldb-commits 
>  wrote:
>>
>> Author: jdevlieghere
>> Date: Wed Sep 25 09:04:38 2019
>> New Revision: 372891
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=372891&view=rev
>> Log:
>> [Dwarf] Make dw_tag_t a typedef for llvm::dwarf::Tag instead of uint16_t.
>>
>> Currently dw_tag_t is a typedef for uint16_t. This patch changes makes
>> dw_tag_t a typedef for llvm::dwarf::Tag. This enables us to use the full
>> power of the DWARF utilities in LLVM without having to do the cast every
>> time. With this approach, we only have to do the cast when reading the
>> ULEB value.
>>
>> Differential revision: https://reviews.llvm.org/D68005
>>
>> Modified:
>> lldb/trunk/include/lldb/Core/dwarf.h
>> 
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
>>
>> Modified: lldb/trunk/include/lldb/Core/dwarf.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/dwarf.h?rev=372891&r1=372890&r2=372891&view=diff
>> ==
>> --- lldb/trunk/include/lldb/Core/dwarf.h (original)
>> +++ lldb/trunk/include/lldb/Core/dwarf.h Wed Sep 25 09:04:38 2019
>> @@ -22,7 +22,7 @@ typedef uint32_t dw_uleb128_t;
>>  typedef int32_t dw_sleb128_t;
>>  typedef uint16_t dw_attr_t;
>>  typedef uint16_t dw_form_t;
>> -typedef uint16_t dw_tag_t;
>> +typedef llvm::dwarf::Tag dw_tag_t;
>>  typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough 
>> for
>>  // any addresses in the compile units that get
>>  // parsed
>>
>> Modified: 
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp?rev=372891&r1=372890&r2=372891&view=diff
>> ==
>> --- 
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp 
>> (original)
>> +++ 
>> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp 
>> Wed Sep 25 09:04:38 2019
>> @@ -18,7 +18,8 @@
>>  using namespace lldb_private;
>>
>>  DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration()
>> -: m_code(InvalidCode), m_tag(0), m_has_children(0), m_attributes() {}
>> +: m_code(InvalidCode), m_tag(llvm::dwarf::DW_TAG_null), 
>> m_has_children(0),
>> +  m_attributes() {}
>>
>>  DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag,
>> uint8_t 
>> has_children)
>> @@ -33,7 +34,7 @@ DWARFAbbreviationDeclaration::extract(co
>>  return DWARFEnumState::Complete;
>>
>>m_attributes.clear();
>> -  m_tag = data.GetULEB128(offset_ptr);
>> +  m_tag = static_cast(data.GetULEB128(offset_ptr));
>>if (m_tag == DW_TAG_null)
>>  return llvm::make_error(
>>  "abbrev decl requires non-null tag.");
>> @@ -68,7 +69,7 @@ DWARFAbbreviationDeclaration::extract(co
>>  }
>>
>>  bool DWARFAbbreviationDeclaration::IsValid() {
>> -  return m_code != 0 && m_tag != 0;
>> +  return m_code != 0 && m_tag != llvm::dwarf::DW_TAG_null;
>>  }
>>
>>  uint32_t
>>
>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp?rev=372891&r1=372890&r2=372891&view=diff
>> ==
>> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp (original)
>> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp Wed Sep 25 
>> 09:04:38 2019
>> @@ -30,7 +30,7 @@ dw_tag_t DWARFBaseDIE::Tag() const {
>>if (m_die)
>>  return m_die->Tag();
>>else
>> -return 0;
>> +return llvm::dwarf::DW_TAG_null;
>>  }
>>
>>  const char *DWARFBaseDIE::GetTagAsCString() const {
>>
>> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=37

[Lldb-commits] [PATCH] D68048: [WIP][RFC] Improve fetching the process list on the android platform

2019-09-25 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 221837.
wallace added a comment.

remove unwanted files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68048

Files:
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h

Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
@@ -38,6 +38,9 @@
  lldb_private::Target *target,
  lldb_private::Status &error) override;
 
+  uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) override;
+
 protected:
   std::string m_device_id;
   std::map m_port_forwards;
Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UriParser.h"
 
@@ -225,3 +226,117 @@
   return PlatformRemoteGDBServer::ConnectProcess(new_connect_url, plugin_name,
  debugger, target, error);
 }
+
+#define INVALID_INDEX -1
+struct PsColumnsIndices {
+  int user;
+  int pid;
+  int ppid;
+  int name;
+  PsColumnsIndices() { user = pid = ppid = name = INVALID_INDEX; }
+  bool isValid() { return pid != INVALID_INDEX && name != INVALID_INDEX; }
+};
+
+bool parsePsHeader(const std::string &line, PsColumnsIndices &indices) {
+  std::stringstream line_stream(line);
+  std::string column;
+  for (int columnIndex = 0; line_stream >> column; columnIndex++) {
+if (column.empty()) {
+  continue;
+}
+if (column == "USER") {
+  indices.user = columnIndex;
+} else if (column == "PID") {
+  indices.pid = columnIndex;
+} else if (column == "PPID") {
+  indices.ppid = columnIndex;
+} else if (column == "NAME") {
+  indices.name = columnIndex;
+}
+  }
+  return indices.isValid();
+}
+
+void parsePsProcessLine(const std::string &line,
+const PsColumnsIndices &column_indices,
+ProcessInstanceInfo &process_info) {
+  std::string user, name;
+  lldb::pid_t pid, ppid;
+  std::stringstream line_stream(line);
+  std::string column;
+  // It is assumed that the name will be the last column because it can
+  // contain spaces or tab separators
+  for (int columnIndex = 0;
+   columnIndex < column_indices.name && line_stream >> column;
+   columnIndex++) {
+if (column.empty()) {
+  continue;
+}
+if (column_indices.user == columnIndex) {
+  user = column;
+} else if (column_indices.pid == columnIndex) {
+  std::stringstream column_stream(column);
+  column_stream >> pid;
+} else if (column_indices.ppid == columnIndex) {
+  std::stringstream column_stream(column);
+  column_stream >> ppid;
+}
+  }
+  std::string name_prefix;
+  line_stream >> name_prefix;
+  getline(line_stream, name, '\n');
+  name = name + name_prefix;
+
+  process_info.SetProcessID(pid);
+  process_info.SetParentProcessID(ppid);
+  process_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
+  // TODO: set architecture: process_info.GetArchitecture().SetTriple(...);
+  // TODO: set user id, we only have the name: process_info.SetUserID(...)
+}
+
+bool findProcessFromCommand(const std::string command,
+ProcessInstanceInfoList &process_infos,
+AdbClient &adb) {
+  process_infos.Clear();
+  std::string output;
+  auto status = adb.Shell(command.c_str(), std::chrono::seconds(5), &output);
+  if (status.Fail()) {
+return false;
+  }
+  std::stringstream output_stream(output);
+  std::string line;
+  getline(output_stream, line, '\n');
+  PsColumnsIndices column_indices;
+  if (!parsePsHeader(line, column_indices)) {
+return false;
+  }
+
+  while (getline(output_stream, line, '\n')) {
+ProcessInstanceInfo process_info;
+parsePsProcessLine(line, column_indices, process_info);
+process_infos.Append(process_info);
+  }
+  return true;
+}
+
+bool findProcessesWithAdb(ProcessInstanceInfoList &process_infos,
+  const std::string device_id) {
+  AdbClient adb;
+  auto error = AdbClient::CreateByDeviceID(device_id, adb);
+  if (error.Fail()) {
+return false;

[Lldb-commits] [PATCH] D68048: [WIP][RFC] Improve fetching the process list on the android platform

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

> There are some things still left.
> 
> architecture:
>  I don't know if we can simply reuse an existing variable and set it for all 
> processes, or if we should really find the architecture of each process.

The only time we might run into an issue is when we have arm32 running on 
arm64. Not sure if that can be detected. For now we can deduce the devices 
architecture and apply to all?

> user id:
>  ps returns a user name, but ProcessInfo expects a numeric user ID. Examples 
> of user names are u0_a306, u0_a84, root, bluetooth, etc. Generally there's a 
> new user name when an apk runs IIRC. Should we include a user name field in 
> ProcessInfo for these cases?

No, we should try and figure out the user ID for the user name if possible. The 
platform code has code to get the username for a user ID.

> process name:
>  ProcessInfo stores its process name as a FileSpec, which does path splitting 
> by / or \. For some problematic system processes, ps shows a process name 
> between brackets like [irq/159-arm-smm]. The FileSpec file will try to parse 
> it as an actual path and the output of the process list command will just 
> include 159-arm-smm].
>  I imagine that it's reasonable to discard all the processes that have names 
> between brackets.

Not sure. Maybe we can get some info from the /proc//maps to find the file 
for the process? We do want to get the process' main binary in the process 
info. Anything that we don't want to attach to and debug can be left off this 
list. Not sure if that means any process those name starts with a '[' character 
or not?

> long process list:
>  Should we discard system and root processes? These are a lot (hundreds on my 
> devices) and can't be debugged.

Probably best to only show things we can attach to. Not sure how to weed this 
out. If the lldb-server in platform mode _is_ running as root, we probably want 
to show the root processes maybe? Normally we show processes that the 
lldb-server user ID has access to, but this falls down real quick with Android 
since each app has its own user ID. Not sure what the best option is here.

> c++:
>  I haven't written c++ in years, and i have forgotten almost everything. 
> Please make as many advices as possible :)

Will do!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68048



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


[Lldb-commits] [PATCH] D68048: [WIP][RFC] Improve fetching the process list on the android platform

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

Added Pavel to the review list. Pavel, please add anyone that has Android 
expertise to this patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68048



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


[Lldb-commits] [PATCH] D67996: Convert FileSystem::Open() to return Expected

2019-09-25 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna marked 19 inline comments as done.
lawrence_danna added a comment.

wow, I didn't realize the part about actually consuming the error.   I thought 
the asserts only checked that you checked if there was an error.   Uploading 
fixes momentarily




Comment at: lldb/unittests/Host/FileSystemTest.cpp:292-322
+TEST(FileSystemTest, OpenErrno) {
+#ifdef _WIN32
+  FileSpec spec("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT");
+#else
+  FileSpec spec("/file/that/does/not/exist.txt");
+#endif
+  FileSystem fs;

labath wrote:
> What's the point of having both of these tests? The error code should be the 
> same no matter how you retrieve it from the expected object, so this is more 
> of a unit test for the Expected class, than anything else...
GDBRemoteCommunicationServerCommon.cpp collects and errno value and sends it 
over the network.   I wanted to confirm FileSystem::Open() was returning and 
Error value that could be correctly converted into errno.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67996



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


[Lldb-commits] [PATCH] D67996: Convert FileSystem::Open() to return Expected

2019-09-25 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 221842.
lawrence_danna marked an inline comment as done.
lawrence_danna added a comment.
Herald added a subscriber: mgorny.

Fixed according to reviewer comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67996

Files:
  lldb/include/lldb/Core/StreamFile.h
  lldb/include/lldb/Host/FileCache.h
  lldb/include/lldb/Host/FileSystem.h
  lldb/include/lldb/lldb-forward.h
  lldb/scripts/Python/python-typemaps.swig
  lldb/source/API/SBStream.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Core/StreamFile.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Host/common/FileCache.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/windows/Host.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Target/ModuleCache.cpp
  lldb/source/Target/Platform.cpp
  lldb/unittests/Host/FileSystemTest.cpp
  lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
  lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/lldb-enumerations.h"
+#include "llvm/Testing/Support/Error.h"
 
 #include "PythonTestSuite.h"
 
@@ -581,10 +582,10 @@
 }
 
 TEST_F(PythonDataObjectsTest, TestPythonFile) {
-  File file;
-  FileSystem::Instance().Open(file, FileSpec(FileSystem::DEV_NULL),
-  File::eOpenOptionRead);
-  PythonFile py_file(file, "r");
+  auto file = FileSystem::Instance().Open(FileSpec(FileSystem::DEV_NULL),
+  File::eOpenOptionRead);
+  ASSERT_THAT_EXPECTED(file, llvm::Succeeded());
+  PythonFile py_file(*file.get(), "r");
   EXPECT_TRUE(PythonFile::Check(py_file.get()));
 }
 
Index: lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
@@ -6,6 +6,7 @@
   LINK_LIBS
 lldbHost
 lldbPluginScriptInterpreterPython
+LLVMTestingSupport
   LINK_COMPONENTS
 Support
   )
\ No newline at end of file
Index: lldb/unittests/Host/FileSystemTest.cpp
===
--- lldb/unittests/Host/FileSystemTest.cpp
+++ lldb/unittests/Host/FileSystemTest.cpp
@@ -288,3 +288,35 @@
   EXPECT_THAT(visited,
   testing::UnorderedElementsAre("/foo", "/bar", "/baz", "/qux"));
 }
+
+TEST(FileSystemTest, OpenErrno) {
+#ifdef _WIN32
+  FileSpec spec("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT");
+#else
+  FileSpec spec("/file/that/does/not/exist.txt");
+#endif
+  FileSystem fs;
+  auto file = fs.Open(spec, File::eOpenOptionRead, 0, true);
+  ASSERT_FALSE(file);
+  std::error_code code = errorToErrorCode(file.takeError());
+  EXPECT_EQ(code.category(), std::system_category());
+  EXPECT_EQ(code.value(), ENOENT);
+}
+
+TEST(FileSystemTest, OpenErrnoHandler) {
+#ifdef _WIN32
+  FileSpec spec("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT");
+#else
+  FileSpec spec("/file/that/does/not/exist.txt");
+#endif
+  FileSystem fs;
+  auto file = fs.Open(spec, File::eOpenOptionRead, 0, true);
+  ASSERT_FALSE(file);
+  std::error_code code;
+  Error error = handleErrors(file.takeError(), [&](const ECError &E) {
+code = E.convertToErrorCode();
+  });
+  ASSERT_FALSE(error);
+  EXPECT_EQ(code.category(), std::system_category());
+  EXPECT_EQ(code.value(), ENOENT);
+}
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1226,15 +1226,15 @@
   if (fs::is_symlink_file(source.GetPath()))
 source_open_options |= File::eOpenOptionDontFollowSymlinks;
 
-  File source_file;
-  Status error = FileSystem::Instance().Open(
-  source_file, source, source_open_options, lldb::eFilePermissionsUserRW);
-  uint32_t permissions = source_file.GetPermissions(error);
+  auto source_file = FileSystem::I

[Lldb-commits] [PATCH] D67776: Don't stop execution in batch mode when process stops with SIGINT or SIGSTOP

2019-09-25 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

LGTM.  Thanks for sticking with this.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67776



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


[Lldb-commits] [PATCH] D68048: [WIP][RFC] Improve fetching the process list on the android platform

2019-09-25 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

In D68048#1683238 , @clayborg wrote:

> > There are some things still left.
> > 
> > architecture:
> >  I don't know if we can simply reuse an existing variable and set it for 
> > all processes, or if we should really find the architecture of each process.
>
> The only time we might run into an issue is when we have arm32 running on 
> arm64. Not sure if that can be detected. For now we can deduce the devices 
> architecture and apply to all?


If you ask the device for what architectures it supports, you could get a list. 
It might be worth figuring out what architecture your process was built to run 
on.

>> user id:
>>  ps returns a user name, but ProcessInfo expects a numeric user ID. Examples 
>> of user names are u0_a306, u0_a84, root, bluetooth, etc. Generally there's a 
>> new user name when an apk runs IIRC. Should we include a user name field in 
>> ProcessInfo for these cases?
> 
> No, we should try and figure out the user ID for the user name if possible. 
> The platform code has code to get the username for a user ID.

+1

>> process name:
>>  ProcessInfo stores its process name as a FileSpec, which does path 
>> splitting by / or \. For some problematic system processes, ps shows a 
>> process name between brackets like [irq/159-arm-smm]. The FileSpec file will 
>> try to parse it as an actual path and the output of the process list command 
>> will just include 159-arm-smm].
>>  I imagine that it's reasonable to discard all the processes that have names 
>> between brackets.
> 
> Not sure. Maybe we can get some info from the /proc//maps to find the 
> file for the process? We do want to get the process' main binary in the 
> process info. Anything that we don't want to attach to and debug can be left 
> off this list. Not sure if that means any process those name starts with a 
> '[' character or not?

It might be worth not storing process names as FileSpecs? I think it could be a 
good idea to have a platform-specific method of finding the executable you want 
to attach to, even if its the case that most platforms will just have the 
binary as the process' main binary. Android, for example, might have the app's 
name as the name (com.foo.bar) meaning that FileSpec might be insufficient here.

Also, my understanding is that process names with brackets like that are 
generally system services or processes that the kernel has running. Most people 
probably can't debug these under normal circumstances.

>> long process list:
>>  Should we discard system and root processes? These are a lot (hundreds on 
>> my devices) and can't be debugged.
> 
> Probably best to only show things we can attach to. Not sure how to weed this 
> out. If the lldb-server in platform mode _is_ running as root, we probably 
> want to show the root processes maybe? Normally we show processes that the 
> lldb-server user ID has access to, but this falls down real quick with 
> Android since each app has its own user ID. Not sure what the best option is 
> here.

If you're running as root (which you might be if you have a rooted device) you 
probably want to see root's processes. I'm unsure if there is an actual good 
way of filtering processes here. Discarding system seems relatively safe to me 
here, but beyond that it's hard to say. I generally think lldb should err on 
the side of showing things that you won't need rather than not showing things 
that you might need.

Weeding out things that you can't attach to is going to be kind of complicated. 
I think that you can have heuristics that help (e.g. can't attach to root 
processes if you're not root) but there's probably not a nice surefire way of 
doing it. :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68048



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


[Lldb-commits] [PATCH] D68048: [WIP][RFC] Improve fetching the process list on the android platform

2019-09-25 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added inline comments.



Comment at: 
lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp:240
+
+bool parsePsHeader(const std::string &line, PsColumnsIndices &indices) {
+  std::stringstream line_stream(line);

You could return the PsColumsnIndices directly instead of returning the bool, 
then have the caller check for validity.



Comment at: 
lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp:302
+  std::string output;
+  auto status = adb.Shell(command.c_str(), std::chrono::seconds(5), &output);
+  if (status.Fail()) {

Where does 5 seconds come from here?



Comment at: 
lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp:340
+  } else {
+return PlatformRemoteGDBServer::FindProcesses(match_info, process_infos);
+  }

nit: remove the else


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68048



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


[Lldb-commits] [PATCH] D67994: [WIP] Modify lldb-test to print out ASTs from symbol file

2019-09-25 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

In D67994#1682051 , @labath wrote:

> For dumping a specific type something like this could be right, but for 
> "indiscriminately dumping" everything, this seems to be a bit fragile.
>
> Would it be possible to make this use the `SymbolFile::DumpClangAST` method 
> (this is what the "image dump ast" lldb command uses), and then possibly 
> change that method to include any extra information you need? I already see 
> the `DefinitionData` line when i do a "image dump clang ast", so it's 
> possible you wouldn't need to change anything there...
>
> FTR, this is what i get from image dump ast:
>
>   Dumping clang ast for 1 modules.
>   TranslationUnitDecl 0x561fa5fd9128 <>  
> 
>   `-NamespaceDecl 0x561fa5fd99e8 <>  Q
> `-CXXRecordDecl 0x561fa5fd9a70 <>  struct A 
> definition
>   |-DefinitionData pass_in_registers empty standard_layout 
> trivially_copyable has_user_declared_ctor can_const_default_init
>   | |-DefaultConstructor exists non_trivial user_provided 
> defaulted_is_constexpr
>   | |-CopyConstructor simple trivial has_const_param needs_implicit 
> implicit_has_const_param
>   | |-MoveConstructor exists simple trivial needs_implicit
>   | |-CopyAssignment trivial has_const_param needs_implicit 
> implicit_has_const_param
>   | |-MoveAssignment exists simple trivial needs_implicit
>   | `-Destructor simple irrelevant trivial needs_implicit
>   `-CXXConstructorDecl 0x561fa5fd9bf0 <>  A 
> 'void ()'
>


Using this approach for this simple example:

  using ULongArrayTypedef = unsigned long[10];
  
  int main() {
  ULongArrayTypedef *p;
  }

I only obtain:

  TranslationUnitDecl 0x7fd5eb023608 <>  


Vs this output for what I have now:

  ULongArrayTypedef *
  PointerType 0x7fea0a825080 'unsigned long (*)[10]'
  `-ConstantArrayType 0x7fea0a824ed0 'unsigned long [10]' 10 
`-BuiltinType 0x7fea0a8247c0 'unsigned long'
  int
  BuiltinType 0x7fea0a824700 'int'
  ULongArrayTypedef
  TypedefDecl 0x7fea0a825000 <>  ULongArrayTypedef 
'unsigned long [10]'
  `-ConstantArrayType 0x7fea0a824ed0 'unsigned long [10]' 10 
`-BuiltinType 0x7fea0a8247c0 'unsigned long'
  long unsigned int
  BuiltinType 0x7fea0a8247c0 'unsigned long'
  unsigned long [10]
  ConstantArrayType 0x7fea0a824ed0 'unsigned long [10]' 10 
  `-BuiltinType 0x7fea0a8247c0 'unsigned long'
  main
  FunctionProtoType 0x7fea0a824f10 'int (void)' cdecl
  `-BuiltinType 0x7fea0a824700 'int'

I believe this is due to us being lazy as to when we import.


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

https://reviews.llvm.org/D67994



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


[Lldb-commits] [PATCH] D67994: [WIP] Modify lldb-test to print out ASTs from symbol file

2019-09-25 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik marked an inline comment as done.
shafik added inline comments.



Comment at: tools/lldb-test/lldb-test.cpp:552-579
+
+lldb_private::TypeList type_list;
+size_t ntypes = symfile->GetTypes(nullptr, eTypeClassAny, type_list);
+printf( "Type list size: %zu\n", ntypes);
+
+for( size_t i = 0; i < ntypes; ++i) {
+auto type = type_list.GetTypeAtIndex(i);

clayborg wrote:
> I know that there is already clang AST stuff in this file, but it seems like 
> anything in this file should be just passed to the type system for dumping? 
> This code could be:
> 
> ```
> lldb_private::TypeList type_list;
> size_t ntypes = symfile->GetTypes(nullptr, eTypeClassAny, type_list);
> printf( "Type list size: %zu\n", ntypes);
> for( size_t i = 0; i < ntypes; ++i)
>   type_list.GetTypeAtIndex(i)->DumpTypeValue(...);
> ```
> 
> Better yet this entire function could just become:
> 
> ```
> Error opts::symbols::dumpAST(lldb_private::Module &Module) {
>   Module.ParseAllDebugSymbols();
> 
>   auto symfile = Module.GetSymbolFile();
>   if (!symfile)
> return make_string_error("Module has no symbol file.");
> 
>   auto type_system_or_err =
>   symfile->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);
>   if (type_system_or_err)
> type_system_or_err->DumpAST(...);
>   else
> return make_string_error("Can't retrieve TypeSystem");
> }
> ```
> And all clang AST specific stuff can be removed from this binary? Tests would 
> need to be updated.
> 
If we do stick with this approach pushing the `DumpAST(...)` into `TypeSystem` 
seems reasonable.


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

https://reviews.llvm.org/D67994



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


[Lldb-commits] [PATCH] D67996: Convert FileSystem::Open() to return Expected

2019-09-25 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna marked 2 inline comments as done.
lawrence_danna added inline comments.



Comment at: lldb/include/lldb/Core/StreamFile.h:48-53
+  void SetFile(std::shared_ptr file) {
+if (file)
+  m_file_sp = file;
+else
+  m_file_sp = std::make_shared();
+  }

labath wrote:
> Could we remove this method? It would make things easier to reason about if 
> we could disallow swapping of a File object backing a stream midway through 
> its lifetime. Looking at the existing callers, it does not seem it should be 
> hard to do that -- this is always called immediately after a stream is 
> constructed via patterns like:
> ```
> auto *stream = new StreamFile();
> auto file = create_a_file();
> if (file.is_ok()) {
>   stream->SetFile(file);
>   use(stream);
> }
> ```
> It should be easy to change that so that the stream is constructed only after 
> we have a valid File object. It would also avoid the need to construct a fake 
> File object just to guarantee it is always initialized.
Yea, it wasn't' too complicated to get rid of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67996



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


[Lldb-commits] [PATCH] D67994: [WIP] Modify lldb-test to print out ASTs from symbol file

2019-09-25 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik marked an inline comment as done.
shafik added inline comments.



Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:3077
+  ParseType(sc, die, &type_is_new).get();
+  printf( "pubname: %s is_type = %d\n", die.GetPubname(), true);
+  break;

aprantl wrote:
> You also probably don't want to actually print anything here?
Apologies, I did not clean up all the these up.


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

https://reviews.llvm.org/D67994



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


[Lldb-commits] [PATCH] D67996: Convert FileSystem::Open() to return Expected

2019-09-25 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 221864.
lawrence_danna added a comment.

got rid of StreamFile::SetFile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67996

Files:
  lldb/include/lldb/Core/StreamFile.h
  lldb/include/lldb/Host/FileCache.h
  lldb/include/lldb/Host/FileSystem.h
  lldb/include/lldb/lldb-forward.h
  lldb/scripts/Python/python-typemaps.swig
  lldb/source/API/SBStream.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Core/StreamFile.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Host/common/FileCache.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/windows/Host.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Target/ModuleCache.cpp
  lldb/source/Target/Platform.cpp
  lldb/unittests/Host/FileSystemTest.cpp
  lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
  lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/lldb-enumerations.h"
+#include "llvm/Testing/Support/Error.h"
 
 #include "PythonTestSuite.h"
 
@@ -581,10 +582,10 @@
 }
 
 TEST_F(PythonDataObjectsTest, TestPythonFile) {
-  File file;
-  FileSystem::Instance().Open(file, FileSpec(FileSystem::DEV_NULL),
-  File::eOpenOptionRead);
-  PythonFile py_file(file, "r");
+  auto file = FileSystem::Instance().Open(FileSpec(FileSystem::DEV_NULL),
+  File::eOpenOptionRead);
+  ASSERT_THAT_EXPECTED(file, llvm::Succeeded());
+  PythonFile py_file(*file.get(), "r");
   EXPECT_TRUE(PythonFile::Check(py_file.get()));
 }
 
Index: lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/unittests/ScriptInterpreter/Python/CMakeLists.txt
@@ -6,6 +6,7 @@
   LINK_LIBS
 lldbHost
 lldbPluginScriptInterpreterPython
+LLVMTestingSupport
   LINK_COMPONENTS
 Support
   )
\ No newline at end of file
Index: lldb/unittests/Host/FileSystemTest.cpp
===
--- lldb/unittests/Host/FileSystemTest.cpp
+++ lldb/unittests/Host/FileSystemTest.cpp
@@ -288,3 +288,35 @@
   EXPECT_THAT(visited,
   testing::UnorderedElementsAre("/foo", "/bar", "/baz", "/qux"));
 }
+
+TEST(FileSystemTest, OpenErrno) {
+#ifdef _WIN32
+  FileSpec spec("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT");
+#else
+  FileSpec spec("/file/that/does/not/exist.txt");
+#endif
+  FileSystem fs;
+  auto file = fs.Open(spec, File::eOpenOptionRead, 0, true);
+  ASSERT_FALSE(file);
+  std::error_code code = errorToErrorCode(file.takeError());
+  EXPECT_EQ(code.category(), std::system_category());
+  EXPECT_EQ(code.value(), ENOENT);
+}
+
+TEST(FileSystemTest, OpenErrnoHandler) {
+#ifdef _WIN32
+  FileSpec spec("C:\\FILE\\THAT\\DOES\\NOT\\EXIST.TXT");
+#else
+  FileSpec spec("/file/that/does/not/exist.txt");
+#endif
+  FileSystem fs;
+  auto file = fs.Open(spec, File::eOpenOptionRead, 0, true);
+  ASSERT_FALSE(file);
+  std::error_code code;
+  Error error = handleErrors(file.takeError(), [&](const ECError &E) {
+code = E.convertToErrorCode();
+  });
+  ASSERT_FALSE(error);
+  EXPECT_EQ(code.category(), std::system_category());
+  EXPECT_EQ(code.value(), ENOENT);
+}
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1226,15 +1226,15 @@
   if (fs::is_symlink_file(source.GetPath()))
 source_open_options |= File::eOpenOptionDontFollowSymlinks;
 
-  File source_file;
-  Status error = FileSystem::Instance().Open(
-  source_file, source, source_open_options, lldb::eFilePermissionsUserRW);
-  uint32_t permissions = source_file.GetPermissions(error);
+  auto source_file = FileSystem::Instance().Open(
+  source, source_open_options, lldb::eFilePermissionsUserRW);
+  if (!

[Lldb-commits] [PATCH] D67891: remove File::SetStream(), make new files instead.

2019-09-25 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 221866.
lawrence_danna added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67891

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/File.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Commands/CommandObjectBreakpointCommand.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Host/common/File.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
  lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
  lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
  lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/ThreadPlanTracer.cpp

Index: lldb/source/Target/ThreadPlanTracer.cpp
===
--- lldb/source/Target/ThreadPlanTracer.cpp
+++ lldb/source/Target/ThreadPlanTracer.cpp
@@ -46,7 +46,7 @@
   else {
 TargetSP target_sp(m_thread.CalculateTarget());
 if (target_sp)
-  return target_sp->GetDebugger().GetOutputFile().get();
+  return &(target_sp->GetDebugger().GetOutputStream());
   }
   return nullptr;
 }
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1358,15 +1358,15 @@
   if (module_sp && !module_sp->LoadScriptingResourceInTarget(
target, error, &feedback_stream)) {
 if (error.AsCString())
-  target->GetDebugger().GetErrorFile()->Printf(
+  target->GetDebugger().GetErrorStream().Printf(
   "unable to load scripting data for module %s - error reported was "
   "%s\n",
   module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
   error.AsCString());
   }
   if (feedback_stream.GetSize())
-target->GetDebugger().GetErrorFile()->Printf("%s\n",
- feedback_stream.GetData());
+target->GetDebugger().GetErrorStream().Printf("%s\n",
+  feedback_stream.GetData());
 }
 
 void Target::ClearModules(bool delete_locations) {
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -1649,7 +1649,7 @@
   Address symbol_address = symbol->GetAddress();
   load_addr = ResolveIndirectFunction(&symbol_address, error);
   if (!error.Success() && show_error) {
-GetTarget().GetDebugger().GetErrorFile()->Printf(
+GetTarget().GetDebugger().GetErrorStream().Printf(
 "warning: failed to resolve indirect function at 0x%" PRIx64
 " for breakpoint %i.%i: %s\n",
 symbol->GetLoadAddress(&GetTarget()),
@@ -1688,7 +1688,7 @@
 } else {
   if (show_error || use_hardware) {
 // Report error for setting breakpoint...
-GetTarget().GetDebugger().GetErrorFile()->Printf(
+GetTarget().GetDebugger().GetErrorStream().Printf(
 "warning: failed to set breakpoint site at 0x%" PRIx64
 " for breakpoint %i.%i: %s\n",
 load_addr, owner->GetBreakpoint().GetID(), owner->GetID(),
@@ -4300,9 +4300,9 @@
   : IOHandler(process->GetTarget().GetDebugger(),
   IOHandler::Type::ProcessIO),
 m_process(process),
+m_read_file(GetInputFD(), File::eOpenOptionRead, false),
 m_write_file(write_fd, File::eOpenOptionWrite, false) {
 m_pipe.CreateNew(false);
-m_read_file.SetDescriptor(GetInputFD(), File::eOpenOptionRead, false);
   }
 
   ~IOHandlerProcessSTDIO() override = default;
Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -1226,8 +1226,8 @@
   if (fs::is_symlink_file(source.GetPath()))
 source_open_options |= File::eOpenOptionDontFollow

[Lldb-commits] [PATCH] D68069: Explicitly set entry point arch when it's thumb

2019-09-25 Thread António Afonso via Phabricator via lldb-commits
aadsm created this revision.
aadsm added reviewers: clayborg, labath, wallace.
Herald added subscribers: lldb-commits, MaskRay, kristof.beyls, arichardson, 
emaste, srhines.
Herald added a reviewer: espindola.
Herald added a project: LLDB.

I found a case where the main android binary (app_process32) had thumb code at 
its entry point but no entry in the symbol table indicating this. This made 
lldb set a 4 byte breakpoint at that address (we default to arm code) instead 
of a 2 byte one (like we should for thumb).
The big deal with this is that the expression evaluator uses the entry point as 
a way to know when a JITed expression has finished executing by putting a 
breakpoint there. Because of this, evaluating expressions on certain android 
devices (Google Pixel something) made the process crash.
This was fixed by checking this specific situation when we parse the symbol 
table and add an artificial symbol for this 2 byte range and indicating that 
it's arm thumb.

I created 2 unit tests for this, one to check that now we know that the entry 
point is arm thumb, and the other to make sure we didn't change the behaviour 
for arm code.

I also run the following on the command line with the `app_process32` where I 
found the issue:
**Before:**

  (lldb) dis -s 0x1640 -e 0x1644
  app_process32[0x1640]: .long  0xf0004668; unknown opcode

**After:**

  (lldb) dis -s 0x1640 -e 0x1644
  app_process32`:
  app_process32[0x1640] <+0>: movr0, sp
  app_process32[0x1642]:  andeq  r0, r0, r0


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68069

Files:
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Index: lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
===
--- lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -172,3 +172,131 @@
   Uuid.SetFromStringRef("1b8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9", 20);
   EXPECT_EQ(Spec.GetUUID(), Uuid);
 }
+
+TEST_F(ObjectFileELFTest, GetSymtab_NoSymEntryPointArmThumbAddressClass) {
+  /*
+  // nosym-entrypoint-arm-thumb.s
+  .global _Start
+  .thumb_func
+  _start:
+  mov r0, #42
+  mov r7, #1
+  svc #0
+  // arm-linux-androideabi-as nosym-entrypoint-arm-thumb.s
+  //   -o nosym-entrypoint-arm-thumb.o
+  // arm-linux-androideabi-ld nosym-entrypoint-arm-thumb.o
+  //   -o nosym-entrypoint-arm-thumb -e 0x8075 -s
+  */
+  auto ExpectedFile = TestFile::fromYaml(R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_ARM
+  Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
+  Entry:   0x8075
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x8074
+AddressAlign:0x0002
+Content: 2A20012700DF
+  - Name:.data
+Type:SHT_PROGBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x9000
+AddressAlign:0x0001
+Content: ''
+  - Name:.bss
+Type:SHT_NOBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x9000
+AddressAlign:0x0001
+  - Name:.note.gnu.gold-version
+Type:SHT_NOTE
+AddressAlign:0x0004
+Content: 040009000400474E5500676F6C6420312E313100
+  - Name:.ARM.attributes
+Type:SHT_ARM_ATTRIBUTES
+AddressAlign:0x0001
+Content: '41130061656162690001090006020901'
+...
+)");
+  ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
+
+  ModuleSpec spec{FileSpec(ExpectedFile->name())};
+  spec.GetSymbolFileSpec().SetFile(ExpectedFile->name(),
+   FileSpec::Style::native);
+  auto module_sp = std::make_shared(spec);
+
+  auto entry_point_addr = module_sp->GetObjectFile()->GetEntryPointAddress();
+  ASSERT_TRUE(entry_point_addr.GetOffset() & 1);
+  // Decrease the offsite by 1 to make it into a breakable address since this
+  // is Thumb.
+  entry_point_addr.SetOffset(entry_point_addr.GetOffset() - 1);
+  ASSERT_EQ(entry_point_addr.GetAddressClass(),
+AddressClass::eCodeAlternateISA);
+}
+
+TEST_F(ObjectFileELFTest, GetSymtab_NoSymEntryPointArmAddressClass) {
+  /*
+  // nosym-entrypoint-arm.s
+  .global _Start
+  _start:
+  mov r0, #42
+  mov r7, #1
+  svc #0
+  // arm-linux-androideabi-as nosym-entrypoint-arm.s
+  //   -o nosym-entrypoint-arm.o
+  // arm-linux-androideabi-ld nosym-entrypoint-arm.o
+  //   -o nosym-entrypoint-arm -e 0x8074 -s
+  */
+  auto ExpectedFile = TestFile::fromYaml(R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS32

[Lldb-commits] [PATCH] D68071: cmake: Link lldb libraries and tools with libclang-cpp.so when CLANG_LINK_LLVM_DYLIB=ON

2019-09-25 Thread Tom Stellard via Phabricator via lldb-commits
tstellar created this revision.
tstellar added reviewers: beanz, smeenai, clayborg, zturner.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68071

Files:
  lldb/cmake/modules/AddLLDB.cmake


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -27,6 +27,22 @@
   endif()
 endfunction(lldb_tablegen)
 
+# Filter out clang libraries and add clang_shared when 
CLANG_LINK_CLANG_DYLIB=ON
+function(lldb_filter_link_libs link_libs)
+
+  set(link_libs_list ${${link_libs}})
+  list(LENGTH link_libs_list lib_count)
+  if (CLANG_LINK_CLANG_DYLIB AND lib_count GREATER 0)
+  list(FILTER link_libs_list EXCLUDE REGEX "^clang")
+  list(LENGTH link_libs_list filtered_lib_count)
+  if (filtered_lib_count LESS lib_count)
+list(APPEND link_libs_list clang-cpp)
+  endif()
+  endif()
+  set(${link_libs} ${link_libs_list} PARENT_SCOPE)
+
+endfunction(lldb_filter_link_libs)
+
 function(add_lldb_library name)
   include_directories(BEFORE
 ${CMAKE_CURRENT_BINARY_DIR}
@@ -85,6 +101,8 @@
   set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
 endif()
 
+lldb_filter_link_libs(PARAM_LINK_LIBS)
+
 llvm_add_library(${name} ${libkind} ${srcs}
   LINK_LIBS ${PARAM_LINK_LIBS}
   DEPENDS ${PARAM_DEPENDS}
@@ -155,6 +173,8 @@
 ${ARG_UNPARSED_ARGUMENTS}
   )
 
+  lldb_filter_link_libs(ARG_LINK_LIBS)
+
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 


Index: lldb/cmake/modules/AddLLDB.cmake
===
--- lldb/cmake/modules/AddLLDB.cmake
+++ lldb/cmake/modules/AddLLDB.cmake
@@ -27,6 +27,22 @@
   endif()
 endfunction(lldb_tablegen)
 
+# Filter out clang libraries and add clang_shared when CLANG_LINK_CLANG_DYLIB=ON
+function(lldb_filter_link_libs link_libs)
+
+  set(link_libs_list ${${link_libs}})
+  list(LENGTH link_libs_list lib_count)
+  if (CLANG_LINK_CLANG_DYLIB AND lib_count GREATER 0)
+  list(FILTER link_libs_list EXCLUDE REGEX "^clang")
+  list(LENGTH link_libs_list filtered_lib_count)
+  if (filtered_lib_count LESS lib_count)
+list(APPEND link_libs_list clang-cpp)
+  endif()
+  endif()
+  set(${link_libs} ${link_libs_list} PARENT_SCOPE)
+
+endfunction(lldb_filter_link_libs)
+
 function(add_lldb_library name)
   include_directories(BEFORE
 ${CMAKE_CURRENT_BINARY_DIR}
@@ -85,6 +101,8 @@
   set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
 endif()
 
+lldb_filter_link_libs(PARAM_LINK_LIBS)
+
 llvm_add_library(${name} ${libkind} ${srcs}
   LINK_LIBS ${PARAM_LINK_LIBS}
   DEPENDS ${PARAM_DEPENDS}
@@ -155,6 +173,8 @@
 ${ARG_UNPARSED_ARGUMENTS}
   )
 
+  lldb_filter_link_libs(ARG_LINK_LIBS)
+
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67390: [LLDB][ELF] Load both, .symtab and .dynsym sections

2019-09-25 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk added a comment.

Please wait before reviewing this patch again. I will let you know when things 
do work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67390



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