[Lldb-commits] [PATCH] D80350: Handle the case where a thread exits while we were running a function on it

2020-05-20 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

It is possible that the thread we are running a function on could exit while we 
are waiting for the function call to return.

We sort of handled that case before, but it really only worked by accident 
because the ThreadPlan still had a pointer to the Thread, and it hadn't 
actually gone away when we touched it after stopping and finding that it had 
exited.  Now that ThreadPlans re-look up the thread after each stop, we were 
handing out a null Thread pointer and crashing.

I moved the checking for vanished threads to the helper routine that handles 
the stop event, added an expression result of eExpressionThreadVanished and 
handle it properly in RunThreadPlan.  I also added a test using a function that 
just called pthread_exit.  This crashed before these changes, and works 
correctly after.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80350

Files:
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Expression/FunctionCaller.cpp
  lldb/source/Expression/LLVMUserExpression.cpp
  lldb/source/Target/Process.cpp
  lldb/test/API/functionalities/thread/exit_during_expression/Makefile
  
lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py
  lldb/test/API/functionalities/thread/exit_during_expression/main.c

Index: lldb/test/API/functionalities/thread/exit_during_expression/main.c
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/exit_during_expression/main.c
@@ -0,0 +1,42 @@
+#include 
+#include 
+#include 
+#include 
+
+static unsigned int g_timeout = 200;
+
+int
+function_to_call() {
+
+  errno = 0;
+  while(1) {
+int result = usleep(g_timeout);
+if (errno != EINTR)
+  break;
+  }
+  
+  pthread_exit((void *) 10);
+
+  return 20; // Prevent warning
+}
+
+void *
+exiting_thread_func (void *unused) {
+  function_to_call(); // Break here and cause the thread to exit
+  return NULL;
+}
+
+int
+main()
+{
+  char *exit_ptr;
+  pthread_t exiting_thread;
+
+  pthread_create(_thread, NULL, exiting_thread_func, NULL);
+
+  pthread_join(exiting_thread, _ptr);
+  int ret_val = (int) exit_ptr;
+  usleep(g_timeout * 4); // Make sure in the "run all threads" case
+ // that we don't run past our breakpoint.
+  return ret_val; // Break here to make sure the thread exited.
+}
Index: lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/exit_during_expression/TestExitDuringExpression.py
@@ -0,0 +1,106 @@
+"""
+Make sure that we handle an expression on a thread, if
+the thread exits while the expression is running.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class TestExitDuringExpression(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipIfWindows
+def test_exit_before_one_thread_unwind(self):
+"""Test the case where we exit within the one thread timeout"""
+self.exiting_expression_test(True, True)
+
+@skipIfWindows
+def test_exit_before_one_thread_no_unwind(self):
+"""Test the case where we exit within the one thread timeout"""
+self.exiting_expression_test(True, False)
+
+@skipIfWindows
+def test_exit_after_one_thread_unwind(self):
+"""Test the case where we exit within the one thread timeout"""
+self.exiting_expression_test(False, True)
+
+@skipIfWindows
+def test_exit_after_one_thread_no_unwind(self):
+"""Test the case where we exit within the one thread timeout"""
+self.exiting_expression_test(False, False)
+
+def setUp(self):
+TestBase.setUp(self)
+self.main_source_file = lldb.SBFileSpec("main.c")
+self.build()
+
+def exiting_expression_test(self, before_one_thread_timeout , unwind):
+"""function_to_call sleeps for g_timeout microseconds, then calls pthread_exit.
+   This test calls function_to_call with an overall timeout of 500
+   microseconds, and a one_thread_timeout as passed in.
+   It also sets unwind_on_exit for the call to the unwind passed in.
+   This allows you to have the thread exit either before the one thread
+   timeout is passed. """
+
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+   "Break here and cause the thread to exit", self.main_source_file)
+
+# We'll continue to this breakpoint after running our expression:
+return_bkpt = target.BreakpointCreateBySourceRegex("Break here to make sure the thread exited", self.main_source_file)
+frame 

[Lldb-commits] [PATCH] D80345: [DwarfExpression] Support entry values for indirect parameters

2020-05-20 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: djtodoro, aprantl, dstenb.
Herald added subscribers: lldb-commits, hiraditya.
Herald added projects: LLDB, LLVM.

A struct argument can be passed-by-value to a callee via a pointer to a
temporary stack copy. Add support for emitting an entry value DBG_VALUE
when an indirect parameter DBG_VALUE becomes unavailable. This is done
by omitting DW_OP_stack_value from the entry value expression, to make
the expression describe the location of an object.

rdar://63373691


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80345

Files:
  lldb/test/API/functionalities/param_entry_vals/basic_entry_values/main.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-indirect-param.mir

Index: llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-indirect-param.mir
===
--- /dev/null
+++ llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-indirect-param.mir
@@ -0,0 +1,143 @@
+# RUN: llc -emit-call-site-info -start-before=livedebugvalues -filetype=obj -o - %s \
+# RUN:   | llvm-dwarfdump - | FileCheck %s -implicit-check-not=DW_OP_entry_value
+
+# // Original Source
+# struct fat_ptr {
+#   int *ptr, *low, *high;
+# };
+# extern int baz(int x);
+# int bar(struct fat_ptr f) {
+#   return baz(baz(*f.ptr));
+# }
+
+# After w0 is clobbered, we should get an indirect parameter entry value for "f".
+
+# CHECK-LABEL: DW_TAG_formal_parameter
+# CHECK-NEXT: DW_AT_location
+# CHECK-NEXT: [0x, 0x0010): DW_OP_breg0 W0+0
+# CHECK-NEXT: [0x0010, 0x001c): DW_OP_entry_value(DW_OP_reg0 W0))
+# CHECK-NEXT: DW_AT_name("f")
+
+--- |
+  target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
+  target triple = "arm64-apple-ios10.0.0"
+  
+  %struct.fat_ptr = type { i32*, i32*, i32* }
+  
+  define i32 @bar(%struct.fat_ptr* nocapture readonly %f) local_unnamed_addr !dbg !13 {
+  entry:
+call void @llvm.dbg.declare(metadata %struct.fat_ptr* %f, metadata !23, metadata !DIExpression()), !dbg !24
+%ptr2 = bitcast %struct.fat_ptr* %f to i32**, !dbg !25
+%0 = load i32*, i32** %ptr2, align 8, !dbg !25
+%1 = load i32, i32* %0, align 4, !dbg !31
+%call = tail call i32 @baz(i32 %1), !dbg !34
+%call1 = tail call i32 @baz(i32 %call), !dbg !35
+ret i32 %call1, !dbg !36
+  }
+  
+  declare void @llvm.dbg.declare(metadata, metadata, metadata)
+  
+  declare !dbg !4 i32 @baz(i32) local_unnamed_addr optsize
+  
+  !llvm.dbg.cu = !{!0}
+  !llvm.module.flags = !{!8, !9, !10, !11}
+  !llvm.ident = !{!12}
+  
+  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None, sysroot: "/")
+  !1 = !DIFile(filename: "indirect.c", directory: "/tmp/fatptr")
+  !2 = !{}
+  !3 = !{!4}
+  !4 = !DISubprogram(name: "baz", scope: !1, file: !1, line: 4, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !5 = !DISubroutineType(types: !6)
+  !6 = !{!7, !7}
+  !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+  !8 = !{i32 7, !"Dwarf Version", i32 4}
+  !9 = !{i32 2, !"Debug Info Version", i32 3}
+  !10 = !{i32 1, !"wchar_size", i32 4}
+  !11 = !{i32 7, !"PIC Level", i32 2}
+  !12 = !{!"clang"}
+  !13 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !14, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !22)
+  !14 = !DISubroutineType(types: !15)
+  !15 = !{!7, !16}
+  !16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "fat_ptr", file: !1, line: 1, size: 192, elements: !17)
+  !17 = !{!18, !20, !21}
+  !18 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !16, file: !1, line: 2, baseType: !19, size: 64)
+  !19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
+  !20 = !DIDerivedType(tag: DW_TAG_member, name: "low", scope: !16, file: !1, line: 2, baseType: !19, size: 64, offset: 64)
+  !21 = !DIDerivedType(tag: DW_TAG_member, name: "high", scope: !16, file: !1, line: 2, baseType: !19, size: 64, offset: 128)
+  !22 = !{!23}
+  !23 = !DILocalVariable(name: "f", arg: 1, scope: !13, file: !1, line: 5, type: !16)
+  !24 = !DILocation(line: 5, column: 24, scope: !13)
+  !25 = !DILocation(line: 6, column: 23, scope: !13)
+  !31 = !DILocation(line: 6, column: 20, scope: !13)
+  !34 = !DILocation(line: 6, column: 16, scope: !13)
+  !35 = !DILocation(line: 6, column: 12, scope: !13)
+  !36 = !DILocation(line: 6, column: 5, scope: !13)
+
+...
+---
+name:bar
+alignment:   4
+exposesReturnsTwice: false
+legalized:   false

[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

This looks good, thanks for subscribing me. We need to have GetNumChildren and 
GetChildAtIndex agreeing on things and we definitely shouldn't be walking more 
than on pointer recursively. My only question is do we need helper functions 
added to TypeSystemClang to avoid this issue since we have GetNumChildren and 
GetChildAtIndex doing things differently? Some function both could/should be 
calling so that things can't get out of sync?


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

https://reviews.llvm.org/D80254



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


[Lldb-commits] [lldb] 8723f84 - [lldb/Test] Support arbitrary file extensions in TestPositionalArgs.test

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T14:09:19-07:00
New Revision: 8723f841aad8815c6d4ab199ad591f6eafdaad83

URL: 
https://github.com/llvm/llvm-project/commit/8723f841aad8815c6d4ab199ad591f6eafdaad83
DIFF: 
https://github.com/llvm/llvm-project/commit/8723f841aad8815c6d4ab199ad591f6eafdaad83.diff

LOG: [lldb/Test] Support arbitrary file extensions in TestPositionalArgs.test

On Windows the line must match:

  Use 'lldb.exe --help' for a complete list of options.

Added: 


Modified: 
lldb/test/Shell/Driver/TestPositionalArgs.test

Removed: 




diff  --git a/lldb/test/Shell/Driver/TestPositionalArgs.test 
b/lldb/test/Shell/Driver/TestPositionalArgs.test
index 8072029ef2eb..b4fa48f3af38 100644
--- a/lldb/test/Shell/Driver/TestPositionalArgs.test
+++ b/lldb/test/Shell/Driver/TestPositionalArgs.test
@@ -28,4 +28,4 @@ RUN: not %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | 
FileCheck %s --check-prefi
 
 UNKNOWN: error: unknown option: -baz
 UNKNOWN: error: unknown option: --quux
-UNKNOWN: Use 'lldb --help' for a complete list of options.
+UNKNOWN: Use 'lldb{{.*}} --help' for a complete list of options.



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


[Lldb-commits] [PATCH] D80173: Give microsoftDemangle() an outparam for how many input bytes were consumed.

2020-05-20 Thread Nico Weber via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc1c3655bfd6: Give microsoftDemangle() an outparam for how 
many input bytes were consumed. (authored by thakis).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D80173?vs=264757=265336#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80173

Files:
  lldb/source/Core/Mangled.cpp
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
  llvm/lib/Demangle/Demangle.cpp
  llvm/lib/Demangle/MicrosoftDemangle.cpp
  llvm/test/Demangle/warn-trailing.test
  llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp
  llvm/tools/llvm-objdump/COFFDump.cpp
  llvm/tools/llvm-undname/llvm-undname.cpp

Index: llvm/tools/llvm-undname/llvm-undname.cpp
===
--- llvm/tools/llvm-undname/llvm-undname.cpp
+++ llvm/tools/llvm-undname/llvm-undname.cpp
@@ -45,6 +45,9 @@
cl::init(false));
 cl::opt RawFile("raw-file", cl::Optional,
  cl::desc("for fuzzer data"), cl::Hidden);
+cl::opt WarnTrailing("warn-trailing", cl::Optional,
+   cl::desc("warn on trailing characters"), cl::Hidden,
+   cl::init(false));
 cl::list Symbols(cl::Positional, cl::desc(""),
   cl::ZeroOrMore);
 
@@ -62,11 +65,15 @@
   if (NoMemberType)
 Flags = MSDemangleFlags(Flags | MSDF_NoMemberType);
 
+  size_t NRead;
   char *ResultBuf =
-  microsoftDemangle(S.c_str(), nullptr, nullptr, , Flags);
+  microsoftDemangle(S.c_str(), , nullptr, nullptr, , Flags);
   if (Status == llvm::demangle_success) {
 outs() << ResultBuf << "\n";
 outs().flush();
+if (WarnTrailing && NRead < S.size())
+  WithColor::warning() << "trailing characters: " << S.c_str() + NRead
+   << "\n";
   } else {
 WithColor::error() << "Invalid mangled name\n";
   }
Index: llvm/tools/llvm-objdump/COFFDump.cpp
===
--- llvm/tools/llvm-objdump/COFFDump.cpp
+++ llvm/tools/llvm-objdump/COFFDump.cpp
@@ -679,11 +679,9 @@
<< "0x" << format("%08x", unsigned(Symbol->getValue())) << " "
<< Name;
 if (Demangle && Name.startswith("?")) {
-  char *DemangledSymbol = nullptr;
-  size_t Size = 0;
   int Status = -1;
-  DemangledSymbol =
-  microsoftDemangle(Name.data(), DemangledSymbol, , );
+  char *DemangledSymbol =
+  microsoftDemangle(Name.data(), nullptr, nullptr, nullptr, );
 
   if (Status == 0 && DemangledSymbol) {
 outs() << " (" << StringRef(DemangledSymbol) << ")";
Index: llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp
===
--- llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp
+++ llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp
@@ -15,6 +15,6 @@
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   std::string NullTerminatedString((const char *)Data, Size);
   free(llvm::microsoftDemangle(NullTerminatedString.c_str(), nullptr, nullptr,
-   nullptr));
+   nullptr, nullptr));
   return 0;
 }
Index: llvm/test/Demangle/warn-trailing.test
===
--- /dev/null
+++ llvm/test/Demangle/warn-trailing.test
@@ -0,0 +1,6 @@
+; RUN: llvm-undname -warn-trailing 2>&1 < %s | FileCheck %s
+
+?x@@3HAasdf
+; CHECK: ?x@@3HAasdf
+; CHECK-NEXT: int x
+; CHECK-NEXT: warning: trailing characters: asdf
Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -2334,14 +2334,16 @@
 std::printf("\n");
 }
 
-char *llvm::microsoftDemangle(const char *MangledName, char *Buf, size_t *N,
+char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled,
+  char *Buf, size_t *N,
   int *Status, MSDemangleFlags Flags) {
-  int InternalStatus = demangle_success;
   Demangler D;
   OutputStream S;
 
   StringView Name{MangledName};
   SymbolNode *AST = D.parse(Name);
+  if (!D.Error && NMangled)
+*NMangled = Name.begin() - MangledName;
 
   if (Flags & MSDF_DumpBackrefs)
 D.dumpBackReferences();
@@ -2356,6 +2358,7 @@
   if (Flags & MSDF_NoMemberType)
 OF = OutputFlags(OF | OF_NoMemberType);
 
+  int InternalStatus = demangle_success;
   if (D.Error)
 InternalStatus = demangle_invalid_mangled_name;
   else if (!initializeOutputStream(Buf, N, S, 1024))

[Lldb-commits] [lldb] bc1c365 - Give microsoftDemangle() an outparam for how many input bytes were consumed.

2020-05-20 Thread Nico Weber via lldb-commits

Author: Nico Weber
Date: 2020-05-20T16:17:31-04:00
New Revision: bc1c3655bfd67a0b4ccece465729c39d769e9707

URL: 
https://github.com/llvm/llvm-project/commit/bc1c3655bfd67a0b4ccece465729c39d769e9707
DIFF: 
https://github.com/llvm/llvm-project/commit/bc1c3655bfd67a0b4ccece465729c39d769e9707.diff

LOG: Give microsoftDemangle() an outparam for how many input bytes were 
consumed.

Demangling Itanium symbols either consumes the whole input or fails,
but Microsoft symbols can be successfully demangled with just some
of the input.

Add an outparam that enables clients to know how much of the input was
consumed, and use this flag to give llvm-undname an opt-in warning
on partially consumed symbols.

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

Added: 
llvm/test/Demangle/warn-trailing.test

Modified: 
lldb/source/Core/Mangled.cpp
llvm/include/llvm/Demangle/Demangle.h
llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/lib/Demangle/Demangle.cpp
llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/tools/llvm-microsoft-demangle-fuzzer/llvm-microsoft-demangle-fuzzer.cpp
llvm/tools/llvm-objdump/COFFDump.cpp
llvm/tools/llvm-undname/llvm-undname.cpp

Removed: 




diff  --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index b44cbeb4fec9..56914ae117dd 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -181,7 +181,7 @@ void Mangled::SetValue(ConstString name) {
 // Local helpers for 
diff erent demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
   char *demangled_cstr = llvm::microsoftDemangle(
-  M, nullptr, nullptr, nullptr,
+  M, nullptr, nullptr, nullptr, nullptr,
   llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier |
 llvm::MSDF_NoCallingConvention |
 llvm::MSDF_NoMemberType));

diff  --git a/llvm/include/llvm/Demangle/Demangle.h 
b/llvm/include/llvm/Demangle/Demangle.h
index 7b85b9a9ccf7..b4006a067d10 100644
--- a/llvm/include/llvm/Demangle/Demangle.h
+++ b/llvm/include/llvm/Demangle/Demangle.h
@@ -40,7 +40,21 @@ enum MSDemangleFlags {
   MSDF_NoReturnType = 1 << 3,
   MSDF_NoMemberType = 1 << 4,
 };
-char *microsoftDemangle(const char *mangled_name, char *buf, size_t *n,
+
+/// Demangles the Microsoft symbol pointed at by mangled_name and returns it.
+/// Returns a pointer to the start of a null-terminated demangled string on
+/// success, or nullptr on error.
+/// If n_read is non-null and demangling was successful, it receives how many
+/// bytes of the input string were consumed.
+/// buf can point to a *n_buf bytes large buffer where the demangled name is
+/// stored. If the buffer is too small, it is grown with realloc(). If buf is
+/// nullptr, then this malloc()s memory for the result.
+/// *n_buf stores the size of buf on input if buf is non-nullptr, and it
+/// receives the size of the demangled string on output if n_buf is not 
nullptr.
+/// status receives one of the demangle_ enum entries above if it's not 
nullptr.
+/// Flags controls various details of the demangled representation.
+char *microsoftDemangle(const char *mangled_name, size_t *n_read,
+char *buf, size_t *n_buf,
 int *status, MSDemangleFlags Flags = MSDF_None);
 
 /// Attempt to demangle a string using 
diff erent demangling schemes.

diff  --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp 
b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index ff017b078019..b055230588df 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -624,7 +624,7 @@ LLVMSymbolizer::DemangleName(const std::string ,
 // Only do MSVC C++ demangling on symbols starting with '?'.
 int status = 0;
 char *DemangledName = microsoftDemangle(
-Name.c_str(), nullptr, nullptr, ,
+Name.c_str(), nullptr, nullptr, nullptr, ,
 MSDemangleFlags(MSDF_NoAccessSpecifier | MSDF_NoCallingConvention |
 MSDF_NoMemberType | MSDF_NoReturnType));
 if (status != 0)

diff  --git a/llvm/lib/Demangle/Demangle.cpp b/llvm/lib/Demangle/Demangle.cpp
index 5f921537b9bd..71dafa0b2e43 100644
--- a/llvm/lib/Demangle/Demangle.cpp
+++ b/llvm/lib/Demangle/Demangle.cpp
@@ -24,8 +24,8 @@ std::string llvm::demangle(const std::string ) {
   if (isItaniumEncoding(MangledName))
 Demangled = itaniumDemangle(MangledName.c_str(), nullptr, nullptr, 
nullptr);
   else
-Demangled =
-microsoftDemangle(MangledName.c_str(), nullptr, nullptr, nullptr);
+Demangled = microsoftDemangle(MangledName.c_str(), nullptr, nullptr,
+  nullptr, nullptr);
 
   if (!Demangled)
 return MangledName;

diff  --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp 
b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index c681d6e25b87..16074314a84d 100644
--- 

[Lldb-commits] [lldb] 690993a - [lldb/Reproducers] Add instrumentation to SBEnvironment

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T13:02:20-07:00
New Revision: 690993a09a0df0d54a5cec7f06fffb6e2210ab8b

URL: 
https://github.com/llvm/llvm-project/commit/690993a09a0df0d54a5cec7f06fffb6e2210ab8b
DIFF: 
https://github.com/llvm/llvm-project/commit/690993a09a0df0d54a5cec7f06fffb6e2210ab8b.diff

LOG: [lldb/Reproducers] Add instrumentation to SBEnvironment

This class should've been instrumented when it landed. Whether the class
is "highly mutable" or not doesn't affect that.

With this patch TestSBEnvironment.py now passes when replayed.

Added: 


Modified: 
lldb/source/API/SBEnvironment.cpp
lldb/source/API/SBReproducer.cpp

Removed: 




diff  --git a/lldb/source/API/SBEnvironment.cpp 
b/lldb/source/API/SBEnvironment.cpp
index f3676b03a9b9..d4de89c32567 100644
--- a/lldb/source/API/SBEnvironment.cpp
+++ b/lldb/source/API/SBEnvironment.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "lldb/API/SBEnvironment.h"
+#include "SBReproducerPrivate.h"
 #include "Utils.h"
 #include "lldb/API/SBStringList.h"
 #include "lldb/Utility/ConstString.h"
@@ -15,12 +16,14 @@
 using namespace lldb;
 using namespace lldb_private;
 
-/// This class is highly mutable, therefore we don't reproducers.
-
-SBEnvironment::SBEnvironment() : m_opaque_up(new Environment()) {}
+SBEnvironment::SBEnvironment() : m_opaque_up(new Environment()) {
+  LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEnvironment);
+}
 
 SBEnvironment::SBEnvironment(const SBEnvironment )
-: m_opaque_up(clone(rhs.m_opaque_up)) {}
+: m_opaque_up(clone(rhs.m_opaque_up)) {
+  LLDB_RECORD_CONSTRUCTOR(SBEnvironment, (const lldb::SBEnvironment &), rhs);
+}
 
 SBEnvironment::SBEnvironment(Environment rhs)
 : m_opaque_up(new Environment(std::move(rhs))) {}
@@ -28,16 +31,24 @@ SBEnvironment::SBEnvironment(Environment rhs)
 SBEnvironment::~SBEnvironment() = default;
 
 const SBEnvironment ::operator=(const SBEnvironment ) {
+  LLDB_RECORD_METHOD(const lldb::SBEnvironment &,
+ SBEnvironment, operator=,(const lldb::SBEnvironment &),
+ rhs);
+
   if (this != )
 m_opaque_up = clone(rhs.m_opaque_up);
-  return *this;
+  return LLDB_RECORD_RESULT(*this);
 }
 
 size_t SBEnvironment::GetNumValues() {
+  LLDB_RECORD_METHOD_NO_ARGS(size_t, SBEnvironment, GetNumValues);
+
   return m_opaque_up->size();
 }
 
 const char *SBEnvironment::Get(const char *name) {
+  LLDB_RECORD_METHOD(const char *, SBEnvironment, Get, (const char *), name);
+
   auto entry = m_opaque_up->find(name);
   if (entry == m_opaque_up->end()) {
 return nullptr;
@@ -46,6 +57,9 @@ const char *SBEnvironment::Get(const char *name) {
 }
 
 const char *SBEnvironment::GetNameAtIndex(size_t index) {
+  LLDB_RECORD_METHOD(const char *, SBEnvironment, GetNameAtIndex, (size_t),
+ index);
+
   if (index >= GetNumValues())
 return nullptr;
   return ConstString(std::next(m_opaque_up->begin(), index)->first())
@@ -53,6 +67,9 @@ const char *SBEnvironment::GetNameAtIndex(size_t index) {
 }
 
 const char *SBEnvironment::GetValueAtIndex(size_t index) {
+  LLDB_RECORD_METHOD(const char *, SBEnvironment, GetValueAtIndex, (size_t),
+ index);
+
   if (index >= GetNumValues())
 return nullptr;
   return ConstString(std::next(m_opaque_up->begin(), index)->second)
@@ -60,6 +77,10 @@ const char *SBEnvironment::GetValueAtIndex(size_t index) {
 }
 
 bool SBEnvironment::Set(const char *name, const char *value, bool overwrite) {
+  LLDB_RECORD_METHOD(bool, SBEnvironment, Set,
+ (const char *, const char *, bool), name, value,
+ overwrite);
+
   if (overwrite) {
 m_opaque_up->insert_or_assign(name, std::string(value));
 return true;
@@ -68,23 +89,33 @@ bool SBEnvironment::Set(const char *name, const char 
*value, bool overwrite) {
 }
 
 bool SBEnvironment::Unset(const char *name) {
+  LLDB_RECORD_METHOD(bool, SBEnvironment, Unset, (const char *), name);
+
   return m_opaque_up->erase(name);
 }
 
 SBStringList SBEnvironment::GetEntries() {
+  LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStringList, SBEnvironment, GetEntries);
+
   SBStringList entries;
   for (const auto  : *m_opaque_up) {
 entries.AppendString(Environment::compose(KV).c_str());
   }
-  return entries;
+  return LLDB_RECORD_RESULT(entries);
 }
 
 void SBEnvironment::PutEntry(const char *name_and_value) {
+  LLDB_RECORD_METHOD(void, SBEnvironment, PutEntry, (const char *),
+ name_and_value);
+
   auto split = llvm::StringRef(name_and_value).split('=');
   m_opaque_up->insert_or_assign(split.first.str(), split.second.str());
 }
 
 void SBEnvironment::SetEntries(const SBStringList , bool append) {
+  LLDB_RECORD_METHOD(void, SBEnvironment, SetEntries,
+ (const lldb::SBStringList &, bool), entries, append);
+
   if (!append)
 

[Lldb-commits] [PATCH] D80257: [lldb] Allows customizing libxml2 for darwin

2020-05-20 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG780d7d77327c: [lldb] Allows customizing libxml2 for darwin 
(authored by hhb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80257

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Host/CMakeLists.txt
  lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt


Index: lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
===
--- lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
+++ lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
@@ -1,5 +1,3 @@
-include_directories(${LIBXML2_INCLUDE_DIR})
-
 add_lldb_library(lldbPluginSymbolVendorMacOSX PLUGIN
   SymbolVendorMacOSX.cpp
 
Index: lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
===
--- lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -6,10 +6,6 @@
   SOURCE ProcessGDBRemoteProperties.td
   TARGET LLDBPluginProcessGDBRemotePropertiesEnumGen)
 
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  include_directories(${LIBXML2_INCLUDE_DIR})
-endif()
-
 set(LLDB_PLUGINS
   lldbPluginProcessUtility
   lldbPluginPlatformMacOSX
Index: lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -25,7 +25,6 @@
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  include_directories(${LIBXML2_INCLUDE_DIR})
   add_subdirectory(objcxx)
   set(OBJC_LIBS "lldbPluginPlatformMacOSXObjCXX")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -83,7 +83,6 @@
 )
 
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
 add_subdirectory(macosx/objcxx)
 set(LLDBObjCLibs lldbHostMacOSXObjCXX)
 add_host_subdirectory(macosx
@@ -137,14 +136,10 @@
 set(EXTRA_LIBS)
 if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND EXTRA_LIBS kvm)
-endif ()
-if (APPLE)
-  list(APPEND EXTRA_LIBS xml2)
-else ()
-  if (LIBXML2_FOUND)
-list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
-  endif()
-endif ()
+endif()
+if (LLDB_ENABLE_LIBXML2)
+  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
 endif()
@@ -156,7 +151,7 @@
 endif()
 if (WIN32)
   list(APPEND LLDB_SYSTEM_LIBS psapi)
-endif ()
+endif()
 
 if (LLDB_ENABLE_LIBEDIT)
   list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES})
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -286,7 +286,6 @@
${CORE_SERVICES_LIBRARY}
${SECURITY_LIBRARY}
${DEBUG_SYMBOLS_LIBRARY})
-  include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
 if( WIN32 AND NOT CYGWIN )


Index: lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
===
--- lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
+++ lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
@@ -1,5 +1,3 @@
-include_directories(${LIBXML2_INCLUDE_DIR})
-
 add_lldb_library(lldbPluginSymbolVendorMacOSX PLUGIN
   SymbolVendorMacOSX.cpp
 
Index: lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
===
--- lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -6,10 +6,6 @@
   SOURCE ProcessGDBRemoteProperties.td
   TARGET LLDBPluginProcessGDBRemotePropertiesEnumGen)
 
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  include_directories(${LIBXML2_INCLUDE_DIR})
-endif()
-
 set(LLDB_PLUGINS
   lldbPluginProcessUtility
   lldbPluginPlatformMacOSX
Index: lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -25,7 +25,6 @@
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  include_directories(${LIBXML2_INCLUDE_DIR})
   add_subdirectory(objcxx)
   set(OBJC_LIBS "lldbPluginPlatformMacOSXObjCXX")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
Index: lldb/source/Host/CMakeLists.txt
===
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -83,7 +83,6 @@
 )
 
   if 

[Lldb-commits] [PATCH] D80253: [lldb] Cleans up system_libs

2020-05-20 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG04daba967031: [lldb] Cleans up system_libs (authored by hhb).

Changed prior to commit:
  https://reviews.llvm.org/D80253?vs=265065=265327#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80253

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Utility/CMakeLists.txt


Index: lldb/source/Utility/CMakeLists.txt
===
--- lldb/source/Utility/CMakeLists.txt
+++ lldb/source/Utility/CMakeLists.txt
@@ -1,6 +1,19 @@
 set(LLDB_SYSTEM_LIBS)
 
-list(APPEND LLDB_SYSTEM_LIBS ${system_libs})
+if (APPLE)
+  list(APPEND LLDB_SYSTEM_LIBS
+   ${FOUNDATION_LIBRARY}
+   ${CORE_FOUNDATION_LIBRARY}
+   ${CORE_SERVICES_LIBRARY}
+   ${SECURITY_LIBRARY}
+   ${DEBUG_SYMBOLS_LIBRARY})
+endif()
+
+if(NOT PURE_WINDOWS)
+  list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_DL_LIBS})
 
 if (CMAKE_SYSTEM_NAME MATCHES "Windows")
   list(APPEND LLDB_SYSTEM_LIBS ws2_32 rpcrt4)
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -234,7 +234,6 @@
 endif()
 
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND system_libs ${LIBXML2_LIBRARIES})
   include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
@@ -280,12 +279,7 @@
   find_library(FOUNDATION_LIBRARY Foundation)
   find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
   find_library(SECURITY_LIBRARY Security)
-  list(APPEND system_libs
-   ${FOUNDATION_LIBRARY}
-   ${CORE_FOUNDATION_LIBRARY}
-   ${CORE_SERVICES_LIBRARY}
-   ${SECURITY_LIBRARY}
-   ${DEBUG_SYMBOLS_LIBRARY})
+  include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
 if( WIN32 AND NOT CYGWIN )
@@ -295,11 +289,8 @@
 if(NOT PURE_WINDOWS)
   set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
   find_package(Threads REQUIRED)
-  list(APPEND system_libs ${CMAKE_THREAD_LIBS_INIT})
 endif()
 
-list(APPEND system_libs ${CMAKE_DL_LIBS})
-
 # Figure out if lldb could use lldb-server.  If so, then we'll
 # ensure we build lldb-server when an lldb target is being built.
 if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|Windows")


Index: lldb/source/Utility/CMakeLists.txt
===
--- lldb/source/Utility/CMakeLists.txt
+++ lldb/source/Utility/CMakeLists.txt
@@ -1,6 +1,19 @@
 set(LLDB_SYSTEM_LIBS)
 
-list(APPEND LLDB_SYSTEM_LIBS ${system_libs})
+if (APPLE)
+  list(APPEND LLDB_SYSTEM_LIBS
+   ${FOUNDATION_LIBRARY}
+   ${CORE_FOUNDATION_LIBRARY}
+   ${CORE_SERVICES_LIBRARY}
+   ${SECURITY_LIBRARY}
+   ${DEBUG_SYMBOLS_LIBRARY})
+endif()
+
+if(NOT PURE_WINDOWS)
+  list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_DL_LIBS})
 
 if (CMAKE_SYSTEM_NAME MATCHES "Windows")
   list(APPEND LLDB_SYSTEM_LIBS ws2_32 rpcrt4)
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -234,7 +234,6 @@
 endif()
 
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND system_libs ${LIBXML2_LIBRARIES})
   include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
@@ -280,12 +279,7 @@
   find_library(FOUNDATION_LIBRARY Foundation)
   find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
   find_library(SECURITY_LIBRARY Security)
-  list(APPEND system_libs
-   ${FOUNDATION_LIBRARY}
-   ${CORE_FOUNDATION_LIBRARY}
-   ${CORE_SERVICES_LIBRARY}
-   ${SECURITY_LIBRARY}
-   ${DEBUG_SYMBOLS_LIBRARY})
+  include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
 if( WIN32 AND NOT CYGWIN )
@@ -295,11 +289,8 @@
 if(NOT PURE_WINDOWS)
   set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
   find_package(Threads REQUIRED)
-  list(APPEND system_libs ${CMAKE_THREAD_LIBS_INIT})
 endif()
 
-list(APPEND system_libs ${CMAKE_DL_LIBS})
-
 # Figure out if lldb could use lldb-server.  If so, then we'll
 # ensure we build lldb-server when an lldb target is being built.
 if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|Windows")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] ce19664 - [lldb/Driver] Print snippet before exiting with unknown argument.

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T12:35:02-07:00
New Revision: ce19664d94b7dacc7291e947b19f5ccab0bba981

URL: 
https://github.com/llvm/llvm-project/commit/ce19664d94b7dacc7291e947b19f5ccab0bba981
DIFF: 
https://github.com/llvm/llvm-project/commit/ce19664d94b7dacc7291e947b19f5ccab0bba981.diff

LOG: [lldb/Driver] Print snippet before exiting with unknown argument.

Print a little snippet before exiting when passed unrecognized
arguments. The goal is twofold:

 - Point users to lldb --help.
 - Make it clear that we exited the debugger.

Added: 


Modified: 
lldb/test/Shell/Driver/TestPositionalArgs.test
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/test/Shell/Driver/TestPositionalArgs.test 
b/lldb/test/Shell/Driver/TestPositionalArgs.test
index c821d668ea07..8072029ef2eb 100644
--- a/lldb/test/Shell/Driver/TestPositionalArgs.test
+++ b/lldb/test/Shell/Driver/TestPositionalArgs.test
@@ -28,3 +28,4 @@ RUN: not %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | 
FileCheck %s --check-prefi
 
 UNKNOWN: error: unknown option: -baz
 UNKNOWN: error: unknown option: --quux
+UNKNOWN: Use 'lldb --help' for a complete list of options.

diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 4e3ea7e4c015..1e639e9a1dea 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -850,9 +850,10 @@ int main(int argc, char const *argv[]) {
   unsigned MAC;
   ArrayRef arg_arr = makeArrayRef(argv + 1, argc - 1);
   opt::InputArgList input_args = T.ParseArgs(arg_arr, MAI, MAC);
+  llvm::StringRef argv0 = llvm::sys::path::filename(argv[0]);
 
   if (input_args.hasArg(OPT_help)) {
-printHelp(T, llvm::sys::path::filename(argv[0]));
+printHelp(T, argv0);
 return 0;
   }
 
@@ -861,6 +862,8 @@ int main(int argc, char const *argv[]) {
 for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
   WithColor::error() << "unknown option: " << arg->getSpelling() << '\n';
 }
+llvm::errs() << "Use '" << argv0
+ << " --help' for a complete list of options.\n";
 return 1;
   }
 



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


[Lldb-commits] [lldb] 04daba9 - [lldb] Cleans up system_libs

2020-05-20 Thread Haibo Huang via lldb-commits

Author: Haibo Huang
Date: 2020-05-20T12:30:08-07:00
New Revision: 04daba967031b7e3a72935613f23cb0051b56fc8

URL: 
https://github.com/llvm/llvm-project/commit/04daba967031b7e3a72935613f23cb0051b56fc8
DIFF: 
https://github.com/llvm/llvm-project/commit/04daba967031b7e3a72935613f23cb0051b56fc8.diff

LOG: [lldb] Cleans up system_libs

Summary:
Long long ago system_libs was appended to LLDB_SYSTEM_LIBS in
cmake/LLDBDependencies.cmake. After that file was removed, system_libs
is orphaned.

Currently the only user is source/Utility. Move the logic there and
remove system_libs.

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/source/Utility/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index c63e5316ccfc..8465cfe3b7b7 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -234,7 +234,6 @@ if (LLDB_ENABLE_LZMA)
 endif()
 
 if (LLDB_ENABLE_LIBXML2)
-  list(APPEND system_libs ${LIBXML2_LIBRARIES})
   include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
@@ -280,12 +279,7 @@ if (APPLE)
   find_library(FOUNDATION_LIBRARY Foundation)
   find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
   find_library(SECURITY_LIBRARY Security)
-  list(APPEND system_libs
-   ${FOUNDATION_LIBRARY}
-   ${CORE_FOUNDATION_LIBRARY}
-   ${CORE_SERVICES_LIBRARY}
-   ${SECURITY_LIBRARY}
-   ${DEBUG_SYMBOLS_LIBRARY})
+  include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
 if( WIN32 AND NOT CYGWIN )
@@ -295,11 +289,8 @@ endif()
 if(NOT PURE_WINDOWS)
   set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
   find_package(Threads REQUIRED)
-  list(APPEND system_libs ${CMAKE_THREAD_LIBS_INIT})
 endif()
 
-list(APPEND system_libs ${CMAKE_DL_LIBS})
-
 # Figure out if lldb could use lldb-server.  If so, then we'll
 # ensure we build lldb-server when an lldb target is being built.
 if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD|Windows")

diff  --git a/lldb/source/Utility/CMakeLists.txt 
b/lldb/source/Utility/CMakeLists.txt
index 48456ef1e3b1..c89d4f9e0072 100644
--- a/lldb/source/Utility/CMakeLists.txt
+++ b/lldb/source/Utility/CMakeLists.txt
@@ -1,6 +1,19 @@
 set(LLDB_SYSTEM_LIBS)
 
-list(APPEND LLDB_SYSTEM_LIBS ${system_libs})
+if (APPLE)
+  list(APPEND LLDB_SYSTEM_LIBS
+   ${FOUNDATION_LIBRARY}
+   ${CORE_FOUNDATION_LIBRARY}
+   ${CORE_SERVICES_LIBRARY}
+   ${SECURITY_LIBRARY}
+   ${DEBUG_SYMBOLS_LIBRARY})
+endif()
+
+if(NOT PURE_WINDOWS)
+  list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+list(APPEND LLDB_SYSTEM_LIBS ${CMAKE_DL_LIBS})
 
 if (CMAKE_SYSTEM_NAME MATCHES "Windows")
   list(APPEND LLDB_SYSTEM_LIBS ws2_32 rpcrt4)



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


[Lldb-commits] [lldb] 780d7d7 - [lldb] Allows customizing libxml2 for darwin

2020-05-20 Thread Haibo Huang via lldb-commits

Author: Haibo Huang
Date: 2020-05-20T12:27:08-07:00
New Revision: 780d7d77327c3537cc2c2aa9314aa2ad92cfe070

URL: 
https://github.com/llvm/llvm-project/commit/780d7d77327c3537cc2c2aa9314aa2ad92cfe070
DIFF: 
https://github.com/llvm/llvm-project/commit/780d7d77327c3537cc2c2aa9314aa2ad92cfe070.diff

LOG: [lldb] Allows customizing libxml2 for darwin

Summary:
This changes allows to disable or use customized libxml2 for lldb.

1. Removes redundant include_directories. The one in LLDBConfig.cmake should be 
enough.

2. Link to ${LIBXML2_LIBRARIES} if xml2 is enabled.

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/source/Host/CMakeLists.txt
lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 6b10f73eff19..c63e5316ccfc 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -286,7 +286,6 @@ if (APPLE)
${CORE_SERVICES_LIBRARY}
${SECURITY_LIBRARY}
${DEBUG_SYMBOLS_LIBRARY})
-  include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
 if( WIN32 AND NOT CYGWIN )

diff  --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index a5e4e352d036..add503a5f36a 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -83,7 +83,6 @@ else()
 )
 
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
 add_subdirectory(macosx/objcxx)
 set(LLDBObjCLibs lldbHostMacOSXObjCXX)
 add_host_subdirectory(macosx
@@ -137,14 +136,10 @@ endif()
 set(EXTRA_LIBS)
 if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND EXTRA_LIBS kvm)
-endif ()
-if (APPLE)
-  list(APPEND EXTRA_LIBS xml2)
-else ()
-  if (LIBXML2_FOUND)
-list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
-  endif()
-endif ()
+endif()
+if (LLDB_ENABLE_LIBXML2)
+  list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
+endif()
 if (HAVE_LIBDL)
   list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
 endif()
@@ -156,7 +151,7 @@ if (LLDB_ENABLE_LZMA)
 endif()
 if (WIN32)
   list(APPEND LLDB_SYSTEM_LIBS psapi)
-endif ()
+endif()
 
 if (LLDB_ENABLE_LIBEDIT)
   list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES})

diff  --git a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt 
b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
index d5a84d87fcd9..447079712056 100644
--- a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -25,7 +25,6 @@ list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  include_directories(${LIBXML2_INCLUDE_DIR})
   add_subdirectory(objcxx)
   set(OBJC_LIBS "lldbPluginPlatformMacOSXObjCXX")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES

diff  --git a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt 
b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
index 477f224b940d..448d032b381f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -6,10 +6,6 @@ lldb_tablegen(ProcessGDBRemotePropertiesEnum.inc 
-gen-lldb-property-enum-defs
   SOURCE ProcessGDBRemoteProperties.td
   TARGET LLDBPluginProcessGDBRemotePropertiesEnumGen)
 
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  include_directories(${LIBXML2_INCLUDE_DIR})
-endif()
-
 set(LLDB_PLUGINS
   lldbPluginProcessUtility
   lldbPluginPlatformMacOSX

diff  --git a/lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt 
b/lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
index 8e82eae1513d..2cf185131238 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
@@ -1,5 +1,3 @@
-include_directories(${LIBXML2_INCLUDE_DIR})
-
 add_lldb_library(lldbPluginSymbolVendorMacOSX PLUGIN
   SymbolVendorMacOSX.cpp
 



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


[Lldb-commits] [PATCH] D80312: [lldb/Reproducers] Make SBStream::Print a first-class API instead of a SWIG extension

2020-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfb278372633: [lldb/Reproducers] Make SBStream::Print an API 
instead of a SWIG extension (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80312

Files:
  lldb/bindings/interface/SBStream.i
  lldb/include/lldb/API/SBStream.h
  lldb/source/API/SBStream.cpp


Index: lldb/source/API/SBStream.cpp
===
--- lldb/source/API/SBStream.cpp
+++ lldb/source/API/SBStream.cpp
@@ -60,6 +60,12 @@
   return static_cast(m_opaque_up.get())->GetSize();
 }
 
+void SBStream::Print(const char *str) {
+  LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str);
+
+  Printf("%s", str);
+}
+
 void SBStream::Printf(const char *format, ...) {
   if (!format)
 return;
@@ -204,6 +210,7 @@
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
   LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+  LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));
 }
 
 }
Index: lldb/include/lldb/API/SBStream.h
===
--- lldb/include/lldb/API/SBStream.h
+++ lldb/include/lldb/API/SBStream.h
@@ -37,6 +37,8 @@
 
   void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
 
+  void Print(const char *str);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);
Index: lldb/bindings/interface/SBStream.i
===
--- lldb/bindings/interface/SBStream.i
+++ lldb/bindings/interface/SBStream.i
@@ -62,14 +62,8 @@
 size_t
 GetSize();
 
-// wrapping the variadic Printf() with a plain Print()
-// because it is hard to support varargs in SWIG bridgings
-%extend {
-void Print (const char* str)
-{
-self->Printf("%s", str);
-}
-}
+void
+Print (const char* str);
 
 void
 RedirectToFile (const char *path, bool append);


Index: lldb/source/API/SBStream.cpp
===
--- lldb/source/API/SBStream.cpp
+++ lldb/source/API/SBStream.cpp
@@ -60,6 +60,12 @@
   return static_cast(m_opaque_up.get())->GetSize();
 }
 
+void SBStream::Print(const char *str) {
+  LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str);
+
+  Printf("%s", str);
+}
+
 void SBStream::Printf(const char *format, ...) {
   if (!format)
 return;
@@ -204,6 +210,7 @@
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
   LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+  LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));
 }
 
 }
Index: lldb/include/lldb/API/SBStream.h
===
--- lldb/include/lldb/API/SBStream.h
+++ lldb/include/lldb/API/SBStream.h
@@ -37,6 +37,8 @@
 
   void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
 
+  void Print(const char *str);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);
Index: lldb/bindings/interface/SBStream.i
===
--- lldb/bindings/interface/SBStream.i
+++ lldb/bindings/interface/SBStream.i
@@ -62,14 +62,8 @@
 size_t
 GetSize();
 
-// wrapping the variadic Printf() with a plain Print()
-// because it is hard to support varargs in SWIG bridgings
-%extend {
-void Print (const char* str)
-{
-self->Printf("%s", str);
-}
-}
+void
+Print (const char* str);
 
 void
 RedirectToFile (const char *path, bool append);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D80165: [lldb/Driver] Fix handling on positional arguments

2020-05-20 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

In D80165#2045882 , @labath wrote:

> In D80165#2044509 , @jingham wrote:
>
> > We should make sure if we do exit that we don't output any other text that 
> > would obscure the error message.  It should be easy to spot the error both 
> > so you can easily fix it and to prevent you from typing lldb commands into 
> > your shell.  If libOption had a "nearest option name to the one you typed" 
> > facility that would be useful in this case as well.
>
>
> That facility exists. Clang uses it for command-line "fix-its". I am not sure 
> what it takes to make use of it.


Jonas said this wasn't part of libOption, but was done by hand in clang.

> 
> 
>> Does anybody remember what gdb does when you mistype a command-line option?  
>> We're not at all required to model their behavior, but it would be 
>> interesting to consider.
> 
>   $ gdb -foobar
>   gdb: unrecognized option '-foobar'
>   Use `gdb --help' for a complete list of options.

You omitted the bit of text that would show whether it quit or not...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80165



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


[Lldb-commits] [PATCH] D80312: [lldb/Reproducers] Make SBStream::Print a first-class API instead of a SWIG extension

2020-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor.
teemperor accepted this revision.
This revision is now accepted and ready to land.

This makes it possible to instrument the call for the reproducers. This fixes 
TestStructuredDataAPI.py with reproducer replay.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D80312

Files:
  lldb/bindings/interface/SBStream.i
  lldb/include/lldb/API/SBStream.h
  lldb/source/API/SBStream.cpp


Index: lldb/source/API/SBStream.cpp
===
--- lldb/source/API/SBStream.cpp
+++ lldb/source/API/SBStream.cpp
@@ -60,6 +60,12 @@
   return static_cast(m_opaque_up.get())->GetSize();
 }
 
+void SBStream::Print(const char *str) {
+  LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str);
+
+  Printf("%s", str);
+}
+
 void SBStream::Printf(const char *format, ...) {
   if (!format)
 return;
@@ -204,6 +210,7 @@
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
   LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+  LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));
 }
 
 }
Index: lldb/include/lldb/API/SBStream.h
===
--- lldb/include/lldb/API/SBStream.h
+++ lldb/include/lldb/API/SBStream.h
@@ -37,6 +37,8 @@
 
   void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
 
+  void Print(const char *str);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);
Index: lldb/bindings/interface/SBStream.i
===
--- lldb/bindings/interface/SBStream.i
+++ lldb/bindings/interface/SBStream.i
@@ -62,14 +62,8 @@
 size_t
 GetSize();
 
-// wrapping the variadic Printf() with a plain Print()
-// because it is hard to support varargs in SWIG bridgings
-%extend {
-void Print (const char* str)
-{
-self->Printf("%s", str);
-}
-}
+void
+Print (const char* str);
 
 void
 RedirectToFile (const char *path, bool append);


Index: lldb/source/API/SBStream.cpp
===
--- lldb/source/API/SBStream.cpp
+++ lldb/source/API/SBStream.cpp
@@ -60,6 +60,12 @@
   return static_cast(m_opaque_up.get())->GetSize();
 }
 
+void SBStream::Print(const char *str) {
+  LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str);
+
+  Printf("%s", str);
+}
+
 void SBStream::Printf(const char *format, ...) {
   if (!format)
 return;
@@ -204,6 +210,7 @@
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
   LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+  LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));
 }
 
 }
Index: lldb/include/lldb/API/SBStream.h
===
--- lldb/include/lldb/API/SBStream.h
+++ lldb/include/lldb/API/SBStream.h
@@ -37,6 +37,8 @@
 
   void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
 
+  void Print(const char *str);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);
Index: lldb/bindings/interface/SBStream.i
===
--- lldb/bindings/interface/SBStream.i
+++ lldb/bindings/interface/SBStream.i
@@ -62,14 +62,8 @@
 size_t
 GetSize();
 
-// wrapping the variadic Printf() with a plain Print()
-// because it is hard to support varargs in SWIG bridgings
-%extend {
-void Print (const char* str)
-{
-self->Printf("%s", str);
-}
-}
+void
+Print (const char* str);
 
 void
 RedirectToFile (const char *path, bool append);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] bfb2783 - [lldb/Reproducers] Make SBStream::Print an API instead of a SWIG extension

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T10:37:18-07:00
New Revision: bfb278372633c50ae595f0b89241a143090c967e

URL: 
https://github.com/llvm/llvm-project/commit/bfb278372633c50ae595f0b89241a143090c967e
DIFF: 
https://github.com/llvm/llvm-project/commit/bfb278372633c50ae595f0b89241a143090c967e.diff

LOG: [lldb/Reproducers] Make SBStream::Print an API instead of a SWIG extension

This makes it possible to instrument the call for the reproducers. This
fixes TestStructuredDataAPI.py with reproducer replay.

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

Added: 


Modified: 
lldb/bindings/interface/SBStream.i
lldb/include/lldb/API/SBStream.h
lldb/source/API/SBStream.cpp

Removed: 




diff  --git a/lldb/bindings/interface/SBStream.i 
b/lldb/bindings/interface/SBStream.i
index 31fb3802bf62..edd67f87c3fb 100644
--- a/lldb/bindings/interface/SBStream.i
+++ b/lldb/bindings/interface/SBStream.i
@@ -62,14 +62,8 @@ public:
 size_t
 GetSize();
 
-// wrapping the variadic Printf() with a plain Print()
-// because it is hard to support varargs in SWIG bridgings
-%extend {
-void Print (const char* str)
-{
-self->Printf("%s", str);
-}
-}
+void
+Print (const char* str);
 
 void
 RedirectToFile (const char *path, bool append);

diff  --git a/lldb/include/lldb/API/SBStream.h 
b/lldb/include/lldb/API/SBStream.h
index 7f0ec49b81c5..6b3753d45aa2 100644
--- a/lldb/include/lldb/API/SBStream.h
+++ b/lldb/include/lldb/API/SBStream.h
@@ -37,6 +37,8 @@ class LLDB_API SBStream {
 
   void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
 
+  void Print(const char *str);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);

diff  --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp
index 5d77410434a2..0f49c5111f28 100644
--- a/lldb/source/API/SBStream.cpp
+++ b/lldb/source/API/SBStream.cpp
@@ -60,6 +60,12 @@ size_t SBStream::GetSize() {
   return static_cast(m_opaque_up.get())->GetSize();
 }
 
+void SBStream::Print(const char *str) {
+  LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str);
+
+  Printf("%s", str);
+}
+
 void SBStream::Printf(const char *format, ...) {
   if (!format)
 return;
@@ -204,6 +210,7 @@ void RegisterMethods(Registry ) {
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
   LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
   LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+  LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));
 }
 
 }



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


[Lldb-commits] [lldb] 4b17702 - [lldb/Reproducers] Skip another test that uses lldb::FileSP under the hood

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T09:49:29-07:00
New Revision: 4b17702434af9631e5e5a16449a93c9734be0c7e

URL: 
https://github.com/llvm/llvm-project/commit/4b17702434af9631e5e5a16449a93c9734be0c7e
DIFF: 
https://github.com/llvm/llvm-project/commit/4b17702434af9631e5e5a16449a93c9734be0c7e.diff

LOG: [lldb/Reproducers] Skip another test that uses lldb::FileSP under the hood

Added: 


Modified: 

lldb/test/API/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py

Removed: 




diff  --git 
a/lldb/test/API/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
 
b/lldb/test/API/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
index 09f44f554118..65c4dac48490 100644
--- 
a/lldb/test/API/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
+++ 
b/lldb/test/API/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
@@ -114,6 +114,7 @@ def test_SBCompileUnit(self):
 sb_compileunit.fuzz_obj(obj)
 
 @add_test_categories(['pyapi'])
+@skipIfReproducer # lldb::FileSP used in typemap cannot be instrumented.
 def test_SBDebugger(self):
 obj = lldb.SBDebugger()
 if self.TraceOn():
@@ -180,6 +181,7 @@ def test_SBFunction(self):
 sb_function.fuzz_obj(obj)
 
 @add_test_categories(['pyapi'])
+@skipIfReproducer # lldb::FileSP used in typemap cannot be instrumented.
 def test_SBFile(self):
 sbf = lldb.SBFile()
 self.assertFalse(sbf.IsValid())



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


[Lldb-commits] [PATCH] D80224: [lldb/Reproducers] Support reproducers for PlatformRemoteGDBServer

2020-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd57b80e13ebd: [lldb/Reproducers] Support reproducers for 
PlatformRemoteGDBServer (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80224

Files:
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h

Index: lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
===
--- lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -12,8 +12,9 @@
 
 #include 
 
-#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
 #include "Plugins/Process/Utility/GDBRemoteSignals.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h"
 #include "lldb/Target/Platform.h"
 
 namespace lldb_private {
@@ -164,6 +165,7 @@
 
 protected:
   process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client;
+  process_gdb_remote::GDBRemoteCommunicationReplayServer m_gdb_replay_server;
   std::string m_platform_description; // After we connect we can get a more
   // complete description of what we are
   // connected to
Index: lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
===
--- lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -288,40 +288,55 @@
"execute 'platform disconnect' to close the "
"current connection",
GetHostname());
+return error;
+  }
+
+  if (args.GetArgumentCount() != 1) {
+error.SetErrorString(
+"\"platform connect\" takes a single argument: ");
+return error;
+  }
+
+  const char *url = args.GetArgumentAtIndex(0);
+  if (!url)
+return Status("URL is null.");
+
+  int port;
+  llvm::StringRef scheme, hostname, pathname;
+  if (!UriParser::Parse(url, scheme, hostname, port, pathname))
+return Status("Invalid URL: %s", url);
+
+  // We're going to reuse the hostname when we connect to the debugserver.
+  m_platform_scheme = std::string(scheme);
+  m_platform_hostname = std::string(hostname);
+
+  m_gdb_client.SetConnection(std::make_unique());
+  if (repro::Reproducer::Instance().IsReplaying()) {
+error = m_gdb_replay_server.Connect(m_gdb_client);
+if (error.Success())
+  m_gdb_replay_server.StartAsyncThread();
   } else {
-if (args.GetArgumentCount() == 1) {
-  m_gdb_client.SetConnection(std::make_unique());
-  // we're going to reuse the hostname when we connect to the debugserver
-  int port;
-  std::string path;
-  const char *url = args.GetArgumentAtIndex(0);
-  if (!url)
-return Status("URL is null.");
-  llvm::StringRef scheme, hostname, pathname;
-  if (!UriParser::Parse(url, scheme, hostname, port, pathname))
-return Status("Invalid URL: %s", url);
-  m_platform_scheme = std::string(scheme);
-  m_platform_hostname = std::string(hostname);
-  path = std::string(pathname);
-
-  const ConnectionStatus status = m_gdb_client.Connect(url, );
-  if (status == eConnectionStatusSuccess) {
-if (m_gdb_client.HandshakeWithServer()) {
-  m_gdb_client.GetHostInfo();
-  // If a working directory was set prior to connecting, send it down
-  // now
-  if (m_working_dir)
-m_gdb_client.SetWorkingDir(m_working_dir);
-} else {
-  m_gdb_client.Disconnect();
-  if (error.Success())
-error.SetErrorString("handshake failed");
-}
-  }
-} else {
-  error.SetErrorString(
-  "\"platform connect\" takes a single argument: ");
+if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
+  repro::GDBRemoteProvider  =
+  g->GetOrCreate();
+  m_gdb_client.SetPacketRecorder(provider.GetNewPacketRecorder());
 }
+m_gdb_client.Connect(url, );
+  }
+
+  if (error.Fail())
+return error;
+
+  if (m_gdb_client.HandshakeWithServer()) {
+m_gdb_client.GetHostInfo();
+// If a working directory was set prior to connecting, send it down
+// now.
+if (m_working_dir)
+  m_gdb_client.SetWorkingDir(m_working_dir);
+  } else {
+m_gdb_client.Disconnect();
+if (error.Success())
+  error.SetErrorString("handshake failed");
   }
   return error;
 }
___
lldb-commits mailing list

[Lldb-commits] [PATCH] D80226: [lldb/Driver] Error out when encountering unknown arguments

2020-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b5b81bcdccb: [lldb/Driver] Error out when encountering 
unknown arguments (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80226

Files:
  lldb/test/Shell/Driver/TestPositionalArgs.test
  lldb/tools/driver/Driver.cpp


Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -856,9 +856,12 @@
 return 0;
   }
 
-  for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
-WithColor::warning() << "ignoring unknown option: " << arg->getSpelling()
- << '\n';
+  // Error out on unknown options.
+  if (input_args.hasArg(OPT_UNKNOWN)) {
+for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
+  WithColor::error() << "unknown option: " << arg->getSpelling() << '\n';
+}
+return 1;
   }
 
   if (auto exit_code = InitializeReproducer(input_args)) {
Index: lldb/test/Shell/Driver/TestPositionalArgs.test
===
--- lldb/test/Shell/Driver/TestPositionalArgs.test
+++ lldb/test/Shell/Driver/TestPositionalArgs.test
@@ -23,10 +23,8 @@
 DASH: Current executable set to {{.*}}foo
 DASH: target.run-args "bar" "-baz" "--quux"
 
-RUN: %lldb -x -b %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix 
UNKNOWN
-RUN: %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix 
UNKNOWN
+RUN: not %lldb -x -b %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix 
UNKNOWN
+RUN: not %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | FileCheck %s 
--check-prefix UNKNOWN
 
-UNKNOWN: warning: ignoring unknown option: -baz
-UNKNOWN: warning: ignoring unknown option: --quux
-UNKNOWN: Current executable set to {{.*}}foo
-UNKNOWN: target.run-args "bar"
+UNKNOWN: error: unknown option: -baz
+UNKNOWN: error: unknown option: --quux


Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -856,9 +856,12 @@
 return 0;
   }
 
-  for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
-WithColor::warning() << "ignoring unknown option: " << arg->getSpelling()
- << '\n';
+  // Error out on unknown options.
+  if (input_args.hasArg(OPT_UNKNOWN)) {
+for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
+  WithColor::error() << "unknown option: " << arg->getSpelling() << '\n';
+}
+return 1;
   }
 
   if (auto exit_code = InitializeReproducer(input_args)) {
Index: lldb/test/Shell/Driver/TestPositionalArgs.test
===
--- lldb/test/Shell/Driver/TestPositionalArgs.test
+++ lldb/test/Shell/Driver/TestPositionalArgs.test
@@ -23,10 +23,8 @@
 DASH: Current executable set to {{.*}}foo
 DASH: target.run-args "bar" "-baz" "--quux"
 
-RUN: %lldb -x -b %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix UNKNOWN
-RUN: %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix UNKNOWN
+RUN: not %lldb -x -b %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix UNKNOWN
+RUN: not %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix UNKNOWN
 
-UNKNOWN: warning: ignoring unknown option: -baz
-UNKNOWN: warning: ignoring unknown option: --quux
-UNKNOWN: Current executable set to {{.*}}foo
-UNKNOWN: target.run-args "bar"
+UNKNOWN: error: unknown option: -baz
+UNKNOWN: error: unknown option: --quux
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5b5b81b - [lldb/Driver] Error out when encountering unknown arguments

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T09:40:40-07:00
New Revision: 5b5b81bcdccb43164e86cfc6a0ac966afc3a143c

URL: 
https://github.com/llvm/llvm-project/commit/5b5b81bcdccb43164e86cfc6a0ac966afc3a143c
DIFF: 
https://github.com/llvm/llvm-project/commit/5b5b81bcdccb43164e86cfc6a0ac966afc3a143c.diff

LOG: [lldb/Driver] Error out when encountering unknown arguments

There appears to be consensus in D80165 that this is the desired
behavior and I personally agree.

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

Added: 


Modified: 
lldb/test/Shell/Driver/TestPositionalArgs.test
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/test/Shell/Driver/TestPositionalArgs.test 
b/lldb/test/Shell/Driver/TestPositionalArgs.test
index 1b6283aa0dbb..c821d668ea07 100644
--- a/lldb/test/Shell/Driver/TestPositionalArgs.test
+++ b/lldb/test/Shell/Driver/TestPositionalArgs.test
@@ -23,10 +23,8 @@ RUN: %lldb -x -b -f %t.foo -- bar -baz --quux | FileCheck %s 
--check-prefix DASH
 DASH: Current executable set to {{.*}}foo
 DASH: target.run-args "bar" "-baz" "--quux"
 
-RUN: %lldb -x -b %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix 
UNKNOWN
-RUN: %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix 
UNKNOWN
+RUN: not %lldb -x -b %t.foo bar -baz --quux 2>&1 | FileCheck %s --check-prefix 
UNKNOWN
+RUN: not %lldb -x -b -f %t.foo bar -baz --quux 2>&1 | FileCheck %s 
--check-prefix UNKNOWN
 
-UNKNOWN: warning: ignoring unknown option: -baz
-UNKNOWN: warning: ignoring unknown option: --quux
-UNKNOWN: Current executable set to {{.*}}foo
-UNKNOWN: target.run-args "bar"
+UNKNOWN: error: unknown option: -baz
+UNKNOWN: error: unknown option: --quux

diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 7b783ad9c3f4..4e3ea7e4c015 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -856,9 +856,12 @@ int main(int argc, char const *argv[]) {
 return 0;
   }
 
-  for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
-WithColor::warning() << "ignoring unknown option: " << arg->getSpelling()
- << '\n';
+  // Error out on unknown options.
+  if (input_args.hasArg(OPT_UNKNOWN)) {
+for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
+  WithColor::error() << "unknown option: " << arg->getSpelling() << '\n';
+}
+return 1;
   }
 
   if (auto exit_code = InitializeReproducer(input_args)) {



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


[Lldb-commits] [PATCH] D80130: [mlir][SystemZ] Fix incompatible datalayout in SystemZ

2020-05-20 Thread Haruki Imai via Phabricator via lldb-commits
imaihal updated this revision to Diff 264769.
imaihal added a comment.
Herald added subscribers: lldb-commits, kbarton, hiraditya, nemanjai.
Herald added a project: LLDB.

[mlir][SystemZ] Fix incompatible datalayout in SystemZ

MLIR tests in "mlir/test/mlir-cpu-runner" fails in SystemZ (z14) because
of incompatible datalayout error. This patch fixes it by setting host
CPU name in createTargetMachine()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80130

Files:
  lldb/docs/man/lldb.rst
  lldb/test/Shell/Driver/TestNoUseColor.test
  lldb/test/Shell/Driver/TestPositionalArgs.test
  lldb/tools/driver/Driver.cpp
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/PowerPC/PPCInstrInfo.h
  llvm/test/CodeGen/BPF/objdump_dis_all.ll
  mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
@@ -119,8 +120,16 @@
 errs() << "NO target: " << errorMessage << "\n";
 return true;
   }
-  std::unique_ptr machine(
-  target->createTargetMachine(targetTriple, "generic", "", {}, {}));
+  std::string cpu = std::string(llvm::sys::getHostCPUName());
+  llvm::SubtargetFeatures features;
+  llvm::StringMap hostFeatures;
+
+  if (llvm::sys::getHostCPUFeatures(hostFeatures))
+for (auto  : hostFeatures)
+  features.AddFeature(f.first(), f.second);
+
+  std::unique_ptr machine(target->createTargetMachine(
+  targetTriple, cpu, features.getString(), {}, {}));
   llvmModule->setDataLayout(machine->createDataLayout());
   llvmModule->setTargetTriple(targetTriple);
   return false;
Index: llvm/test/CodeGen/BPF/objdump_dis_all.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/objdump_dis_all.ll
@@ -0,0 +1,26 @@
+; RUN: llc -march=bpfel -filetype=obj -o - %s | llvm-objdump -D - | FileCheck %s
+;
+; Source:
+;   /* *(u64 *)(r10 - 16) = r1 */
+;   unsigned long long g = 0xfff01a7bULL;
+;   /* *(u64 *)(r15 - 16) = r1 */
+;   unsigned long long h = 0xfff01f7bULL;
+;   int test() {
+; return 0;
+;   }
+; Compilation flag:
+;  clang -target bpf -O2 -S -emit-llvm t.c
+
+@g = dso_local local_unnamed_addr global i64 4293925499, align 8
+@h = dso_local local_unnamed_addr global i64 4293926779, align 8
+
+; Function Attrs: norecurse nounwind readnone
+define dso_local i32 @test() local_unnamed_addr {
+entry:
+  ret i32 0
+}
+; CHECK-LABEL: section .data
+; CHECK-LABEL: g
+; CHECK:   *(u64 *)(r10 - 16) = r1
+; CHECK-LABEL: h
+; CHECK:   
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.h
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.h
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.h
@@ -252,6 +252,8 @@
  MachineInstr ,
  MachineInstr ) const override;
 
+  void setSpecialOperandAttr(MachineInstr , uint16_t Flags) const override;
+
   bool isCoalescableExtInstr(const MachineInstr ,
  Register , Register ,
  unsigned ) const override;
Index: llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
===
--- llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
+++ llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
@@ -183,6 +183,14 @@
 
   if (Result == MCDisassembler::Fail) return MCDisassembler::Fail;
 
+  /* to ensure registers in range */
+  for (unsigned i = 0, e = Instr.getNumOperands(); i != e; ++i) {
+const MCOperand  = Instr.getOperand(i);
+if (MO.isReg() &&
+(MO.getReg() <= BPF::NoRegister || MO.getReg() >= BPF::NUM_TARGET_REGS))
+  return MCDisassembler::Fail;
+  }
+
   switch (Instr.getOpcode()) {
   case BPF::LD_imm64:
   case BPF::LD_pseudo: {
Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -361,13 +361,8 @@
   if (m_option_data.m_process_name.empty() &&
   m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID) {
 
-// If the option data args array is empty that means the file was not
-// specified with -f and we need to get it from the input args.
-if (m_option_data.m_args.empty()) {
-  if (auto *arg = args.getLastArgNoClaim(OPT_INPUT)) {
-m_option_data.m_args.push_back(arg->getAsString((args)));
-  }
-}
+for (auto 

[Lldb-commits] [PATCH] D80130: [mlir][SystemZ] Fix incompatible datalayout in SystemZ

2020-05-20 Thread Haruki Imai via Phabricator via lldb-commits
imaihal marked an inline comment as done.
imaihal added a comment.

Thanks for the review! I changed the variable name to `camelBack`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80130



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


[Lldb-commits] [PATCH] D80130: [mlir][SystemZ] Fix incompatible datalayout in SystemZ

2020-05-20 Thread Haruki Imai via Phabricator via lldb-commits
imaihal added a comment.

My wrong operation(submission) may add LLDB tag on this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80130



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


[Lldb-commits] [PATCH] D80130: [mlir][SystemZ] Fix incompatible datalayout in SystemZ

2020-05-20 Thread Haruki Imai via Phabricator via lldb-commits
imaihal updated this revision to Diff 264770.
imaihal added a comment.

- [NFC] Replace MaybeAlign with Align in TargetTransformInfo.
- [mlir][SystemZ] Fix incompatible datalayout in SystemZ


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80130

Files:
  mlir/lib/ExecutionEngine/ExecutionEngine.cpp


Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
@@ -119,8 +120,16 @@
 errs() << "NO target: " << errorMessage << "\n";
 return true;
   }
-  std::unique_ptr machine(
-  target->createTargetMachine(targetTriple, "generic", "", {}, {}));
+  std::string cpu = std::string(llvm::sys::getHostCPUName());
+  llvm::SubtargetFeatures features;
+  llvm::StringMap hostFeatures;
+
+  if (llvm::sys::getHostCPUFeatures(hostFeatures))
+for (auto  : hostFeatures)
+  features.AddFeature(f.first(), f.second);
+
+  std::unique_ptr machine(target->createTargetMachine(
+  targetTriple, cpu, features.getString(), {}, {}));
   llvmModule->setDataLayout(machine->createDataLayout());
   llvmModule->setTargetTriple(targetTriple);
   return false;


Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
@@ -119,8 +120,16 @@
 errs() << "NO target: " << errorMessage << "\n";
 return true;
   }
-  std::unique_ptr machine(
-  target->createTargetMachine(targetTriple, "generic", "", {}, {}));
+  std::string cpu = std::string(llvm::sys::getHostCPUName());
+  llvm::SubtargetFeatures features;
+  llvm::StringMap hostFeatures;
+
+  if (llvm::sys::getHostCPUFeatures(hostFeatures))
+for (auto  : hostFeatures)
+  features.AddFeature(f.first(), f.second);
+
+  std::unique_ptr machine(target->createTargetMachine(
+  targetTriple, cpu, features.getString(), {}, {}));
   llvmModule->setDataLayout(machine->createDataLayout());
   llvmModule->setTargetTriple(targetTriple);
   return false;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D80130: [mlir][SystemZ] Fix incompatible datalayout in SystemZ

2020-05-20 Thread Mehdi AMINI via Phabricator via lldb-commits
mehdi_amini accepted this revision.
mehdi_amini added inline comments.



Comment at: mlir/lib/ExecutionEngine/ExecutionEngine.cpp:123
   }
-  std::unique_ptr machine(
-  target->createTargetMachine(targetTriple, "generic", "", {}, {}));
+  std::string cpu = std::string(llvm::sys::getHostCPUName());
+  llvm::SubtargetFeatures features;

You should be able to write just `std::string cpu = 
llvm::sys::getHostCPUName();`? (Or `std::string 
cpu(llvm::sys::getHostCPUName());`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80130



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


Re: [Lldb-commits] [PATCH] D80150: [lldb/DataFormatter] Check for overflow when finding NSDate epoch

2020-05-20 Thread Eric Christopher via lldb-commits
Agreed. Something is off here. My change was only to silence a few
warnings, but they're definitely highlighting a conversion issue. What's up
with NSDate conversions here. Does the API have a way to convert from
time_t?

On Wed, May 20, 2020, 2:07 AM Pavel Labath via Phabricator via lldb-commits
 wrote:

> labath added a comment.
>
> In D80150#2045364 , @vsk wrote:
>
> > @labath Agreed on all points, I've addressed the feedback in 82dbf4aca84
>  by
> moving "DataFormatters/Mock.h" to "Plugins/Language/ObjC/Utilities.h", and
> adding a separate LanguageObjCTests unit test.
>
>
> Cool. Thanks.
>
>
>
> 
> Comment at: lldb/unittests/DataFormatter/MockTests.cpp:30
> +  // Can't convert the date_value to a time_t.
> +  EXPECT_EQ(formatDateValue(std::numeric_limits::max() + 1),
> +llvm::None);
> 
> vsk wrote:
> > labath wrote:
> > > Isn't this actually `std::numeric_limits::min()` (and UB due
> to singed wraparound) ? Did you want to convert to double before doing the
> `+1` ?
> > Yes, thank you! It looks like Eric caught this before I did.
> Actually, thinking about that further, (for 64-bit `time_t`s),
> `double(numeric_limits::max())` is [[ https://godbolt.org/z/t3iSd7
> | exactly the same value ]] as `double(numeric_limits::max())+1.0`
> because `double` doesn't have enough bits to represent the value precisely.
> So, I have a feeling these checks are still not testing the exact thing you
> want to test (though I'm not sure what that is exactly).
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D80150/new/
>
> https://reviews.llvm.org/D80150
>
>
>
> ___
> 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] d57b80e - [lldb/Reproducers] Support reproducers for PlatformRemoteGDBServer

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T09:18:57-07:00
New Revision: d57b80e13ebd140f0b9acefa02423e1bc4a835d4

URL: 
https://github.com/llvm/llvm-project/commit/d57b80e13ebd140f0b9acefa02423e1bc4a835d4
DIFF: 
https://github.com/llvm/llvm-project/commit/d57b80e13ebd140f0b9acefa02423e1bc4a835d4.diff

LOG: [lldb/Reproducers] Support reproducers for PlatformRemoteGDBServer

Add reproducer support to PlatformRemoteGDBServer. The logic is
essentially the same as for ProcessGDBRemote. During capture we record
the GDB packets and during replay we connect to a replay server.

This fixes TestPlatformClient.py when run form a reproducer.

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

Added: 


Modified: 
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 657b8fdc729a..18631a0c5315 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -288,40 +288,55 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args ) 
{
"execute 'platform disconnect' to close the 
"
"current connection",
GetHostname());
+return error;
+  }
+
+  if (args.GetArgumentCount() != 1) {
+error.SetErrorString(
+"\"platform connect\" takes a single argument: ");
+return error;
+  }
+
+  const char *url = args.GetArgumentAtIndex(0);
+  if (!url)
+return Status("URL is null.");
+
+  int port;
+  llvm::StringRef scheme, hostname, pathname;
+  if (!UriParser::Parse(url, scheme, hostname, port, pathname))
+return Status("Invalid URL: %s", url);
+
+  // We're going to reuse the hostname when we connect to the debugserver.
+  m_platform_scheme = std::string(scheme);
+  m_platform_hostname = std::string(hostname);
+
+  m_gdb_client.SetConnection(std::make_unique());
+  if (repro::Reproducer::Instance().IsReplaying()) {
+error = m_gdb_replay_server.Connect(m_gdb_client);
+if (error.Success())
+  m_gdb_replay_server.StartAsyncThread();
   } else {
-if (args.GetArgumentCount() == 1) {
-  m_gdb_client.SetConnection(std::make_unique());
-  // we're going to reuse the hostname when we connect to the debugserver
-  int port;
-  std::string path;
-  const char *url = args.GetArgumentAtIndex(0);
-  if (!url)
-return Status("URL is null.");
-  llvm::StringRef scheme, hostname, pathname;
-  if (!UriParser::Parse(url, scheme, hostname, port, pathname))
-return Status("Invalid URL: %s", url);
-  m_platform_scheme = std::string(scheme);
-  m_platform_hostname = std::string(hostname);
-  path = std::string(pathname);
-
-  const ConnectionStatus status = m_gdb_client.Connect(url, );
-  if (status == eConnectionStatusSuccess) {
-if (m_gdb_client.HandshakeWithServer()) {
-  m_gdb_client.GetHostInfo();
-  // If a working directory was set prior to connecting, send it down
-  // now
-  if (m_working_dir)
-m_gdb_client.SetWorkingDir(m_working_dir);
-} else {
-  m_gdb_client.Disconnect();
-  if (error.Success())
-error.SetErrorString("handshake failed");
-}
-  }
-} else {
-  error.SetErrorString(
-  "\"platform connect\" takes a single argument: ");
+if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
+  repro::GDBRemoteProvider  =
+  g->GetOrCreate();
+  m_gdb_client.SetPacketRecorder(provider.GetNewPacketRecorder());
 }
+m_gdb_client.Connect(url, );
+  }
+
+  if (error.Fail())
+return error;
+
+  if (m_gdb_client.HandshakeWithServer()) {
+m_gdb_client.GetHostInfo();
+// If a working directory was set prior to connecting, send it down
+// now.
+if (m_working_dir)
+  m_gdb_client.SetWorkingDir(m_working_dir);
+  } else {
+m_gdb_client.Disconnect();
+if (error.Success())
+  error.SetErrorString("handshake failed");
   }
   return error;
 }

diff  --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h 
b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index ee195d90ee3b..b06eafacc802 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -12,8 +12,9 @@
 
 #include 
 
-#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
 #include "Plugins/Process/Utility/GDBRemoteSignals.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include 

[Lldb-commits] [PATCH] D80257: [lldb] Allows customizing libxml2 for darwin

2020-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80257



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


[Lldb-commits] [lldb] 667be33 - [lldb/Reproducers] Update macosx remote tests for passive replay

2020-05-20 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-20T09:03:16-07:00
New Revision: 667be3319d9eff4fbcf1cb1714a1205e84c9b848

URL: 
https://github.com/llvm/llvm-project/commit/667be3319d9eff4fbcf1cb1714a1205e84c9b848
DIFF: 
https://github.com/llvm/llvm-project/commit/667be3319d9eff4fbcf1cb1714a1205e84c9b848.diff

LOG: [lldb/Reproducers] Update macosx remote tests for passive replay

Skip tests or part thereof that are not supposed to work with replay.

Added: 


Modified: 
lldb/test/API/macosx/dyld-trie-symbols/TestDyldTrieSymbols.py
lldb/test/API/macosx/function-starts/TestFunctionStarts.py
lldb/test/API/macosx/profile_vrs_detach/TestDetachVrsProfile.py
lldb/test/API/macosx/thread-names/TestInterruptThreadNames.py

Removed: 




diff  --git a/lldb/test/API/macosx/dyld-trie-symbols/TestDyldTrieSymbols.py 
b/lldb/test/API/macosx/dyld-trie-symbols/TestDyldTrieSymbols.py
index 6b7f12ede35f..d4073a9ed02d 100644
--- a/lldb/test/API/macosx/dyld-trie-symbols/TestDyldTrieSymbols.py
+++ b/lldb/test/API/macosx/dyld-trie-symbols/TestDyldTrieSymbols.py
@@ -15,7 +15,7 @@ class DyldTrieSymbolsTestCase(TestBase):
 
 @skipIfRemote
 @skipUnlessDarwin
-
+
 def test_dyld_trie_symbols(self):
 """Test that we make create symbol table entries from the dyld trie 
data structure."""
 self.build()
@@ -89,20 +89,24 @@ def test_dyld_trie_symbols(self):
 # stripped off the objc prefix from the symbol names.
 syms_ctx = stripped_target.FindSymbols("SourceBase")
 self.assertEqual(syms_ctx.GetSize(), 2)
-sym1 = syms_ctx.GetContextAtIndex(0).GetSymbol()
-sym2 = syms_ctx.GetContextAtIndex(1).GetSymbol()
-
-# one of these should be a lldb.eSymbolTypeObjCClass, the other
-# should be lldb.eSymbolTypeObjCMetaClass.
-if sym1.GetType() == lldb.eSymbolTypeObjCMetaClass:
-self.assertEqual(sym2.GetType(), lldb.eSymbolTypeObjCClass)
-else:
-if sym1.GetType() == lldb.eSymbolTypeObjCClass:
-self.assertEqual(sym2.GetType(), lldb.eSymbolTypeObjCMetaClass)
-else:
-self.assertTrue(sym1.GetType() == 
lldb.eSymbolTypeObjCMetaClass or sym1.GetType() == lldb.eSymbolTypeObjCClass)
 
-syms_ctx = stripped_target.FindSymbols("SourceDerived._derivedValue")
-self.assertEqual(syms_ctx.GetSize(), 1)
-sym = syms_ctx.GetContextAtIndex(0).GetSymbol()
-self.assertEqual(sym.GetType(), lldb.eSymbolTypeObjCIVar)
+# The next part if not deterministic and potentially causes replay to
+# fail when the order is 
diff erent during capture and replay.
+if not configuration.is_reproducer():
+sym1 = syms_ctx.GetContextAtIndex(0).GetSymbol()
+sym2 = syms_ctx.GetContextAtIndex(1).GetSymbol()
+
+# one of these should be a lldb.eSymbolTypeObjCClass, the other
+# should be lldb.eSymbolTypeObjCMetaClass.
+if sym1.GetType() == lldb.eSymbolTypeObjCMetaClass:
+self.assertEqual(sym2.GetType(), lldb.eSymbolTypeObjCClass)
+else:
+if sym1.GetType() == lldb.eSymbolTypeObjCClass:
+self.assertEqual(sym2.GetType(), 
lldb.eSymbolTypeObjCMetaClass)
+else:
+self.assertTrue(sym1.GetType() == 
lldb.eSymbolTypeObjCMetaClass or sym1.GetType() == lldb.eSymbolTypeObjCClass)
+
+syms_ctx = 
stripped_target.FindSymbols("SourceDerived._derivedValue")
+self.assertEqual(syms_ctx.GetSize(), 1)
+sym = syms_ctx.GetContextAtIndex(0).GetSymbol()
+self.assertEqual(sym.GetType(), lldb.eSymbolTypeObjCIVar)

diff  --git a/lldb/test/API/macosx/function-starts/TestFunctionStarts.py 
b/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
index e876cdf8b5da..141f4e70930a 100644
--- a/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
+++ b/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
@@ -19,6 +19,7 @@ class FunctionStartsTestCase(TestBase):
 
 @skipIfRemote
 @skipUnlessDarwin
+@skipIfReproducer # File synchronization is not supported during replay.
 def test_function_starts_binary(self):
 """Test that we make synthetic symbols when we have the binary."""
 self.build()
@@ -26,13 +27,14 @@ def test_function_starts_binary(self):
 
 @skipIfRemote
 @skipUnlessDarwin
+@skipIfReproducer # File synchronization is not supported during replay.
 def test_function_starts_no_binary(self):
 """Test that we make synthetic symbols when we don't have the binary"""
 self.build()
 self.do_function_starts(True)
 
 def do_function_starts(self, in_memory):
-"""Run the binary, stop at our unstripped function, 
+"""Run the binary, stop at our unstripped function,
make sure the caller has synthetic 

[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:5215
+uint32_t num_pointee_children = 0;
+if (pointee_clang_type.IsAggregateType())
+  num_pointee_children =

jarin wrote:
> shafik wrote:
> > I am curious what cases are pointers aggregates? Do we test this case?
> As far as I understand, pointers are never aggregates, see [ 
> https://github.com/llvm/llvm-project/blob/58684fbb6f2e6871f3f96ac8c7166a7d7486e971/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L2683
>  | IsAggregate ]].
Apologies, I misread that as `pointer_clang_type` , makes more sense now.


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

https://reviews.llvm.org/D80254



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


[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin updated this revision to Diff 265237.
jarin marked 3 inline comments as done.
jarin added a comment.

Merged the ObjC pointer case with the reference case, simplified the test.


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

https://reviews.llvm.org/D80254

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/functionalities/pointer_num_children/Makefile
  lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py
  lldb/test/API/functionalities/pointer_num_children/main.cpp

Index: lldb/test/API/functionalities/pointer_num_children/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/pointer_num_children/main.cpp
@@ -0,0 +1,16 @@
+struct Inner {
+  int a;
+  int b;
+};
+
+struct Outer {
+  Inner *inner;
+};
+
+int main() {
+  Inner inner{42, 56};
+  Outer outer{};
+  Inner **Ptr = &(outer.inner);
+  Inner * = outer.inner;
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py
===
--- /dev/null
+++ lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py
@@ -0,0 +1,28 @@
+"""
+Test children counts of pointer values.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestPointerNumChilden(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test_pointer_num_children(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+result = self.frame().FindVariable("Ref")
+self.assertEqual(1, result.GetNumChildren())
+self.assertEqual(2, result.GetChildAtIndex(0).GetNumChildren())
+self.assertEqual("42", result.GetChildAtIndex(0).GetChildAtIndex(0).GetValue())
+self.assertEqual("56", result.GetChildAtIndex(0).GetChildAtIndex(1).GetValue())
+
+result = self.frame().FindVariable("Ptr")
+self.assertEqual(1, result.GetNumChildren())
+self.assertEqual(2, result.GetChildAtIndex(0).GetNumChildren())
+self.assertEqual("42", result.GetChildAtIndex(0).GetChildAtIndex(0).GetValue())
+self.assertEqual("56", result.GetChildAtIndex(0).GetChildAtIndex(1).GetValue())
Index: lldb/test/API/functionalities/pointer_num_children/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/pointer_num_children/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5172,12 +5172,15 @@
 }
 break;
 
+  case clang::Type::LValueReference:
+  case clang::Type::RValueReference:
   case clang::Type::ObjCObjectPointer: {
-const clang::ObjCObjectPointerType *pointer_type =
-llvm::cast(qual_type.getTypePtr());
-clang::QualType pointee_type = pointer_type->getPointeeType();
-uint32_t num_pointee_children =
-GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
+CompilerType pointee_clang_type(GetPointeeType(type));
+
+uint32_t num_pointee_children = 0;
+if (pointee_clang_type.IsAggregateType())
+  num_pointee_children =
+  pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx);
 // If this type points to a simple type, then it has 1 child
 if (num_pointee_children == 0)
   num_children = 1;
@@ -5209,8 +5212,11 @@
 const clang::PointerType *pointer_type =
 llvm::cast(qual_type.getTypePtr());
 clang::QualType pointee_type(pointer_type->getPointeeType());
-uint32_t num_pointee_children =
-GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
+CompilerType pointee_clang_type(GetType(pointee_type));
+uint32_t num_pointee_children = 0;
+if (pointee_clang_type.IsAggregateType())
+  num_pointee_children =
+  pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx);
 if (num_pointee_children == 0) {
   // We have a pointer to a pointee type that claims it has no children. We
   // will want to look at
@@ -5219,20 +5225,6 @@
   num_children = num_pointee_children;
   } break;
 
-  case clang::Type::LValueReference:
-  case clang::Type::RValueReference: {
-const clang::ReferenceType *reference_type =
-llvm::cast(qual_type.getTypePtr());
-clang::QualType pointee_type = reference_type->getPointeeType();
-uint32_t num_pointee_children =
-GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
-// If this type points to a simple type, then it 

[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a comment.

In D80254#2046275 , @labath wrote:

> Looks fine to me too. The way this test is phrased, it would probably make 
> more sense under `test/API/python_api/value`, than here. (I mean, it's not 
> technically wrong because everything is a "functionality", but i'd like to 
> avoid putting stuff here precisely because the category is so vague.)


I was actually considering `lang/cpp` since this is about Clang's type system 
and how it handles pointers and references. In any case, 
`test/API/python_api/value` is C, so I could not even test the reference case 
there. Would you prefer creating a new subdirectory in `python_api`?


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

https://reviews.llvm.org/D80254



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


[Lldb-commits] [lldb] aa04ce7 - [lldb][NFC] Minor NamespaceMap refactor

2020-05-20 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-05-20T15:29:20+02:00
New Revision: aa04ce761793bfff6de398091125823476a6e924

URL: 
https://github.com/llvm/llvm-project/commit/aa04ce761793bfff6de398091125823476a6e924
DIFF: 
https://github.com/llvm/llvm-project/commit/aa04ce761793bfff6de398091125823476a6e924.diff

LOG: [lldb][NFC] Minor NamespaceMap refactor

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index 8cdc1a817a08..ed32eac2b4af 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -102,8 +102,8 @@ class ClangASTImporter {
   // Namespace maps
   //
 
-  typedef std::vector>
-  NamespaceMap;
+  typedef std::pair NamespaceMapItem;
+  typedef std::vector NamespaceMap;
   typedef std::shared_ptr NamespaceMapSP;
 
   void RegisterNamespaceMap(const clang::NamespaceDecl *decl,

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 7d66cc0c29f4..7d40cd0e8a0e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -676,13 +676,11 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
 LLDB_LOGV(log, "  CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} 
entries)",
   namespace_map.get(), namespace_map->size());
 
-for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
-  e = namespace_map->end();
- i != e; ++i) {
+for (ClangASTImporter::NamespaceMapItem  : *namespace_map) {
   LLDB_LOG(log, "  CEDM::FEVD Searching namespace {0} in module {1}",
-   i->second.GetName(), i->first->GetFileSpec().GetFilename());
+   n.second.GetName(), n.first->GetFileSpec().GetFilename());
 
-  FindExternalVisibleDecls(context, i->first, i->second);
+  FindExternalVisibleDecls(context, n.first, n.second);
 }
   } else if (isa(context.m_decl_context)) {
 CompilerDeclContext namespace_decl;



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


[Lldb-commits] [lldb] 587f81f - Revert "[lldb-server] Reset stop reason of all threads when resuming"

2020-05-20 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-05-20T13:29:04+02:00
New Revision: 587f81f54a3abab88fe9be5f113c74fc12655ee0

URL: 
https://github.com/llvm/llvm-project/commit/587f81f54a3abab88fe9be5f113c74fc12655ee0
DIFF: 
https://github.com/llvm/llvm-project/commit/587f81f54a3abab88fe9be5f113c74fc12655ee0.diff

LOG: Revert "[lldb-server] Reset stop reason of all threads when resuming"

This reverts commit 56de738d18e11c86169f0248b97b2854c37e35ce.

This broke the aarch64 bot. Reverting on behalf of jarin.

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.h

Removed: 
lldb/test/API/functionalities/thread/break_step_other/Makefile

lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
lldb/test/API/functionalities/thread/break_step_other/main.cpp



diff  --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 1275e8ac9ce3..950cda5c7005 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1062,8 +1062,6 @@ Status NativeProcessLinux::Resume(const ResumeActionList 
_actions) {
 if (action == nullptr) {
   LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(),
thread->GetID());
-  // Make sure we reset the stop reason for all the threads.
-  static_cast(*thread).ResetStopReason();
   continue;
 }
 

diff  --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
index 08992f9ebb2a..14eea2df3810 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -396,10 +396,7 @@ void NativeThreadLinux::SetStoppedByTrace() {
 
 void NativeThreadLinux::SetStoppedWithNoReason() {
   SetStopped();
-  ResetStopReason();
-}
 
-void NativeThreadLinux::ResetStopReason() {
   m_stop_info.reason = StopReason::eStopReasonNone;
   m_stop_info.details.signal.signo = 0;
 }

diff  --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h 
b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
index af9783b4dbfb..fd43c89489f7 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -94,8 +94,6 @@ class NativeThreadLinux : public NativeThreadProtocol {
 
   void SetStopped();
 
-  void ResetStopReason();
-
   // Member Variables
   lldb::StateType m_state;
   ThreadStopInfo m_stop_info;

diff  --git a/lldb/test/API/functionalities/thread/break_step_other/Makefile 
b/lldb/test/API/functionalities/thread/break_step_other/Makefile
deleted file mode 100644
index c46619c66234..
--- a/lldb/test/API/functionalities/thread/break_step_other/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-CXX_SOURCES := main.cpp
-ENABLE_THREADS := YES
-
-include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
 
b/lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
deleted file mode 100644
index 656f269ef1f8..
--- 
a/lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test stop reasons after hitting and deleting a breakpoint and
-stepping another thread. Scenario:
-  - run a thread
-  - stop the thread at a breakpoint
-  - delete the breakpoint
-  - single step on the main thread
-The thread stopped at the deleted breakpoint should have stop reason
-'none'.
-"""
-
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class ThreadBreakStepOtherTestCase(TestBase):
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-def test_hit_breakpoint_delete_step_other_thread(self):
-main_source_file = lldb.SBFileSpec("main.cpp")
-self.build()
-(target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(
-self, "// main break here", main_source_file, only_one_thread = 
False)
-
-# Run until the breakpoint in the thread.
-thread_breakpoint = target.BreakpointCreateBySourceRegex(
-"// thread break here", main_source_file)
-self.assertGreater(
-thread_breakpoint.GetNumLocations(),
-0,
-"thread breakpoint has no locations associated with it.")
-process.Continue()
-stopped_threads = lldbutil.get_threads_stopped_at_breakpoint(
-process, thread_breakpoint)
-self.assertEquals(
-1,
-len(stopped_threads),
-"only one thread expected 

[Lldb-commits] [PATCH] D80150: [lldb/DataFormatter] Check for overflow when finding NSDate epoch

2020-05-20 Thread Michael Forster via Phabricator via lldb-commits
MForster added a comment.

Reverts of a few follow-up changes were necessary as well:

- 79fcd35c688b94becadd162a6c37e9b95df5c084 

- 23f29b2fcc5668c51f15809067a1c3503b422c64 

- f67f9e86e86e68d4cbc05ef8d6ffd0cb33246d45 

- 0f1195a58648998d21bcfa1575a78a4706eaa52c 

- 8214eff467f583309e9fbb971862d3c1cdcc65e4 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80150



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


[Lldb-commits] [lldb] 23f29b2 - Revert "Silence warnings around int/float conversions."

2020-05-20 Thread Dmitri Gribenko via lldb-commits

Author: Dmitri Gribenko
Date: 2020-05-20T12:44:19+02:00
New Revision: 23f29b2fcc5668c51f15809067a1c3503b422c64

URL: 
https://github.com/llvm/llvm-project/commit/23f29b2fcc5668c51f15809067a1c3503b422c64
DIFF: 
https://github.com/llvm/llvm-project/commit/23f29b2fcc5668c51f15809067a1c3503b422c64.diff

LOG: Revert "Silence warnings around int/float conversions."

This reverts commit 15ee8a3a58223b48afbe33cb60084f864ef20889. It is a
follow-up to b783f70a42575a5d9147bea1ac97e872370fe55b, which I'm
reverting -- see the explanation in that revert.

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/unittests/DataFormatter/MockTests.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 37b352263260..1ad443b8b74e 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -794,8 +794,8 @@ bool 
lldb_private::formatters::NSDate::FormatDateValue(double date_value,
 return true;
   }
 
-  if ((time_t)date_value > std::numeric_limits::max() ||
-  (time_t)date_value < std::numeric_limits::min())
+  if (date_value > std::numeric_limits::max() ||
+  date_value < std::numeric_limits::min())
 return false;
 
   time_t epoch = GetOSXEpoch();

diff  --git a/lldb/unittests/DataFormatter/MockTests.cpp 
b/lldb/unittests/DataFormatter/MockTests.cpp
index f7daaf22d140..1185d7bf2c9c 100644
--- a/lldb/unittests/DataFormatter/MockTests.cpp
+++ b/lldb/unittests/DataFormatter/MockTests.cpp
@@ -28,14 +28,14 @@ TEST(DataFormatterMockTest, NSDate) {
   EXPECT_EQ(*formatDateValue(-63114076800), "0001-12-30 00:00:00 +");
 
   // Can't convert the date_value to a time_t.
-  EXPECT_EQ(formatDateValue((double)(std::numeric_limits::max()) + 1),
+  EXPECT_EQ(formatDateValue(std::numeric_limits::max() + 1),
 llvm::None);
-  EXPECT_EQ(formatDateValue((double)(std::numeric_limits::min()) - 1),
+  EXPECT_EQ(formatDateValue(std::numeric_limits::min() - 1),
 llvm::None);
 
   // Can't add the macOS epoch to the converted date_value (the add overflows).
-  EXPECT_EQ(formatDateValue((double)std::numeric_limits::max()), 
llvm::None);
-  EXPECT_EQ(formatDateValue((double)std::numeric_limits::min()), 
llvm::None);
+  EXPECT_EQ(formatDateValue(std::numeric_limits::max()), llvm::None);
+  EXPECT_EQ(formatDateValue(std::numeric_limits::min()), llvm::None);
 
   // FIXME: The formatting result is wrong on Windows because we adjust the
   // epoch when _WIN32 is defined (see GetOSXEpoch).



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


[Lldb-commits] [lldb] 79fcd35 - Revert "[lldb/test] Move "DataFormatters/Mock.h" to "Plugins/Language/ObjC/Utilities.h""

2020-05-20 Thread Dmitri Gribenko via lldb-commits

Author: Dmitri Gribenko
Date: 2020-05-20T12:44:18+02:00
New Revision: 79fcd35c688b94becadd162a6c37e9b95df5c084

URL: 
https://github.com/llvm/llvm-project/commit/79fcd35c688b94becadd162a6c37e9b95df5c084
DIFF: 
https://github.com/llvm/llvm-project/commit/79fcd35c688b94becadd162a6c37e9b95df5c084.diff

LOG: Revert "[lldb/test] Move "DataFormatters/Mock.h" to 
"Plugins/Language/ObjC/Utilities.h""

This reverts commit 82dbf4aca84ec889d0dc390674ff44e30441bcfd. It is a
follow-up to b783f70a42575a5d9147bea1ac97e872370fe55b, which I'm
reverting -- see the explanation in that revert.

Added: 
lldb/include/lldb/DataFormatters/Mock.h
lldb/unittests/DataFormatter/MockTests.cpp

Modified: 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/unittests/DataFormatter/CMakeLists.txt
lldb/unittests/Language/CMakeLists.txt

Removed: 
lldb/source/Plugins/Language/ObjC/Utilities.h
lldb/unittests/Language/ObjC/CMakeLists.txt
lldb/unittests/Language/ObjC/UtilitiesTests.cpp



diff  --git a/lldb/source/Plugins/Language/ObjC/Utilities.h 
b/lldb/include/lldb/DataFormatters/Mock.h
similarity index 73%
rename from lldb/source/Plugins/Language/ObjC/Utilities.h
rename to lldb/include/lldb/DataFormatters/Mock.h
index 4cfeb2b28bfd..b3fc10cd2e51 100644
--- a/lldb/source/Plugins/Language/ObjC/Utilities.h
+++ b/lldb/include/lldb/DataFormatters/Mock.h
@@ -1,4 +1,4 @@
-//===-- Utilities.h -*- C++ 
-*-===//
+//===-- Mock.h --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 
//===--===//
 
-#ifndef LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
-#define LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
+#ifndef LLDB_DATAFORMATTERS_MOCK_H
+#define LLDB_DATAFORMATTERS_MOCK_H
 
 namespace lldb_private {
 
@@ -23,4 +23,4 @@ bool FormatDateValue(double date_value, Stream );
 } // namespace formatters
 } // namespace lldb_private
 
-#endif // LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
+#endif // LLDB_DATAFORMATTERS_MOCK_H

diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 5128f2865879..37b352263260 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -8,12 +8,12 @@
 
 #include "Cocoa.h"
 
-#include "Plugins/Language/ObjC/Utilities.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Core/Mangled.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/Mock.h"
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeSummary.h"
 #include "lldb/Host/Time.h"

diff  --git a/lldb/unittests/DataFormatter/CMakeLists.txt 
b/lldb/unittests/DataFormatter/CMakeLists.txt
index 45011c56b0b0..716c8e735287 100644
--- a/lldb/unittests/DataFormatter/CMakeLists.txt
+++ b/lldb/unittests/DataFormatter/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_unittest(LLDBFormatterTests
   FormatManagerTests.cpp
+  MockTests.cpp
   StringPrinterTests.cpp
 
   LINK_LIBS

diff  --git a/lldb/unittests/Language/ObjC/UtilitiesTests.cpp 
b/lldb/unittests/DataFormatter/MockTests.cpp
similarity index 84%
rename from lldb/unittests/Language/ObjC/UtilitiesTests.cpp
rename to lldb/unittests/DataFormatter/MockTests.cpp
index b28060973d86..f7daaf22d140 100644
--- a/lldb/unittests/Language/ObjC/UtilitiesTests.cpp
+++ b/lldb/unittests/DataFormatter/MockTests.cpp
@@ -1,4 +1,4 @@
-//===-- UtilitiesTests.cpp 
===//
+//===-- MockTests.cpp 
-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "Plugins/Language/ObjC/Utilities.h"
+#include "lldb/DataFormatters/Mock.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
@@ -25,8 +25,7 @@ static llvm::Optional formatDateValue(double 
date_value) {
 }
 
 TEST(DataFormatterMockTest, NSDate) {
-  EXPECT_EQ(formatDateValue(-63114076800),
-std::string("0001-12-30 00:00:00 +"));
+  EXPECT_EQ(*formatDateValue(-63114076800), "0001-12-30 00:00:00 +");
 
   // Can't convert the date_value to a time_t.
   EXPECT_EQ(formatDateValue((double)(std::numeric_limits::max()) + 1),
@@ -35,10 +34,8 @@ TEST(DataFormatterMockTest, NSDate) {
 llvm::None);
 
   // Can't add the macOS epoch to the converted date_value (the add overflows).
-  

[Lldb-commits] [lldb] f67f9e8 - Revert "[lldb/test] Disable NSDate format check under _WIN32"

2020-05-20 Thread Dmitri Gribenko via lldb-commits

Author: Dmitri Gribenko
Date: 2020-05-20T12:44:19+02:00
New Revision: f67f9e86e86e68d4cbc05ef8d6ffd0cb33246d45

URL: 
https://github.com/llvm/llvm-project/commit/f67f9e86e86e68d4cbc05ef8d6ffd0cb33246d45
DIFF: 
https://github.com/llvm/llvm-project/commit/f67f9e86e86e68d4cbc05ef8d6ffd0cb33246d45.diff

LOG: Revert "[lldb/test] Disable NSDate format check under _WIN32"

This reverts commit e3aa4cd9dbcee6441f51102e3958c35321698c67. It is a
follow-up to b783f70a42575a5d9147bea1ac97e872370fe55b, which I'm
reverting -- see the explanation in that revert.

Added: 


Modified: 
lldb/unittests/DataFormatter/MockTests.cpp

Removed: 




diff  --git a/lldb/unittests/DataFormatter/MockTests.cpp 
b/lldb/unittests/DataFormatter/MockTests.cpp
index 1185d7bf2c9c..752e3987dac9 100644
--- a/lldb/unittests/DataFormatter/MockTests.cpp
+++ b/lldb/unittests/DataFormatter/MockTests.cpp
@@ -37,10 +37,6 @@ TEST(DataFormatterMockTest, NSDate) {
   EXPECT_EQ(formatDateValue(std::numeric_limits::max()), llvm::None);
   EXPECT_EQ(formatDateValue(std::numeric_limits::min()), llvm::None);
 
-  // FIXME: The formatting result is wrong on Windows because we adjust the
-  // epoch when _WIN32 is defined (see GetOSXEpoch).
-#ifndef _WIN32
   EXPECT_TRUE(
   llvm::StringRef(*formatDateValue(0)).startswith("2001-01-01 00:00:00"));
-#endif
 }



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


[Lldb-commits] [lldb] 8214eff - Revert "[lldb/DataFormatter] Check for overflow when finding NSDate epoch"

2020-05-20 Thread Dmitri Gribenko via lldb-commits

Author: Dmitri Gribenko
Date: 2020-05-20T12:44:19+02:00
New Revision: 8214eff467f583309e9fbb971862d3c1cdcc65e4

URL: 
https://github.com/llvm/llvm-project/commit/8214eff467f583309e9fbb971862d3c1cdcc65e4
DIFF: 
https://github.com/llvm/llvm-project/commit/8214eff467f583309e9fbb971862d3c1cdcc65e4.diff

LOG: Revert "[lldb/DataFormatter] Check for overflow when finding NSDate epoch"

This reverts commit b783f70a42575a5d9147bea1ac97e872370fe55b. This
change had multiple issues which required post-commit fixups, and not
all issues are fixed yet. In particular, the LLDB build bot for ARM is
still broken. There is also an ongoing conversation in the original
phabricator review about whether there is undefined behavior in the
code.

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/unittests/DataFormatter/CMakeLists.txt

Removed: 
lldb/include/lldb/DataFormatters/Mock.h
lldb/unittests/DataFormatter/MockTests.cpp



diff  --git a/lldb/include/lldb/DataFormatters/Mock.h 
b/lldb/include/lldb/DataFormatters/Mock.h
deleted file mode 100644
index b3fc10cd2e51..
--- a/lldb/include/lldb/DataFormatters/Mock.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//===-- Mock.h --*- C++ 
-*-===//
-//
-// 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
-//
-//===--===//
-
-#ifndef LLDB_DATAFORMATTERS_MOCK_H
-#define LLDB_DATAFORMATTERS_MOCK_H
-
-namespace lldb_private {
-
-class Stream;
-
-namespace formatters {
-namespace NSDate {
-
-/// Format the date_value field of a NSDate.
-bool FormatDateValue(double date_value, Stream );
-
-} // namespace NSDate
-} // namespace formatters
-} // namespace lldb_private
-
-#endif // LLDB_DATAFORMATTERS_MOCK_H

diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 1ad443b8b74e..8a44811dd36b 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -13,7 +13,6 @@
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/DataFormatters/Mock.h"
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeSummary.h"
 #include "lldb/Host/Time.h"
@@ -28,7 +27,6 @@
 
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/bit.h"
-#include "llvm/Support/CheckedArithmetic.h"
 
 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
 
@@ -787,34 +785,6 @@ static double decodeTaggedTimeInterval(uint64_t 
encodedTimeInterval) {
   return llvm::bit_cast(decodedBits);
 }
 
-bool lldb_private::formatters::NSDate::FormatDateValue(double date_value,
-   Stream ) {
-  if (date_value == -63114076800) {
-stream.Printf("0001-12-30 00:00:00 +");
-return true;
-  }
-
-  if (date_value > std::numeric_limits::max() ||
-  date_value < std::numeric_limits::min())
-return false;
-
-  time_t epoch = GetOSXEpoch();
-  if (auto osx_epoch = llvm::checkedAdd(epoch, (time_t)date_value))
-epoch = *osx_epoch;
-  else
-return false;
-  tm *tm_date = gmtime();
-  if (!tm_date)
-return false;
-  std::string buffer(1024, 0);
-  if (strftime([0], 1023, "%Z", tm_date) == 0)
-return false;
-  stream.Printf("%04d-%02d-%02d %02d:%02d:%02d %s", tm_date->tm_year + 1900,
-tm_date->tm_mon + 1, tm_date->tm_mday, tm_date->tm_hour,
-tm_date->tm_min, tm_date->tm_sec, buffer.c_str());
-  return true;
-}
-
 bool lldb_private::formatters::NSDateSummaryProvider(
 ValueObject , Stream , const TypeSummaryOptions ) {
   ProcessSP process_sp = valobj.GetProcessSP();
@@ -858,16 +828,6 @@ bool lldb_private::formatters::NSDateSummaryProvider(
 if (descriptor->GetTaggedPointerInfo(_bits, _bits)) {
   date_value_bits = ((value_bits << 8) | (info_bits << 4));
   memcpy(_value, _value_bits, sizeof(date_value_bits));
-
-  // Accomodate the __NSTaggedDate format introduced in Foundation 1600.
-  if (class_name == g___NSTaggedDate) {
-auto *apple_runtime = llvm::dyn_cast_or_null(
-ObjCLanguageRuntime::Get(*process_sp));
-if (!apple_runtime)
-  return false;
-if (apple_runtime->GetFoundationVersion() >= 1600)
-  date_value = decodeTaggedTimeInterval(value_bits << 4);
-  }
 } else {
   llvm::Triple triple(
   process_sp->GetTarget().GetArchitecture().GetTriple());
@@ -890,7 +850,34 @@ bool lldb_private::formatters::NSDateSummaryProvider(
   } else
 return false;
 
-  return NSDate::FormatDateValue(date_value, stream);
+  if (date_value == 

[Lldb-commits] [lldb] 0f1195a - Revert "[lldb/test] Relax NSDate mock test for non-Apple platforms"

2020-05-20 Thread Dmitri Gribenko via lldb-commits

Author: Dmitri Gribenko
Date: 2020-05-20T12:44:19+02:00
New Revision: 0f1195a58648998d21bcfa1575a78a4706eaa52c

URL: 
https://github.com/llvm/llvm-project/commit/0f1195a58648998d21bcfa1575a78a4706eaa52c
DIFF: 
https://github.com/llvm/llvm-project/commit/0f1195a58648998d21bcfa1575a78a4706eaa52c.diff

LOG: Revert "[lldb/test] Relax NSDate mock test for non-Apple platforms"

This reverts commit fff3a8464d4d518c7086c928fba967908eb294d7. It is a
follow-up to b783f70a42575a5d9147bea1ac97e872370fe55b, which I'm
reverting -- see the explanation in that revert.

Added: 


Modified: 
lldb/unittests/DataFormatter/MockTests.cpp

Removed: 




diff  --git a/lldb/unittests/DataFormatter/MockTests.cpp 
b/lldb/unittests/DataFormatter/MockTests.cpp
index 752e3987dac9..0042888243f7 100644
--- a/lldb/unittests/DataFormatter/MockTests.cpp
+++ b/lldb/unittests/DataFormatter/MockTests.cpp
@@ -9,7 +9,6 @@
 #include "lldb/DataFormatters/Mock.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/ADT/Optional.h"
-#include "llvm/ADT/StringRef.h"
 #include "gtest/gtest.h"
 #include 
 
@@ -37,6 +36,5 @@ TEST(DataFormatterMockTest, NSDate) {
   EXPECT_EQ(formatDateValue(std::numeric_limits::max()), llvm::None);
   EXPECT_EQ(formatDateValue(std::numeric_limits::min()), llvm::None);
 
-  EXPECT_TRUE(
-  llvm::StringRef(*formatDateValue(0)).startswith("2001-01-01 00:00:00"));
+  EXPECT_EQ(*formatDateValue(0), "2001-01-01 00:00:00 UTC");
 }



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


[Lldb-commits] [lldb] 4bee2af - [lldb][NFC] Modernize TestCPPStaticMethods

2020-05-20 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-05-20T12:27:44+02:00
New Revision: 4bee2afcd7ea10c9f58f6172924f822849fed8f9

URL: 
https://github.com/llvm/llvm-project/commit/4bee2afcd7ea10c9f58f6172924f822849fed8f9
DIFF: 
https://github.com/llvm/llvm-project/commit/4bee2afcd7ea10c9f58f6172924f822849fed8f9.diff

LOG: [lldb][NFC] Modernize TestCPPStaticMethods

Now with LLVM code style and expect_expr for checking. Also some minor changes
to be more similar to the structure we use in other tests.

Added: 


Modified: 
lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
lldb/test/API/lang/cpp/static_methods/main.cpp

Removed: 




diff  --git a/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py 
b/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
index d358757d8837..ee4cc60df97f 100644
--- a/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
+++ b/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
@@ -15,10 +15,7 @@ class CPPStaticMethodsTestCase(TestBase):
 def test_with_run_command(self):
 """Test that static methods are properly distinguished from regular 
methods"""
 self.build()
-lldbutil.run_to_source_breakpoint(self, "// Break at this line", 
lldb.SBFileSpec("main.cpp"))
+lldbutil.run_to_source_breakpoint(self, "// Break here", 
lldb.SBFileSpec("main.cpp"))
 
-self.expect("expression -- A::getStaticValue()",
-startstr="(int) $0 = 5")
-
-self.expect("expression -- my_a.getMemberValue()",
-startstr="(int) $1 = 3")
+self.expect_expr("A::getStaticValue()", result_type="int", 
result_value="5")
+self.expect_expr("a.getMemberValue()", result_type="int", 
result_value="3")

diff  --git a/lldb/test/API/lang/cpp/static_methods/main.cpp 
b/lldb/test/API/lang/cpp/static_methods/main.cpp
index de1c2ff3e119..332fca62f4be 100644
--- a/lldb/test/API/lang/cpp/static_methods/main.cpp
+++ b/lldb/test/API/lang/cpp/static_methods/main.cpp
@@ -1,29 +1,13 @@
-#include 
-
-class A
-{
+struct A {
 public:
-  static int getStaticValue();
-  int getMemberValue();
+  static int getStaticValue() { return 5; }
+  int getMemberValue() { return a; }
   int a;
 };
 
-int A::getStaticValue()
-{
-  return 5;
-} 
-
-int A::getMemberValue()
-{
-  return a;
-}
-
 int main()
 {
-  A my_a;
-
-  my_a.a = 3;
-
-  printf("%d\n", A::getStaticValue()); // Break at this line
-  printf("%d\n", my_a.getMemberValue());
+  A a;
+  a.a = 3;
+  return A::getStaticValue() + a.getMemberValue(); // Break here
 }



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


[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looks fine to me too. The way this test is phrased, it would probably make more 
sense under `test/API/python_api/value`, than here. (I mean, it's not 
technically wrong because everything is a "functionality", but i'd like to 
avoid putting stuff here precisely because the category is so vague.)




Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:5228
   case clang::Type::RValueReference: {
 const clang::ReferenceType *reference_type =
 llvm::cast(qual_type.getTypePtr());

teemperor wrote:
> If you feel like refactoring this (by deleting code): You can also just 
> delete all this and add the `RValueReference` and `LValueReference` to the 
> `ObjCObjectPointer` above. `GetPointeeType` there is doing the same as the 
> lines below and handles all ptrs/references. But that's optional.
+1 for merging this stuff



Comment at: lldb/test/API/functionalities/pointer_num_children/main.cpp:13-14
+  Outer outer{};
+  auto Ptr = &(outer.inner);
+  auto  = outer.inner;
+  return 0; // break here

Since this test doesn't deal with `auto` in any way, I think we should just 
follow the llvm style guide here and spell out the type explicitly.


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

https://reviews.llvm.org/D80254



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


[Lldb-commits] [PATCH] D80150: [lldb/DataFormatter] Check for overflow when finding NSDate epoch

2020-05-20 Thread Michael Forster via Phabricator via lldb-commits
MForster added subscribers: gribozavr2, MForster.
MForster added a comment.

In D80150#2045632 , @omjavaid wrote:

> This patch breaks lldb unit tests on lldb-arm-ubuntu buildbot.
>
> http://lab.llvm.org:8014/builders/lldb-arm-ubuntu/builds/1697


It also breaks our internal build bots with an "Illegal instruction". Here is 
the stacktrace:

  0  libsupport.so0x7f8c5f6d87ba 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 58
  1  libsupport.so0x7f8c5f6d8c79
  2  libsupport.so0x7f8c5f6d71bb 
llvm::sys::RunSignalHandlers() + 123
  3  libsupport.so0x7f8c5f6d92fb
  4  libpthread.so.00x7f8c5e7509a0
  5  libcore.so   0x7f8c764820b1 
lldb_private::formatters::NSDate::FormatDateValue(double, 
lldb_private::Stream&) + 129
  6  unittests_Sliblanguage_Utests.so 0x7f8c771c29b5
  7  unittests_Sliblanguage_Utests.so 0x7f8c771c24d8 
DataFormatterMockTest_NSDate_Test::TestBody() + 248
  8  libgtest.so  0x7f8c5f85ce44 void 
testing::internal::HandleSehExceptionsInMethodIfSupported(testing::Test*, void (testing::Test::*)(), char const*) + 132
  9  libgtest.so  0x7f8c5f84b532 void 
testing::internal::HandleExceptionsInMethodIfSupported(testing::Test*, void (testing::Test::*)(), char const*) + 114
  10 libgtest.so  0x7f8c5f840866 
testing::Test::Run() + 182
  11 libgtest.so  0x7f8c5f840eb5 
testing::TestInfo::Run() + 213
  12 libgtest.so  0x7f8c5f8413e4 
testing::TestCase::Run() + 228
  13 libgtest.so  0x7f8c5f8461db 
testing::internal::UnitTestImpl::RunAllTests() + 731
  14 libgtest.so  0x7f8c5f861a24 bool 
testing::internal::HandleSehExceptionsInMethodIfSupported(testing::internal::UnitTestImpl*, bool 
(testing::internal::UnitTestImpl::*)(), char const*) + 132
  15 libgtest.so  0x7f8c5f84cf42 bool 
testing::internal::HandleExceptionsInMethodIfSupported(testing::internal::UnitTestImpl*, bool 
(testing::internal::UnitTestImpl::*)(), char const*) + 114
  16 libgtest.so  0x7f8c5f845eda 
testing::UnitTest::Run() + 186
  17 libgtest_Umain.so0x7f8c5f8b7ce1 
RUN_ALL_TESTS() + 17
  18 libgtest_Umain.so0x7f8c5f8b7c6a main + 186
  19 libc.so.6  0x7f8c5e5bebbd 
__libc_start_main + 253
  20 language_tests 0x556b0f40dd09
  Illegal instruction

@gribozavr2 is preparing a revert of this commit and the two follow-up changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80150



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


[Lldb-commits] [PATCH] D80150: [lldb/DataFormatter] Check for overflow when finding NSDate epoch

2020-05-20 Thread Michael Forster via Phabricator via lldb-commits
MForster added a subscriber: echristo.
MForster added inline comments.



Comment at: lldb/source/Plugins/Language/ObjC/Cocoa.cpp:797
+
+  if (date_value > std::numeric_limits::max() ||
+  date_value < std::numeric_limits::min())

This is the line where the "Illegal instruction" happens. Actually [[ 
https://github.com/llvm/llvm-project/blob/82dbf4aca84ec889d0dc390674ff44e30441bcfd/lldb/source/Plugins/Language/ObjC/Cocoa.cpp#L797
 | here ]], exactly (as there has been a follow-up change by @echristo) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80150



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


[Lldb-commits] [PATCH] D79308: [lldb-server] Reset stop reason of all threads when resuming

2020-05-20 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG56de738d18e1: [lldb-server] Reset stop reason of all threads 
when resuming (authored by jarin, committed by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79308

Files:
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
  lldb/test/API/functionalities/thread/break_step_other/Makefile
  
lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
  lldb/test/API/functionalities/thread/break_step_other/main.cpp

Index: lldb/test/API/functionalities/thread/break_step_other/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/break_step_other/main.cpp
@@ -0,0 +1,27 @@
+#include 
+#include "pseudo_barrier.h"
+
+// Barrier for starting the thread and reaching the loop in main.
+pseudo_barrier_t g_barrier;
+volatile int g_foo = 0;
+
+void thread_func() {
+  // Wait until all the threads are running
+  pseudo_barrier_wait(g_barrier);
+  g_foo = 1; // thread break here
+}
+
+int main() {
+  g_foo = 0; // main break here
+
+  pseudo_barrier_init(g_barrier, 2);
+  std::thread t(thread_func);
+  pseudo_barrier_wait(g_barrier);
+
+  // A dummy loop to have something to step through.
+  volatile int i = 0;
+  while (g_foo == 0)
+++i;
+  t.join();
+  return 0;
+}
Index: lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
@@ -0,0 +1,63 @@
+"""
+Test stop reasons after hitting and deleting a breakpoint and
+stepping another thread. Scenario:
+  - run a thread
+  - stop the thread at a breakpoint
+  - delete the breakpoint
+  - single step on the main thread
+The thread stopped at the deleted breakpoint should have stop reason
+'none'.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ThreadBreakStepOtherTestCase(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_hit_breakpoint_delete_step_other_thread(self):
+main_source_file = lldb.SBFileSpec("main.cpp")
+self.build()
+(target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(
+self, "// main break here", main_source_file, only_one_thread = False)
+
+# Run until the breakpoint in the thread.
+thread_breakpoint = target.BreakpointCreateBySourceRegex(
+"// thread break here", main_source_file)
+self.assertGreater(
+thread_breakpoint.GetNumLocations(),
+0,
+"thread breakpoint has no locations associated with it.")
+process.Continue()
+stopped_threads = lldbutil.get_threads_stopped_at_breakpoint(
+process, thread_breakpoint)
+self.assertEquals(
+1,
+len(stopped_threads),
+"only one thread expected stopped at the thread breakpoint")
+breakpoint_thread = stopped_threads[0]
+
+# Delete the breakpint in the thread and do a step in the main thread.
+target.BreakpointDelete(thread_breakpoint.GetID())
+main_thread.StepInstruction(False)
+
+# Check the stop reasons.
+reason = main_thread.GetStopReason()
+self.assertEqual(
+lldb.eStopReasonPlanComplete,
+reason,
+"Expected thread stop reason 'plancomplete', but got '%s'" %
+lldbutil.stop_reason_to_str(reason))
+
+reason = breakpoint_thread.GetStopReason()
+self.assertEqual(
+lldb.eStopReasonNone,
+reason,
+"Expected thread stop reason 'none', but got '%s'" %
+lldbutil.stop_reason_to_str(reason))
Index: lldb/test/API/functionalities/thread/break_step_other/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/break_step_other/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+ENABLE_THREADS := YES
+
+include Makefile.rules
Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -94,6 +94,8 @@
 
   void SetStopped();
 
+  void ResetStopReason();
+
   // Member Variables
   lldb::StateType m_state;
   ThreadStopInfo m_stop_info;
Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===
--- 

[Lldb-commits] [PATCH] D79757: Use IPv4 for Android connections

2020-05-20 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa9d7b458c094: Use IPv4 for Android connections (authored by 
emrekultursay, committed by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79757

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


Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -188,7 +188,7 @@
 if (error.Success()) {
   m_port_forwards[pid] = local_port;
   std::ostringstream url_str;
-  url_str << "connect://localhost:" << local_port;
+  url_str << "connect://127.0.0.1:" << local_port;
   connect_url = url_str.str();
   break;
 }
Index: lldb/source/Plugins/Platform/Android/AdbClient.cpp
===
--- lldb/source/Plugins/Platform/Android/AdbClient.cpp
+++ lldb/source/Plugins/Platform/Android/AdbClient.cpp
@@ -141,7 +141,7 @@
   if (const char *env_port = std::getenv("ANDROID_ADB_SERVER_PORT")) {
 port = env_port;
   }
-  std::string uri = "connect://localhost:" + port;
+  std::string uri = "connect://127.0.0.1:" + port;
   m_conn->Connect(uri.c_str(), );
 
   return error;


Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -188,7 +188,7 @@
 if (error.Success()) {
   m_port_forwards[pid] = local_port;
   std::ostringstream url_str;
-  url_str << "connect://localhost:" << local_port;
+  url_str << "connect://127.0.0.1:" << local_port;
   connect_url = url_str.str();
   break;
 }
Index: lldb/source/Plugins/Platform/Android/AdbClient.cpp
===
--- lldb/source/Plugins/Platform/Android/AdbClient.cpp
+++ lldb/source/Plugins/Platform/Android/AdbClient.cpp
@@ -141,7 +141,7 @@
   if (const char *env_port = std::getenv("ANDROID_ADB_SERVER_PORT")) {
 port = env_port;
   }
-  std::string uri = "connect://localhost:" + port;
+  std::string uri = "connect://127.0.0.1:" + port;
   m_conn->Connect(uri.c_str(), );
 
   return error;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added subscribers: labath, clayborg.
teemperor added a comment.
This revision is now accepted and ready to land.

I think this looks good beside some minor nit-picks. Maybe @labath should take 
a second look too.




Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:5228
   case clang::Type::RValueReference: {
 const clang::ReferenceType *reference_type =
 llvm::cast(qual_type.getTypePtr());

If you feel like refactoring this (by deleting code): You can also just delete 
all this and add the `RValueReference` and `LValueReference` to the 
`ObjCObjectPointer` above. `GetPointeeType` there is doing the same as the 
lines below and handles all ptrs/references. But that's optional.



Comment at: 
lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py:1
+"""
+"""

I guess this was just a placeholder?



Comment at: 
lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py:16
+(_, _, thread, _) = lldbutil.run_to_source_breakpoint(self, "// break 
here", self.main_source_file)
+frame = thread.GetSelectedFrame()
+

You can also do `self.frame()` and then you don't need to capture the thread 
above or declare a variable here. And I don't think you need to assign 
`self.main_source_file` (I believe this has no special meaning, other tests 
just did this because they liked to share the setup code in one setUp method).

```
lang=python
lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))

result = self.frame().FindVariable("Ref")
```


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

https://reviews.llvm.org/D80254



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


[Lldb-commits] [lldb] a9d7b45 - Use IPv4 for Android connections

2020-05-20 Thread Pavel Labath via lldb-commits

Author: Emre Kultursay
Date: 2020-05-20T11:32:03+02:00
New Revision: a9d7b458c094d62a8c11ada11e39bf0d4da596c8

URL: 
https://github.com/llvm/llvm-project/commit/a9d7b458c094d62a8c11ada11e39bf0d4da596c8
DIFF: 
https://github.com/llvm/llvm-project/commit/a9d7b458c094d62a8c11ada11e39bf0d4da596c8.diff

LOG: Use IPv4 for Android connections

Summary:
When adb client connects to adb server, or when lldb connects to
lldb server on Android device, IPv6 does not work (at least on
Windows it does not work).

For Android on Windows, each IPv6 failure (fallback-to-IPv4) wastes
2 seconds, and since this is called 5 times when attaching, LLDB
is wasting 10 seconds. This CL brings a big improvement to attach latency.

Reviewers: labath

Reviewed By: labath

Subscribers: aadsm, clayborg, mgrang, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/Platform/Android/AdbClient.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/Android/AdbClient.cpp 
b/lldb/source/Plugins/Platform/Android/AdbClient.cpp
index 81698b74a1b1..14d97ebe7c3c 100644
--- a/lldb/source/Plugins/Platform/Android/AdbClient.cpp
+++ b/lldb/source/Plugins/Platform/Android/AdbClient.cpp
@@ -141,7 +141,7 @@ Status AdbClient::Connect() {
   if (const char *env_port = std::getenv("ANDROID_ADB_SERVER_PORT")) {
 port = env_port;
   }
-  std::string uri = "connect://localhost:" + port;
+  std::string uri = "connect://127.0.0.1:" + port;
   m_conn->Connect(uri.c_str(), );
 
   return error;

diff  --git 
a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp 
b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
index a94ead11b08b..6dd5306a93e8 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -188,7 +188,7 @@ Status PlatformAndroidRemoteGDBServer::MakeConnectURL(
 if (error.Success()) {
   m_port_forwards[pid] = local_port;
   std::ostringstream url_str;
-  url_str << "connect://localhost:" << local_port;
+  url_str << "connect://127.0.0.1:" << local_port;
   connect_url = url_str.str();
   break;
 }



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


[Lldb-commits] [lldb] 56de738 - [lldb-server] Reset stop reason of all threads when resuming

2020-05-20 Thread Pavel Labath via lldb-commits

Author: Jaroslav Sevcik
Date: 2020-05-20T11:08:34+02:00
New Revision: 56de738d18e11c86169f0248b97b2854c37e35ce

URL: 
https://github.com/llvm/llvm-project/commit/56de738d18e11c86169f0248b97b2854c37e35ce
DIFF: 
https://github.com/llvm/llvm-project/commit/56de738d18e11c86169f0248b97b2854c37e35ce.diff

LOG: [lldb-server] Reset stop reason of all threads when resuming

Summary:
This patch makes the stop reason reset logic similar to MacOS' debugserver, 
where exceptions are reset for all threads when resuming process for stepping 
or continuing (see [[ 
https://github.com/llvm/llvm-project/blob/96f3ea0d21b48ca088355db10d4d1a2e9bc9f884/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp#L433
 | MachThreadList::ProcessWillResume ]] and [[ 
https://github.com/llvm/llvm-project/blob/96f3ea0d21b48ca088355db10d4d1a2e9bc9f884/lldb/tools/debugserver/source/MacOSX/MachThread.cpp#L363
 | MachThread::ThreadWillResume ]]).

Resetting stop reasons on resume fixes problems where LLDB spuriously reports 
SIGTRAP signal stop reason for deleted breakpoints (both internal and public) 
and where  LLDB stops on an internal breakpoint while stepping over while a 
breakpoint is hit in another thread. See [[ 
https://bugs.llvm.org/show_bug.cgi?id=45642 | PR45642 ]] for details.

Reviewed By: jingham, labath

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

Added: 
lldb/test/API/functionalities/thread/break_step_other/Makefile

lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
lldb/test/API/functionalities/thread/break_step_other/main.cpp

Modified: 
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 950cda5c7005..1275e8ac9ce3 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1062,6 +1062,8 @@ Status NativeProcessLinux::Resume(const ResumeActionList 
_actions) {
 if (action == nullptr) {
   LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(),
thread->GetID());
+  // Make sure we reset the stop reason for all the threads.
+  static_cast(*thread).ResetStopReason();
   continue;
 }
 

diff  --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
index 14eea2df3810..08992f9ebb2a 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -396,7 +396,10 @@ void NativeThreadLinux::SetStoppedByTrace() {
 
 void NativeThreadLinux::SetStoppedWithNoReason() {
   SetStopped();
+  ResetStopReason();
+}
 
+void NativeThreadLinux::ResetStopReason() {
   m_stop_info.reason = StopReason::eStopReasonNone;
   m_stop_info.details.signal.signo = 0;
 }

diff  --git a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h 
b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
index fd43c89489f7..af9783b4dbfb 100644
--- a/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -94,6 +94,8 @@ class NativeThreadLinux : public NativeThreadProtocol {
 
   void SetStopped();
 
+  void ResetStopReason();
+
   // Member Variables
   lldb::StateType m_state;
   ThreadStopInfo m_stop_info;

diff  --git a/lldb/test/API/functionalities/thread/break_step_other/Makefile 
b/lldb/test/API/functionalities/thread/break_step_other/Makefile
new file mode 100644
index ..c46619c66234
--- /dev/null
+++ b/lldb/test/API/functionalities/thread/break_step_other/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+ENABLE_THREADS := YES
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
 
b/lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
new file mode 100644
index ..656f269ef1f8
--- /dev/null
+++ 
b/lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
@@ -0,0 +1,63 @@
+"""
+Test stop reasons after hitting and deleting a breakpoint and
+stepping another thread. Scenario:
+  - run a thread
+  - stop the thread at a breakpoint
+  - delete the breakpoint
+  - single step on the main thread
+The thread stopped at the deleted breakpoint should have stop reason
+'none'.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ThreadBreakStepOtherTestCase(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def 

[Lldb-commits] [PATCH] D79726: Add terminateCommands to lldb-vscode protocol

2020-05-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Unfortunately I've had to revert this because it was making a number of vscode 
tests hang nondeterministically: 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/10557, 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/10545, 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/10544, 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/10537, 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/10533, 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/10530.

It seems that the python process driving lldb-vscode gets stuck during teardown 
waiting for a reply to the "disconnect" packet. lldb-vscode has already exited 
at that point. Here's a stack trace of the python process in this stuck state 
(the line numbers extracted by gdb don't seem to add up completely, but the 
function names are quite believable):

  (gdb) bt
  #0  0x7f1462739364 in do_futex_wait.constprop () from 
/lib64/libpthread.so.0
  #1  0x7f1462739458 in __new_sem_wait_slow.constprop.0 () from 
/lib64/libpthread.so.0
  #2  0x7f1462b0ab76 in PyThread_acquire_lock_timed (lock=0x555fa3b20740, 
microseconds=-100, intr_flag=1) at Python/thread_pthread.h:459
  #3  0x7f1462b7865e in acquire_timed (lock=0x555fa3b20740, 
timeout=-10) at ./Modules/_threadmodule.c:63
  #4  0x7f1462b788e1 in lock_PyThread_acquire_lock (self=0x7f1456b453c0, 
args=(), kwds=0x0) at ./Modules/_threadmodule.c:146
  #5  0x7f14629aa239 in method_vectorcall_VARARGS_KEYWORDS 
(func=, args=0x555fa3b29518, 
nargsf=9223372036854775809, kwnames=0x0) at Objects/descrobject.c:332
  #6  0x7f1462a96c8b in _PyObject_Vectorcall (callable=, args=0x555fa3b29518, nargsf=9223372036854775809, 
kwnames=0x0) at ./Include/cpython/abstract.h:127
  #7  0x7f1462aa943b in call_function (tstate=0x555fa369c860, 
pp_stack=0x7ffc169a16d0, oparg=1, kwnames=0x0) at Python/ceval.c:4987
  #8  0x7f1462aa47c5 in _PyEval_EvalFrameDefault (
  f=Frame 0x555fa3b29380, for file /usr/lib/python3.8/threading.py, line 
302, in wait (self=, 
acquire=, release=, _release_save=, _acquire_restore=, 
_is_owned=, _waiters=) at 
remote 0x7f1456a4d550>, timeout=None, waiter=<_thread.lock at remote 
0x7f1456b453c0>, saved_state=(1, 139725526402880), gotit=False), throwflag=0) 
at Python/ceval.c:3486
  #9  0x7f1462a98877 in PyEval_EvalFrameEx (
  f=Frame 0x555fa3b29380, for file /usr/lib/python3.8/threading.py, line 
302, in wait (self=, 
acquire=, release=, _release_save=, _acquire_restore=, 
_is_owned=, _waiters=) at 
remote 0x7f1456a4d550>, timeout=None, waiter=<_thread.lock at remote 
0x7f1456b453c0>, saved_state=(1, 139725526402880), gotit=False), throwflag=0) 
at Python/ceval.c:741
  #10 0x7f1462aa7829 in _PyEval_EvalCodeWithName (_co=, 
  globals={'__name__': 'threading', '__doc__': "Thread module emulating a 
subset of Java's threading model.", '__package__': '', '__loader__': 
, '__spec__': , 
origin='/usr/lib/python3.8/threading.py', loader_state=None, 
submodule_search_locations=None, _set_fileattr=True, 
_cached='/usr/lib/python3.8/__pycache__/threading.cpython-38.pyc', 
_initializing=False) at remote 0x7f1461b5cb50>, '__file__': 
'/usr/lib/python3.8/threading.py', '__cached__': 
'/usr/lib/python3.8/__pycache__/threading.cpython-38.pyc', '__builtins__': 
{'__name__': 'builtins', '__doc__': "Built-in functions, exceptions, and other 
objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in 
slices.", '__package__': '', '__loader__': , 
'__spec__': , origin=None, loader_state=None, 
submodule_search_loc...(truncated), locals=0x0, args=0x555fa39e6b90, 
argcount=2, kwnames=0x0, kwargs=0x555fa39e6ba0, kwcount=0, kwstep=1, 
defs=0x7f1461b6a058, defcount=1, 
  kwdefs=0x0, closure=0x0, name='wait', qualname='Condition.wait') at 
Python/ceval.c:4298
  #11 0x7f146299e947 in _PyFunction_Vectorcall (func=, stack=0x555fa39e6b90, nargsf=9223372036854775810, kwnames=0x0) 
at Objects/call.c:435
  #12 0x7f1462a96c8b in _PyObject_Vectorcall (callable=, args=0x555fa39e6b90, nargsf=9223372036854775810, kwnames=0x0) 
at ./Include/cpython/abstract.h:127
  #13 0x7f1462aa943b in call_function (tstate=0x555fa369c860, 
pp_stack=0x7ffc169a2aa0, oparg=2, kwnames=0x0) at Python/ceval.c:4987
  #14 0x7f1462aa47c5 in _PyEval_EvalFrameDefault (
  f=Frame 0x555fa39e69d0, for file 
mono/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py, line 787, 
in recv_packet (self=, _input=None, _communication_started=False, 
args=['build/opt/bin/lldb-vscode'], stdin=<_io.BufferedWriter at remote 
0x7f1456a6beb0>, stdout=<_io.BufferedReader at remote 0x7f1456a70040>, 
stderr=<_io.BufferedReader at remote 0x7f1456a70300>, pid=24978, 
returncode=None, encoding=None, errors=None, text_mode=None, 
_sigint_wait_secs=, 
_closed_child_pipe_fds=True, _child_created=True) at remote 0x7f1456a4d580>, 
trace_file=None, send=<_io.BufferedWriter at remote 

[Lldb-commits] [PATCH] D80150: [lldb/DataFormatter] Check for overflow when finding NSDate epoch

2020-05-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D80150#2045364 , @vsk wrote:

> @labath Agreed on all points, I've addressed the feedback in 82dbf4aca84 
>  by 
> moving "DataFormatters/Mock.h" to "Plugins/Language/ObjC/Utilities.h", and 
> adding a separate LanguageObjCTests unit test.


Cool. Thanks.




Comment at: lldb/unittests/DataFormatter/MockTests.cpp:30
+  // Can't convert the date_value to a time_t.
+  EXPECT_EQ(formatDateValue(std::numeric_limits::max() + 1),
+llvm::None);

vsk wrote:
> labath wrote:
> > Isn't this actually `std::numeric_limits::min()` (and UB due to 
> > singed wraparound) ? Did you want to convert to double before doing the 
> > `+1` ?
> Yes, thank you! It looks like Eric caught this before I did.
Actually, thinking about that further, (for 64-bit `time_t`s), 
`double(numeric_limits::max())` is [[ https://godbolt.org/z/t3iSd7 | 
exactly the same value ]] as `double(numeric_limits::max())+1.0` 
because `double` doesn't have enough bits to represent the value precisely. So, 
I have a feeling these checks are still not testing the exact thing you want to 
test (though I'm not sure what that is exactly).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80150



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


[Lldb-commits] [PATCH] D79308: [lldb-server] Reset stop reason of all threads when resuming

2020-05-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Sure.

Btw, at this point, I think one of you guys should get commit-after-aproval 
 access to the 
repository, so you can handle these things yourselves.


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

https://reviews.llvm.org/D79308



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


[Lldb-commits] [lldb] 2a227b3 - Revert "Add terminateCommands to lldb-vscode protocol"

2020-05-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-05-20T10:48:29+02:00
New Revision: 2a227b36b010e559bb9495a6deaca086952a8d64

URL: 
https://github.com/llvm/llvm-project/commit/2a227b36b010e559bb9495a6deaca086952a8d64
DIFF: 
https://github.com/llvm/llvm-project/commit/2a227b36b010e559bb9495a6deaca086952a8d64.diff

LOG: Revert "Add terminateCommands to lldb-vscode protocol"

This reverts commit a3609b0ec68522cb417ffe36ce9eb2e25ca61578, because it
makes a number of lldb-vscode tests flaky.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
lldb/tools/lldb-vscode/README.md
lldb/tools/lldb-vscode/VSCode.cpp
lldb/tools/lldb-vscode/VSCode.h
lldb/tools/lldb-vscode/lldb-vscode.cpp
lldb/tools/lldb-vscode/package.json

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index 15eb77c4fb1e..790628d2b0fd 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -179,9 +179,6 @@ def get_stdout(self, timeout=0.0):
 def get_console(self, timeout=0.0):
 return self.vscode.get_output('console', timeout=timeout)
 
-def collect_console(self, duration):
-return self.vscode.collect_output('console', duration=duration)
-
 def get_local_as_int(self, name, threadId=None):
 value = self.vscode.get_local_variable_value(name, threadId=threadId)
 if value.startswith('0x'):
@@ -242,16 +239,14 @@ def continue_to_exit(self, exitCode=0):
 
 def attach(self, program=None, pid=None, waitFor=None, trace=None,
initCommands=None, preRunCommands=None, stopCommands=None,
-   exitCommands=None, attachCommands=None, terminateCommands=None,
-   coreFile=None):
+   exitCommands=None, attachCommands=None, coreFile=None):
 '''Build the default Makefile target, create the VSCode debug adaptor,
and attach to the process.
 '''
 # Make sure we disconnect and terminate the VSCode debug adaptor even
 # if we throw an exception during the test case.
 def cleanup():
-if self.vscode.debugging:
-self.vscode.request_disconnect(terminateDebuggee=True)
+self.vscode.request_disconnect(terminateDebuggee=True)
 self.vscode.terminate()
 
 # Execute the cleanup function during test case tear down.
@@ -262,8 +257,7 @@ def cleanup():
 program=program, pid=pid, waitFor=waitFor, trace=trace,
 initCommands=initCommands, preRunCommands=preRunCommands,
 stopCommands=stopCommands, exitCommands=exitCommands,
-attachCommands=attachCommands, terminateCommands=terminateCommands,
-coreFile=coreFile)
+attachCommands=attachCommands, coreFile=coreFile)
 if not (response and response['success']):
 self.assertTrue(response['success'],
 'attach failed (%s)' % (response['message']))
@@ -272,17 +266,15 @@ def launch(self, program=None, args=None, cwd=None, 
env=None,
stopOnEntry=False, disableASLR=True,
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
-   stopCommands=None, exitCommands=None, terminateCommands=None,
-   sourcePath=None, debuggerRoot=None, launchCommands=None,
-   sourceMap=None):
+   stopCommands=None, exitCommands=None,sourcePath=None,
+   debuggerRoot=None, launchCommands=None, sourceMap=None):
 '''Sending launch request to vscode
 '''
 
 # Make sure we disconnect and terminate the VSCode debug adapter,
 # if we throw an exception during the test case
 def cleanup():
-if self.vscode.debugging:
-self.vscode.request_disconnect(terminateDebuggee=True)
+self.vscode.request_disconnect(terminateDebuggee=True)
 self.vscode.terminate()
 
 # Execute the cleanup function during test case tear down.
@@ -304,7 +296,6 @@ def cleanup():
 preRunCommands=preRunCommands,
 stopCommands=stopCommands,
 exitCommands=exitCommands,
-terminateCommands=terminateCommands,
 sourcePath=sourcePath,
 debuggerRoot=debuggerRoot,
 launchCommands=launchCommands,
@@ -318,8 +309,7 @@ def build_and_launch(self, program, args=None, cwd=None, 
env=None,
  

[Lldb-commits] [PATCH] D80257: [lldb] Allows customizing libxml2 for darwin

2020-05-20 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.

Yes, that's a lot cleaner.

A better way to ensure lldb is not accidentally built without xml support is to 
set LLDB_ENABLE_LIBXML=On in the cmake config/cache file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80257



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


[Lldb-commits] [PATCH] D80165: [lldb/Driver] Fix handling on positional arguments

2020-05-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D80165#2044509 , @jingham wrote:

> We should make sure if we do exit that we don't output any other text that 
> would obscure the error message.  It should be easy to spot the error both so 
> you can easily fix it and to prevent you from typing lldb commands into your 
> shell.  If libOption had a "nearest option name to the one you typed" 
> facility that would be useful in this case as well.


That facility exists. Clang uses it for command-line "fix-its". I am not sure 
what it takes to make use of it.

> Does anybody remember what gdb does when you mistype a command-line option?  
> We're not at all required to model their behavior, but it would be 
> interesting to consider.

  $ gdb -foobar
  gdb: unrecognized option '-foobar'
  Use `gdb --help' for a complete list of options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80165



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


[Lldb-commits] [PATCH] D80253: [lldb] Cleans up system_libs

2020-05-20 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.

Yes, that's definitely cleaner. Thanks.

Some of these could/should probably be moved up to lldbHost, but that's ok if 
you want to keep this NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80253



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


[Lldb-commits] [PATCH] D80226: [lldb/Driver] Error out when encountering unknown arguments

2020-05-20 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.

yep


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D80226



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


[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin marked an inline comment as not done.
jarin added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:5215
+uint32_t num_pointee_children = 0;
+if (pointee_clang_type.IsAggregateType())
+  num_pointee_children =

shafik wrote:
> I am curious what cases are pointers aggregates? Do we test this case?
As far as I understand, pointers are never aggregates, see [ 
https://github.com/llvm/llvm-project/blob/58684fbb6f2e6871f3f96ac8c7166a7d7486e971/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L2683
 | IsAggregate ]].


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

https://reviews.llvm.org/D80254



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


[Lldb-commits] [PATCH] D80254: Prevent GetNumChildren from transitively walking pointer chains

2020-05-20 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin updated this revision to Diff 265141.
jarin marked 2 inline comments as done.
jarin added a comment.

Added more assertions, reformatted the test code.


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

https://reviews.llvm.org/D80254

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/functionalities/pointer_num_children/Makefile
  lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py
  lldb/test/API/functionalities/pointer_num_children/main.cpp

Index: lldb/test/API/functionalities/pointer_num_children/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/pointer_num_children/main.cpp
@@ -0,0 +1,16 @@
+struct Inner {
+  int a;
+  int b;
+};
+
+struct Outer {
+  Inner *inner;
+};
+
+int main() {
+  Inner inner{42, 56};
+  Outer outer{};
+  auto Ptr = &(outer.inner);
+  auto  = outer.inner;
+  return 0; // break here
+}
Index: lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py
===
--- /dev/null
+++ lldb/test/API/functionalities/pointer_num_children/TestPointerNumChildren.py
@@ -0,0 +1,28 @@
+"""
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestPointerNumChilden(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test_pointer_num_children(self):
+self.main_source_file = lldb.SBFileSpec("main.cpp")
+self.build()
+(_, _, thread, _) = lldbutil.run_to_source_breakpoint(self, "// break here", self.main_source_file)
+frame = thread.GetSelectedFrame()
+
+result = frame.FindVariable("Ref")
+self.assertEqual(1, result.GetNumChildren())
+self.assertEqual(2, result.GetChildAtIndex(0).GetNumChildren())
+self.assertEqual("42", result.GetChildAtIndex(0).GetChildAtIndex(0).GetValue())
+self.assertEqual("56", result.GetChildAtIndex(0).GetChildAtIndex(1).GetValue())
+
+result = frame.FindVariable("Ptr")
+self.assertEqual(1, result.GetNumChildren())
+self.assertEqual(2, result.GetChildAtIndex(0).GetNumChildren())
+self.assertEqual("42", result.GetChildAtIndex(0).GetChildAtIndex(0).GetValue())
+self.assertEqual("56", result.GetChildAtIndex(0).GetChildAtIndex(1).GetValue())
Index: lldb/test/API/functionalities/pointer_num_children/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/pointer_num_children/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5173,11 +5173,12 @@
 break;
 
   case clang::Type::ObjCObjectPointer: {
-const clang::ObjCObjectPointerType *pointer_type =
-llvm::cast(qual_type.getTypePtr());
-clang::QualType pointee_type = pointer_type->getPointeeType();
-uint32_t num_pointee_children =
-GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
+CompilerType pointee_clang_type(GetPointeeType(type));
+
+uint32_t num_pointee_children = 0;
+if (pointee_clang_type.IsAggregateType())
+  num_pointee_children =
+  pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx);
 // If this type points to a simple type, then it has 1 child
 if (num_pointee_children == 0)
   num_children = 1;
@@ -5209,8 +5210,11 @@
 const clang::PointerType *pointer_type =
 llvm::cast(qual_type.getTypePtr());
 clang::QualType pointee_type(pointer_type->getPointeeType());
-uint32_t num_pointee_children =
-GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
+CompilerType pointee_clang_type(GetType(pointee_type));
+uint32_t num_pointee_children = 0;
+if (pointee_clang_type.IsAggregateType())
+  num_pointee_children =
+  pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx);
 if (num_pointee_children == 0) {
   // We have a pointer to a pointee type that claims it has no children. We
   // will want to look at
@@ -5223,9 +5227,11 @@
   case clang::Type::RValueReference: {
 const clang::ReferenceType *reference_type =
 llvm::cast(qual_type.getTypePtr());
-clang::QualType pointee_type = reference_type->getPointeeType();
-uint32_t num_pointee_children =
-GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
+CompilerType pointee_clang_type = GetType(reference_type->getPointeeType());
+uint32_t num_pointee_children = 0;
+if (pointee_clang_type.IsAggregateType())
+  num_pointee_children =
+