[Lldb-commits] [PATCH] D32149: [lldb] [Process] Add proper support for NetBSD core files with threads

2019-03-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 189658.
mgorny edited the summary of this revision.
mgorny added a comment.

I've added one more test case, and added stop reason/signal checking for both 
threads. I think it's ready for review now.


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

https://reviews.llvm.org/D32149

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.amd64
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.amd64.core
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/1lwp_SIGSEGV.c
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.amd64
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.amd64.core
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_process_SIGSEGV.c
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.amd64
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.amd64.core
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/2lwp_t2_SIGSEGV.c
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/GNUmakefile
  
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/elf-core/RegisterUtilities.h

Index: lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
===
--- lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -27,9 +27,42 @@
 }
 
 namespace NETBSD {
-enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
+enum { NT_PROCINFO = 1, NT_AUXV = 2 };
+
+/* Size in bytes */
+enum { NT_PROCINFO_SIZE = 160 };
+
+/* Size in bytes */
+enum {
+  NT_PROCINFO_CPI_VERSION_SIZE = 4,
+  NT_PROCINFO_CPI_CPISIZE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGNO_SIZE = 4,
+  NT_PROCINFO_CPI_SIGCODE_SIZE = 4,
+  NT_PROCINFO_CPI_SIGPEND_SIZE = 16,
+  NT_PROCINFO_CPI_SIGMASK_SIZE = 16,
+  NT_PROCINFO_CPI_SIGIGNORE_SIZE = 16,
+  NT_PROCINFO_CPI_SIGCATCH_SIZE = 16,
+  NT_PROCINFO_CPI_PID_SIZE = 4,
+  NT_PROCINFO_CPI_PPID_SIZE = 4,
+  NT_PROCINFO_CPI_PGRP_SIZE = 4,
+  NT_PROCINFO_CPI_SID_SIZE = 4,
+  NT_PROCINFO_CPI_RUID_SIZE = 4,
+  NT_PROCINFO_CPI_EUID_SIZE = 4,
+  NT_PROCINFO_CPI_SVUID_SIZE = 4,
+  NT_PROCINFO_CPI_RGID_SIZE = 4,
+  NT_PROCINFO_CPI_EGID_SIZE = 4,
+  NT_PROCINFO_CPI_SVGID_SIZE = 4,
+  NT_PROCINFO_CPI_NLWPS_SIZE = 4,
+  NT_PROCINFO_CPI_NAME_SIZE = 32,
+  NT_PROCINFO_CPI_SIGLWP_SIZE = 4,
+};
+
+namespace AMD64 {
+enum { NT_REGS = 33, NT_FPREGS = 35 };
 }
 
+} // namespace NETBSD
+
 namespace OPENBSD {
 enum {
   NT_PROCINFO = 10,
@@ -91,7 +124,7 @@
 // The result from FXSAVE is in NT_PRXFPREG for i386 core files
 {llvm::Triple::Linux, llvm::Triple::x86, LINUX::NT_PRXFPREG},
 {llvm::Triple::Linux, llvm::Triple::UnknownArch, LINUX::NT_FPREGSET},
-{llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::NT_AMD64_FPREGS},
+{llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::AMD64::NT_FPREGS},
 {llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS},
 };
 
Index: lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -446,16 +446,48 @@
   thread_data.gpregset = DataExtractor(data, offset, len);
 }
 
-static void ParseNetBSDProcInfo(ThreadData &thread_data,
-const DataExtractor &data) {
+static llvm::Error ParseNetBSDProcInfo(const DataExtractor &data,
+   uint32_t &cpi_nlwps,
+   uint32_t &cpi_signo,
+   uint32_t &cpi_siglwp,
+   uint32_t &cpi_pid) {
   lldb::offset_t offset = 0;
 
-  int version = data.GetU32(&offset);
+  uint32_t version = data.GetU32(&offset);
   if (version != 1)
-return;
+return llvm::make_error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo version",
+llvm::inconvertibleErrorCode());
 
-  offset += 4;
-  thread_data.signo = data.GetU32(&offset);
+  uint32_t cpisize = data.GetU32(&offset);
+  if (cpisize != NETBSD::NT_PROCINFO_SIZE)
+return llvm::make_error(
+"Error parsing NetBSD core(5) notes: Unsupported procinfo size",
+llvm::inconvertibleErrorCode());
+
+  cpi_signo = data.GetU32(&offset); /* killing signal */
+
+  offset += NETBSD::NT_PROCINFO_CPI_SIGCODE_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGPEND_SIZE;
+  offset += NETBSD::NT_PROCINFO_CPI_SIGMASK_SIZE;

[Lldb-commits] [PATCH] D59072: [ExpressionParser] Implement ComputeClangResourceDir for Windows

2019-03-07 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.

lgtm


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59072



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


[Lldb-commits] [PATCH] D58962: Sanity check --max-gdbserver-port

2019-03-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D58962#1420529 , @jankratochvil 
wrote:

> In D58962#1420137 , @JDevlieghere 
> wrote:
>
> > There's a tools folder (`lit/tools`) where this would fit. It's lowercase, 
> > possibly to match llvm's `test/tools` directory?
>
>
> Yes, `lit/tools/lldb-server/TestGdbserverPort.test` looks as the right 
> location.


Looks good to me.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D58962



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


[Lldb-commits] [PATCH] D59004: [lldb] Fix DW_OP_addrx uses.

2019-03-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thank you. The test looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59004



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


[Lldb-commits] [PATCH] D57475: [Reproducers] Add SBReproducer macros

2019-03-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Jonas, would it be possible to just not intercept the functions which work with 
thread IDs and similar stuff (an all OSs)?
Using the naive serialization approach will not be correct for these, even if 
the types happen to be implemented as primitive types (most likely we will need 
some runtime remapping of thread id's or something), so I am hoping it would 
not affect the ability to record&replay the recordings which don't use these 
functions.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D57475



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


[Lldb-commits] [PATCH] D32149: [lldb] [Process] Add proper support for NetBSD core files with threads

2019-03-07 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

Looks good to me.


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

https://reviews.llvm.org/D32149



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


[Lldb-commits] [PATCH] D59088: Fix TestDataFormatter.test uninitialized variable

2019-03-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: JDevlieghere.
jankratochvil added a project: LLDB.
Herald added subscribers: teemperor, jfb.

After D55626  I see a failure in my Fedora 
buildbot 
:

  FAIL: LLDB :: Reproducer/Functionalities/TestDataFormatter.test (76 of 1540)
   TEST 'LLDB :: 
Reproducer/Functionalities/TestDataFormatter.test' FAILED 
  Script:
  --
  : 'RUN: at line 5';   rm -rf 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/tools/lldb/lit/Reproducer/Functionalities/Output/TestDataFormatter.test.tmp.repro
  : 'RUN: at line 6';   
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/bin/clang 
-pthread 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/lit/Reproducer/Functionalities/Inputs/foo.cpp
 -g -o 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/tools/lldb/lit/Reproducer/Functionalities/Output/TestDataFormatter.test.tmp.out
  : 'RUN: at line 8';   
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/bin/lldb 
--no-lldbinit -S 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/lit/lit-lldb-init
 -x -b -s 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
 --capture 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/tools/lldb/lit/Reproducer/Functionalities/Output/TestDataFormatter.test.tmp.repro
 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/tools/lldb/lit/Reproducer/Functionalities/Output/TestDataFormatter.test.tmp.out
 | 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/bin/FileCheck 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/lit/Reproducer/Functionalities/TestDataFormatter.test
  : 'RUN: at line 9';   
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/bin/lldb 
--no-lldbinit -S 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/lit/lit-lldb-init
 --replay 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/tools/lldb/lit/Reproducer/Functionalities/Output/TestDataFormatter.test.tmp.repro
 | 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/build/bin/FileCheck 
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/lit/Reproducer/Functionalities/TestDataFormatter.test
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/lit/Reproducer/Functionalities/TestDataFormatter.test:12:10:
 error: CHECK: expected string not found in input
  # CHECK: (Foo) foo = (m_i = 0, m_d = 0)
   ^
  :15:2: note: scanning from here
   frame #0: 0x0040112e TestDataFormatter.test.tmp.out`main(argc=1, 
argv=0x7fffea08) at foo.cpp:11:7
   ^
  :43:1: note: possible intended match here
  (Foo) foo = (m_i = 1, m_d = 2)
  ^

There is uninitialized variable as the Foo constructor has not been run and 
`foo` is an autovariable:

  (lldb) breakpoint set -f foo.cpp -l 11
  Breakpoint 1: where = TestDataFormatter.test.tmp.out`main + 30 at 
foo.cpp:11:7, address = 0x0040112e
  (lldb) run
  Process 801065 stopped
  * thread #1, name = 'TestDataFormatt', stop reason = breakpoint 1.1
  frame #0: 0x0040112e TestDataFormatter.test.tmp.out`main(argc=1, 
argv=0x7fffcc48) at foo.cpp:11:7
 8  };
 9  
 10 int main(int argc, char **argv) {
  -> 11   Foo foo(1, 2.22);
 12   return 0;
 13 }
  
  Process 801065 launched: 
'/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestDataFormatter.test.tmp.out'
 (x86_64)
  (lldb) frame var
  (int) argc = 1
  (char **) argv = 0x7fffcc48
  (Foo) foo = (m_i = 4198432, m_d = 0)

While the testcase expects `m_i` will be 0.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D59088

Files:
  lldb/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
  lldb/lit/Reproducer/Functionalities/Inputs/foo.cpp
  lldb/lit/Reproducer/Functionalities/TestDataFormatter.test


Index: lldb/lit/Reproducer/Functionalities/TestDataFormatter.test
===
--- lldb/lit/Reproducer/Functionalities/TestDataFormatter.test
+++ lldb/lit/Reproducer/Functionalities/TestDataFormatter.test
@@ -3,7 +3,7 @@
 # This tests that data formatters continue to work when replaying a reproducer.
 
 # RUN: rm -rf %t.repro
-# RUN: %clang %S/Inputs/foo.cpp -g -o %t.out
+# RUN: %clangxx %S/Inputs/foo.cpp -g -o %t.out
 
 # RUN: %lldb -x -b -s %S/Inputs/DataFormatter.in --capture %t.repro %t.out | 
FileCheck %s
 # RUN: %lldb --replay %t.repro | FileCheck %s
Index: lldb/lit/Reproducer/Functionalities/Inp

[Lldb-commits] [PATCH] D55626: [Reproducers] Add tests for functionality

2019-03-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

There is also failing `TestImagineList` on my Fedora buildbot 
:

  ++ : 'RUN: at line 19'
  ++ cat 
/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.txt
  ++ /home/jkratoch/redhat/llvm-monorepo-clangassert/bin/FileCheck 
/home/jkratoch/redhat/llvm-monorepo/lldb/lit/Reproducer/Functionalities/TestImagineList.test
  
/home/jkratoch/redhat/llvm-monorepo/lldb/lit/Reproducer/Functionalities/TestImagineList.test:24:10:
 error: CHECK: expected string not found in input
  # CHECK: [ 1] [[ONE:.*]]
   ^
  :11:1: note: scanning from here
  (lldb) reproducer generate
  ^
  :16:22: note: possible intended match here
  (lldb) # LLDB init file for the LIT tests.
   ^

The output is missing `[  1]`, unaware why it should be required and what is 
there probably on OSX:

  CAPTURE
  (lldb) command source -s 0 
'/quad/home/jkratoch/redhat/llvm-monorepo/lldb/lit/lit-lldb-init'
  Executing commands in 
'/quad/home/jkratoch/redhat/llvm-monorepo/lldb/lit/lit-lldb-init'.
  (lldb) # LLDB init file for the LIT tests.
  (lldb) settings set symbols.enable-external-lookup false
  (lldb) settings set interpreter.echo-comment-commands false
  (lldb) target create 
"/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.out"
  Current executable set to 
'/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.out'
 (x86_64).
  (lldb) image list
  [  0] 39FC470D 0x0040 
/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.out
 
  (lldb) reproducer generate
  Reproducer written to 
'/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.repro'
  REPLAY
  (lldb) command source -s 0 
'/quad/home/jkratoch/redhat/llvm-monorepo/lldb/lit/lit-lldb-init'
  Executing commands in 
'/quad/home/jkratoch/redhat/llvm-monorepo/lldb/lit/lit-lldb-init'.
  (lldb) # LLDB init file for the LIT tests.
  (lldb) settings set symbols.enable-external-lookup false
  (lldb) settings set interpreter.echo-comment-commands false
  (lldb) target create 
"/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.out"
  Current executable set to 
'/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.out'
 (x86_64).
  (lldb) image list
  [  0] 39FC470D 0x0040 
/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/lit/Reproducer/Functionalities/Output/TestImagineList.test.tmp.out
 
  (lldb) reproducer generate


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55626



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


[Lldb-commits] [PATCH] D58930: Add XCOFF triple object format type for AIX

2019-03-07 Thread Jason Liu via Phabricator via lldb-commits
jasonliu updated this revision to Diff 189713.
jasonliu added a comment.

Share the same "unsupported error" message with WASM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58930

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1258,6 +1258,11 @@
   EXPECT_EQ(Triple::Wasm,
 Triple("wasm64-unknown-wasi-musl-wasm").getObjectFormat());
 
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc-ibm-aix").getObjectFormat());
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc64-ibm-aix").getObjectFormat());
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat());
+  EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat());
+
   Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
   EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
 
@@ -1276,6 +1281,9 @@
 
   T.setObjectFormat(Triple::MachO);
   EXPECT_EQ(Triple::MachO, T.getObjectFormat());
+  
+  T.setObjectFormat(Triple::XCOFF);
+  EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
 }
 
 TEST(TripleTest, NormalizeWindows) {
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -5594,6 +5594,9 @@
   case MCObjectFileInfo::IsWasm:
 CurrentFormat = WASM;
 break;
+  case MCObjectFileInfo::IsXCOFF:
+llvm_unreachable("unexpected object format");
+break;
   }
 
   if (~Prefix->SupportedFormats & CurrentFormat) {
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -534,6 +534,9 @@
 
 static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
   return StringSwitch(EnvironmentName)
+// "xcoff" must come before "coff" because of the order-dependendent
+// pattern matching.
+.EndsWith("xcoff", Triple::XCOFF)
 .EndsWith("coff", Triple::COFF)
 .EndsWith("elf", Triple::ELF)
 .EndsWith("macho", Triple::MachO)
@@ -622,6 +625,7 @@
   case Triple::ELF: return "elf";
   case Triple::MachO: return "macho";
   case Triple::Wasm: return "wasm";
+  case Triple::XCOFF: return "xcoff";
   }
   llvm_unreachable("unknown object format type");
 }
@@ -686,6 +690,8 @@
   case Triple::ppc64:
 if (T.isOSDarwin())
   return Triple::MachO;
+else if (T.isOSAIX())
+  return Triple::XCOFF;
 return Triple::ELF;
 
   case Triple::wasm32:
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -710,6 +710,9 @@
   case MCObjectFileInfo::IsWasm:
 PlatformParser.reset(createWasmAsmParser());
 break;
+  case MCObjectFileInfo::IsXCOFF:
+// TODO: Need to implement createXCOFFAsmParser for XCOFF format.
+break;
   }
 
   PlatformParser->Initialize(*this);
Index: llvm/lib/MC/MCObjectFileInfo.cpp
===
--- llvm/lib/MC/MCObjectFileInfo.cpp
+++ llvm/lib/MC/MCObjectFileInfo.cpp
@@ -801,6 +801,10 @@
 Env = IsWasm;
 initWasmMCObjectFileInfo(TT);
 break;
+  case Triple::XCOFF:
+Env = IsXCOFF;
+// TODO: Initialize MCObjectFileInfo for XCOFF format when MCSectionXCOFF is ready.
+break;
   case Triple::UnknownObjectFormat:
 report_fatal_error("Cannot initialize MC for unknown object file format.");
 break;
@@ -816,6 +820,7 @@
   case Triple::MachO:
   case Triple::COFF:
   case Triple::Wasm:
+  case Triple::XCOFF:
   case Triple::UnknownObjectFormat:
 report_fatal_error("Cannot get DWARF comdat section for this object file "
"format: not implemented.");
Index: llvm/lib/MC/MCContext.cpp
===
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -161,6 +161,9 @@
   return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
 case MCObjectFileInfo::IsWasm:
   return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
+case MCObjectFileInfo::IsXCOFF:
+  // TODO: Need to implement class MCSymbolXCOFF.
+  break;
 }
   }
   return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
Inde

Re: [Lldb-commits] [PATCH] D57475: [Reproducers] Add SBReproducer macros

2019-03-07 Thread Jonas Devlieghere via lldb-commits
Yes, I think that makes sense. I'll remove the register macro for now,
which initializes the types. The record macro I'll leave in place to ensure
the toggling between boundaries doesn't get affected by this. The "nice"
side effect is that it will trigger an assertion during replay, which
hopefully makes this easier to triage down the line.

On Thu, Mar 7, 2019 at 12:52 AM Pavel Labath via Phabricator <
revi...@reviews.llvm.org> wrote:

> labath added a comment.
>
> Jonas, would it be possible to just not intercept the functions which work
> with thread IDs and similar stuff (an all OSs)?
> Using the naive serialization approach will not be correct for these, even
> if the types happen to be implemented as primitive types (most likely we
> will need some runtime remapping of thread id's or something), so I am
> hoping it would not affect the ability to record&replay the recordings
> which don't use these functions.
>
>
> Repository:
>   rLLDB LLDB
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D57475/new/
>
> https://reviews.llvm.org/D57475
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r355610 - [Reproducers] Disable registering lldb::thread_t everywhere

2019-03-07 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Mar  7 09:27:33 2019
New Revision: 355610

URL: http://llvm.org/viewvc/llvm-project?rev=355610&view=rev
Log:
[Reproducers] Disable registering lldb::thread_t everywhere

As discussed on the mailing list, default serialization for thread ids
is not correct, even if they're represented as basic types. I'm
purposely leaving the corresponding record macros in place so that we
don't break the API boundary detection.

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

Modified: lldb/trunk/source/API/SBReproducer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBReproducer.cpp?rev=355610&r1=355609&r2=355610&view=diff
==
--- lldb/trunk/source/API/SBReproducer.cpp (original)
+++ lldb/trunk/source/API/SBReproducer.cpp Thu Mar  7 09:27:33 2019
@@ -1116,17 +1116,6 @@ SBRegistry::SBRegistry() {
 LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS,
 GetUserHomeDirectory, ());
 LLDB_REGISTER_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *));
-#ifndef _WIN32
-// FIXME: On Windows, lldb::thread_t is just a void*, so the we will try to
-//allocate an object of type void when deserializing.
-LLDB_REGISTER_STATIC_METHOD(bool, SBHostOS, ThreadCancel,
-(lldb::thread_t, lldb::SBError *));
-LLDB_REGISTER_STATIC_METHOD(bool, SBHostOS, ThreadDetach,
-(lldb::thread_t, lldb::SBError *));
-LLDB_REGISTER_STATIC_METHOD(
-bool, SBHostOS, ThreadJoin,
-(lldb::thread_t, lldb::thread_result_t *, lldb::SBError *));
-#endif
   }
   {
 LLDB_REGISTER_CONSTRUCTOR(SBInstruction, ());


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


[Lldb-commits] [PATCH] D59088: Fix TestDataFormatter.test uninitialized variable

2019-03-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59088



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


[Lldb-commits] [lldb] r355611 - Fix TestDataFormatter.test uninitialized variable

2019-03-07 Thread Jan Kratochvil via lldb-commits
Author: jankratochvil
Date: Thu Mar  7 09:35:47 2019
New Revision: 355611

URL: http://llvm.org/viewvc/llvm-project?rev=355611&view=rev
Log:
Fix TestDataFormatter.test uninitialized variable

After D55626 I see a failure in my Fedora buildbot.

There is uninitialized variable as the Foo constructor has not been run and foo
is an autovariable.

(lldb) breakpoint set -f foo.cpp -l 11
Breakpoint 1: where = TestDataFormatter.test.tmp.out`main + 30 at foo.cpp:11:7, 
address = 0x0040112e
(lldb) run
Process 801065 stopped
* thread #1, name = 'TestDataFormatt', stop reason = breakpoint 1.1
frame #0: 0x0040112e TestDataFormatter.test.tmp.out`main(argc=1, 
argv=0x7fffcc48) at foo.cpp:11:7
   8};
   9
   10   int main(int argc, char **argv) {
-> 11 Foo foo(1, 2.22);
   12 return 0;
   13   }

Process 801065 launched: 
'.../tools/lldb/lit/Reproducer/Functionalities/Output/TestDataFormatter.test.tmp.out'
 (x86_64)
(lldb) frame var
(int) argc = 1
(char **) argv = 0x7fffcc48
(Foo) foo = (m_i = 4198432, m_d = 0)

While the testcase expects m_i will be 0.

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

Modified:
lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test

Modified: lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in?rev=355611&r1=355610&r2=355611&view=diff
==
--- lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in (original)
+++ lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in Thu Mar  
7 09:35:47 2019
@@ -1,7 +1,7 @@
 breakpoint set -f foo.cpp -l 11
 run
-frame var
+frame var foo
 next
-frame var
+frame var foo
 cont
 reproducer generate

Modified: lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp?rev=355611&r1=355610&r2=355611&view=diff
==
--- lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp (original)
+++ lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp Thu Mar  7 
09:35:47 2019
@@ -8,6 +8,6 @@ private:
 };
 
 int main(int argc, char **argv) {
-  Foo foo(1, 2.22);
+  static Foo foo(1, 2.22);
   return 0;
 }

Modified: lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test?rev=355611&r1=355610&r2=355611&view=diff
==
--- lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test (original)
+++ lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test Thu Mar  7 
09:35:47 2019
@@ -3,7 +3,7 @@
 # This tests that data formatters continue to work when replaying a reproducer.
 
 # RUN: rm -rf %t.repro
-# RUN: %clang %S/Inputs/foo.cpp -g -o %t.out
+# RUN: %clangxx %S/Inputs/foo.cpp -g -o %t.out
 
 # RUN: %lldb -x -b -s %S/Inputs/DataFormatter.in --capture %t.repro %t.out | 
FileCheck %s
 # RUN: %lldb --replay %t.repro | FileCheck %s


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


[Lldb-commits] [PATCH] D59088: Fix TestDataFormatter.test uninitialized variable

2019-03-07 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355611: Fix TestDataFormatter.test uninitialized variable 
(authored by jankratochvil, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59088?vs=189685&id=189735#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59088

Files:
  lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
  lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
  lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test


Index: lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
===
--- lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
+++ lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
@@ -8,6 +8,6 @@
 };
 
 int main(int argc, char **argv) {
-  Foo foo(1, 2.22);
+  static Foo foo(1, 2.22);
   return 0;
 }
Index: lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
===
--- lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
+++ lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
@@ -1,7 +1,7 @@
 breakpoint set -f foo.cpp -l 11
 run
-frame var
+frame var foo
 next
-frame var
+frame var foo
 cont
 reproducer generate
Index: lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test
===
--- lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test
+++ lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test
@@ -3,7 +3,7 @@
 # This tests that data formatters continue to work when replaying a reproducer.
 
 # RUN: rm -rf %t.repro
-# RUN: %clang %S/Inputs/foo.cpp -g -o %t.out
+# RUN: %clangxx %S/Inputs/foo.cpp -g -o %t.out
 
 # RUN: %lldb -x -b -s %S/Inputs/DataFormatter.in --capture %t.repro %t.out | 
FileCheck %s
 # RUN: %lldb --replay %t.repro | FileCheck %s


Index: lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
===
--- lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
+++ lldb/trunk/lit/Reproducer/Functionalities/Inputs/foo.cpp
@@ -8,6 +8,6 @@
 };
 
 int main(int argc, char **argv) {
-  Foo foo(1, 2.22);
+  static Foo foo(1, 2.22);
   return 0;
 }
Index: lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
===
--- lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
+++ lldb/trunk/lit/Reproducer/Functionalities/Inputs/DataFormatter.in
@@ -1,7 +1,7 @@
 breakpoint set -f foo.cpp -l 11
 run
-frame var
+frame var foo
 next
-frame var
+frame var foo
 cont
 reproducer generate
Index: lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test
===
--- lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test
+++ lldb/trunk/lit/Reproducer/Functionalities/TestDataFormatter.test
@@ -3,7 +3,7 @@
 # This tests that data formatters continue to work when replaying a reproducer.
 
 # RUN: rm -rf %t.repro
-# RUN: %clang %S/Inputs/foo.cpp -g -o %t.out
+# RUN: %clangxx %S/Inputs/foo.cpp -g -o %t.out
 
 # RUN: %lldb -x -b -s %S/Inputs/DataFormatter.in --capture %t.repro %t.out | FileCheck %s
 # RUN: %lldb --replay %t.repro | FileCheck %s
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r355612 - [testsuite] Drop characters that can't be decoded, restoring parity with Py2.

2019-03-07 Thread Davide Italiano via lldb-commits
Author: davide
Date: Thu Mar  7 09:45:53 2019
New Revision: 355612

URL: http://llvm.org/viewvc/llvm-project?rev=355612&view=rev
Log:
[testsuite] Drop characters that can't be decoded, restoring parity with Py2.

Tests that check the output of `memory find` may trip over
unreadable characters, and in Python 3 this is an error.

Modified:
lldb/trunk/packages/Python/lldbsuite/support/encoded_file.py

Modified: lldb/trunk/packages/Python/lldbsuite/support/encoded_file.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/support/encoded_file.py?rev=355612&r1=355611&r2=355612&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/support/encoded_file.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/support/encoded_file.py Thu Mar  7 
09:45:53 2019
@@ -31,6 +31,9 @@ def _encoded_write(old_write, encoding):
 # as unicode before attempting to write.
 if isinstance(s, six.binary_type):
 s = s.decode(encoding, "replace")
+# Filter unreadable characters, Python 3 is stricter than python 2 
about them.
+import re
+s = re.sub(r'[^\x00-\x7f]',r' ',s)
 return old_write(s)
 return impl
 


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


[Lldb-commits] [lldb] r355615 - [testsuite] Spring cleaning: this tests `stty`, not `lldb`.

2019-03-07 Thread Davide Italiano via lldb-commits
Author: davide
Date: Thu Mar  7 10:05:18 2019
New Revision: 355615

URL: http://llvm.org/viewvc/llvm-project?rev=355615&view=rev
Log:
[testsuite] Spring cleaning: this tests `stty`, not `lldb`.

Removed:
lldb/trunk/packages/Python/lldbsuite/test/terminal/

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


[Lldb-commits] [PATCH] D59102: Add an LLVM-style dump method to CompilerType for extra convenience during debugging

2019-03-07 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added a reviewer: davide.
Herald added a subscriber: jdoerfert.
Herald added a project: LLDB.

I find myself extracting m_type and and casting it to call dump() on the raw 
AST type several times per day, so why not make this a little more convenient!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59102

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/source/Symbol/CompilerType.cpp


Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -800,6 +800,15 @@
   }
 }
 
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void CompilerType::dump() const {
+  if (IsValid())
+m_type_system->dump(m_type);
+  else
+llvm::errs() << "\n";
+}
+#endif
+
 bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
 lldb::offset_t data_byte_offset,
 size_t data_byte_size,
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -9086,6 +9086,16 @@
 //--
 #define DEPTH_INCREMENT 2
 
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void
+ClangASTContext::dump(lldb::opaque_compiler_type_t type) const {
+  if (!type)
+return;
+  clang::QualType qual_type(GetQualType(type));
+  qual_type.dump();
+}
+#endif
+
 void ClangASTContext::Dump(Stream &s) {
   Decl *tu = Decl::castFromDeclContext(GetTranslationUnitDecl());
   tu->dump(s.AsRawOstream());
Index: lldb/include/lldb/Symbol/TypeSystem.h
===
--- lldb/include/lldb/Symbol/TypeSystem.h
+++ lldb/include/lldb/Symbol/TypeSystem.h
@@ -355,6 +355,12 @@
   // Dumping types
   //--
 
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  LLVM_DUMP_METHOD virtual void
+  dump(lldb::opaque_compiler_type_t type) const = 0;
+#endif
+  
   virtual void DumpValue(lldb::opaque_compiler_type_t type,
  ExecutionContext *exe_ctx, Stream *s,
  lldb::Format format, const DataExtractor &data,
Index: lldb/include/lldb/Symbol/CompilerType.h
===
--- lldb/include/lldb/Symbol/CompilerType.h
+++ lldb/include/lldb/Symbol/CompilerType.h
@@ -388,6 +388,13 @@
   //--
   // Dumping types
   //--
+
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  /// Don't call this function from actual code.
+  LLVM_DUMP_METHOD void dump() const;
+#endif
+
   void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
  const DataExtractor &data, lldb::offset_t data_offset,
  size_t data_byte_size, uint32_t bitfield_bit_size,
Index: lldb/include/lldb/Symbol/ClangASTContext.h
===
--- lldb/include/lldb/Symbol/ClangASTContext.h
+++ lldb/include/lldb/Symbol/ClangASTContext.h
@@ -929,6 +929,13 @@
   //--
   // Dumping types
   //--
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  /// In contrast to the other \p Dump() methods this directly invokes
+  /// \p clang::QualType::dump().
+  LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
+#endif
+
   void Dump(Stream &s);
 
   void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,


Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -800,6 +800,15 @@
   }
 }
 
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void CompilerType::dump() const {
+  if (IsValid())
+m_type_system->dump(m_type);
+  else
+llvm::errs() << "\n";
+}
+#endif
+
 bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
 lldb::offset_t data_byte_offset,
 size_t data_byte_size,
Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -9086,6 +9086,16 @@
 //---

[Lldb-commits] [PATCH] D59102: Add an LLVM-style dump method to CompilerType for extra convenience during debugging

2019-03-07 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

This will save me characters typing, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59102



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


[Lldb-commits] [PATCH] D59102: Add an LLVM-style dump method to CompilerType for extra convenience during debugging

2019-03-07 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

We should also add it to `SwiftASTContext` downstream.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59102



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


[Lldb-commits] [PATCH] D59104: [lldb-vscode] Make server mode work on Windows

2019-03-07 Thread Zachary Turner via Phabricator via lldb-commits
zturner created this revision.
zturner added a reviewer: clayborg.
Herald added a subscriber: mgorny.

For historical reasons, Windows unfortunately doesn't support using sockets in 
standard system calls like read/write, which means that they also can't be 
buffered with a `FILE*`.  This violates some fundamental assumptions of how 
lldb-vscode was written, so fixing it requires some replumbing of the guts.  I 
introduced an abstraction called `IOStream` which basically knows whether the 
descriptor is a socket or a non-socket, and then delegates to the appropriate 
underlying APIs accordingly.  This means calling `read/write` on `stdin/stdout` 
and calling `recv/send` on sockets.  Luckily this same strategy will also work 
on non-Windows platforms, so the abstractions needed aren't too egregious.


https://reviews.llvm.org/D59104

Files:
  lldb/tools/lldb-vscode/CMakeLists.txt
  lldb/tools/lldb-vscode/IOStream.cpp
  lldb/tools/lldb-vscode/IOStream.h
  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

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -56,6 +56,9 @@
 	]
 },
 "program": "./bin/lldb-vscode",
+"windows": {
+	"program": "./bin/lldb-vscode.exe"
+},
 "configurationAttributes": {
 	"launch": {
 		"required": [
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -23,6 +23,7 @@
 #define NOMINMAX
 #include 
 #undef GetObject
+#include 
 #else
 #include 
 #include 
@@ -68,9 +69,9 @@
 
 enum VSCodeBroadcasterBits { eBroadcastBitStopEventThread = 1u << 0 };
 
-int AcceptConnection(int portno) {
+SOCKET AcceptConnection(int portno) {
   // Accept a socket connection from any host on "portno".
-  int newsockfd = -1;
+  SOCKET newsockfd = -1;
   struct sockaddr_in serv_addr, cli_addr;
   SOCKET sockfd = socket(AF_INET, SOCK_STREAM, 0);
   if (sockfd < 0) {
@@ -2635,23 +2636,19 @@
 #endif
   int portno = atoi(arg);
   printf("Listening on port %i...\n", portno);
-  int socket_fd = AcceptConnection(portno);
+  SOCKET socket_fd = AcceptConnection(portno);
   if (socket_fd >= 0) {
-// We must open two FILE objects, one for reading and one for writing
-// the FILE objects have a mutex in them that won't allow reading and
-// writing to the socket stream.
-g_vsc.in = fdopen(socket_fd, "r");
-g_vsc.out = fdopen(socket_fd, "w");
-if (g_vsc.in == nullptr || g_vsc.out == nullptr) {
-  if (g_vsc.log)
-*g_vsc.log << "fdopen failed (" << strerror(errno) << ")"
-   << std::endl;
-  exit(1);
-}
+g_vsc.input.descriptor = StreamDescriptor::from_socket(socket_fd, true);
+g_vsc.output.descriptor =
+StreamDescriptor::from_socket(socket_fd, false);
   } else {
 exit(1);
   }
 }
+  } else {
+g_vsc.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false);
+g_vsc.output.descriptor =
+StreamDescriptor::from_file(fileno(stdout), false);
   }
   auto request_handlers = GetRequestHandlers();
   uint32_t packet_idx = 0;
Index: lldb/tools/lldb-vscode/VSCode.h
===
--- lldb/tools/lldb-vscode/VSCode.h
+++ lldb/tools/lldb-vscode/VSCode.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBreakpoint.h"
@@ -43,6 +44,7 @@
 
 #include "ExceptionBreakpoint.h"
 #include "FunctionBreakpoint.h"
+#include "IOStream.h"
 #include "SourceBreakpoint.h"
 #include "SourceReference.h"
 
@@ -62,8 +64,8 @@
 enum class OutputType { Console, Stdout, Stderr, Telemetry };
 
 struct VSCode {
-  FILE *in;
-  FILE *out;
+  InputStream input;
+  OutputStream output;
   lldb::SBDebugger debugger;
   lldb::SBTarget target;
   lldb::SBAttachInfo attach_info;
@@ -94,8 +96,6 @@
   ~VSCode();
   VSCode(const VSCode &rhs) = delete;
   void operator=(const VSCode &rhs) = delete;
-  void CloseInputStream();
-  void CloseOutputStream();
   int64_t GetLineForPC(int64_t sourceReference, lldb::addr_t pc) const;
   ExceptionBreakpoint *GetExceptionBreakpoint(const std::string &filter);
   ExceptionBreakpoint *GetExceptionBreakpoint(const lldb::break_id_t bp_id);
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -10,12 +10,15 @@
 #include 
 #include 
 
-#include "VSCode.h"
 #include "LLDBUtils.h"
+#incl

[Lldb-commits] [PATCH] D59004: [lldb] Fix DW_OP_addrx uses.

2019-03-07 Thread Ali Tamur via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355629: [lldb] Fix DW_OP_addrx uses. (authored by tamur, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59004?vs=189652&id=189761#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59004

Files:
  lldb/trunk/lit/SymbolFile/DWARF/dwarf5_locations.s
  lldb/trunk/source/Expression/DWARFExpression.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -326,6 +326,7 @@
 break;
 
   // signed or unsigned LEB 128 values
+  case DW_FORM_addrx:
   case DW_FORM_sdata:
   case DW_FORM_udata:
   case DW_FORM_ref_udata:
@@ -456,6 +457,7 @@
 
 case DW_AT_high_pc:
   if (form_value.Form() == DW_FORM_addr ||
+  form_value.Form() == DW_FORM_addrx ||
   form_value.Form() == DW_FORM_GNU_addr_index) {
 hi_pc = form_value.Address();
   } else {
@@ -1031,7 +1033,8 @@
   if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value, nullptr,
 check_specification_or_abstract_origin)) {
 dw_form_t form = form_value.Form();
-if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index)
+if (form == DW_FORM_addr || form == DW_FORM_addrx ||
+form == DW_FORM_GNU_addr_index)
   return form_value.Address();
 
 // DWARF4 can specify the hi_pc as an 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -681,6 +681,7 @@
 return 1;
   switch (a_form) {
   case DW_FORM_addr:
+  case DW_FORM_addrx:
   case DW_FORM_flag:
   case DW_FORM_data1:
   case DW_FORM_data2:
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -166,6 +166,7 @@
   case DW_FORM_ref_sig8:
 llvm_unreachable("Unhandled atom form");
 
+  case DW_FORM_addrx:
   case DW_FORM_string:
   case DW_FORM_block:
   case DW_FORM_block1:
Index: lldb/trunk/source/Expression/DWARFExpression.cpp
===
--- lldb/trunk/source/Expression/DWARFExpression.cpp
+++ lldb/trunk/source/Expression/DWARFExpression.cpp
@@ -514,6 +514,10 @@
   s->Printf("DW_OP_GNU_addr_index(0x%" PRIx64 ")",
 m_data.GetULEB128(&offset));
   break;
+case DW_OP_addrx:
+  s->Printf("DW_OP_addrx(0x%" PRIx64 ")",
+m_data.GetULEB128(&offset));
+  break;
 case DW_OP_GNU_const_index: // 0xfc
   s->Printf("DW_OP_GNU_const_index(0x%" PRIx64 ")",
 m_data.GetULEB128(&offset));
@@ -877,6 +881,7 @@
 return 8;
 
   // All opcodes that have a single ULEB (signed or unsigned) argument
+  case DW_OP_addrx:   // 0xa1 1 ULEB128 index
   case DW_OP_constu:  // 0x10 1 ULEB128 constant
   case DW_OP_consts:  // 0x11 1 SLEB128 constant
   case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend
@@ -957,7 +962,7 @@
 return op_file_addr;
   else
 ++curr_op_addr_idx;
-} else if (op == DW_OP_GNU_addr_index) {
+} else if (op == DW_OP_GNU_addr_index || op == DW_OP_addrx) {
   uint64_t index = m_data.GetULEB128(&offset);
   if (curr_op_addr_idx == op_addr_idx) {
 if (!m_dwarf_cu) {
@@ -2902,13 +2907,14 @@
 } break;
 
 //--
-// OPCODE: DW_OP_GNU_addr_index
+// OPCODE: DW_OP_addrx (DW_OP_GNU_addr_index is the legacy name.)
 // OPERANDS: 1
 //  ULEB128: index to the .debug_addr section
 // DESCRIPTION: Pushes an address to the stack from the .debug_addr
 // section with the base address specified by the DW_AT_addr_base attribute
 // and the 0 based index is the ULEB128 encoded index.
 //--
+case DW_OP_addrx:
 case DW_OP_GNU_addr_index: {
   if (!dwarf_cu) {
 if (error_ptr)
@@ -3194,6 +3200,7 @@
   case DW_OP_call_ref:
 size = dwarf_ref_size;
 b

[Lldb-commits] [lldb] r355631 - [ExpressionParser] Implement ComputeClangResourceDir for Windows

2019-03-07 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Thu Mar  7 12:09:15 2019
New Revision: 355631

URL: http://llvm.org/viewvc/llvm-project?rev=355631&view=rev
Log:
[ExpressionParser] Implement ComputeClangResourceDir for Windows

Summary: This function is useful for expression evaluation, especially when 
doing swift debugging on windows.

Reviewers: aprantl, labath

Reviewed By: labath

Subscribers: teemperor, jdoerfert, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Host/HostInfoBase.h
lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h
lldb/trunk/source/Host/common/HostInfoBase.cpp
lldb/trunk/source/Host/posix/HostInfoPosix.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h
lldb/trunk/unittests/Expression/ClangParserTest.cpp

Modified: lldb/trunk/include/lldb/Host/HostInfoBase.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostInfoBase.h?rev=355631&r1=355630&r2=355631&view=diff
==
--- lldb/trunk/include/lldb/Host/HostInfoBase.h (original)
+++ lldb/trunk/include/lldb/Host/HostInfoBase.h Thu Mar  7 12:09:15 2019
@@ -99,6 +99,9 @@ public:
   //---
   static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
 
+  static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
+   llvm::StringRef dir);
+
 protected:
   static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
   static bool ComputeSupportExeDirectory(FileSpec &file_spec);

Modified: lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h?rev=355631&r1=355630&r2=355631&view=diff
==
--- lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h (original)
+++ lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h Thu Mar  7 12:09:15 2019
@@ -32,9 +32,6 @@ public:
 
   static bool GetEnvironmentVar(const std::string &var_name, std::string &var);
 
-  static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
-   llvm::StringRef dir);
-
   static UserIDResolver &GetUserIDResolver();
 
 protected:

Modified: lldb/trunk/source/Host/common/HostInfoBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=355631&r1=355630&r2=355631&view=diff
==
--- lldb/trunk/source/Host/common/HostInfoBase.cpp (original)
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp Thu Mar  7 12:09:15 2019
@@ -214,6 +214,38 @@ ArchSpec HostInfoBase::GetAugmentedArchS
   return ArchSpec(normalized_triple);
 }
 
+bool HostInfoBase::ComputePathRelativeToLibrary(FileSpec &file_spec,
+llvm::StringRef dir) {
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
+  FileSpec lldb_file_spec = GetShlibDir();
+  if (!lldb_file_spec)
+return false;
+
+  std::string raw_path = lldb_file_spec.GetPath();
+  if (log)
+log->Printf("HostInfo::%s() attempting to "
+"derive the path %s relative to liblldb install path: %s",
+__FUNCTION__, dir.data(), raw_path.c_str());
+
+  // Drop bin (windows) or lib
+  llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path);
+  if (parent_path.empty()) {
+if (log)
+  log->Printf("HostInfo::%s() failed to find liblldb within the shared "
+  "lib path",
+  __FUNCTION__);
+return false;
+  }
+
+  raw_path = (parent_path + dir).str();
+  if (log)
+log->Printf("HostInfo::%s() derived the path as: %s", __FUNCTION__,
+raw_path.c_str());
+  file_spec.GetDirectory().SetString(raw_path);
+  return (bool)file_spec.GetDirectory();
+}
+
 bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) {
   // To get paths related to LLDB we get the path to the executable that
   // contains this function. On MacOSX this will be "LLDB.framework/.../LLDB".

Modified: lldb/trunk/source/Host/posix/HostInfoPosix.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/HostInfoPosix.cpp?rev=355631&r1=355630&r2=355631&view=diff
==
--- lldb/trunk/source/Host/posix/HostInfoPosix.cpp (original)
+++ lldb/trunk/source/Host/posix/HostInfoPosix.cpp Thu Mar  7 12:09:15 2019
@@ -120,43 +120,6 @@ uint32_t HostInfoPosix::GetEffectiveGrou
 
 FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); }
 
-bool HostInfoPosix::ComputePathRelativeToLibrary(FileSpec &file_spec,
- llvm::St

[Lldb-commits] [PATCH] D59072: [ExpressionParser] Implement ComputeClangResourceDir for Windows

2019-03-07 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355631: [ExpressionParser] Implement ComputeClangResourceDir 
for Windows (authored by xiaobai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59072?vs=189642&id=189766#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59072

Files:
  lldb/trunk/include/lldb/Host/HostInfoBase.h
  lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h
  lldb/trunk/source/Host/common/HostInfoBase.cpp
  lldb/trunk/source/Host/posix/HostInfoPosix.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h
  lldb/trunk/unittests/Expression/ClangParserTest.cpp

Index: lldb/trunk/unittests/Expression/ClangParserTest.cpp
===
--- lldb/trunk/unittests/Expression/ClangParserTest.cpp
+++ lldb/trunk/unittests/Expression/ClangParserTest.cpp
@@ -31,7 +31,6 @@
 };
 } // namespace
 
-#if !defined(_WIN32)
 static std::string ComputeClangResourceDir(std::string lldb_shlib_path,
bool verify = false) {
   FileSpec clang_dir;
@@ -41,8 +40,13 @@
 }
 
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
+#if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
   std::string path_to_clang_dir = "/foo/bar/lib/clang/" CLANG_VERSION_STRING;
+#else
+  std::string path_to_liblldb = "C:\\foo\\bar\\lib";
+  std::string path_to_clang_dir = "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_STRING;
+#endif
   EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);
 
   // The path doesn't really exist, so setting verify to true should make
@@ -91,4 +95,3 @@
 ComputeClangResourceDir(GetInputFilePath(xcode)));
 }
 #endif // __APPLE__
-#endif // !_WIN32
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -18,9 +18,6 @@
 
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
-#if !defined(_WIN32)
-#include "lldb/Host/posix/HostInfoPosix.h"
-#endif
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Log.h"
 
@@ -28,12 +25,6 @@
 
 using namespace lldb_private;
 
-#if defined(_WIN32)
-static bool ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
-  FileSpec &file_spec, bool verify) {
-  return false;
-}
-#else
 static bool VerifyClangPath(const llvm::Twine &clang_path) {
   if (FileSystem::Instance().IsDirectory(clang_path))
 return true;
@@ -67,7 +58,7 @@
 return true;
   }
 
-  return HostInfoPosix::ComputePathRelativeToLibrary(file_spec, relative_path);
+  return HostInfo::ComputePathRelativeToLibrary(file_spec, relative_path);
 }
 
 bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
@@ -141,7 +132,6 @@
   return true;
 #endif // __APPLE__
 }
-#endif // _WIN32
 
 FileSpec lldb_private::GetClangResourceDir() {
   static FileSpec g_cached_resource_dir;
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h
@@ -13,10 +13,8 @@
 
 class FileSpec;
 
-#if !defined(_WIN32)
 bool ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
FileSpec &file_spec, bool verify);
-#endif
 
 FileSpec GetClangResourceDir();
 
Index: lldb/trunk/source/Host/posix/HostInfoPosix.cpp
===
--- lldb/trunk/source/Host/posix/HostInfoPosix.cpp
+++ lldb/trunk/source/Host/posix/HostInfoPosix.cpp
@@ -120,43 +120,6 @@
 
 FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); }
 
-bool HostInfoPosix::ComputePathRelativeToLibrary(FileSpec &file_spec,
- llvm::StringRef dir) {
-  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-
-  FileSpec lldb_file_spec = GetShlibDir();
-  if (!lldb_file_spec)
-return false;
-
-  std::string raw_path = lldb_file_spec.GetPath();
-  // drop library directory
-  llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path);
-
-  // Most Posix systems (e.g. Linux/*BSD) will attempt to replace a */lib with
-  // */bin as the base directory for helper exe programs.  This will fail if
-  // the /lib and /bin directories are rooted in entirely different trees.
-  if (log)
-log->Printf("HostInfoPosix::ComputePathRelativeToLibrary() attempting to "
-"derive the %s path from

[Lldb-commits] [lldb] r355632 - Add an LLVM-style dump method to CompilerType for extra convenience during debugging

2019-03-07 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Mar  7 12:20:02 2019
New Revision: 355632

URL: http://llvm.org/viewvc/llvm-project?rev=355632&view=rev
Log:
Add an LLVM-style dump method to CompilerType for extra convenience during 
debugging

This change has no effect on Release (NoAsserts) builds.

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

Modified:
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/CompilerType.h
lldb/trunk/include/lldb/Symbol/TypeSystem.h
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/CompilerType.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=355632&r1=355631&r2=355632&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Mar  7 12:20:02 2019
@@ -929,6 +929,13 @@ public:
   //--
   // Dumping types
   //--
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  /// In contrast to the other \p Dump() methods this directly invokes
+  /// \p clang::QualType::dump().
+  LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
+#endif
+
   void Dump(Stream &s);
 
   void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,

Modified: lldb/trunk/include/lldb/Symbol/CompilerType.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerType.h?rev=355632&r1=355631&r2=355632&view=diff
==
--- lldb/trunk/include/lldb/Symbol/CompilerType.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompilerType.h Thu Mar  7 12:20:02 2019
@@ -388,6 +388,13 @@ public:
   //--
   // Dumping types
   //--
+
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  /// Don't call this function from actual code.
+  LLVM_DUMP_METHOD void dump() const;
+#endif
+
   void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
  const DataExtractor &data, lldb::offset_t data_offset,
  size_t data_byte_size, uint32_t bitfield_bit_size,

Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=355632&r1=355631&r2=355632&view=diff
==
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Thu Mar  7 12:20:02 2019
@@ -355,6 +355,12 @@ public:
   // Dumping types
   //--
 
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  LLVM_DUMP_METHOD virtual void
+  dump(lldb::opaque_compiler_type_t type) const = 0;
+#endif
+  
   virtual void DumpValue(lldb::opaque_compiler_type_t type,
  ExecutionContext *exe_ctx, Stream *s,
  lldb::Format format, const DataExtractor &data,

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=355632&r1=355631&r2=355632&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Mar  7 12:20:02 2019
@@ -9086,6 +9086,16 @@ ClangASTContext::ConvertStringToFloatVal
 //--
 #define DEPTH_INCREMENT 2
 
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void
+ClangASTContext::dump(lldb::opaque_compiler_type_t type) const {
+  if (!type)
+return;
+  clang::QualType qual_type(GetQualType(type));
+  qual_type.dump();
+}
+#endif
+
 void ClangASTContext::Dump(Stream &s) {
   Decl *tu = Decl::castFromDeclContext(GetTranslationUnitDecl());
   tu->dump(s.AsRawOstream());

Modified: lldb/trunk/source/Symbol/CompilerType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompilerType.cpp?rev=355632&r1=355631&r2=355632&view=diff
==
--- lldb/trunk/source/Symbol/CompilerType.cpp (original)
+++ lldb/trunk/source/Symbol/CompilerType.cpp Thu Mar  7 12:20:02 2019
@@ -800,6 +800,15 @@ void CompilerType::DumpTypeDescription(S
   }
 }
 
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void CompilerType::dump() const {
+  if (IsValid())
+m_type_system->dump

[Lldb-commits] [PATCH] D59102: Add an LLVM-style dump method to CompilerType for extra convenience during debugging

2019-03-07 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355632: Add an LLVM-style dump method to CompilerType for 
extra convenience during… (authored by adrian, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59102?vs=189754&id=189767#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59102

Files:
  lldb/trunk/include/lldb/Symbol/ClangASTContext.h
  lldb/trunk/include/lldb/Symbol/CompilerType.h
  lldb/trunk/include/lldb/Symbol/TypeSystem.h
  lldb/trunk/source/Symbol/ClangASTContext.cpp
  lldb/trunk/source/Symbol/CompilerType.cpp


Index: lldb/trunk/include/lldb/Symbol/CompilerType.h
===
--- lldb/trunk/include/lldb/Symbol/CompilerType.h
+++ lldb/trunk/include/lldb/Symbol/CompilerType.h
@@ -388,6 +388,13 @@
   //--
   // Dumping types
   //--
+
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  /// Don't call this function from actual code.
+  LLVM_DUMP_METHOD void dump() const;
+#endif
+
   void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format,
  const DataExtractor &data, lldb::offset_t data_offset,
  size_t data_byte_size, uint32_t bitfield_bit_size,
Index: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
===
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h
@@ -929,6 +929,13 @@
   //--
   // Dumping types
   //--
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  /// In contrast to the other \p Dump() methods this directly invokes
+  /// \p clang::QualType::dump().
+  LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
+#endif
+
   void Dump(Stream &s);
 
   void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
Index: lldb/trunk/include/lldb/Symbol/TypeSystem.h
===
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h
@@ -355,6 +355,12 @@
   // Dumping types
   //--
 
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  LLVM_DUMP_METHOD virtual void
+  dump(lldb::opaque_compiler_type_t type) const = 0;
+#endif
+  
   virtual void DumpValue(lldb::opaque_compiler_type_t type,
  ExecutionContext *exe_ctx, Stream *s,
  lldb::Format format, const DataExtractor &data,
Index: lldb/trunk/source/Symbol/ClangASTContext.cpp
===
--- lldb/trunk/source/Symbol/ClangASTContext.cpp
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp
@@ -9086,6 +9086,16 @@
 //--
 #define DEPTH_INCREMENT 2
 
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void
+ClangASTContext::dump(lldb::opaque_compiler_type_t type) const {
+  if (!type)
+return;
+  clang::QualType qual_type(GetQualType(type));
+  qual_type.dump();
+}
+#endif
+
 void ClangASTContext::Dump(Stream &s) {
   Decl *tu = Decl::castFromDeclContext(GetTranslationUnitDecl());
   tu->dump(s.AsRawOstream());
Index: lldb/trunk/source/Symbol/CompilerType.cpp
===
--- lldb/trunk/source/Symbol/CompilerType.cpp
+++ lldb/trunk/source/Symbol/CompilerType.cpp
@@ -800,6 +800,15 @@
   }
 }
 
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void CompilerType::dump() const {
+  if (IsValid())
+m_type_system->dump(m_type);
+  else
+llvm::errs() << "\n";
+}
+#endif
+
 bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
 lldb::offset_t data_byte_offset,
 size_t data_byte_size,


Index: lldb/trunk/include/lldb/Symbol/CompilerType.h
===
--- lldb/trunk/include/lldb/Symbol/CompilerType.h
+++ lldb/trunk/include/lldb/Symbol/CompilerType.h
@@ -388,6 +388,13 @@
   //--
   // Dumping types
   //--
+
+#ifndef NDEBUG
+  /// Convenience LLVM-style dump method for use in the debugger only.
+  /// Don't call this function from actual code.
+  LLVM_DUMP_METHOD void dump() c

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

2019-03-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere abandoned this revision.
JDevlieghere added a comment.
Herald added a reviewer: serge-sans-paille.
Herald added a subscriber: jdoerfert.

Abandoning this until we can replace the dotest driver with lit.


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

https://reviews.llvm.org/D47062



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


[Lldb-commits] [lldb] r355637 - [lldb-vscode] Support running in server mode on Windows.

2019-03-07 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Mar  7 13:23:21 2019
New Revision: 355637

URL: http://llvm.org/viewvc/llvm-project?rev=355637&view=rev
Log:
[lldb-vscode] Support running in server mode on Windows.

Windows can't use standard i/o system calls such as read and write
to work with sockets, it instead needs to use the specific send
and recv calls.  This complicates matters for the debug adapter,
since it needs to be able to work in both server mode where it
communicates over a socket, as well as non-server mode where it
communicates via stdin and stdout.  To abstract this out, I've
introduced a class IOStream which hides all these details and
exposes a read/write interface that does the right on each
platform.

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

Added:
lldb/trunk/tools/lldb-vscode/IOStream.cpp
lldb/trunk/tools/lldb-vscode/IOStream.h
Modified:
lldb/trunk/tools/lldb-vscode/CMakeLists.txt
lldb/trunk/tools/lldb-vscode/VSCode.cpp
lldb/trunk/tools/lldb-vscode/VSCode.h
lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
lldb/trunk/tools/lldb-vscode/package.json

Modified: lldb/trunk/tools/lldb-vscode/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/CMakeLists.txt?rev=355637&r1=355636&r2=355637&view=diff
==
--- lldb/trunk/tools/lldb-vscode/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-vscode/CMakeLists.txt Thu Mar  7 13:23:21 2019
@@ -15,6 +15,7 @@ add_lldb_tool(lldb-vscode
   BreakpointBase.cpp
   ExceptionBreakpoint.cpp
   FunctionBreakpoint.cpp
+  IOStream.cpp
   JSONUtils.cpp
   LLDBUtils.cpp
   SourceBreakpoint.cpp

Added: lldb/trunk/tools/lldb-vscode/IOStream.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/IOStream.cpp?rev=355637&view=auto
==
--- lldb/trunk/tools/lldb-vscode/IOStream.cpp (added)
+++ lldb/trunk/tools/lldb-vscode/IOStream.cpp Thu Mar  7 13:23:21 2019
@@ -0,0 +1,153 @@
+//===-- IOStream.cpp *- 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
+//
+//===--===//
+
+#include "IOStream.h"
+
+#if defined(_WIN32)
+#include 
+#else
+#include 
+#include 
+#include 
+#endif
+
+#include 
+#include 
+#include 
+
+using namespace lldb_vscode;
+
+StreamDescriptor::StreamDescriptor() {}
+
+StreamDescriptor::StreamDescriptor(StreamDescriptor &&other) {
+  *this = std::move(other);
+}
+
+StreamDescriptor::~StreamDescriptor() {
+  if (!m_close)
+return;
+
+  if (m_is_socket)
+#if defined(_WIN32)
+::closesocket(m_socket);
+#else
+::close(m_socket);
+#endif
+  else
+::close(m_fd);
+}
+
+StreamDescriptor &StreamDescriptor::operator=(StreamDescriptor &&other) {
+  m_close = other.m_close;
+  other.m_close = false;
+  m_is_socket = other.m_is_socket;
+  if (m_is_socket)
+m_socket = other.m_socket;
+  else
+m_fd = other.m_fd;
+  return *this;
+}
+
+StreamDescriptor StreamDescriptor::from_socket(SOCKET s, bool close) {
+  StreamDescriptor sd;
+  sd.m_is_socket = true;
+  sd.m_socket = s;
+  sd.m_close = close;
+  return sd;
+}
+
+StreamDescriptor StreamDescriptor::from_file(int fd, bool close) {
+  StreamDescriptor sd;
+  sd.m_is_socket = false;
+  sd.m_fd = fd;
+  sd.m_close = close;
+  return sd;
+}
+
+bool OutputStream::write_full(llvm::StringRef str) {
+  while (!str.empty()) {
+int bytes_written = 0;
+if (descriptor.m_is_socket)
+  bytes_written = ::send(descriptor.m_socket, str.data(), str.size(), 0);
+else
+  bytes_written = ::write(descriptor.m_fd, str.data(), str.size());
+
+if (bytes_written < 0) {
+  if (errno == EINTR || errno == EAGAIN)
+continue;
+  return false;
+}
+str = str.drop_front(bytes_written);
+  }
+
+  return true;
+}
+
+bool InputStream::read_full(std::ofstream *log, size_t length,
+std::string &text) {
+  std::string data;
+  data.resize(length);
+
+  char *ptr = &data[0];
+  while (length != 0) {
+int bytes_read = 0;
+if (descriptor.m_is_socket)
+  bytes_read = ::recv(descriptor.m_socket, ptr, length, 0);
+else
+  bytes_read = ::read(descriptor.m_fd, ptr, length);
+
+if (bytes_read < 0) {
+  int reason = 0;
+#if defined(_WIN32)
+  if (descriptor.m_is_socket)
+reason = WSAGetLastError();
+  else
+reason = errno;
+#else
+  reason = errno;
+  if (reason == EINTR || reason == EAGAIN)
+continue;
+#endif
+
+  if (log)
+*log << "Error " << reason << " reading from input file.\n";
+  return false;
+}
+
+assert(bytes_read <= length);
+ptr += bytes_read;
+length -= bytes_read

[Lldb-commits] [PATCH] D59104: [lldb-vscode] Make server mode work on Windows

2019-03-07 Thread Zachary Turner via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355637: [lldb-vscode] Support running in server mode on 
Windows. (authored by zturner, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59104?vs=189759&id=189777#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59104

Files:
  lldb/trunk/tools/lldb-vscode/CMakeLists.txt
  lldb/trunk/tools/lldb-vscode/IOStream.cpp
  lldb/trunk/tools/lldb-vscode/IOStream.h
  lldb/trunk/tools/lldb-vscode/VSCode.cpp
  lldb/trunk/tools/lldb-vscode/VSCode.h
  lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
  lldb/trunk/tools/lldb-vscode/package.json

Index: lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
@@ -23,6 +23,7 @@
 #define NOMINMAX
 #include 
 #undef GetObject
+#include 
 #else
 #include 
 #include 
@@ -53,7 +54,6 @@
 constexpr const char *dev_null_path = "nul";
 
 #else
-typedef int SOCKET;
 constexpr const char *dev_null_path = "/dev/null";
 
 #endif
@@ -68,9 +68,9 @@
 
 enum VSCodeBroadcasterBits { eBroadcastBitStopEventThread = 1u << 0 };
 
-int AcceptConnection(int portno) {
+SOCKET AcceptConnection(int portno) {
   // Accept a socket connection from any host on "portno".
-  int newsockfd = -1;
+  SOCKET newsockfd = -1;
   struct sockaddr_in serv_addr, cli_addr;
   SOCKET sockfd = socket(AF_INET, SOCK_STREAM, 0);
   if (sockfd < 0) {
@@ -2635,23 +2635,19 @@
 #endif
   int portno = atoi(arg);
   printf("Listening on port %i...\n", portno);
-  int socket_fd = AcceptConnection(portno);
+  SOCKET socket_fd = AcceptConnection(portno);
   if (socket_fd >= 0) {
-// We must open two FILE objects, one for reading and one for writing
-// the FILE objects have a mutex in them that won't allow reading and
-// writing to the socket stream.
-g_vsc.in = fdopen(socket_fd, "r");
-g_vsc.out = fdopen(socket_fd, "w");
-if (g_vsc.in == nullptr || g_vsc.out == nullptr) {
-  if (g_vsc.log)
-*g_vsc.log << "fdopen failed (" << strerror(errno) << ")"
-   << std::endl;
-  exit(1);
-}
+g_vsc.input.descriptor = StreamDescriptor::from_socket(socket_fd, true);
+g_vsc.output.descriptor =
+StreamDescriptor::from_socket(socket_fd, false);
   } else {
 exit(1);
   }
 }
+  } else {
+g_vsc.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false);
+g_vsc.output.descriptor =
+StreamDescriptor::from_file(fileno(stdout), false);
   }
   auto request_handlers = GetRequestHandlers();
   uint32_t packet_idx = 0;
Index: lldb/trunk/tools/lldb-vscode/CMakeLists.txt
===
--- lldb/trunk/tools/lldb-vscode/CMakeLists.txt
+++ lldb/trunk/tools/lldb-vscode/CMakeLists.txt
@@ -15,6 +15,7 @@
   BreakpointBase.cpp
   ExceptionBreakpoint.cpp
   FunctionBreakpoint.cpp
+  IOStream.cpp
   JSONUtils.cpp
   LLDBUtils.cpp
   SourceBreakpoint.cpp
Index: lldb/trunk/tools/lldb-vscode/IOStream.h
===
--- lldb/trunk/tools/lldb-vscode/IOStream.h
+++ lldb/trunk/tools/lldb-vscode/IOStream.h
@@ -0,0 +1,69 @@
+//===-- IOStream.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 LLDBVSCODE_IOSTREAM_H_
+#define LLDBVSCODE_IOSTREAM_H_
+
+#if defined(_WIN32)
+// We need to #define NOMINMAX in order to skip `min()` and `max()` macro
+// definitions that conflict with other system headers.
+// We also need to #undef GetObject (which is defined to GetObjectW) because
+// the JSON code we use also has methods named `GetObject()` and we conflict
+// against these.
+#define NOMINMAX
+#include 
+#else
+typedef int SOCKET;
+#endif
+
+#include "llvm/ADT/StringRef.h"
+
+#include 
+#include 
+
+// Windows requires different system calls for dealing with sockets and other
+// types of files, so we can't simply have one code path that just uses read
+// and write everywhere.  So we need an abstraction in order to allow us to
+// treat them identically.
+namespace lldb_vscode {
+struct StreamDescriptor {
+  StreamDescriptor();
+  ~StreamDescriptor();
+  StreamDescriptor(StreamDescriptor &&other);
+
+  StreamDescriptor &operator=(StreamDescriptor &&other);
+
+  static StreamDescriptor from_socket(SOCKET s, bool close);
+  static StreamDescriptor from_file(int fd, bool 

[Lldb-commits] [PATCH] D59072: [ExpressionParser] Implement ComputeClangResourceDir for Windows

2019-03-07 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

This broke the Windows bot because now one of the TestPaths tests passes on 
Windows:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/2394

There's also this comment in the test file:

1. TODO: Merge into test_path when GetClangResourceDir is implemented on
2. windows


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59072



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


[Lldb-commits] [lldb] r355640 - [testsuite] Recommit the TestTerminal directory.

2019-03-07 Thread Davide Italiano via lldb-commits
Author: davide
Date: Thu Mar  7 13:33:43 2019
New Revision: 355640

URL: http://llvm.org/viewvc/llvm-project?rev=355640&view=rev
Log:
[testsuite] Recommit the TestTerminal directory.

Turns out this is actually testing that editline doesn't
screw up the terminal.

Added:
lldb/trunk/packages/Python/lldbsuite/test/terminal/
lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py

Added: 
lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py?rev=355640&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py 
(added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py 
Thu Mar  7 13:33:43 2019
@@ -0,0 +1,111 @@
+"""
+Test that 'stty -a' displays the same output before and after running the lldb 
command.
+"""
+
+from __future__ import print_function
+
+
+import os
+import lldb
+import six
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestSTTYBeforeAndAfter(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@classmethod
+def classCleanup(cls):
+"""Cleanup the test byproducts."""
+cls.RemoveTempFile("child_send1.txt")
+cls.RemoveTempFile("child_read1.txt")
+cls.RemoveTempFile("child_send2.txt")
+cls.RemoveTempFile("child_read2.txt")
+
+@expectedFailureAll(
+hostoslist=["windows"],
+bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+@no_debug_info_test
+def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self):
+"""Test that 'stty -a' displays the same output before and after 
running the lldb command."""
+import pexpect
+if not which('expect'):
+self.skipTest(
+"The 'expect' program cannot be located, skip the test")
+
+# The expect prompt.
+expect_prompt = "expect[0-9.]+> "
+# The default lldb prompt.
+lldb_prompt = "(lldb) "
+
+# So that the child gets torn down after the test.
+self.child = pexpect.spawn('expect')
+child = self.child
+
+child.expect(expect_prompt)
+child.setecho(True)
+if self.TraceOn():
+child.logfile = sys.stdout
+
+if self.platformIsDarwin():
+child.sendline('set env(TERM) xterm')
+else:
+child.sendline('set env(TERM) vt100')
+child.expect(expect_prompt)
+child.sendline('puts $env(TERM)')
+child.expect(expect_prompt)
+
+# Turn on loggings for input/output to/from the child.
+child.logfile_send = child_send1 = six.StringIO()
+child.logfile_read = child_read1 = six.StringIO()
+child.sendline('stty -a')
+child.expect(expect_prompt)
+
+# Now that the stage1 logging is done, restore logfile to None to
+# stop further logging.
+child.logfile_send = None
+child.logfile_read = None
+
+# Invoke the lldb command.
+child.sendline('%s %s' % (lldbtest_config.lldbExec, self.lldbOption))
+child.expect_exact(lldb_prompt)
+
+# Immediately quit.
+child.sendline('quit')
+child.expect(expect_prompt)
+
+child.logfile_send = child_send2 = six.StringIO()
+child.logfile_read = child_read2 = six.StringIO()
+child.sendline('stty -a')
+child.expect(expect_prompt)
+
+child.sendline('exit')
+
+# Now that the stage2 logging is done, restore logfile to None to
+# stop further logging.
+child.logfile_send = None
+child.logfile_read = None
+
+if self.TraceOn():
+print("\n\nContents of child_send1:")
+print(child_send1.getvalue())
+print("\n\nContents of child_read1:")
+print(child_read1.getvalue())
+print("\n\nContents of child_send2:")
+print(child_send2.getvalue())
+print("\n\nContents of child_read2:")
+print(child_read2.getvalue())
+
+stty_output1_lines = child_read1.getvalue().splitlines()
+stty_output2_lines = child_read2.getvalue().splitlines()
+zipped = list(zip(stty_output1_lines, stty_output2_lines))
+for tuple in zipped:
+if self.TraceOn():
+print("tuple->%s" % str(tuple))
+# Every line should compare equal until the first blank line.
+if len(tuple[0]) == 0:
+break
+self.assertTrue(tuple[0] == tuple[1])


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


[Lldb-commits] [lldb] r355644 - Fix TestAppleSimulatorOSType.py with Xcode 10.2

2019-03-07 Thread Frederic Riss via lldb-commits
Author: friss
Date: Thu Mar  7 14:12:03 2019
New Revision: 355644

URL: http://llvm.org/viewvc/llvm-project?rev=355644&view=rev
Log:
Fix TestAppleSimulatorOSType.py with Xcode 10.2

It looks like the simctl tool shipped in Xcode10.2 changed the format of
its json output.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py?rev=355644&r1=355643&r2=355644&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
 Thu Mar  7 14:12:03 2019
@@ -29,7 +29,9 @@ class TestAppleSimulatorOSType(gdbremote
 if not platform in runtime.lower():
 continue
 for device in devices:
-if device['availability'] != '(available)':
+if 'availability' in device and device['availability'] != 
'(available)':
+continue
+if 'isAvailable' in device and device['isAvailable'] != True:
 continue
 deviceUDID = device['udid']
 break


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


[Lldb-commits] [PATCH] D59101: [SBAPI] Log from record macro

2019-03-07 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

As long as we are still seeing all argument values, I check the first 10 or so 
calls and it looked like this was the case, then I am good with this.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59101



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


[Lldb-commits] [PATCH] D59101: [SBAPI] Log from record macro

2019-03-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D59101#1422129 , @clayborg wrote:

> As long as we are still seeing all argument values, I check the first 10 or 
> so calls and it looked like this was the case, then I am good with this.


Correct, the macros forward the arguments to the log.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59101



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


[Lldb-commits] [lldb] r355647 - Add logging to TestQueues.py

2019-03-07 Thread Frederic Riss via lldb-commits
Author: friss
Date: Thu Mar  7 14:28:01 2019
New Revision: 355647

URL: http://llvm.org/viewvc/llvm-project?rev=355647&view=rev
Log:
Add logging to TestQueues.py

In an attempt to understand why the test is still failing after r35,
add some logging.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py?rev=355647&r1=355646&r2=355647&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py Thu 
Mar  7 14:28:01 2019
@@ -56,7 +56,23 @@ class TestQueues(TestBase):
  expected_running,
  (queue.GetNumRunningItems(
 
+def describe_threads(self):
+desc = []
+for x in self.inferior_process:
+id = x.GetIndexID()
+reason_str = lldbutil.stop_reason_to_str(x.GetStopReason())
+
+location = "\t".join([lldbutil.get_description(
+x.GetFrameAtIndex(i)) for i in range(x.GetNumFrames())])
+desc.append(
+"thread %d: %s at\n\t%s" %
+(id, reason_str, location))
+print('\n'.join(desc))
+
 def check_number_of_threads_owned_by_queue(self, queue, number_threads):
+if (queue.GetNumThreads() != number_threads):
+self.describe_threads()
+
 self.assertTrue(
 queue.GetNumThreads() == number_threads,
 "queue %s should have %d thread executing, but has %d" %
@@ -125,6 +141,8 @@ class TestQueues(TestBase):
 if len(threads) != 1:
 self.fail("Failed to stop at breakpoint 1.")
 
+self.inferior_process = process
+
 queue_submittor_1 = lldb.SBQueue()
 queue_performer_1 = lldb.SBQueue()
 queue_performer_2 = lldb.SBQueue()
@@ -291,6 +309,8 @@ class TestQueues(TestBase):
 if len(threads) != 1:
 self.fail("Failed to stop at breakpoint 1.")
 
+self.inferior_process = process
+
 libbtr_module_filespec = lldb.SBFileSpec("libBacktraceRecording.dylib")
 libbtr_module = target.FindModule(libbtr_module_filespec)
 if not libbtr_module.IsValid():


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


Re: [Lldb-commits] [lldb] r355647 - Add logging to TestQueues.py

2019-03-07 Thread Jonas Devlieghere via lldb-commits
🎉🎉🎉

On Thu, Mar 7, 2019 at 2:26 PM Frederic Riss via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: friss
> Date: Thu Mar  7 14:28:01 2019
> New Revision: 355647
>
> URL: http://llvm.org/viewvc/llvm-project?rev=355647&view=rev
> Log:
> Add logging to TestQueues.py
>
> In an attempt to understand why the test is still failing after r35,
> add some logging.
>
> Modified:
> lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
>
> Modified:
> lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py?rev=355647&r1=355646&r2=355647&view=diff
>
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
> (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
> Thu Mar  7 14:28:01 2019
> @@ -56,7 +56,23 @@ class TestQueues(TestBase):
>   expected_running,
>   (queue.GetNumRunningItems(
>
> +def describe_threads(self):
> +desc = []
> +for x in self.inferior_process:
> +id = x.GetIndexID()
> +reason_str = lldbutil.stop_reason_to_str(x.GetStopReason())
> +
> +location = "\t".join([lldbutil.get_description(
> +x.GetFrameAtIndex(i)) for i in range(x.GetNumFrames())])
> +desc.append(
> +"thread %d: %s at\n\t%s" %
> +(id, reason_str, location))
> +print('\n'.join(desc))
> +
>  def check_number_of_threads_owned_by_queue(self, queue,
> number_threads):
> +if (queue.GetNumThreads() != number_threads):
> +self.describe_threads()
> +
>  self.assertTrue(
>  queue.GetNumThreads() == number_threads,
>  "queue %s should have %d thread executing, but has %d" %
> @@ -125,6 +141,8 @@ class TestQueues(TestBase):
>  if len(threads) != 1:
>  self.fail("Failed to stop at breakpoint 1.")
>
> +self.inferior_process = process
> +
>  queue_submittor_1 = lldb.SBQueue()
>  queue_performer_1 = lldb.SBQueue()
>  queue_performer_2 = lldb.SBQueue()
> @@ -291,6 +309,8 @@ class TestQueues(TestBase):
>  if len(threads) != 1:
>  self.fail("Failed to stop at breakpoint 1.")
>
> +self.inferior_process = process
> +
>  libbtr_module_filespec =
> lldb.SBFileSpec("libBacktraceRecording.dylib")
>  libbtr_module = target.FindModule(libbtr_module_filespec)
>  if not libbtr_module.IsValid():
>
>
> ___
> 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] r355648 - Fix TestPaths.py on windows

2019-03-07 Thread Alex Langford via lldb-commits
Author: xiaobai
Date: Thu Mar  7 14:37:23 2019
New Revision: 355648

URL: http://llvm.org/viewvc/llvm-project?rev=355648&view=rev
Log:
Fix TestPaths.py on windows

I committed an implementation of GetClangResourceDir on windows but
forgot to update this test. I merged the tests like I intended to, but I
realized that the test was actually failing. After looking into it, it
appears that FileSystem::Resolve was taking the path and setting
the FileSpec's Directory to "/path/to/lldb/lib/clang/" and the File to
"9.0.0" which isn't what we want. So I removed the resolve line from
DefaultComputeClangResourceDir.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py?rev=355648&r1=355647&r2=355648&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/paths/TestPaths.py 
Thu Mar  7 14:37:23 2019
@@ -25,22 +25,14 @@ class TestPaths(TestBase):
   lldb.ePathTypePythonDir,
   lldb.ePathTypeLLDBSystemPlugins,
   lldb.ePathTypeLLDBUserPlugins,
-  lldb.ePathTypeLLDBTempSystemDir]
+  lldb.ePathTypeLLDBTempSystemDir,
+  lldb.ePathTypeClangDir]
 
 for path_type in dir_path_types:
 f = lldb.SBHostOS.GetLLDBPath(path_type)
 # No directory path types should have the filename set
 self.assertTrue(f.GetFilename() is None)
 
-# TODO: Merge into test_path when GetClangResourceDir is implemented on
-# windows
-@expectedFailureAll(oslist=["windows"])
-@no_debug_info_test
-def test_clang_dir_path(self):
-  '''Test to make sure clang dir is set correctly'''
-  clang_dir = lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeClangDir)
-  self.assertFalse(clang_dir.GetDirectory() is None)
-
 @no_debug_info_test
 def test_directory_doesnt_end_with_slash(self):
 current_directory_spec = lldb.SBFileSpec(os.path.curdir)

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp?rev=355648&r1=355647&r2=355648&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp Thu Mar  7 
14:37:23 2019
@@ -54,7 +54,6 @@ static bool DefaultComputeClangResourceD
   llvm::sys::path::append(clang_dir, relative_path);
   if (!verify || VerifyClangPath(clang_dir)) {
 file_spec.GetDirectory().SetString(clang_dir);
-FileSystem::Instance().Resolve(file_spec);
 return true;
   }
 


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


[Lldb-commits] [PATCH] D59072: [ExpressionParser] Implement ComputeClangResourceDir for Windows

2019-03-07 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

In D59072#1422059 , @stella.stamenova 
wrote:

> This broke the Windows bot because now one of the TestPaths tests passes on 
> Windows:
>
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/2394
>
> There's also this comment in the test file:
>
> 1. TODO: Merge into test_path when GetClangResourceDir is implemented on
> 2. windows


Submitted a forward fix with rL355648 


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59072



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


[Lldb-commits] [lldb] r355650 - Remove unused function

2019-03-07 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Mar  7 14:58:39 2019
New Revision: 355650

URL: http://llvm.org/viewvc/llvm-project?rev=355650&view=rev
Log:
Remove unused function

Modified:
lldb/trunk/tools/lldb-vscode/VSCode.cpp

Modified: lldb/trunk/tools/lldb-vscode/VSCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/VSCode.cpp?rev=355650&r1=355649&r2=355650&view=diff
==
--- lldb/trunk/tools/lldb-vscode/VSCode.cpp (original)
+++ lldb/trunk/tools/lldb-vscode/VSCode.cpp Thu Mar  7 14:58:39 2019
@@ -23,12 +23,6 @@
 
 using namespace lldb_vscode;
 
-namespace {
-  inline bool IsEmptyLine(llvm::StringRef S) {
-return S.ltrim().empty();
-  }
-} // namespace
-
 namespace lldb_vscode {
 
 VSCode g_vsc;


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


[Lldb-commits] [PATCH] D59114: [lldb-vscode] Don't hang indefinitely on invalid program

2019-03-07 Thread Zachary Turner via Phabricator via lldb-commits
zturner created this revision.
zturner added a reviewer: clayborg.

When you configure your launch settings, if you pass a path to an invalid 
program, we would previously hand indefinitely.  This is because a combination 
of two bugs working together.  The first is that we did not attempt to detect 
when handling the request whether the file existed, and we would just pass it 
through to the `Process::Launch` method.  The second is that the 
`Process::Launch` method did not properly report an error in the case where the 
file does not exist.  It actually reported that the launch succeeded, which 
would then cause LLDB to wait on the broadcaster to receive some events, which 
would obviously never come.

Although fixing this in either place independently will get lldb-vscode working 
properly when an invalid executable is specified, I'm fixing it in both places 
because it seems like the right thing to do.  Note that for the first fix (the 
one in `lldb-vscode.cpp`) we were previously checking the value of 
`error.Fail()`, but the previous call did not actually communicate an error via 
an `SBError` return, instead it communicated an error via a null `SBModule` 
return.  So this condition is changed.


https://reviews.llvm.org/D59114

Files:
  lldb/source/Target/Process.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1227,20 +1227,23 @@
 
   // Grab the name of the program we need to debug and set it as the first
   // argument that will be passed to the program we will debug.
-  const auto program = GetString(arguments, "program");
+  llvm::StringRef program = GetString(arguments, "program");
   if (!program.empty()) {
 lldb::SBFileSpec program_fspec(program.data(), true /*resolve_path*/);
-
 g_vsc.launch_info.SetExecutableFile(program_fspec,
 true /*add_as_first_arg*/);
 const char *target_triple = nullptr;
 const char *uuid_cstr = nullptr;
 // Stand alone debug info file if different from executable
 const char *symfile = nullptr;
-g_vsc.target.AddModule(program.data(), target_triple, uuid_cstr, symfile);
-if (error.Fail()) {
+lldb::SBModule module = g_vsc.target.AddModule(
+program.data(), target_triple, uuid_cstr, symfile);
+if (!module.IsValid()) {
   response["success"] = llvm::json::Value(false);
-  EmplaceSafeString(response, "message", std::string(error.GetCString()));
+
+  EmplaceSafeString(
+  response, "message",
+  llvm::formatv("Could not load program '{0}'.", program).str());
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
   }
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -2519,108 +2519,112 @@
   m_process_input_reader.reset();
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
-  if (exe_module) {
-char local_exec_file_path[PATH_MAX];
-char platform_exec_file_path[PATH_MAX];
-exe_module->GetFileSpec().GetPath(local_exec_file_path,
-  sizeof(local_exec_file_path));
-exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
-  sizeof(platform_exec_file_path));
-if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
-  // Install anything that might need to be installed prior to launching.
-  // For host systems, this will do nothing, but if we are connected to a
-  // remote platform it will install any needed binaries
-  error = GetTarget().Install(&launch_info);
-  if (error.Fail())
-return error;
+  if (!exe_module) {
+error.SetErrorString("executable module does not exist");
+return error;
+  }
 
-  if (PrivateStateThreadIsValid())
-PausePrivateStateThread();
+  char local_exec_file_path[PATH_MAX];
+  char platform_exec_file_path[PATH_MAX];
+  exe_module->GetFileSpec().GetPath(local_exec_file_path,
+sizeof(local_exec_file_path));
+  exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
+sizeof(platform_exec_file_path));
+  if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
+// Install anything that might need to be installed prior to launching.
+// For host systems, this will do nothing, but if we are connected to a
+// remote platform it will install any needed binaries
+error = GetTarget().Install(&launch_info);
+if (error.Fail())
+  return error;
 
-  error = WillLaunch(exe_module);
-  if (error.Success()) {
-const bool restarted = false;
-SetPublicState(eStateLaunching, restarted);
-

[Lldb-commits] [lldb] r355651 - Make bytes_read an unsigned

2019-03-07 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Mar  7 14:59:55 2019
New Revision: 355651

URL: http://llvm.org/viewvc/llvm-project?rev=355651&view=rev
Log:
Make bytes_read an unsigned

Modified:
lldb/trunk/tools/lldb-vscode/IOStream.cpp

Modified: lldb/trunk/tools/lldb-vscode/IOStream.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/IOStream.cpp?rev=355651&r1=355650&r2=355651&view=diff
==
--- lldb/trunk/tools/lldb-vscode/IOStream.cpp (original)
+++ lldb/trunk/tools/lldb-vscode/IOStream.cpp Thu Mar  7 14:59:55 2019
@@ -95,7 +95,7 @@ bool InputStream::read_full(std::ofstrea
 
   char *ptr = &data[0];
   while (length != 0) {
-int bytes_read = 0;
+size_t bytes_read = 0;
 if (descriptor.m_is_socket)
   bytes_read = ::recv(descriptor.m_socket, ptr, length, 0);
 else


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


[Lldb-commits] [lldb] r355654 - [Reproducers] Use partial template specialization instead of overload

2019-03-07 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Mar  7 15:37:46 2019
New Revision: 355654

URL: http://llvm.org/viewvc/llvm-project?rev=355654&view=rev
Log:
[Reproducers] Use partial template specialization instead of overload

Not sure if this is what's causing MSVC to claim the function to be
already defined elsewhere, but worth a shot.

Modified:
lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h

Modified: lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h?rev=355654&r1=355653&r2=355654&view=diff
==
--- lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h (original)
+++ lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h Thu Mar  7 
15:37:46 2019
@@ -37,7 +37,9 @@ void log_append(llvm::raw_string_ostream
   ss << t;
 }
 
-void log_append(llvm::raw_string_ostream &ss, const char *t) { ss << t; }
+template <> void log_append(llvm::raw_string_ostream &ss, const char *t) 
{
+  ss << t;
+}
 
 template 
 void log_helper(llvm::raw_string_ostream &ss, const Head &head) {


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


[Lldb-commits] [lldb] r355656 - [lldb-vscode] Report an error if an invalid program is specified.

2019-03-07 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Mar  7 16:11:27 2019
New Revision: 355656

URL: http://llvm.org/viewvc/llvm-project?rev=355656&view=rev
Log:
[lldb-vscode] Report an error if an invalid program is specified.

Previously if an invalid program was specified, there was a bug
which, when we attempted to launch the program, would report that
the operation succeeded, causing LLDB to then hang while waiting
indefinitely to receive some events from the process.

After this patch, when an invalid program is specified, we immediately
return to vs code with an error message that indicates that the
program can not be found.

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

Modified:
lldb/trunk/source/Target/Process.cpp
lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp

Modified: lldb/trunk/source/Target/Process.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=355656&r1=355655&r2=355656&view=diff
==
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Mar  7 16:11:27 2019
@@ -2519,108 +2519,112 @@ Status Process::Launch(ProcessLaunchInfo
   m_process_input_reader.reset();
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
-  if (exe_module) {
-char local_exec_file_path[PATH_MAX];
-char platform_exec_file_path[PATH_MAX];
-exe_module->GetFileSpec().GetPath(local_exec_file_path,
-  sizeof(local_exec_file_path));
-exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
-  sizeof(platform_exec_file_path));
-if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
-  // Install anything that might need to be installed prior to launching.
-  // For host systems, this will do nothing, but if we are connected to a
-  // remote platform it will install any needed binaries
-  error = GetTarget().Install(&launch_info);
-  if (error.Fail())
-return error;
-
-  if (PrivateStateThreadIsValid())
-PausePrivateStateThread();
-
-  error = WillLaunch(exe_module);
-  if (error.Success()) {
-const bool restarted = false;
-SetPublicState(eStateLaunching, restarted);
-m_should_detach = false;
-
-if (m_public_run_lock.TrySetRunning()) {
-  // Now launch using these arguments.
-  error = DoLaunch(exe_module, launch_info);
-} else {
-  // This shouldn't happen
-  error.SetErrorString("failed to acquire process run lock");
+  if (!exe_module) {
+error.SetErrorString("executable module does not exist");
+return error;
+  }
+
+  char local_exec_file_path[PATH_MAX];
+  char platform_exec_file_path[PATH_MAX];
+  exe_module->GetFileSpec().GetPath(local_exec_file_path,
+sizeof(local_exec_file_path));
+  exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
+sizeof(platform_exec_file_path));
+  if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
+// Install anything that might need to be installed prior to launching.
+// For host systems, this will do nothing, but if we are connected to a
+// remote platform it will install any needed binaries
+error = GetTarget().Install(&launch_info);
+if (error.Fail())
+  return error;
+
+if (PrivateStateThreadIsValid())
+  PausePrivateStateThread();
+
+error = WillLaunch(exe_module);
+if (error.Success()) {
+  const bool restarted = false;
+  SetPublicState(eStateLaunching, restarted);
+  m_should_detach = false;
+
+  if (m_public_run_lock.TrySetRunning()) {
+// Now launch using these arguments.
+error = DoLaunch(exe_module, launch_info);
+  } else {
+// This shouldn't happen
+error.SetErrorString("failed to acquire process run lock");
+  }
+
+  if (error.Fail()) {
+if (GetID() != LLDB_INVALID_PROCESS_ID) {
+  SetID(LLDB_INVALID_PROCESS_ID);
+  const char *error_string = error.AsCString();
+  if (error_string == nullptr)
+error_string = "launch failed";
+  SetExitStatus(-1, error_string);
 }
+  } else {
+EventSP event_sp;
 
-if (error.Fail()) {
-  if (GetID() != LLDB_INVALID_PROCESS_ID) {
-SetID(LLDB_INVALID_PROCESS_ID);
-const char *error_string = error.AsCString();
-if (error_string == nullptr)
-  error_string = "launch failed";
-SetExitStatus(-1, error_string);
-  }
-} else {
-  EventSP event_sp;
-
-  // Now wait for the process to launch and return control to us, and 
then call
-  // DidLaunch:
-  StateType state = WaitForProcessStopPrivate(event_sp, seconds(10));
-
-  if (state == eStateInvalid

[Lldb-commits] [PATCH] D59114: [lldb-vscode] Don't hang indefinitely on invalid program

2019-03-07 Thread Zachary Turner via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355656: [lldb-vscode] Report an error if an invalid program 
is specified. (authored by zturner, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59114?vs=189788&id=189799#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59114

Files:
  lldb/trunk/source/Target/Process.cpp
  lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/trunk/source/Target/Process.cpp
===
--- lldb/trunk/source/Target/Process.cpp
+++ lldb/trunk/source/Target/Process.cpp
@@ -2519,108 +2519,112 @@
   m_process_input_reader.reset();
 
   Module *exe_module = GetTarget().GetExecutableModulePointer();
-  if (exe_module) {
-char local_exec_file_path[PATH_MAX];
-char platform_exec_file_path[PATH_MAX];
-exe_module->GetFileSpec().GetPath(local_exec_file_path,
-  sizeof(local_exec_file_path));
-exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
-  sizeof(platform_exec_file_path));
-if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
-  // Install anything that might need to be installed prior to launching.
-  // For host systems, this will do nothing, but if we are connected to a
-  // remote platform it will install any needed binaries
-  error = GetTarget().Install(&launch_info);
-  if (error.Fail())
-return error;
+  if (!exe_module) {
+error.SetErrorString("executable module does not exist");
+return error;
+  }
 
-  if (PrivateStateThreadIsValid())
-PausePrivateStateThread();
+  char local_exec_file_path[PATH_MAX];
+  char platform_exec_file_path[PATH_MAX];
+  exe_module->GetFileSpec().GetPath(local_exec_file_path,
+sizeof(local_exec_file_path));
+  exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
+sizeof(platform_exec_file_path));
+  if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
+// Install anything that might need to be installed prior to launching.
+// For host systems, this will do nothing, but if we are connected to a
+// remote platform it will install any needed binaries
+error = GetTarget().Install(&launch_info);
+if (error.Fail())
+  return error;
 
-  error = WillLaunch(exe_module);
-  if (error.Success()) {
-const bool restarted = false;
-SetPublicState(eStateLaunching, restarted);
-m_should_detach = false;
+if (PrivateStateThreadIsValid())
+  PausePrivateStateThread();
 
-if (m_public_run_lock.TrySetRunning()) {
-  // Now launch using these arguments.
-  error = DoLaunch(exe_module, launch_info);
-} else {
-  // This shouldn't happen
-  error.SetErrorString("failed to acquire process run lock");
-}
+error = WillLaunch(exe_module);
+if (error.Success()) {
+  const bool restarted = false;
+  SetPublicState(eStateLaunching, restarted);
+  m_should_detach = false;
 
-if (error.Fail()) {
-  if (GetID() != LLDB_INVALID_PROCESS_ID) {
-SetID(LLDB_INVALID_PROCESS_ID);
-const char *error_string = error.AsCString();
-if (error_string == nullptr)
-  error_string = "launch failed";
-SetExitStatus(-1, error_string);
-  }
-} else {
-  EventSP event_sp;
+  if (m_public_run_lock.TrySetRunning()) {
+// Now launch using these arguments.
+error = DoLaunch(exe_module, launch_info);
+  } else {
+// This shouldn't happen
+error.SetErrorString("failed to acquire process run lock");
+  }
 
-  // Now wait for the process to launch and return control to us, and then call
-  // DidLaunch:
-  StateType state = WaitForProcessStopPrivate(event_sp, seconds(10));
-
-  if (state == eStateInvalid || !event_sp) {
-// We were able to launch the process, but we failed to catch the
-// initial stop.
-error.SetErrorString("failed to catch stop after launch");
-SetExitStatus(0, "failed to catch stop after launch");
-Destroy(false);
-  } else if (state == eStateStopped || state == eStateCrashed) {
-DidLaunch();
-
-DynamicLoader *dyld = GetDynamicLoader();
-if (dyld)
-  dyld->DidLaunch();
-
-GetJITLoaders().DidLaunch();
-
-SystemRuntime *system_runtime = GetSystemRuntime();
-if (system_runtime)
-  system_runtime->DidLaunch();
-
-if (!m_os_up)
-  LoadOperatingSystemPlugi

[Lldb-commits] [lldb] r355657 - [Reproducers] Mark partial specialization as inline

2019-03-07 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Mar  7 16:24:06 2019
New Revision: 355657

URL: http://llvm.org/viewvc/llvm-project?rev=355657&view=rev
Log:
[Reproducers] Mark partial specialization as inline

The overload and/or template specialization are regular functions and
should be marked inline when implemented in the header. Writing the
previous commit message should've made that obvious but I was already
overthinking it. This will fix the windows bot.

Modified:
lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h

Modified: lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h?rev=355657&r1=355656&r2=355657&view=diff
==
--- lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h (original)
+++ lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h Thu Mar  7 
16:24:06 2019
@@ -37,7 +37,8 @@ void log_append(llvm::raw_string_ostream
   ss << t;
 }
 
-template <> void log_append(llvm::raw_string_ostream &ss, const char *t) 
{
+inline template <>
+void log_append(llvm::raw_string_ostream &ss, const char *t) {
   ss << t;
 }
 


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


[Lldb-commits] [lldb] r355658 - [Reproducers] TestImagineList.test -> TestImageList.test

2019-03-07 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Mar  7 16:53:57 2019
New Revision: 355658

URL: http://llvm.org/viewvc/llvm-project?rev=355658&view=rev
Log:
[Reproducers] TestImagineList.test -> TestImageList.test

And run the actual binary so we load the shared libraries.

Added:
lldb/trunk/lit/Reproducer/Functionalities/TestImageList.test
Removed:
lldb/trunk/lit/Reproducer/Functionalities/TestImagineList.test

Added: lldb/trunk/lit/Reproducer/Functionalities/TestImageList.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/Functionalities/TestImageList.test?rev=355658&view=auto
==
--- lldb/trunk/lit/Reproducer/Functionalities/TestImageList.test (added)
+++ lldb/trunk/lit/Reproducer/Functionalities/TestImageList.test Thu Mar  7 
16:53:57 2019
@@ -0,0 +1,30 @@
+# UNSUPPORTED: system-windows, system-freebsd
+
+# This tests that image list works when replaying. We arbitrarily assume
+# there's at least two entries and compare that they're identical.
+
+# RUN: %clang %S/Inputs/stepping.c -g -o %t.out
+
+# RUN: rm -rf %t.txt
+
+# RUN: echo "CAPTURE" >> %t.txt
+# RUN: %lldb -x -b  --capture %t.repro \
+# RUN:-o 'run' \
+# RUN:-o 'image list' \
+# RUN:-o 'reproducer generate' \
+# RUN:%t.out >> %t.txt 2>&1
+
+# RUN: echo "REPLAY" >> %t.txt
+# RUN: %lldb -x -b --replay %t.repro >> %t.txt 2>&1
+
+# RUN: cat %t.txt | FileCheck %s
+
+# CHECK: CAPTURE
+# CHECK: image list
+# CHECK: [  0] [[ZERO:.*]]
+# CHECK: [  1] [[ONE:.*]]
+
+# CHECK: REPLAY
+# CHECK: image list
+# CHECK: [  0] {{.*}}[[ZERO]]
+# CHECK: [  1] {{.*}}[[ONE]]

Removed: lldb/trunk/lit/Reproducer/Functionalities/TestImagineList.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/Functionalities/TestImagineList.test?rev=355657&view=auto
==
--- lldb/trunk/lit/Reproducer/Functionalities/TestImagineList.test (original)
+++ lldb/trunk/lit/Reproducer/Functionalities/TestImagineList.test (removed)
@@ -1,29 +0,0 @@
-# UNSUPPORTED: system-windows, system-freebsd
-
-# This tests that image list works when replaying. We arbitrarily assume
-# there's at least two entries and compare that they're identical.
-
-# RUN: %clang %S/Inputs/stepping.c -g -o %t.out
-
-# RUN: rm -rf %t.txt
-
-# RUN: echo "CAPTURE" >> %t.txt
-# RUN: %lldb -x -b  --capture %t.repro \
-# RUN:-o 'image list' \
-# RUN:-o 'reproducer generate' \
-# RUN:%t.out >> %t.txt 2>&1
-
-# RUN: echo "REPLAY" >> %t.txt
-# RUN: %lldb -x -b --replay %t.repro >> %t.txt 2>&1
-
-# RUN: cat %t.txt | FileCheck %s
-
-# CHECK: CAPTURE
-# CHECK: image list
-# CHECK: [  0] [[ZERO:.*]]
-# CHECK: [  1] [[ONE:.*]]
-
-# CHECK: REPLAY
-# CHECK: image list
-# CHECK: [  0] {{.*}}[[ZERO]]
-# CHECK: [  1] {{.*}}[[ONE]]


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


[Lldb-commits] [lldb] r355661 - Add ASAN llvm build directory variants to

2019-03-07 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Thu Mar  7 20:18:21 2019
New Revision: 355661

URL: http://llvm.org/viewvc/llvm-project?rev=355661&view=rev
Log:
Add ASAN llvm build directory variants to
get_llvm_bin_dirs().

Modified:
lldb/trunk/packages/Python/lldbsuite/test/dotest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=355661&r1=355660&r2=355661&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Thu Mar  7 20:18:21 2019
@@ -650,8 +650,11 @@ def get_llvm_bin_dirs():
 "llvm-build/Release/x86_64/bin",
 "llvm-build/Debug/x86_64/bin",
 "llvm-build/Ninja-DebugAssert/llvm-macosx-x86_64/bin",
+"llvm-build/Ninja-DebugAssert+asan/llvm-macosx-x86_64/bin",
 "llvm-build/Ninja-ReleaseAssert/llvm-macosx-x86_64/bin",
+"llvm-build/Ninja-ReleaseAssert+asan/llvm-macosx-x86_64/bin",
 "llvm-build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/bin",
+"llvm-build/Ninja-RelWithDebInfoAssert+asan/llvm-macosx-x86_64/bin",
 ]
 for p in paths_to_try:
 path = os.path.join(lldb_root_path, p)


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