[Lldb-commits] [PATCH] D68134: [LLDB] Use the llvm microsoft demangler instead of the windows dbghelp api

2019-10-09 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo marked an inline comment as done.
mstorsjo added a comment.

In D68134#1700453 , @amccarth wrote:

> LGTM after one question.


Thanks! I'll hold off committing for a bit still, as I might try to add more 
options to the microsoft demangler, to match the previous output.




Comment at: lldb/lit/SymbolFile/PDB/udt-layout.test:1
 REQUIRES: system-windows, lld
 RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp

amccarth wrote:
> Is `system-windows` still required after you've removed the dependency on 
> dbghelp?
Yes, this test depends on the system-provided PDB support, so it needs to run 
on windows.


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

https://reviews.llvm.org/D68134



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


[Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha accepted this revision.
tatyana-krasnukha added a comment.

I have longed for this change, thank you!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68606



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


[Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 223888.
JDevlieghere added a comment.

We discussed this on IRC a bit and this is my updated proposal for the 
directory names:

- API
- Shell
- Unit

The corresponding targets are `lldb-check-unit` (unchanged), `lldb-check-shell` 
(runs just the FileCheck / ShTests) and `lldb-check-api` (runs just the 
dotest.py tests). I've also added a README to both `API` and `Unit` explaining 
where the actual tests can be found.


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

https://reviews.llvm.org/D68606

Files:
  lldb/lit/API/README.md
  lldb/lit/API/lit.cfg
  lldb/lit/API/lit.site.cfg.in
  lldb/lit/API/lldbtest.py
  lldb/lit/Breakpoint/Inputs/case-sensitive.c
  lldb/lit/Breakpoint/Inputs/debug_addrx.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml
  lldb/lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lldb/lit/Breakpoint/Inputs/jitbp.cpp
  lldb/lit/Breakpoint/Inputs/ppc64-localentry.s
  lldb/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
  lldb/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml
  lldb/lit/Breakpoint/case-insensitive.test
  lldb/lit/Breakpoint/case-sensitive.test
  lldb/lit/Breakpoint/debug_addrx.test
  lldb/lit/Breakpoint/debug_rnglist_basic.test
  lldb/lit/Breakpoint/debug_rnglist_offset_pair.test
  lldb/lit/Breakpoint/debug_rnglist_rlestartend.test
  lldb/lit/Breakpoint/debug_rnglistx_rlex.test
  lldb/lit/Breakpoint/implicit_const_form_support.test
  lldb/lit/Breakpoint/jitbp_elf.test
  lldb/lit/Breakpoint/ppc64-localentry.test
  lldb/lit/Breakpoint/single-file-split-dwarf.test
  lldb/lit/Breakpoint/split-dwarf-5-addrbase.test
  lldb/lit/Breakpoint/split-dwarf5-debug-stroffsets.test
  lldb/lit/BuildScript/compiler-full-path.test
  lldb/lit/BuildScript/modes.test
  lldb/lit/BuildScript/script-args.test
  lldb/lit/BuildScript/toolchain-clang-cl.test
  lldb/lit/BuildScript/toolchain-clang.test
  lldb/lit/BuildScript/toolchain-msvc.test
  lldb/lit/CMakeLists.txt
  
lldb/lit/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputConsole.test
  
lldb/lit/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputFile.test
  lldb/lit/Commands/CommandScriptImmediateOutput/Inputs/custom_command.py
  lldb/lit/Commands/CommandScriptImmediateOutput/lit.local.cfg
  lldb/lit/Commands/Inputs/frame.py
  lldb/lit/Commands/Inputs/main.c
  lldb/lit/Commands/command-backtrace.test
  lldb/lit/Commands/command-regex-delete.test
  lldb/lit/Commands/command-regex-unalias.test
  lldb/lit/Commands/command-script-import.test
  lldb/lit/Commands/command-source.test
  lldb/lit/Driver/Inputs/.lldbinit
  lldb/lit/Driver/Inputs/Print0.in
  lldb/lit/Driver/Inputs/Print2.in
  lldb/lit/Driver/Inputs/Print4.in
  lldb/lit/Driver/Inputs/Print6.in
  lldb/lit/Driver/Inputs/convenience.in
  lldb/lit/Driver/Inputs/hello.c
  lldb/lit/Driver/Inputs/hello.cpp
  lldb/lit/Driver/Inputs/process_attach_pid.in
  lldb/lit/Driver/Inputs/syntax_error.py
  lldb/lit/Driver/LocalLLDBInit.test
  lldb/lit/Driver/TestCommands.test
  lldb/lit/Driver/TestConvenienceVariables.test
  lldb/lit/Driver/TestCore.test
  lldb/lit/Driver/TestFile.test
  lldb/lit/Driver/TestNoUseColor.test
  lldb/lit/Driver/TestProcessAttach.test
  lldb/lit/Driver/TestRepl.test
  lldb/lit/Driver/TestSingleQuote.test
  lldb/lit/Driver/TestTarget.test
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-1.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook.c
  lldb/lit/ExecControl/StopHook/stop-hook-threads.test
  lldb/lit/ExecControl/StopHook/stop-hook.test
  lldb/lit/Expr/Inputs/call-function.cpp
  lldb/lit/Expr/Inputs/ir-memory-map-basic
  lldb/lit/Expr/Inputs/ir-memory-map-mix-malloc-free
  lldb/lit/Expr/Inputs/ir-memory-map-overlap1
  lldb/lit/Expr/TestIRMemoryMap.test
  lldb/lit/Expr/TestIRMemoryMapWindows.test
  lldb/lit/Expr/TestMultilineExpr.test
  lldb/lit/Expr/TestTypeOfDeclTypeExpr.test
  lldb/lit/Heap/Inputs/cstr.c
  lldb/lit/Heap/heap-cstr.test
  lldb/lit/Host/Inputs/simple.c
  lldb/lit/Host/TestCustomShell.test
  lldb/lit/Minidump/Inputs/linux-x86_64.syms
  lldb/lit/Minidump/Inputs/linux-x86_64.yaml
  lldb/lit/Minidump/Windows/Inputs/find-module.dmp.y

[Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

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

In D68606#1699197 , @thopre wrote:

> Shouldn't the CMake target remain check-lldb-unit to be consistant with 
> check-llvm-unit/check-clang-unit etc.?




In D68606#1699219 , @mstorsjo wrote:

> > and finally rename `lit` to `tests`
>
> Shouldn't that be `test`, to be consistent with llvm/lld/clang and others?


+1 to both of these.

More generally, there are other things here which are not consistent with llvm 
layouts, and I am wondering how much should try to be compatible with that. On 
one hand, consistency is good, but on the other, llvm does not have _three_ 
kinds of tests to worry about. For instance,  `test/Unit` *is* consistent with 
the llvm location of unit tests, and by extension `test/Suite` could be 
considered the "right place" for non-filecheck tests too (though maybe it 
shouldn't be called "Suite"). Speaking of that, I am not completely sure about 
the name "filecheck" either -- technically this should be "shtest" as that is 
their main distinguishing feature, though that may end up being too pedantic.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68606



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


[Lldb-commits] [PATCH] D68258: [Windows] Introduce a switch for the `lldb-server` mode on Windows

2019-10-09 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.

Hello! I am sorry for a delay with reply, I was OOO. Thanks all for the review!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68258



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


[Lldb-commits] [lldb] r374145 - [lldb] Don't crash when the ASTImporter produces diagnostics but instead log them.

2019-10-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Oct  9 01:30:06 2019
New Revision: 374145

URL: http://llvm.org/viewvc/llvm-project?rev=374145&view=rev
Log:
[lldb] Don't crash when the ASTImporter produces diagnostics but instead log 
them.

When playing with the C++ module prototype I noticed I can get LLDB to crash
by making a result type that depends on __make_integer_seq (a BuiltinTemplate)
which is not supported by the ASTImporter yet. This causes the ASTImporter to 
emit
a diagnostic when copying the type to the ScratchASTContext. As deporting the 
result
type is done after we are done parsing and the Clang's diagnostic engine 
asserts that
it can only be used during parsing, it crashes LLDB while trying to render the 
diagnostic
in the HandleDiagnostic method of ClangDiagnosticManagerAdapter.

This patch just moves the HandleDiagnostic call to Clang behind our check that 
we still
have a DiagnosticManager (which we remove after parsing) which prevents the 
assert
from firing. We also shouldn't ignore such diagnostics, so I added a log 
statement for
them.

There doesn't seem to way to test this as these diagnostic only happen when we 
copy
a node that's not supported by the ASTImporter which should never happen once
we can copy everything with the ASTImporter, so every test case we add here will
eventually become invalid.

(Note that most of this diff is just whitespace changes as we now use an early 
exit
instead of a huge 'if' block).

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

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=374145&r1=374144&r2=374145&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Wed Oct  9 01:30:06 2019
@@ -162,51 +162,66 @@ public:
 
   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const clang::Diagnostic &Info) override {
+if (!m_manager) {
+  // We have no DiagnosticManager before/after parsing but we still could
+  // receive diagnostics (e.g., by the ASTImporter failing to copy decls
+  // when we move the expression result ot the ScratchASTContext). Let's at
+  // least log these diagnostics until we find a way to properly render
+  // them and display them to the user.
+  Log 
*log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+  if (log) {
+llvm::SmallVector diag_str;
+Info.FormatDiagnostic(diag_str);
+diag_str.push_back('\0');
+const char *plain_diag = diag_str.data();
+LLDB_LOG(log, "Received diagnostic outside parsing: {0}", plain_diag);
+  }
+  return;
+}
+
 // Render diagnostic message to m_output.
 m_output.clear();
 m_passthrough->HandleDiagnostic(DiagLevel, Info);
 m_os->flush();
 
-if (m_manager) {
-  lldb_private::DiagnosticSeverity severity;
-  bool make_new_diagnostic = true;
-
-  switch (DiagLevel) {
-  case DiagnosticsEngine::Level::Fatal:
-  case DiagnosticsEngine::Level::Error:
-severity = eDiagnosticSeverityError;
-break;
-  case DiagnosticsEngine::Level::Warning:
-severity = eDiagnosticSeverityWarning;
-break;
-  case DiagnosticsEngine::Level::Remark:
-  case DiagnosticsEngine::Level::Ignored:
-severity = eDiagnosticSeverityRemark;
-break;
-  case DiagnosticsEngine::Level::Note:
-m_manager->AppendMessageToDiagnostic(m_output);
-make_new_diagnostic = false;
-  }
-  if (make_new_diagnostic) {
-// ClangDiagnostic messages are expected to have no whitespace/newlines
-// around them.
-std::string stripped_output = llvm::StringRef(m_output).trim();
-
-ClangDiagnostic *new_diagnostic =
-new ClangDiagnostic(stripped_output, severity, Info.getID());
-m_manager->AddDiagnostic(new_diagnostic);
-
-// Don't store away warning fixits, since the compiler doesn't have
-// enough context in an expression for the warning to be useful.
-// FIXME: Should we try to filter out FixIts that apply to our 
generated
-// code, and not the user's expression?
-if (severity == eDiagnosticSeverityError) {
-  size_t num_fixit_hints = Info.getNumFixItHints();
-  for (size_t i = 0; i < num_fixit_hints; i++) {
-const clang::FixItHint &fixit = Info.getFixItHint(i);
-if (!fixit.isNull())
-  new_diagnostic->AddFixitHint(fixit);
-  }
+lldb_private::DiagnosticSeverity severity;
+bool make_new_diagnostic = true;
+
+switch (DiagLevel) {
+case DiagnosticsEngine::Level::Fatal:

[Lldb-commits] [lldb] r374148 - Unify the two CRC implementations

2019-10-09 Thread Hans Wennborg via lldb-commits
Author: hans
Date: Wed Oct  9 02:06:30 2019
New Revision: 374148

URL: http://llvm.org/viewvc/llvm-project?rev=374148&view=rev
Log:
Unify the two CRC implementations

David added the JamCRC implementation in r246590. More recently, Eugene
added a CRC-32 implementation in r357901, which falls back to zlib's
crc32 function if present.

These checksums are essentially the same, so having multiple
implementations seems unnecessary. This replaces the CRC-32
implementation with the simpler one from JamCRC, and implements the
JamCRC interface in terms of CRC-32 since this means it can use zlib's
implementation when available, saving a few bytes and potentially making
it faster.

JamCRC took an ArrayRef argument, and CRC-32 took a StringRef.
This patch changes it to ArrayRef which I think is the best
choice, and simplifies a few of the callers nicely.

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

Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=374148&r1=374147&r2=374148&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Oct  9 
02:06:30 2019
@@ -36,7 +36,7 @@
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Object/Decompressor.h"
 #include "llvm/Support/ARMBuildAttributes.h"
-#include "llvm/Support/JamCRC.h"
+#include "llvm/Support/CRC.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MipsABIFlags.h"
@@ -398,10 +398,8 @@ bool ObjectFileELF::MagicBytesMatch(Data
 }
 
 static uint32_t calc_crc32(uint32_t init, const DataExtractor &data) {
-  llvm::JamCRC crc(~init);
-  crc.update(llvm::makeArrayRef(
-  reinterpret_cast(data.GetDataStart()), 
data.GetByteSize()));
-  return ~crc.getCRC();
+  return llvm::crc32(
+  init, llvm::makeArrayRef(data.GetDataStart(), data.GetByteSize()));
 }
 
 uint32_t ObjectFileELF::CalculateELFNotesSegmentsCRC32(


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


[Lldb-commits] [PATCH] D68570: Unify the two CRC implementations

2019-10-09 Thread Hans via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1e1e3ba2526e: Unify the two CRC implementations (authored by 
hansw).
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68570

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  lld/COFF/PDB.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  llvm/include/llvm/Support/CRC.h
  llvm/include/llvm/Support/JamCRC.h
  llvm/lib/DebugInfo/PDB/Native/Hash.cpp
  llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
  llvm/lib/DebugInfo/PDB/Native/TpiHashing.cpp
  llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CRC.cpp
  llvm/lib/Support/JamCRC.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
  llvm/tools/llvm-objcopy/CopyConfig.cpp
  llvm/unittests/Support/CRCTest.cpp
  llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -79,7 +79,6 @@
 "IntervalMap.cpp",
 "ItaniumManglingCanonicalizer.cpp",
 "JSON.cpp",
-"JamCRC.cpp",
 "KnownBits.cpp",
 "LEB128.cpp",
 "LineIterator.cpp",
Index: llvm/unittests/Support/CRCTest.cpp
===
--- llvm/unittests/Support/CRCTest.cpp
+++ llvm/unittests/Support/CRCTest.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "llvm/Support/CRC.h"
+#include "llvm/ADT/StringExtras.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -18,12 +19,26 @@
 namespace {
 
 TEST(CRCTest, CRC32) {
-  EXPECT_EQ(0x414FA339U,
-llvm::crc32(
-0, StringRef("The quick brown fox jumps over the lazy dog")));
+  EXPECT_EQ(0x414FA339U, llvm::crc32(arrayRefFromStringRef(
+ "The quick brown fox jumps over the lazy dog")));
+
   // CRC-32/ISO-HDLC test vector
   // http://reveng.sourceforge.net/crc-catalogue/17plus.htm#crc.cat.crc-32c
-  EXPECT_EQ(0xCBF43926U, llvm::crc32(0, StringRef("123456789")));
+  EXPECT_EQ(0xCBF43926U, llvm::crc32(arrayRefFromStringRef("123456789")));
+
+  // Check the CRC-32 of each byte value, exercising all of CRCTable.
+  for (int i = 0; i < 256; i++) {
+// Compute CRCTable[i] using Hacker's Delight (2nd ed.) Figure 14-7.
+uint32_t crc = i;
+for (int j = 7; j >= 0; j--) {
+  uint32_t mask = -(crc & 1);
+  crc = (crc >> 1) ^ (0xEDB88320 & mask);
+}
+
+// CRCTable[i] is the CRC-32 of i without the initial and final bit flips.
+uint8_t byte = i;
+EXPECT_EQ(crc, ~llvm::crc32(0xU, byte));
+  }
 }
 
 } // end anonymous namespace
Index: llvm/tools/llvm-objcopy/CopyConfig.cpp
===
--- llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -14,10 +14,10 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/CRC.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Errc.h"
-#include "llvm/Support/JamCRC.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/StringSaver.h"
 #include 
@@ -461,12 +461,8 @@
 if (!DebugOrErr)
   return createFileError(Config.AddGnuDebugLink, DebugOrErr.getError());
 auto Debug = std::move(*DebugOrErr);
-JamCRC CRC;
-CRC.update(
-ArrayRef(Debug->getBuffer().data(), Debug->getBuffer().size()));
-// The CRC32 value needs to be complemented because the JamCRC doesn't
-// finalize the CRC32 value.
-Config.GnuDebugLinkCRC32 = ~CRC.getCRC();
+Config.GnuDebugLinkCRC32 =
+llvm::crc32(arrayRefFromStringRef(Debug->getBuffer()));
   }
   Config.BuildIdLinkDir = InputArgs.getLastArgValue(OBJCOPY_build_id_link_dir);
   if (InputArgs.hasArg(OBJCOPY_build_id_link_input))
Index: llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
===
--- llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
+++ llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
@@ -16,8 +16,8 @@
 
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/COFF.h"
+#include "llvm/Support/CRC.h"
 #include "llvm/Support/Errc.h"
-#include "llvm/Support/JamCRC.h"
 #include "llvm/Support/Path.h"
 #include 
 
@@ -40,22 +40,13 @@
  Obj.IsPE ? Obj.PeHeader.SectionAlignment : 1);
 }
 
-static uint32_t getCRC32(StringRef Data) {
-  JamCRC CRC;
-  CRC.update(ArrayRef(Data.data(), Data.size()));
-  // The CRC32 value needs to be 

[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-09 Thread James Henderson via Phabricator via lldb-commits
jhenderson added subscribers: MaskRay, grimar.
jhenderson added a comment.

FYI, I'm going to be away for 2 and a half weeks from the end of work today, so 
won't have time to look at these if I don't get to them later today. I have no 
issues with other people reviewing them. You might want to add @grimar and 
@MaskRay to the reviews as they've been doing a lot of work in 
obj2yaml/yaml2obj recently.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


[Lldb-commits] [PATCH] D68454: Fix the unwinding plan augmentation from x86 assembly

2019-10-09 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a reviewer: labath.
jarin added a comment.

Pavel, could you possibly take a look? It looks like Jason is busy with 
something else...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68454



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


[Lldb-commits] [PATCH] D68691: [lldb] Add MemorySource abstraction, unit test StringPrinter and document found bugs

2019-10-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Btw, the current declaration of MemorySource is just what I came up with on the 
fly. Not sure where the documentation should go or if that class deserves its 
own header.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68691



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


[Lldb-commits] [PATCH] D68691: [lldb] Add MemorySource abstraction, unit test StringPrinter and document found bugs

2019-10-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: labath.
Herald added subscribers: lldb-commits, JDevlieghere, abidh, mgorny.
Herald added a project: LLDB.
teemperor added a comment.

Btw, the current declaration of MemorySource is just what I came up with on the 
fly. Not sure where the documentation should go or if that class deserves its 
own header.


As we found out already, StringPrinter has some surprising behaviour and bugs. 
This patch adds a (hopefully) exhaustive
test of all the StringPrinter functionality for all supported encodings and API 
variants. Also adds a bunch of
FIXME's into the test for all the unexpected behaviour I found. This patch is 
not fully NFC as it changes that
the StringPrinter now treats both 0 and LLDB_INVALID_ADDRESS as invalid 
addresses (this
seems like a really safe fix to me and it makes the test a bit simpler).

Also adds the MemorySource abstraction class that allows us to mock a process 
in this unit test. It essentially has
the minimal interface so that StringPrinter can do all the calls it currently 
does, but obviously the implementation
could be more minimal. We can reduce that interface more in the future once 
StringPrinter doesn't use all of these
functions to do its job.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68691

Files:
  lldb/include/lldb/DataFormatters/StringPrinter.h
  lldb/include/lldb/Target/Process.h
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/unittests/CMakeLists.txt
  lldb/unittests/DataFormatters/CMakeLists.txt
  lldb/unittests/DataFormatters/StringPrinterTest.cpp

Index: lldb/unittests/DataFormatters/StringPrinterTest.cpp
===
--- /dev/null
+++ lldb/unittests/DataFormatters/StringPrinterTest.cpp
@@ -0,0 +1,784 @@
+//===-- StringPrinterTest.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 "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Utility/Endian.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace lldb_private::formatters;
+
+namespace {
+/// A memory source that just stores a string and pretend it's the memory of
+/// a process.
+struct MockMemorySource : public MemorySource {
+  virtual ~MockMemorySource() = default;
+  std::string m_data;
+  lldb::ByteOrder m_byte_order;
+  uint32_t m_addr_size;
+
+  MockMemorySource(const std::string &data, lldb::ByteOrder order,
+   unsigned addr_size)
+  : m_data(data), m_byte_order(order), m_addr_size(addr_size) {
+// We currently only support the host byte order (as this is the one we
+// encode our string literals in). StringPrinter anyway doesn't do any
+// byte order handling on its own, so different byte orders aren't really
+// useful here.
+assert(order == endian::InlHostByteOrder() &&
+   "only little endian should be used");
+// Address size doesn't really influence this test or the StringPrinter,
+// so let's just make sure we have something reasonable.
+assert(addr_size == 4U && "only 4 byte addresses should be used");
+  }
+
+  virtual size_t ReadStringFromMemory(lldb::addr_t vm_addr, char *str,
+  size_t max_bytes, Status &error,
+  size_t type_width = 1) {
+std::memset(str, 0, max_bytes);
+std::string terminator(type_width, '\0');
+for (size_t i = 0; i < max_bytes - type_width; ++i) {
+  const size_t mem_offset = i + vm_addr;
+  assert(mem_offset < m_data.size() && "Out of bounds read?");
+  str[i] = m_data.at(mem_offset);
+  if (llvm::StringRef(m_data).substr(mem_offset).startswith(terminator))
+return i;
+}
+return max_bytes;
+  }
+
+  virtual size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr,
+   size_t cstr_max_len, Status &error) {
+for (size_t i = 0; i < cstr_max_len; ++i) {
+  char c = m_data.at(i + vm_addr);
+  if (c == '\0')
+return i;
+  if (i == cstr_max_len)
+break;
+  cstr[i] = c;
+}
+return cstr_max_len;
+  }
+
+  virtual size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf,
+size_t size, Status &error) {
+assert(size + vm_addr < m_data.size());
+std::memcpy(buf, m_data.data() + vm_addr, size);
+return size;
+  }
+
+  virtual lldb::ByteOrder GetByteOrder() const { return m_byte_order; }
+
+  virtual uint32_t GetAddressByteSize() const { return m_addr_size; }
+};
+} // namespace
+
+#define MEM_STR(DATA) (std::string(DATA, sizeof(DATA)))
+
+namespace {
+struct St

[Lldb-commits] [PATCH] D68674: Remove the is_mangled flag from Mangled and Symbol

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

Looks like a nice cleanup, if we can get away with that. I tried to come up 
with a situation where we would have a more authoritative source on whether 
something is mangled or not than just looking at the string, but I haven't come 
up with anything, so the answer is hopefully yes.


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

https://reviews.llvm.org/D68674



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


[Lldb-commits] [PATCH] D68696: [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: jingham, JDevlieghere, labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The SearchCallback has a bool parameter that we always set to false, we never 
use in any callback implementation and that also changes its name
from one file to the other (either `containing` and `complete`). It was added 
in the original LLDB check in, so there isn't any history what
this was supposed to be, so let's just remove it.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68696

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Core/AddressResolverFileLine.h
  lldb/include/lldb/Core/AddressResolverName.h
  lldb/include/lldb/Core/FileLineResolver.h
  lldb/include/lldb/Core/SearchFilter.h
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Core/AddressResolverFileLine.cpp
  lldb/source/Core/AddressResolverName.cpp
  lldb/source/Core/FileLineResolver.cpp
  lldb/source/Core/SearchFilter.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp

Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -111,12 +111,11 @@
   ~ExceptionBreakpointResolver() override = default;
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override {
+  SymbolContext &context,
+  Address *addr) override {
 
 if (SetActualResolver())
-  return m_actual_resolver_sp->SearchCallback(filter, context, addr,
-  containing);
+  return m_actual_resolver_sp->SearchCallback(filter, context, addr);
 else
   return eCallbackReturnStop;
   }
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -67,8 +67,8 @@
   void Dump(Stream *s) const override {}
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
@@ -117,8 +117,8 @@
   void Dump(Stream *s) const override {}
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
@@ -262,8 +262,8 @@
   void Dump(Stream *s) const override {}
 
   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
-  SymbolContext &context, Address *addr,
-  bool containing) override;
+  SymbolContext &context,
+  Address *addr) override;
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -790,7 +790,7 @@
 // symbol.
 Searcher::

[Lldb-commits] [PATCH] D68696: [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I just realised the same is true for `addr` (beside that it is consistently 
named). I'll remove this too after this has landed.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68696



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


[Lldb-commits] [PATCH] D68696: [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-09 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.

lol


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68696



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


[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

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



Comment at: lldb/source/Core/IOHandler.cpp:317-321
+  size_t end = pos + 1;
+  while (end > 0 &&
+ (line_buffer[end - 1] == '\n' || line_buffer[end - 1] == '\r'))
+end--;
+  std::string line = line_buffer.substr(0, end);

`line = StringRef(line_buffer.begin(), pos).rtrim("\n\r")` ?



Comment at: lldb/source/Core/IOHandler.cpp:326-341
+// Append newchars to the buffer and split out a line.
+static Optional AppendAndSplitLine(std::string &line_buffer,
+StringRef newchars) {
+  size_t pos = newchars.find('\n');
+  if (pos == StringRef::npos) {
+line_buffer.append(newchars);
+return None;

This looks like too much optimization. Why not just append the new stuff and 
then call `SplitLine` ?



Comment at: lldb/source/Core/IOHandler.cpp:346-347
+static Optional SplitLineEOF(std::string &line_buffer) {
+  if (line_buffer.empty())
+return None;
+  if (std::all_of(line_buffer.begin(), line_buffer.end(), isspace))

Technically, this check is subsumed by the next one.



Comment at: lldb/source/Core/IOHandler.cpp:348
+return None;
+  if (std::all_of(line_buffer.begin(), line_buffer.end(), isspace))
+return None;

`llvm::all_of(line_buffer, ::isspace)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622



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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

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

I think this is looking pretty good. I like how the read/write methods look 
now. Just one more question about the PythonBuffer class.




Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1258-1265
+  // you must check PyErr_Occurred() after calling this constructor.
+  PythonBuffer(PythonObject &obj, int flags = PyBUF_SIMPLE)
+  : m_buffer({}), m_error(Error::success()) {
+PyObject_GetBuffer(obj.get(), &m_buffer, flags);
+if (!m_buffer.obj) {
+  m_error = llvm::make_error();
+}

Storing the Error as a member is quite unusual. It would be better to have a 
factory function which returns Expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

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

Some nits inline, otherwise it looks fine to me.




Comment at: lldb/include/lldb/Utility/ReproducerInstrumentation.h:243
+template  struct serializer_tag {
+  typedef typename std::conditional::value, 
ValueTag, NotImplementedTag>::type type;
+};

clang-format this



Comment at: lldb/source/API/SBCommandReturnObject.cpp:118-142
 size_t SBCommandReturnObject::PutOutput(FILE *fh) {
   LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh);
-
   if (fh) {
 size_t num_bytes = GetOutputSize();
 if (num_bytes)
   return ::fprintf(fh, "%s", GetOutput());
   }

Have these methods delegate to one another (I'm not sure which should be the 
"base" one TBH).



Comment at: lldb/source/API/SBCommandReturnObject.cpp:133
+return 0;
+  return file_sp->Printf("%s", GetOutput());
+}

Why not just `file_sp->Write(GetOutput(), GetOutputSize())` ? It invoking 
formatting function for this seems overkill (and ideally I would like to remove 
formatted output capabilities from the file class completely).



Comment at: lldb/source/API/SBCommandReturnObject.cpp:275-284
+  FileSP file = std::make_shared(fh, transfer_ownership);
+  ref().SetImmediateOutputFile(file);
 }
 
 void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh,
   bool transfer_ownership) {
   LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,

Here the need isn't as pressing, but I'd probably have these delegate too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434



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


[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar added inline comments.



Comment at: include/llvm/ObjectYAML/MinidumpYAML.h:111
+
+  explicit MemoryInfoListStream(std::vector Infos)
+  : Stream(StreamKind::MemoryInfoList,

Maybe be more explicit here, i.e.

```
std::vector &&Infos
```
?



Comment at: lib/ObjectYAML/MinidumpEmitter.cpp:166
+Header.SizeOfEntry = sizeof(minidump::MemoryInfo);
+Header.NumberOfEntries = InfoList.Infos.size();
+File.allocateNewObject(Header);

Probably just

```
minidump::MemoryInfoListHeader Header = {
(support::ulittle32_t)sizeof(minidump::MemoryInfoListHeader),
(support::ulittle32_t)sizeof(minidump::MemoryInfo),
(support::ulittle64_t)InfoList.Infos.size()};
```

?

Or perhaps it could have a constructor.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-09 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 224065.
labath marked 2 inline comments as done.
labath added a comment.

Address review comments


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645

Files:
  include/llvm/BinaryFormat/Minidump.h
  include/llvm/ObjectYAML/MinidumpYAML.h
  lib/ObjectYAML/MinidumpEmitter.cpp
  lib/ObjectYAML/MinidumpYAML.cpp
  test/tools/obj2yaml/basic-minidump.yaml

Index: test/tools/obj2yaml/basic-minidump.yaml
===
--- test/tools/obj2yaml/basic-minidump.yaml
+++ test/tools/obj2yaml/basic-minidump.yaml
@@ -55,6 +55,27 @@
 Memory Ranges:   
   - Start of Memory Range: 0x7C7D7E7F80818283
 Content:   '8485868788'
+  - Type:MemoryInfoList
+Memory Ranges:
+  - Base Address:0x
+Allocation Protect: [  ]
+Region Size: 0x0001
+State:   [ MEM_FREE ]
+Protect: [ PAGE_NO_ACCESS ]
+Type:[  ]
+  - Base Address:0x0001
+Allocation Protect: [ PAGE_READ_WRITE ]
+Region Size: 0x0001
+State:   [ MEM_COMMIT ]
+Type:[ MEM_MAPPED ]
+  - Base Address:0x0002
+Allocation Base: 0x
+Allocation Protect: [ PAGE_READ_WRITE, PAGE_WRITECOMBINE ]
+Reserved0:   0xDEADBEEF
+Region Size: 0x0001
+State:   [ MEM_COMMIT, MEM_FREE ]
+Type:[ MEM_PRIVATE, MEM_MAPPED ]
+Reserved1:   0xBAADF00D
 ...
 
 # CHECK:  --- !minidump
@@ -112,4 +133,25 @@
 # CHECK-NEXT: Memory Ranges:   
 # CHECK-NEXT:   - Start of Memory Range: 0x7C7D7E7F80818283
 # CHECK-NEXT: Content:   '8485868788'
+# CHECK-NEXT:   - Type:MemoryInfoList
+# CHECK-NEXT: Memory Ranges:
+# CHECK-NEXT:   - Base Address:   0x
+# CHECK-NEXT: Allocation Protect: [  ]
+# CHECK-NEXT: Region Size:0x0001
+# CHECK-NEXT: State:  [ MEM_FREE ]
+# CHECK-NEXT: Protect:[ PAGE_NO_ACCESS ]
+# CHECK-NEXT: Type:   [  ]
+# CHECK-NEXT:   - Base Address:   0x0001
+# CHECK-NEXT: Allocation Protect: [ PAGE_READ_WRITE ]
+# CHECK-NEXT: Region Size:0x0001
+# CHECK-NEXT: State:  [ MEM_COMMIT ]
+# CHECK-NEXT: Type:   [ MEM_MAPPED ]
+# CHECK-NEXT:   - Base Address:   0x0002
+# CHECK-NEXT: Allocation Base:0x
+# CHECK-NEXT: Allocation Protect: [ PAGE_READ_WRITE, PAGE_WRITECOMBINE ]
+# CHECK-NEXT: Reserved0:  0xDEADBEEF
+# CHECK-NEXT: Region Size:0x0001
+# CHECK-NEXT: State:  [ MEM_COMMIT, MEM_FREE ]
+# CHECK-NEXT: Type:   [ MEM_PRIVATE, MEM_MAPPED ]
+# CHECK-NEXT: Reserved1:  0xBAADF00D
 # CHECK-NEXT: ...
Index: lib/ObjectYAML/MinidumpYAML.cpp
===
--- lib/ObjectYAML/MinidumpYAML.cpp
+++ lib/ObjectYAML/MinidumpYAML.cpp
@@ -69,6 +69,8 @@
 
 Stream::StreamKind Stream::getKind(StreamType Type) {
   switch (Type) {
+  case StreamType::MemoryInfoList:
+return StreamKind::MemoryInfoList;
   case StreamType::MemoryList:
 return StreamKind::MemoryList;
   case StreamType::ModuleList:
@@ -93,6 +95,8 @@
 std::unique_ptr Stream::create(StreamType Type) {
   StreamKind Kind = getKind(Type);
   switch (Kind) {
+  case StreamKind::MemoryInfoList:
+return std::make_unique();
   case StreamKind::MemoryList:
 return std::make_unique();
   case StreamKind::ModuleList:
@@ -109,6 +113,25 @@
   llvm_unreachable("Unhandled stream kind!");
 }
 
+void yaml::ScalarBitSetTraits::bitset(
+IO &IO, MemoryProtection &Protect) {
+#define HANDLE_MDMP_PROTECT(CODE, NAME, NATIVENAME)\
+  IO.bitSetCase(Protect, #NATIVENAME, MemoryProtection::NAME);
+#include "llvm/BinaryFormat/MinidumpConstants.def"
+}
+
+void yaml::ScalarBitSetTraits::bitset(IO &IO, MemoryState &State) {
+#define HANDLE_MDMP_MEMSTATE(CODE, NAME, NATIVENAME)   \
+  IO.bitSetCase(State, #NATIVENAME, MemoryState::NAME);
+#include "llvm/BinaryFormat/MinidumpConstants.def"
+}
+
+void yaml::ScalarBitSetTraits::bitset(IO &IO, MemoryType &Type) {
+#define HANDLE_MDMP_MEMTYPE(CODE, NAME, NATIVENAME)\
+  IO.bitSetCase(Type, #NATIVENAME, MemoryType::NAME);
+#include "llvm/BinaryFormat/MinidumpConstants.def"
+}
+
 void yaml::ScalarEnumerationTraits::enumeration(
 IO &IO, ProcessorArchitecture &Arch) {
 #define HANDLE_MDMP_ARCH(CODE, NAME)   \
@@ -215,6 +238,20 @@
   

[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

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



Comment at: lib/ObjectYAML/MinidumpEmitter.cpp:166
+Header.SizeOfEntry = sizeof(minidump::MemoryInfo);
+Header.NumberOfEntries = InfoList.Infos.size();
+File.allocateNewObject(Header);

grimar wrote:
> Probably just
> 
> ```
> minidump::MemoryInfoListHeader Header = {
> (support::ulittle32_t)sizeof(minidump::MemoryInfoListHeader),
> (support::ulittle32_t)sizeof(minidump::MemoryInfo),
> (support::ulittle64_t)InfoList.Infos.size()};
> ```
> 
> ?
> 
> Or perhaps it could have a constructor.
The thought of a constructor has crossed my mind too. I've now added it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


[Lldb-commits] [PATCH] D68270: DWARFDebugLoc: Add a function to get the address range of an entry

2019-10-09 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

In D68270#1700108 , @probinson wrote:

> Do we care whether llvm-dwarfdump's output bears any similarities to the 
> output from GNU readelf or objdump?  There has been a push lately to get the 
> LLVM "binutils" to behave more like GNU's, although AFAIK it hasn't gotten to 
> the DWARF dumping part.


Generally I hope not to deal with that until there's a user with a need for it 
who wants to do the work & has a specific use-case that can help motivate which 
similarities are desirable and which ones don't matter (& perhaps if there's 
enough that they start to tradeoff usability - maybe the "compatibility mode" 
is a separate tool or separate flag to the existing tool).

My broader hope is probably that llvm-dwarfdump is more for interactive uses 
than other dumpers, so fewer people might try to build automated things on top 
of it & thus expect specific output (this gives us both the freedom not to 
match the GNU tools, and the freedom not to match previous llvm-dwarfdump 
behavior (which we've done a fair bit in the past - which seems to support the 
theory that people don't seem to be building much on top of this))




Comment at: lib/DebugInfo/DWARF/DWARFDebugLoc.cpp:291-295
+  EntryIterator Absolute =
+  getAbsoluteLocations(
+  SectionedAddress{BaseAddr, SectionedAddress::UndefSection},
+  LookupPooledAddress)
+  .begin();

labath wrote:
> dblaikie wrote:
> > labath wrote:
> > > dblaikie wrote:
> > > > labath wrote:
> > > > > This parallel iteration is not completely nice, but I think it's 
> > > > > worth being able to reuse the absolute range computation code. I'm 
> > > > > open to ideas for improvement though.
> > > > Ah, I see - this is what you meant about "In particular it makes it 
> > > > possible to reuse this stuff in the dumping code, which would have been 
> > > > pretty hard with callbacks.".
> > > > 
> > > > I'm wondering if that might be worth revisiting somewhat. A full 
> > > > iterator abstraction for one user here (well, two once you include lldb 
> > > > - but I assume it's likely going to build its own data structure from 
> > > > the iteration anyway, right? (it's not going to keep the iterator 
> > > > around, do anything interesting like partial iterations, re-iterate/etc 
> > > > - such that a callback would suffice))
> > > > 
> > > > I could imagine two callback APIs for this - one that gets entries and 
> > > > locations and one that only gets locations by filtering on the entry 
> > > > version.
> > > > 
> > > > eg:
> > > > 
> > > >   // for non-verbose output:
> > > >   LL.forEachEntry([&](const Entry &E, Expected L) {
> > > > if (Verbose && actually dumping debug_loc)
> > > >   print(E) // print any LLE_*, raw parameters, etc
> > > > if (L)
> > > >   print(*L) // print the resulting address range, section name (if 
> > > > verbose), 
> > > > else
> > > >   print(error stuff)
> > > >   });
> > > > 
> > > > One question would be "when/where do we print the DWARF expression" - 
> > > > if there's an error computing the address range, we can still print the 
> > > > expression, so maybe that happens unconditionally at the end of the 
> > > > callback, using the expression in the Entry? (then, arguably, the 
> > > > expression doesn't need to be in the DWARFLocation - and I'd say make 
> > > > the DWARFLocation a sectioned range, exactly the same type as for 
> > > > ranges so that part of the dumping code, etc, can be maximally reused)
> > > Actually, what lldb currently does is that it does not build any data 
> > > structures at all (except storing the pointer to the right place in the 
> > > debug_loc section. Then, whenever it wants to do something to the 
> > > loclist, it parses it afresh. I don't know why it does this exactly, but 
> > > I assume it has something to do with most locations never being used, or 
> > > being only a couple of times, and the actual parsing being fairly fast. 
> > > What this means is that lldb is not really a single "user", but there are 
> > > like four or five places where it iterates through the list, depending on 
> > > what does it actually want to do with it. It also does partial iteration 
> > > where it stops as soon as it find the entry it was interested in.
> > > Now, all of that is possible with a callback (though I am generally 
> > > trying to avoid them), but it does resurface the issue of what should be 
> > > the value of the second argument for DW_LLE_base_address entries (the 
> > > thing which I originally used a error type for).
> > > Maybe this should be actually one callback API, taking two callback 
> > > functions, with one of them being invoked for base_address entries, and 
> > > one for others? However, if we stick to the current approaches in both 
> > > LLE and RLE of making the address pool resolution function a parameter 
> > > (which I'd like to keep, as i

[Lldb-commits] [lldb] r374180 - Remove the is_mangled flag from Mangled and Symbol

2019-10-09 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Oct  9 09:22:14 2019
New Revision: 374180

URL: http://llvm.org/viewvc/llvm-project?rev=374180&view=rev
Log:
Remove the is_mangled flag from Mangled and Symbol

Testing whether a name is mangled or not is extremely cheap and can be
done by looking at the first two characters. Mangled knows how to do
it. On the flip side, many call sites that currently pass in an
is_mangled determination do not know how to correctly do it (for
example, they leave out Swift mangling prefixes).

This patch removes this entry point and just forced Mangled to
determine the mangledness of a string itself.

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

Modified:
lldb/trunk/include/lldb/Core/Mangled.h
lldb/trunk/include/lldb/Symbol/Function.h
lldb/trunk/include/lldb/Symbol/Symbol.h
lldb/trunk/source/API/SBType.cpp
lldb/trunk/source/Core/Mangled.cpp
lldb/trunk/source/Expression/IRExecutionUnit.cpp

lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/trunk/source/Symbol/Function.cpp
lldb/trunk/source/Symbol/Symbol.cpp
lldb/trunk/unittests/Core/MangledTest.cpp

Modified: lldb/trunk/include/lldb/Core/Mangled.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Mangled.h?rev=374180&r1=374179&r2=374180&view=diff
==
--- lldb/trunk/include/lldb/Core/Mangled.h (original)
+++ lldb/trunk/include/lldb/Core/Mangled.h Wed Oct  9 09:22:14 2019
@@ -53,20 +53,6 @@ public:
 
   /// Construct with name.
   ///
-  /// Constructor with an optional string and a boolean indicating if it is
-  /// the mangled version.
-  ///
-  /// \param[in] name
-  /// The already const name to copy into this object.
-  ///
-  /// \param[in] is_mangled
-  /// If \b true then \a name is a mangled name, if \b false then
-  /// \a name is demangled.
-  Mangled(ConstString name, bool is_mangled);
-  Mangled(llvm::StringRef name, bool is_mangled);
-
-  /// Construct with name.
-  ///
   /// Constructor with an optional string and auto-detect if \a name is
   /// mangled or not.
   ///
@@ -76,12 +62,6 @@ public:
 
   explicit Mangled(llvm::StringRef name);
 
-  /// Destructor
-  ///
-  /// Releases its ref counts on the mangled and demangled strings that live
-  /// in the global string pool.
-  ~Mangled();
-
   /// Convert to pointer operator.
   ///
   /// This allows code to check a Mangled object to see if it contains a valid

Modified: lldb/trunk/include/lldb/Symbol/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=374180&r1=374179&r2=374180&view=diff
==
--- lldb/trunk/include/lldb/Symbol/Function.h (original)
+++ lldb/trunk/include/lldb/Symbol/Function.h Wed Oct  9 09:22:14 2019
@@ -140,7 +140,7 @@ public:
   /// \param[in] call_decl_ptr
   /// Optional calling location declaration information that
   /// describes from where this inlined function was called.
-  InlineFunctionInfo(const char *name, const char *mangled,
+  InlineFunctionInfo(const char *name, llvm::StringRef mangled,
  const Declaration *decl_ptr,
  const Declaration *call_decl_ptr);
 

Modified: lldb/trunk/include/lldb/Symbol/Symbol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=374180&r1=374179&r2=374180&view=diff
==
--- lldb/trunk/include/lldb/Symbol/Symbol.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symbol.h Wed Oct  9 09:22:14 2019
@@ -24,9 +24,8 @@ public:
   // drastically different meanings and sorting requirements.
   Symbol();
 
-  Symbol(uint32_t symID, const char *name, bool name_is_mangled,
- lldb::SymbolType type, bool external, bool is_debug,
- bool is_trampoline, bool is_artificial,
+  Symbol(uint32_t symID, llvm::StringRef name, lldb::SymbolType type,
+ bool external, bool is_debug, bool is_trampoline, bool is_artificial,
  const lldb::SectionSP §ion_sp, lldb::addr_t value,
  lldb::addr_t size, bool size_is_valid,
  bool contains_linker_annotations, uint32_t flags);

Modified: lldb/trunk/source/API/SBType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=374180&r1=374179&r2=374180&view=diff
==
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Wed Oct  9 09:22:14 2019
@@ -799,7 +799,7 @@ const char *SBTypeMemberFunction::GetDem
   if (m_opaque_sp) {
 ConstString mangled_str = m_opaque_sp

[Lldb-commits] [PATCH] D68674: Remove the is_mangled flag from Mangled and Symbol

2019-10-09 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG939411c1aaa8: Remove the is_mangled flag from Mangled and 
Symbol (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68674?vs=223965&id=224079#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68674

Files:
  lldb/include/lldb/Core/Mangled.h
  lldb/include/lldb/Symbol/Function.h
  lldb/include/lldb/Symbol/Symbol.h
  lldb/source/API/SBType.cpp
  lldb/source/Core/Mangled.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Symbol/Function.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/unittests/Core/MangledTest.cpp

Index: lldb/unittests/Core/MangledTest.cpp
===
--- lldb/unittests/Core/MangledTest.cpp
+++ lldb/unittests/Core/MangledTest.cpp
@@ -29,9 +29,7 @@
 
 TEST(MangledTest, ResultForValidName) {
   ConstString MangledName("_ZN1a1b1cIiiiEEvm");
-  bool IsMangled = true;
-
-  Mangled TheMangled(MangledName, IsMangled);
+  Mangled TheMangled(MangledName);
   ConstString TheDemangled =
   TheMangled.GetDemangledName(eLanguageTypeC_plus_plus);
 
@@ -41,9 +39,7 @@
 
 TEST(MangledTest, EmptyForInvalidName) {
   ConstString MangledName("_ZN1a1b1cmxktpEEvm");
-  bool IsMangled = true;
-
-  Mangled TheMangled(MangledName, IsMangled);
+  Mangled TheMangled(MangledName);
   ConstString TheDemangled =
   TheMangled.GetDemangledName(eLanguageTypeC_plus_plus);
 
Index: lldb/source/Symbol/Symbol.cpp
===
--- lldb/source/Symbol/Symbol.cpp
+++ lldb/source/Symbol/Symbol.cpp
@@ -31,9 +31,8 @@
   m_is_weak(false), m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(),
   m_flags() {}
 
-Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled,
-   SymbolType type, bool external, bool is_debug,
-   bool is_trampoline, bool is_artificial,
+Symbol::Symbol(uint32_t symID, llvm::StringRef name, SymbolType type, bool external,
+   bool is_debug, bool is_trampoline, bool is_artificial,
const lldb::SectionSP §ion_sp, addr_t offset, addr_t size,
bool size_is_valid, bool contains_linker_annotations,
uint32_t flags)
@@ -42,9 +41,9 @@
   m_is_debug(is_debug), m_is_external(external), m_size_is_sibling(false),
   m_size_is_synthesized(false), m_size_is_valid(size_is_valid || size > 0),
   m_demangled_is_synthesized(false),
-  m_contains_linker_annotations(contains_linker_annotations), 
+  m_contains_linker_annotations(contains_linker_annotations),
   m_is_weak(false), m_type(type),
-  m_mangled(ConstString(name), name_is_mangled),
+  m_mangled(name),
   m_addr_range(section_sp, offset, size), m_flags(flags) {}
 
 Symbol::Symbol(uint32_t symID, const Mangled &mangled, SymbolType type,
Index: lldb/source/Symbol/Function.cpp
===
--- lldb/source/Symbol/Function.cpp
+++ lldb/source/Symbol/Function.cpp
@@ -59,10 +59,11 @@
   return m_name.MemorySize() + m_declaration.MemorySize();
 }
 
-InlineFunctionInfo::InlineFunctionInfo(const char *name, const char *mangled,
+InlineFunctionInfo::InlineFunctionInfo(const char *name,
+   llvm::StringRef mangled,
const Declaration *decl_ptr,
const Declaration *call_decl_ptr)
-: FunctionInfo(name, decl_ptr), m_mangled(ConstString(mangled), true),
+: FunctionInfo(name, decl_ptr), m_mangled(mangled),
   m_call_decl(call_decl_ptr) {}
 
 InlineFunctionInfo::InlineFunctionInfo(ConstString name,
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1422,7 +1422,6 @@
 symtab.AddSymbol(
 Symbol(pub_symbol->getSymIndexId(),   // symID
pub_symbol->getName().c_str(), // name
-   true,  // name_is_mangled
pub_symbol->isCode() ? eSymbolTypeCode : eSymbolTypeData, // type
true,  // external
false, // is_debug
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/source/Plugins/SymbolFile/Breakpad/Symbo

[Lldb-commits] [lldb] r374184 - [test] Split LLDB tests into API, Shell & Unit

2019-10-09 Thread Jonas Devlieghere via lldb-commits
Added: lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test?rev=374184&view=auto
==
--- lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test (added)
+++ lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test Wed Oct  9 09:38:47 2019
@@ -0,0 +1,59 @@
+REQUIRES: system-windows, msvc
+RUN: %build --compiler=msvc --arch=32 --nodefaultlib 
--output=%T/SimpleTypesTest.cpp.typedefs.exe %S/Inputs/SimpleTypesTest.cpp
+RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s
+
+; Generate 32-bit target
+
+; FIXME: PDB does not have line information for typedef statements so source
+; and line information for them is not tested.
+
+; Note, types `long double` and `double` have same bit size in MSVC and there
+; is no information in the PDB to distinguish them. So the compiler type for
+; both of them is the same.
+
+CHECK: Module [[MOD:.*]]
+CHECK: SymbolFile pdb ([[MOD]])
+CHECK-DAG: name = "char32_t", size = 4, compiler_type = {{.*}} char32_t
+CHECK-DAG: name = "char16_t", size = 2, compiler_type = {{.*}} char16_t
+CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = 
{{.*}} unsigned long
+CHECK-DAG: Type{{.*}} , size = 40, compiler_type = {{.*}} unsigned long [10]
+CHECK-DAG: Type{{.*}} , name = "ULongArrayTypedef", compiler_type = {{.*}} 
typedef ULongArrayTypedef
+
+; Note: compiler_type of `long double` is represented by the one for `double`
+CHECK-DAG: Type{{.*}} , name = "double", size = 8, compiler_type = {{.*}} 
double
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double *
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double *&
+CHECK-DAG: Type{{.*}} , name = "RefTypedef", compiler_type = {{.*}} typedef 
RefTypedef
+
+CHECK-DAG: Type{{.*}} , name = "wchar_t", size = 2, compiler_type = {{.*}} 
wchar_t
+
+CHECK-DAG: Type{{.*}} , name = "int", size = 4, compiler_type = {{.*}} int
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &
+CHECK-DAG: Type{{.*}} , name = "unsigned char", size = 1, compiler_type = 
{{.*}} unsigned char
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char *
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char **
+CHECK-DAG: Type{{.*}} , name = "short", size = 2, compiler_type = {{.*}} short
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} short *
+CHECK-DAG: Type{{.*}} , name = "const double", size = 8, compiler_type = 
{{.*}} const double
+CHECK-DAG: Type{{.*}} , name = "volatile bool", size = 1, compiler_type = 
{{.*}} volatile _Bool
+CHECK-DAG: Type{{.*}} , name = "long long", size = 8, compiler_type = {{.*}} 
long long
+CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} long long (int &, unsigned char 
**, short *, const double, volatile _Bool)
+CHECK-DAG: Type{{.*}} , name = "FuncPtrTypedef", compiler_type = {{.*}} 
typedef FuncPtrTypedef
+
+CHECK-DAG: Type{{.*}} , name = "void", compiler_type = {{.*}} void
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} void *
+CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long
+CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = 
{{.*}} unsigned short
+CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = 
{{.*}} unsigned int
+CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = {{.*}} char
+CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} 
signed char
+CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} char (void *, long, unsigned 
short, unsigned int, ...)
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} char (*)(void *, 
long, unsigned short, unsigned int, ...)
+CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} 
typedef VarArgsFuncTypedef
+
+CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float
+CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} float (...)
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} float (*)(...)
+CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedefA", compiler_type = {{.*}} 
typedef VarArgsFuncTypedefA
+
+CHECK-DAG: {{^[0-9A-F]+}}:   CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = 
"c++", file = '{{.*}}\SimpleTypesTest.cpp'

Added: lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test?rev=374184&view=auto
==
--- lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test (added)
+++ lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test Wed Oct  9 09:38:47 
2019
@@ -0,0 +1,51 @@
+REQUIRES: system-windows, lld
+RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
+RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+
+CHECK:(int) int C::abc = 123
+CHECK:(List [16]) ls = {
+C

[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

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



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1258-1265
+  // you must check PyErr_Occurred() after calling this constructor.
+  PythonBuffer(PythonObject &obj, int flags = PyBUF_SIMPLE)
+  : m_buffer({}), m_error(Error::success()) {
+PyObject_GetBuffer(obj.get(), &m_buffer, flags);
+if (!m_buffer.obj) {
+  m_error = llvm::make_error();
+}

labath wrote:
> Storing the Error as a member is quite unusual. It would be better to have a 
> factory function which returns Expected.
Oh yea I’ll fix that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [lldb] r374185 - Remove obsolete parameter.

2019-10-09 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Oct  9 09:55:27 2019
New Revision: 374185

URL: http://llvm.org/viewvc/llvm-project?rev=374185&view=rev
Log:
Remove obsolete parameter.

Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=374185&r1=374184&r2=374185&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Oct  9 
09:55:27 2019
@@ -2789,7 +2789,6 @@ Symtab *ObjectFileELF::GetSymtab() {
 uint64_t symbol_id = m_symtab_up->GetNumSymbols();
 Symbol symbol(symbol_id,
   GetNextSyntheticSymbolName().GetCString(), // Symbol 
name.
-  false,   // Is the symbol name mangled?
   eSymbolTypeCode, // Type of this symbol.
   true,// Is this globally visible?
   false,   // Is this symbol debug info?


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


[Lldb-commits] [PATCH] D68645: MinidumpYAML: Add support for the memory info list stream

2019-10-09 Thread George Rimar via Phabricator via lldb-commits
grimar accepted this revision.
grimar added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68645



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


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

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

`SymbolFile/Breakpad.symtab.test` is failing on green dragon cmake build see: 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2378/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68533



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


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-09 Thread Cameron via Phabricator via lldb-commits
cameron314 added a comment.

Any objections before I commit?


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

https://reviews.llvm.org/D68641



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


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

2019-10-09 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

@shafik thanks, checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68533



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


[Lldb-commits] [PATCH] D68696: [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-09 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

One of the oddities of the Search -> Search callback stuff is that the 
Searcher's Filter might be narrower than the level at which the Search Callback 
wants to be invoked.  The former is whatever the user actually wants limit the 
search to which is really undetermined, whereas the latter is the level that is 
convenient for implementing the callback, so there's no necessary linkage.  
That means that every time the callback finds a match, it has to check with the 
filter to see if the match falls within the filter.  This parameter was 
supposed to be a way for the searcher to tell the callback that it's search 
scope exactly matched the filter, so the callback didn't need to check.

That would be useful if checking the filter ever showed up as a performance 
issue, but it never has.  So it's fine to remove this.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68696



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


[Lldb-commits] [lldb] r374187 - Revert [test] Split LLDB tests into API, Shell & Unit

2019-10-09 Thread Adrian Prantl via lldb-commits
Added: lldb/trunk/lit/helper/__init__.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/helper/__init__.py?rev=374187&view=auto
==
(empty)

Added: lldb/trunk/lit/helper/build.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/helper/build.py?rev=374187&view=auto
==
--- lldb/trunk/lit/helper/build.py (added)
+++ lldb/trunk/lit/helper/build.py Wed Oct  9 10:35:43 2019
@@ -0,0 +1,799 @@
+#! /usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import os
+import signal
+import subprocess
+import sys
+
+if sys.platform == 'win32':
+# This module was renamed in Python 3.  Make sure to import it using a
+# consistent name regardless of python version.
+try:
+import winreg
+except:
+import _winreg as winreg
+
+if __name__ != "__main__":
+raise RuntimeError("Do not import this script, run it instead")
+
+
+parser = argparse.ArgumentParser(description='LLDB compilation wrapper')
+parser.add_argument('--arch',
+metavar='arch',
+dest='arch',
+required=True,
+default='host',
+choices=['32', '64', 'host'],
+help='Specify the architecture to target.')
+
+parser.add_argument('--compiler',
+metavar='compiler',
+dest='compiler',
+required=True,
+help='Path to a compiler executable, or one of the values 
[any, msvc, clang-cl, gcc, clang]')
+
+parser.add_argument('--libs-dir',
+metavar='directory',
+dest='libs_dir',
+required=False,
+action='append',
+help='If specified, a path to linked libraries to be 
passed via -L')
+
+parser.add_argument('--tools-dir',
+metavar='directory',
+dest='tools_dir',
+required=False,
+action='append',
+help='If specified, a path to search in addition to PATH 
when --compiler is not an exact path')
+
+if sys.platform == 'darwin':
+parser.add_argument('--apple-sdk',
+metavar='apple_sdk',
+dest='apple_sdk',
+default="macosx",
+help='Specify the name of the Apple SDK (macosx, 
macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the 
appropriate tools from that SDK\'s toolchain.')
+
+parser.add_argument('--output', '-o',
+dest='output',
+metavar='file',
+required=False,
+default='',
+help='Path to output file')
+
+parser.add_argument('--outdir', '-d',
+dest='outdir',
+metavar='directory',
+required=False,
+help='Directory for output files')
+
+parser.add_argument('--nodefaultlib',
+dest='nodefaultlib',
+action='store_true',
+default=False,
+help='When specified, the resulting image should not link 
against system libraries or include system headers.  Useful when writing 
cross-targeting tests.')
+
+parser.add_argument('--opt',
+dest='opt',
+default='none',
+choices=['none', 'basic', 'lto'],
+help='Optimization level')
+
+parser.add_argument('--mode',
+dest='mode',
+default='compile-and-link',
+choices=['compile', 'link', 'compile-and-link'],
+help='Specifies whether to compile, link, or both')
+
+parser.add_argument('--noclean',
+dest='clean',
+action='store_false',
+default=True,
+help='Dont clean output file before building')
+
+parser.add_argument('--verbose',
+dest='verbose',
+action='store_true',
+default=False,
+help='Print verbose output')
+
+parser.add_argument('-n', '--dry-run',
+dest='dry',
+action='store_true',
+default=False,
+help='Print the commands that would run, but dont actually 
run them')
+
+parser.add_argument('inputs',
+metavar='file',
+nargs='+',
+help='Source file(s) to compile / object file(s) to link')
+
+
+args = parser.parse_args(args=sys.argv[1:])
+
+
+def to_string(b):
+"""Return the parameter as type 'str', possibly encoding it.
+
+In Python2, the 'str' type is the same as 'bytes'. In Python3, the
+'str' type i

[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-09 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Please go ahead!


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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [PATCH] D68696: [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback

2019-10-09 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I have no memory of adding the 'addr' parameter.

If you had a search that was guaranteed to only return one address per 
invocation, this would allow you to have the searcher coordinate gathering the 
results, rather than having the callback record them on its own.  That might be 
another convenient usage pattern, but if we really wanted to do that we should 
have passed in a vector of addresses, since it seems hard to guarantee 
one-match per invocation.  Since we've never actually wanted to handle searches 
this way, it seems fine to remove this parameter.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68696



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


[Lldb-commits] [lldb] r374192 - Update breakpad lit test to be independent of the unnamed symbol number

2019-10-09 Thread Antonio Afonso via lldb-commits
Author: aadsm
Date: Wed Oct  9 11:02:59 2019
New Revision: 374192

URL: http://llvm.org/viewvc/llvm-project?rev=374192&view=rev
Log:
Update breakpad lit test to be independent of the unnamed symbol number

Modified:
lldb/trunk/lit/SymbolFile/Breakpad/symtab.test

Modified: lldb/trunk/lit/SymbolFile/Breakpad/symtab.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/Breakpad/symtab.test?rev=374192&r1=374191&r2=374192&view=diff
==
--- lldb/trunk/lit/SymbolFile/Breakpad/symtab.test (original)
+++ lldb/trunk/lit/SymbolFile/Breakpad/symtab.test Wed Oct  9 11:02:59 2019
@@ -5,7 +5,7 @@
 # CHECK-LABEL: (lldb) image dump symtab symtab.out
 # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address
   Size   Flags  Name
-# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol1$$symtab.out
+# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}$$symtab.out
 # CHECK: [1]  0   X Code0x004000c0 
   0x0010 0x f2
 # CHECK: [2]  0   X Code0x004000d0 
   0x0022 0x _start
 # CHECK: [3]  0   X Code0x004000a0 
   0x000d 0x func_only


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


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

2019-10-09 Thread António Afonso via Phabricator via lldb-commits
aadsm added a comment.

@shafik I just pushed a fix, the issue was because on mac there are more 
unnamed symbols so the number didn't match, I changed it to match any number 
since this can easily change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68533



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


[Lldb-commits] [PATCH] D68719: Fix build with Visual Studio

2019-10-09 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: hhb.
tatyana-krasnukha added a project: LLDB.
Herald added subscribers: lldb-commits, JDevlieghere.

The script failed to make a symlink for liblldb.dll because it tried to find it 
in //__build_root__/bin// whereas Visual Studio places it in 
//__build_root__/Debug/bin// (for Debug configuration).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68719

Files:
  finishSwigPythonLLDB.py


Index: finishSwigPythonLLDB.py
===
--- finishSwigPythonLLDB.py
+++ finishSwigPythonLLDB.py
@@ -332,12 +332,18 @@
 bDbg = "-d" in vDictArgs
 bOk = True
 strErrMsg = ""
+strPrefix = vDictArgs['--prefix']
 
 target_filename = os.path.basename(strTarget)
 if eOSType == utilsOsType.EnumOsType.Unknown:
 bOk = False
 strErrMsg = strErrMsgOsTypeUnknown
 elif eOSType == utilsOsType.EnumOsType.Windows:
+strBuildCfgDir = vDictArgs['--cmakeBuildConfiguration']
+
+strSrc = os.path.normcase(os.path.join(strPrefix, strBuildCfgDir, 
strSrc))
+strSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
+
 if bDbg:
 print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
 bOk, strErrMsg = make_symlink_windows(strSrc,
@@ -347,6 +353,10 @@
 if bDbg:
 print((strMsgSymlinkExists % target_filename))
 return (bOk, strErrMsg)
+
+strSrc = os.path.normcase(os.path.join(strPrefix, strSrc))
+strSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
+
 if bDbg:
 print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
 bOk, strErrMsg = make_symlink_other_platforms(strSrc,
@@ -373,13 +383,10 @@
 dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink()")
 strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile)
 strTarget = os.path.normcase(strTarget)
-strPrefix = vDictArgs['--prefix']
 
 os.chdir(vstrFrameworkPythonDir)
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
-return make_symlink_native(vDictArgs, strRelSrc, strTarget)
+return make_symlink_native(vDictArgs, vstrSrcFile, strTarget)
 
 #++---
 # Details:  Make the symbolic that the script bridge for Python will need in


Index: finishSwigPythonLLDB.py
===
--- finishSwigPythonLLDB.py
+++ finishSwigPythonLLDB.py
@@ -332,12 +332,18 @@
 bDbg = "-d" in vDictArgs
 bOk = True
 strErrMsg = ""
+strPrefix = vDictArgs['--prefix']
 
 target_filename = os.path.basename(strTarget)
 if eOSType == utilsOsType.EnumOsType.Unknown:
 bOk = False
 strErrMsg = strErrMsgOsTypeUnknown
 elif eOSType == utilsOsType.EnumOsType.Windows:
+strBuildCfgDir = vDictArgs['--cmakeBuildConfiguration']
+
+strSrc = os.path.normcase(os.path.join(strPrefix, strBuildCfgDir, strSrc))
+strSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
+
 if bDbg:
 print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
 bOk, strErrMsg = make_symlink_windows(strSrc,
@@ -347,6 +353,10 @@
 if bDbg:
 print((strMsgSymlinkExists % target_filename))
 return (bOk, strErrMsg)
+
+strSrc = os.path.normcase(os.path.join(strPrefix, strSrc))
+strSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
+
 if bDbg:
 print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
 bOk, strErrMsg = make_symlink_other_platforms(strSrc,
@@ -373,13 +383,10 @@
 dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink()")
 strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile)
 strTarget = os.path.normcase(strTarget)
-strPrefix = vDictArgs['--prefix']
 
 os.chdir(vstrFrameworkPythonDir)
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
-return make_symlink_native(vDictArgs, strRelSrc, strTarget)
+return make_symlink_native(vDictArgs, vstrSrcFile, strTarget)
 
 #++---
 # Details:  Make the symbolic that the script bridge for Python will need in
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-09 Thread Cameron via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89386daa9571: [LLDB] Fix for synthetic children memory leak 
(authored by cameron314).

Changed prior to commit:
  https://reviews.llvm.org/D68641?vs=223919&id=224112#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68641

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Index: lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -39,9 +39,14 @@
   bool GetSummary(Stream &stream, const TypeSummaryOptions &options);
 
 private:
-  ValueObjectSP m_ptr_obj;
-  ValueObjectSP m_obj_obj;
-  ValueObjectSP m_del_obj;
+  // The lifetime of a ValueObject and all its derivative ValueObjects
+  // (children, clones, etc.) is managed by a ClusterManager. These
+  // objects are only destroyed when every shared pointer to any of them
+  // is destroyed, so we must not store a shared pointer to any ValueObject
+  // derived from our backend ValueObject (since we're in the same cluster).
+  ValueObject* m_ptr_obj = nullptr;
+  ValueObject* m_obj_obj = nullptr;
+  ValueObject* m_del_obj = nullptr;
 
   ValueObjectSP GetTuple();
 };
@@ -92,17 +97,17 @@
 
   ValueObjectSP ptr_obj = tuple_frontend->GetChildAtIndex(0);
   if (ptr_obj)
-m_ptr_obj = ptr_obj->Clone(ConstString("pointer"));
+m_ptr_obj = ptr_obj->Clone(ConstString("pointer")).get();
 
   ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1);
   if (del_obj)
-m_del_obj = del_obj->Clone(ConstString("deleter"));
+m_del_obj = del_obj->Clone(ConstString("deleter")).get();
 
   if (m_ptr_obj) {
 Status error;
 ValueObjectSP obj_obj = m_ptr_obj->Dereference(error);
 if (error.Success()) {
-  m_obj_obj = obj_obj->Clone(ConstString("object"));
+  m_obj_obj = obj_obj->Clone(ConstString("object")).get();
 }
   }
 
@@ -114,11 +119,11 @@
 lldb::ValueObjectSP
 LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
   if (idx == 0)
-return m_ptr_obj;
+return m_ptr_obj->GetSP();
   if (idx == 1)
-return m_del_obj;
+return m_del_obj->GetSP();
   if (idx == 2)
-return m_obj_obj;
+return m_obj_obj->GetSP();
   return lldb::ValueObjectSP();
 }
 
Index: lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -37,7 +37,12 @@
   size_t GetIndexOfChildWithName(ConstString name) override;
 
 private:
-  std::vector m_members;
+  // The lifetime of a ValueObject and all its derivative ValueObjects
+  // (children, clones, etc.) is managed by a ClusterManager. These
+  // objects are only destroyed when every shared pointer to any of them
+  // is destroyed, so we must not store a shared pointer to any ValueObject
+  // derived from our backend ValueObject (since we're in the same cluster).
+  std::vector m_members;
 };
 
 } // end of anonymous namespace
@@ -72,7 +77,7 @@
 if (value_sp) {
   StreamString name;
   name.Printf("[%zd]", m_members.size());
-  m_members.push_back(value_sp->Clone(ConstString(name.GetString(;
+  m_members.push_back(value_sp->Clone(ConstString(name.GetString())).get());
 }
   }
 }
@@ -86,7 +91,7 @@
 lldb::ValueObjectSP
 LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
   if (idx < m_members.size())
-return m_members[idx];
+return m_members[idx]->GetSP();
   return lldb::ValueObjectSP();
 }
 
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
@@ -184,7 +184,6 @@
 
 private:
   size_t m_size = 0;
-  ValueObjectSP m_base_sp;
 };
 } // namespace
 
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
@@ -30,47 +30,56 @@
   ValueObjectSP GetChildAtIndex(size_t idx) override;
 
 private:
-  std::vector m_elements;
-  ValueObjectSP m_base_sp;
+  // The lifetime of

[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224114.
lawrence_danna marked an inline comment as done.
lawrence_danna added a comment.

fixed pybuffer error handling weirdness


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188

Files:
  lldb/include/lldb/API/SBFile.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig
  lldb/scripts/interface/SBFile.i
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1028,22 +1028,23 @@
   // first-class object type anymore.  `PyFile_FromFd` is just a thin wrapper
   // over `io.open()`, which returns some object derived from `io.IOBase`. As a
   // result, the only way to detect a file in Python 3 is to check whether it
-  // inherits from `io.IOBase`.  Since it is possible for non-files to also
-  // inherit from `io.IOBase`, we additionally verify that it has the `fileno`
-  // attribute, which should guarantee that it is backed by the file system.
-  PythonObject io_module(PyRefType::Owned, PyImport_ImportModule("io"));
-  PythonDictionary io_dict(PyRefType::Borrowed,
-   PyModule_GetDict(io_module.get()));
-  PythonObject io_base_class = io_dict.GetItemForKey(PythonString("IOBase"));
-
-  PythonObject object_type(PyRefType::Owned, PyObject_Type(py_obj));
-
-  if (1 != PyObject_IsSubclass(object_type.get(), io_base_class.get()))
+  // inherits from `io.IOBase`.
+  auto io_module = PythonModule::Import("io");
+  if (!io_module) {
+llvm::consumeError(io_module.takeError());
 return false;
-  if (!object_type.HasAttribute("fileno"))
+  }
+  auto iobase = io_module.get().Get("IOBase");
+  if (!iobase) {
+llvm::consumeError(iobase.takeError());
 return false;
-
-  return true;
+  }
+  int r = PyObject_IsInstance(py_obj, iobase.get().get());
+  if (r < 0) {
+llvm::consumeError(exception()); // clear the exception and log it.
+return false;
+  }
+  return !!r;
 #endif
 }
 
@@ -1096,6 +1097,20 @@
   return file;
 }
 
+namespace {
+class GIL {
+public:
+  GIL() {
+m_state = PyGILState_Ensure();
+assert(!PyErr_Occurred());
+  }
+  ~GIL() { PyGILState_Release(m_state); }
+
+protected:
+  PyGILState_STATE m_state;
+};
+} // namespace
+
 const char *PythonException::toCString() const {
   if (!m_repr_bytes)
 return "unknown exception";
@@ -1150,4 +1165,378 @@
 
 char PythonException::ID = 0;
 
+llvm::Expected GetOptionsForPyObject(const PythonObject &obj) {
+  uint32_t options = 0;
+#if PY_MAJOR_VERSION >= 3
+  auto readable = As(obj.CallMethod("readable"));
+  if (!readable)
+return readable.takeError();
+  auto writable = As(obj.CallMethod("writable"));
+  if (!writable)
+return writable.takeError();
+  if (readable.get())
+options |= File::eOpenOptionRead;
+  if (writable.get())
+options |= File::eOpenOptionWrite;
+#else
+  PythonString py_mode = obj.GetAttributeValue("mode").AsType();
+  options = File::GetOptionsFromMode(py_mode.GetString());
+#endif
+  return options;
+}
+
+// Base class template for python files.   All it knows how to do
+// is hold a reference to the python object and close or flush it
+// when the File is closed.
+namespace {
+template  class OwnedPythonFile : public Base {
+public:
+  template 
+  OwnedPythonFile(const PythonFile &file, bool borrowed, Args... args)
+  : Base(args...), m_py_obj(file), m_borrowed(borrowed) {
+assert(m_py_obj);
+  }
+
+  ~OwnedPythonFile() override {
+assert(m_py_obj);
+GIL takeGIL;
+Close();
+m_py_obj.Reset();
+  }
+
+  bool IsPythonSideValid() const {
+GIL takeGIL;
+auto closed = As(m_py_obj.GetAttribute("closed"));
+if (!closed) {
+  llvm::consumeError(closed.takeError());
+  return false;
+}
+return !closed.get();
+  }
+
+  bool IsValid() const override {
+return IsPythonSideValid() && Base::IsValid();
+  }
+
+  Status Close() override {
+assert(m_py_obj);
+Status py_error, base_error;
+GIL takeGIL;
+if (!m_borrowed) {
+  auto r = m_py_obj.CallMethod("close");
+  if (!r)
+py_error = Status(r.takeError());
+}
+base_error = Base::Close();
+if (py_error.Fail())
+  return py_error;
+return base_error;
+  };
+
+protected:
+  PythonFile m_py_obj;
+  bool m_borrowed;
+};
+} // namespace
+
+// A SimplePythonFile is a OwnedPythonFile that just does all I/O as
+// a NativeFile
+namespace {
+class SimplePythonFile : public OwnedPythonFile {
+public:
+  SimplePythonFile(const PythonFile &file, bool borrowed, int fd,
+   uint32_t options)
+  : Owned

[Lldb-commits] [lldb] r374197 - protect libedit and LLDB gui from receiving null FILE* streams

2019-10-09 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Wed Oct  9 11:43:03 2019
New Revision: 374197

URL: http://llvm.org/viewvc/llvm-project?rev=374197&view=rev
Log:
protect libedit and LLDB gui from receiving null FILE* streams

Summary:
We now have valid files that will return NULL from GetStream().
libedit and the LLDB gui are the only places left that need FILE*
streams.  Both are doing curses-like user interaction that only
make sense with a real terminal anyway, so there is no need to convert
them off of their use of FILE*.   But we should check for null streams
before enabling these features.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Commands/CommandObjectGUI.cpp
lldb/trunk/source/Core/IOHandler.cpp

Modified: lldb/trunk/source/Commands/CommandObjectGUI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectGUI.cpp?rev=374197&r1=374196&r2=374197&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectGUI.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectGUI.cpp Wed Oct  9 11:43:03 2019
@@ -29,7 +29,9 @@ bool CommandObjectGUI::DoExecute(Args &a
 Debugger &debugger = GetDebugger();
 
 File &input = debugger.GetInputFile();
-if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+File &output = debugger.GetOutputFile();
+if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
 debugger.PushIOHandler(io_handler_sp);

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=374197&r1=374196&r2=374197&view=diff
==
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Wed Oct  9 11:43:03 2019
@@ -266,7 +266,8 @@ IOHandlerEditline::IOHandlerEditline(
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
 m_editline_up.reset(new Editline(editline_name, GetInputFILE(),


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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-09 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1284
+  PythonBuffer(PythonObject &obj, int flags) : m_buffer({}) {
+PyObject_GetBuffer(obj.get(), &m_buffer, flags);
+  }

I would slightly prefer if the PyObject_GetBuffer happened in the Create 
function (and the constructor took an already-constructed Py_buffer). That way, 
the call is next to the exception check and you avoid creating an "invalid" 
PythonBuffer object, even as an implementation detail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188



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


[Lldb-commits] [PATCH] D68677: protect libedit and LLDB gui from receiving null FILE* streams

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG609010d0631a: protect libedit and LLDB gui from receiving 
null FILE* streams (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68677

Files:
  lldb/source/Commands/CommandObjectGUI.cpp
  lldb/source/Core/IOHandler.cpp


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -266,7 +266,8 @@
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
 m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
Index: lldb/source/Commands/CommandObjectGUI.cpp
===
--- lldb/source/Commands/CommandObjectGUI.cpp
+++ lldb/source/Commands/CommandObjectGUI.cpp
@@ -29,7 +29,9 @@
 Debugger &debugger = GetDebugger();
 
 File &input = debugger.GetInputFile();
-if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+File &output = debugger.GetOutputFile();
+if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
 debugger.PushIOHandler(io_handler_sp);


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -266,7 +266,8 @@
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+ m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
 m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
Index: lldb/source/Commands/CommandObjectGUI.cpp
===
--- lldb/source/Commands/CommandObjectGUI.cpp
+++ lldb/source/Commands/CommandObjectGUI.cpp
@@ -29,7 +29,9 @@
 Debugger &debugger = GetDebugger();
 
 File &input = debugger.GetInputFile();
-if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+File &output = debugger.GetOutputFile();
+if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+input.GetIsInteractive()) {
   IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
   if (io_handler_sp)
 debugger.PushIOHandler(io_handler_sp);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 224119.
lawrence_danna marked 4 inline comments as done.
lawrence_danna added a comment.

review fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/source/Core/IOHandler.cpp

Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -305,94 +305,123 @@
   m_delegate.IOHandlerDeactivated(*this);
 }
 
+using llvm::None;
+using llvm::Optional;
+using llvm::StringRef;
+
+// Split out a line from the buffer, if there is a full one to get.
+static Optional SplitLine(std::string &line_buffer) {
+  size_t pos = line_buffer.find('\n');
+  if (pos == std::string::npos)
+return None;
+  std::string line = StringRef(line_buffer.c_str(), pos).rtrim("\n\r");
+  line_buffer = line_buffer.substr(pos + 1);
+  return line;
+}
+
+// If the final line of the file ends without a end-of-line, return
+// it as a line anyway.
+static Optional SplitLineEOF(std::string &line_buffer) {
+  if (llvm::all_of(line_buffer, isspace))
+return None;
+  std::string line = std::move(line_buffer);
+  line_buffer.clear();
+  return line;
+}
+
 bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
 #ifndef LLDB_DISABLE_LIBEDIT
   if (m_editline_up) {
 bool b = m_editline_up->GetLine(line, interrupted);
-if (m_data_recorder)
+if (b && m_data_recorder)
   m_data_recorder->Record(line, true);
 return b;
-  } else {
+  }
 #endif
-line.clear();
 
-FILE *in = GetInputFILE();
-if (in) {
-  if (GetIsInteractive()) {
-const char *prompt = nullptr;
+  line.clear();
 
-if (m_multi_line && m_curr_line_idx > 0)
-  prompt = GetContinuationPrompt();
+  if (GetIsInteractive()) {
+const char *prompt = nullptr;
 
-if (prompt == nullptr)
-  prompt = GetPrompt();
+if (m_multi_line && m_curr_line_idx > 0)
+  prompt = GetContinuationPrompt();
 
-if (prompt && prompt[0]) {
-  if (m_output_sp) {
-m_output_sp->Printf("%s", prompt);
-m_output_sp->Flush();
-  }
-}
+if (prompt == nullptr)
+  prompt = GetPrompt();
+
+if (prompt && prompt[0]) {
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
+  }
+}
+  }
+
+  Optional got_line = SplitLine(m_line_buffer);
+
+  if (!got_line && !m_input_sp) {
+// No more input file, we are done...
+SetIsDone(true);
+return false;
+  }
+
+  FILE *in = GetInputFILE();
+  char buffer[256];
+
+  if (!got_line && !in && m_input_sp) {
+// there is no FILE*, fall back on just reading bytes from the stream.
+while (!got_line) {
+  size_t bytes_read = sizeof(buffer);
+  Status error = m_input_sp->Read((void *)buffer, bytes_read);
+  if (error.Success() && !bytes_read) {
+got_line = SplitLineEOF(m_line_buffer);
+break;
   }
-  char buffer[256];
-  bool done = false;
-  bool got_line = false;
-  m_editing = true;
-  while (!done) {
+  if (error.Fail())
+break;
+  m_line_buffer += StringRef(buffer, bytes_read);
+  got_line = SplitLine(m_line_buffer);
+}
+  }
+
+  if (!got_line && in) {
+m_editing = true;
+while (!got_line) {
+  char *r = fgets(buffer, sizeof(buffer), in);
 #ifdef _WIN32
-// ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
-// according to the docs on MSDN. However, this has evidently been a
-// known bug since Windows 8. Therefore, we can't detect if a signal
-// interrupted in the fgets. So pressing ctrl-c causes the repl to end
-// and the process to exit. A temporary workaround is just to attempt to
-// fgets twice until this bug is fixed.
-if (fgets(buffer, sizeof(buffer), in) == nullptr &&
-fgets(buffer, sizeof(buffer), in) == nullptr) {
-  // this is the equivalent of EINTR for Windows
-  if (GetLastError() == ERROR_OPERATION_ABORTED)
-continue;
-#else
-  if (fgets(buffer, sizeof(buffer), in) == nullptr) {
+  // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
+  // according to the docs on MSDN. However, this has evidently been a
+  // known bug since Windows 8. Therefore, we can't detect if a signal
+  // interrupted in the fgets. So pressing ctrl-c causes the repl to end
+  // and the process to exit. A temporary workaround is just to attempt to
+  // fgets twice until this bug is fixed.
+  if (r == nullptr)
+r = fgets(buffer, sizeof(buffer), in);
+  // this is the equivalent of EINTR for Windows
+  if (r == nullptr && GetLastError()

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

2019-10-09 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.

My hope was that something like -find=variable -dump-clang-ast would make sense 
at least from a theoretical perspective. However, after reading to source code, 
it looks like that may not be true as (I think) we don't actually create ast 
nodes for variables. So, making this option a sort of a "top-level" thing may 
be the best thing to do. Given that now the "symbols" subcommand has a fair set 
of options, all of which are mutually incompatible (-verify, --dump-ast, 
-dump-clang-ast, the "default" mode), I think it might make sense to create new 
subcommands for each of these "modes" ("lldb-test symbols ast") so that they 
can each get their own options, independently of the others. However, I don't 
want to hold up other progress over that...


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

https://reviews.llvm.org/D67994



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


[Lldb-commits] [PATCH] D68622: IOHandler: fall back on File::Read if a FILE* isn't available.

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68622



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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

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

Pavel would slightly prefer if the PyObject_GetBuffer happened in the Create 
function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188

Files:
  lldb/include/lldb/API/SBFile.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig
  lldb/scripts/interface/SBFile.i
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1028,22 +1028,23 @@
   // first-class object type anymore.  `PyFile_FromFd` is just a thin wrapper
   // over `io.open()`, which returns some object derived from `io.IOBase`. As a
   // result, the only way to detect a file in Python 3 is to check whether it
-  // inherits from `io.IOBase`.  Since it is possible for non-files to also
-  // inherit from `io.IOBase`, we additionally verify that it has the `fileno`
-  // attribute, which should guarantee that it is backed by the file system.
-  PythonObject io_module(PyRefType::Owned, PyImport_ImportModule("io"));
-  PythonDictionary io_dict(PyRefType::Borrowed,
-   PyModule_GetDict(io_module.get()));
-  PythonObject io_base_class = io_dict.GetItemForKey(PythonString("IOBase"));
-
-  PythonObject object_type(PyRefType::Owned, PyObject_Type(py_obj));
-
-  if (1 != PyObject_IsSubclass(object_type.get(), io_base_class.get()))
+  // inherits from `io.IOBase`.
+  auto io_module = PythonModule::Import("io");
+  if (!io_module) {
+llvm::consumeError(io_module.takeError());
 return false;
-  if (!object_type.HasAttribute("fileno"))
+  }
+  auto iobase = io_module.get().Get("IOBase");
+  if (!iobase) {
+llvm::consumeError(iobase.takeError());
 return false;
-
-  return true;
+  }
+  int r = PyObject_IsInstance(py_obj, iobase.get().get());
+  if (r < 0) {
+llvm::consumeError(exception()); // clear the exception and log it.
+return false;
+  }
+  return !!r;
 #endif
 }
 
@@ -1096,6 +1097,20 @@
   return file;
 }
 
+namespace {
+class GIL {
+public:
+  GIL() {
+m_state = PyGILState_Ensure();
+assert(!PyErr_Occurred());
+  }
+  ~GIL() { PyGILState_Release(m_state); }
+
+protected:
+  PyGILState_STATE m_state;
+};
+} // namespace
+
 const char *PythonException::toCString() const {
   if (!m_repr_bytes)
 return "unknown exception";
@@ -1150,4 +1165,376 @@
 
 char PythonException::ID = 0;
 
+llvm::Expected GetOptionsForPyObject(const PythonObject &obj) {
+  uint32_t options = 0;
+#if PY_MAJOR_VERSION >= 3
+  auto readable = As(obj.CallMethod("readable"));
+  if (!readable)
+return readable.takeError();
+  auto writable = As(obj.CallMethod("writable"));
+  if (!writable)
+return writable.takeError();
+  if (readable.get())
+options |= File::eOpenOptionRead;
+  if (writable.get())
+options |= File::eOpenOptionWrite;
+#else
+  PythonString py_mode = obj.GetAttributeValue("mode").AsType();
+  options = File::GetOptionsFromMode(py_mode.GetString());
+#endif
+  return options;
+}
+
+// Base class template for python files.   All it knows how to do
+// is hold a reference to the python object and close or flush it
+// when the File is closed.
+namespace {
+template  class OwnedPythonFile : public Base {
+public:
+  template 
+  OwnedPythonFile(const PythonFile &file, bool borrowed, Args... args)
+  : Base(args...), m_py_obj(file), m_borrowed(borrowed) {
+assert(m_py_obj);
+  }
+
+  ~OwnedPythonFile() override {
+assert(m_py_obj);
+GIL takeGIL;
+Close();
+m_py_obj.Reset();
+  }
+
+  bool IsPythonSideValid() const {
+GIL takeGIL;
+auto closed = As(m_py_obj.GetAttribute("closed"));
+if (!closed) {
+  llvm::consumeError(closed.takeError());
+  return false;
+}
+return !closed.get();
+  }
+
+  bool IsValid() const override {
+return IsPythonSideValid() && Base::IsValid();
+  }
+
+  Status Close() override {
+assert(m_py_obj);
+Status py_error, base_error;
+GIL takeGIL;
+if (!m_borrowed) {
+  auto r = m_py_obj.CallMethod("close");
+  if (!r)
+py_error = Status(r.takeError());
+}
+base_error = Base::Close();
+if (py_error.Fail())
+  return py_error;
+return base_error;
+  };
+
+protected:
+  PythonFile m_py_obj;
+  bool m_borrowed;
+};
+} // namespace
+
+// A SimplePythonFile is a OwnedPythonFile that just does all I/O as
+// a NativeFile
+namespace {
+class SimplePythonFile : public OwnedPythonFile {
+public:
+  SimplePythonFile(const PythonFile &file, bool borrowed, int fd,
+   uint32_t options)
+  : OwnedPy

[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

2019-10-09 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade updated this revision to Diff 224120.
guiandrade added a comment.

Dissociating the use of g/G packets and trying to address the AVX/MPX offset bug


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
  lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -128,6 +128,11 @@
   ASSERT_EQ(0,
 memcmp(buffer_sp->GetBytes(), one_register, sizeof one_register));
 
+  async_result = std::async(std::launch::async,
+[&] { return client.GetgPacketSupported(tid); });
+  HandlePacket(server, "g;thread:0047;", all_registers_hex);
+  ASSERT_TRUE(async_result.get());
+
   read_result = std::async(std::launch::async,
[&] { return client.ReadAllRegisters(tid); });
   HandlePacket(server, "g;thread:0047;", all_registers_hex);
Index: lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -301,13 +301,15 @@
 if (process_sp) {
   ProcessGDBRemote *gdb_process =
   static_cast(process_sp.get());
-  // read_all_registers_at_once will be true if 'p' packet is not
-  // supported.
   bool read_all_registers_at_once =
-  !gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
+  gdb_process->GetGDBRemote().GetgPacketSupported(GetID()) &&
+  gdb_process->m_use_g_packet_for_reading;
+  bool write_all_registers_at_once =
+  gdb_process->GetGDBRemote().GetGPacketSupported(GetID()) &&
+  gdb_process->m_use_g_packet_for_writing;
   reg_ctx_sp = std::make_shared(
   *this, concrete_frame_idx, gdb_process->m_register_info,
-  read_all_registers_at_once);
+  read_all_registers_at_once, write_all_registers_at_once);
 }
   } else {
 Unwind *unwinder = GetUnwinder();
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
@@ -13,4 +13,12 @@
 Global,
 DefaultFalse,
 Desc<"If true, the libraries-svr4 feature will be used to get a hold of the process's loaded modules.">;
+  def UseGPacketForReading: Property<"use-g-packet-for-reading", "Boolean">,
+Global,
+DefaultTrue,
+Desc<"Specify if the server should use 'g' packets to read registers.">;
+  def UseGPacketForWriting: Property<"use-g-packet-for-writing", "Boolean">,
+Global,
+DefaultFalse,
+Desc<"Specify if the server should use 'g' packets to write registers.">;
 }
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -284,6 +284,8 @@
   lldb::CommandObjectSP m_command_sp;
   int64_t m_breakpoint_pc_offset;
   lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
+  bool m_use_g_packet_for_reading;
+  bool m_use_g_packet_for_writing;
 
   bool m_replay_mode;
   bool m_allow_flash_writes;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -154,6 +154,16

[Lldb-commits] [lldb] r374201 - Re-land "[test] Split LLDB tests into API, Shell & Unit"

2019-10-09 Thread Jonas Devlieghere via lldb-commits
Added: lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test?rev=374201&view=auto
==
--- lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test (added)
+++ lldb/trunk/test/Shell/SymbolFile/PDB/typedefs.test Wed Oct  9 12:22:02 2019
@@ -0,0 +1,59 @@
+REQUIRES: system-windows, msvc
+RUN: %build --compiler=msvc --arch=32 --nodefaultlib 
--output=%T/SimpleTypesTest.cpp.typedefs.exe %S/Inputs/SimpleTypesTest.cpp
+RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s
+
+; Generate 32-bit target
+
+; FIXME: PDB does not have line information for typedef statements so source
+; and line information for them is not tested.
+
+; Note, types `long double` and `double` have same bit size in MSVC and there
+; is no information in the PDB to distinguish them. So the compiler type for
+; both of them is the same.
+
+CHECK: Module [[MOD:.*]]
+CHECK: SymbolFile pdb ([[MOD]])
+CHECK-DAG: name = "char32_t", size = 4, compiler_type = {{.*}} char32_t
+CHECK-DAG: name = "char16_t", size = 2, compiler_type = {{.*}} char16_t
+CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = 
{{.*}} unsigned long
+CHECK-DAG: Type{{.*}} , size = 40, compiler_type = {{.*}} unsigned long [10]
+CHECK-DAG: Type{{.*}} , name = "ULongArrayTypedef", compiler_type = {{.*}} 
typedef ULongArrayTypedef
+
+; Note: compiler_type of `long double` is represented by the one for `double`
+CHECK-DAG: Type{{.*}} , name = "double", size = 8, compiler_type = {{.*}} 
double
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double *
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double *&
+CHECK-DAG: Type{{.*}} , name = "RefTypedef", compiler_type = {{.*}} typedef 
RefTypedef
+
+CHECK-DAG: Type{{.*}} , name = "wchar_t", size = 2, compiler_type = {{.*}} 
wchar_t
+
+CHECK-DAG: Type{{.*}} , name = "int", size = 4, compiler_type = {{.*}} int
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &
+CHECK-DAG: Type{{.*}} , name = "unsigned char", size = 1, compiler_type = 
{{.*}} unsigned char
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char *
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char **
+CHECK-DAG: Type{{.*}} , name = "short", size = 2, compiler_type = {{.*}} short
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} short *
+CHECK-DAG: Type{{.*}} , name = "const double", size = 8, compiler_type = 
{{.*}} const double
+CHECK-DAG: Type{{.*}} , name = "volatile bool", size = 1, compiler_type = 
{{.*}} volatile _Bool
+CHECK-DAG: Type{{.*}} , name = "long long", size = 8, compiler_type = {{.*}} 
long long
+CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} long long (int &, unsigned char 
**, short *, const double, volatile _Bool)
+CHECK-DAG: Type{{.*}} , name = "FuncPtrTypedef", compiler_type = {{.*}} 
typedef FuncPtrTypedef
+
+CHECK-DAG: Type{{.*}} , name = "void", compiler_type = {{.*}} void
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} void *
+CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long
+CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = 
{{.*}} unsigned short
+CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = 
{{.*}} unsigned int
+CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = {{.*}} char
+CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} 
signed char
+CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} char (void *, long, unsigned 
short, unsigned int, ...)
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} char (*)(void *, 
long, unsigned short, unsigned int, ...)
+CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} 
typedef VarArgsFuncTypedef
+
+CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float
+CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} float (...)
+CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} float (*)(...)
+CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedefA", compiler_type = {{.*}} 
typedef VarArgsFuncTypedefA
+
+CHECK-DAG: {{^[0-9A-F]+}}:   CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = 
"c++", file = '{{.*}}\SimpleTypesTest.cpp'

Added: lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test?rev=374201&view=auto
==
--- lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test (added)
+++ lldb/trunk/test/Shell/SymbolFile/PDB/udt-layout.test Wed Oct  9 12:22:02 
2019
@@ -0,0 +1,51 @@
+REQUIRES: system-windows, lld
+RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
+RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+
+CHECK:(int) int C::abc = 123
+CHECK:(List [16]) ls = {
+C

[Lldb-commits] [PATCH] D62931: [lldb-server] Add setting to force 'g' packet use

2019-10-09 Thread Guilherme Andrade via Phabricator via lldb-commits
guiandrade added a comment.

In D62931#1699746 , @labath wrote:

> In D62931#1697999 , @guiandrade 
> wrote:
>
> > Thank you for looking into this, @labath
> >
> > I'd like to fix that, but I'm not sure if I understand the code well 
> > enough/ it's not clear to me what the solution would look like.
> >
> > > I think the only reasonable way to do that would be to change the 
> > > RegisterInfo offset for BND registers to mean the gdb-remote offset
> >
> > Would that involve hard-coding an extra offset at RegisterInfos_x86_64.h:28 
> > 
> >  and RegisterInfos_i386.h:32 
> > ?
>
>
> I would very much like to avoid adding new members to the RegisterInfo 
> struct. As this stuff is specific to the x86 linux context, I'd like to keep 
> this stuff there, if necessary then via keeping a side-table of "ptrace" 
> offsets for each of the register (though I am hoping there's some better way 
> to achieve that).
>
> > 
> > 
> >> change any code which uses it for the OS context offset to do something 
> >> else (the only place doing something like that should be 
> >> RegisterContextLinux_x86_64.cpp)
> > 
> > Would that be NativeRegisterContextLinux_x86_64.cpp 
> > ?
> >  If yes, the idea would be to somehow remove that extra factor before the 
> > `ptrace` calls?
>
> Yes, I meant `NativeRegisterContextLinux_x86_64`. And yes, the idea is to 
> remove that factor, or recompute that the ptrace offset in some other way. 
> This could be a side table, a switch on the register set type, or whatever is 
> the simplest.


I updated this change with an initial attempt to implement that idea to see if 
we're on the same page. Please let me know what you think. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62931



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


[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-09 Thread Dimitry Andric via Phabricator via lldb-commits
dim created this revision.
dim added reviewers: devnexen, emaste, MaskRay, mgorny.
Herald added a subscriber: krytarowski.
dim added a comment.

After rLLDB365761 , and with 
`LLVM_ENABLE_ABI_BREAKING_CHECKS` enabled, launching
any process on FreeBSD crashes lldb with:

  Expected must be checked before access or destruction.
  Expected value was in success state. (Note: Expected values in success 
mode must still be checked prior to being destroyed).

This is because `m_operation_thread` and `m_monitor_thread` were wrapped in
`llvm::Expected<>`, but this requires the objects to be correctly initialized
before accessing them.

To fix the crashes, revert the wrapping, and use local variables to store the
return values of `LaunchThread` and `StartMonitoringChildProcess`.  Then, only
assign to the member variables after checking if the return values indicated
success.


https://reviews.llvm.org/D68723

Files:
  source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  source/Plugins/Process/FreeBSD/ProcessMonitor.h

Index: source/Plugins/Process/FreeBSD/ProcessMonitor.h
===
--- source/Plugins/Process/FreeBSD/ProcessMonitor.h
+++ source/Plugins/Process/FreeBSD/ProcessMonitor.h
@@ -183,8 +183,8 @@
 private:
   ProcessFreeBSD *m_process;
 
-  llvm::Expected m_operation_thread;
-  llvm::Expected m_monitor_thread;
+  lldb_private::HostThread m_operation_thread;
+  lldb_private::HostThread m_monitor_thread;
   lldb::pid_t m_pid;
 
   int m_terminal_fd;
Index: source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
===
--- source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -703,7 +703,7 @@
 const lldb_private::ProcessLaunchInfo & /* launch_info */,
 lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
   using namespace std::placeholders;
 
   std::unique_ptr args(
@@ -730,20 +730,21 @@
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  auto monitor_thread = Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process launch failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid,
lldb_private::Status &error)
 : m_process(static_cast(process)),
-  m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(pid), m_terminal_fd(-1), m_operation(0) {
+  m_operation_thread(), m_monitor_thread(), m_pid(pid), m_terminal_fd(-1), m_operation(0) {
   using namespace std::placeholders;
 
   sem_init(&m_operation_pending, 0, 0);
@@ -768,14 +769,15 @@
   }
 
   // Finally, start monitoring the child process for change in state.
-  m_monitor_thread = Host::StartMonitoringChildProcess(
+  auto monitor_thread = Host::StartMonitoringChildProcess(
   std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
   GetPID(), true);
-  if (!m_monitor_thread->IsJoinable()) {
+  if (!monitor_thread || !monitor_thread->IsJoinable()) {
 error.SetErrorToGenericError();
 error.SetErrorString("Process attach failed.");
 return;
   }
+  m_monitor_thread = *monitor_thread;
 }
 
 ProcessMonitor::~ProcessMonitor() { StopMonitor(); }
@@ -784,13 +786,15 @@
 void ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Status &error) {
   static const char *g_thread_name = "lldb.process.freebsd.operation";
 
-  if (m_operation_thread->IsJoinable())
+  if (m_operation_thread.IsJoinable())
 return;
 
-  m_operation_thread =
+  auto operation_thread =
   ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
-  if (!m_operation_thread)
- error = m_operation_thread.takeError();
+  if (operation_thread)
+m_operation_thread = *operation_thread;
+  else
+error = operation_thread.takeError();
 }
 
 void *ProcessMonitor::LaunchOpThread(void *arg) {
@@ -952,14 +956,15 @@
  lldb_private::Status &error) {
   static const char *g_thread_name = "lldb.process.freebsd.operation";
 
-  if (m_operation_thread->IsJoinable())
+  if (m_operation_thread.IsJoinable())
 return;
 
-  m_operation_thread =
+  auto operation_thread =
   ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args);
-
-  if (!m_operation_thread)
-	error = m_

[Lldb-commits] [PATCH] D68723: Fix process launch failure on FreeBSD after r365761

2019-10-09 Thread Dimitry Andric via Phabricator via lldb-commits
dim added a comment.

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

https://reviews.llvm.org/D68723



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


[Lldb-commits] [lldb] r374212 - [test] Skip entry value test when clang < 10.0.0

2019-10-09 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Oct  9 13:21:33 2019
New Revision: 374212

URL: http://llvm.org/viewvc/llvm-project?rev=374212&view=rev
Log:
[test] Skip entry value test when clang < 10.0.0

clang-9 emitted the wrong opcode for entry values on Darwin.

rdar://56119661

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py?rev=374212&r1=374211&r2=374212&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
 Wed Oct  9 13:21:33 2019
@@ -7,6 +7,7 @@ supported_platforms.extend(lldbplatformu
 
 lldbinline.MakeInlineTest(__file__, globals(),
 [decorators.skipUnlessPlatform(supported_platforms),
+ decorators.skipIf(compiler="clang", compiler_version=['<', '10.0']),
  decorators.skipUnlessArch('x86_64'),
  decorators.skipUnlessHasCallSiteInfo,
  decorators.skipIf(dwarf_version=['<', '4'])])


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


[Lldb-commits] [PATCH] D68678: WIP: Speed up accelerator table lookups

2019-10-09 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 224140.
aprantl added a comment.

Now with testcase!


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

https://reviews.llvm.org/D68678

Files:
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,17 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
+  // When searching for "std::vector::const_iterator", reject any
+  // files without "vector" early, since there will be many other
+  // "const_iterators".
+  if (context.GetSize() > 1 && context[1].tag == DW_TAG_class_type) {
+DIEArray class_matches;
+m_apple_types_up->FindByName(context[1].name, class_matches);
+if (class_matches.empty())
+  return;
+  }
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME) \
+  class NAME {  \
+public: \
+class Inner {   \
+  int j = #NAME[0]; \
+};  \
+Inner *i = nullptr; \
+  };\
+\
+  static NAME::Inner inner; \
+  static NAME obj;  \
+  NAME::Inner &getInner##NAME() { return inner; }
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME) \
+  class NAME {  \
+  public:   \
+struct Inner;   \
+Inner *i = nullptr; \
+  };\
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+  A::Inner &inner_a = getInnerA();
+  B::Inner &inner_b = getInnerB();
+  C::Inner &inner_c = getInnerC();
+  D::Inner &inner_d = getInnerD();
+  E::Inner &inner_e = getInnerE();
+  F::Inner &inner_f = getInnerF();
+  G::Inner &inner_g = getInnerG();
+
+  return 0; // break here
+}
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(G)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(F)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(E)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(D)
Index: lldb/packages/Python/lldbsuite/test/l

[Lldb-commits] [lldb] r374215 - [utils] Update lldb-dotest for new test layout

2019-10-09 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Oct  9 13:30:54 2019
New Revision: 374215

URL: http://llvm.org/viewvc/llvm-project?rev=374215&view=rev
Log:
[utils] Update lldb-dotest for new test layout

The path to dotest.py changed after the test directory reorganization.

Modified:
lldb/trunk/utils/lldb-dotest/lldb-dotest.in

Modified: lldb/trunk/utils/lldb-dotest/lldb-dotest.in
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/lldb-dotest/lldb-dotest.in?rev=374215&r1=374214&r2=374215&view=diff
==
--- lldb/trunk/utils/lldb-dotest/lldb-dotest.in (original)
+++ lldb/trunk/utils/lldb-dotest/lldb-dotest.in Wed Oct  9 13:30:54 2019
@@ -2,7 +2,7 @@
 import subprocess
 import sys
 
-dotest_path = '@LLDB_SOURCE_DIR@/test/dotest.py'
+dotest_path = '@LLDB_SOURCE_DIR@/test/API/dotest.py'
 build_dir = '@LLDB_TEST_BUILD_DIRECTORY@'
 dotest_args_str = '@LLDB_DOTEST_ARGS@'
 


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


[Lldb-commits] [lldb] r374216 - [CMake] Fix add_lldb_test_dependency

2019-10-09 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Oct  9 13:36:29 2019
New Revision: 374216

URL: http://llvm.org/viewvc/llvm-project?rev=374216&view=rev
Log:
[CMake] Fix add_lldb_test_dependency

This function would ignore all but the first argument. Now it correctly
adds every dependency by iterating over its arguments.

Modified:
lldb/trunk/cmake/modules/AddLLDB.cmake
lldb/trunk/test/CMakeLists.txt

Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=374216&r1=374215&r2=374216&view=diff
==
--- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
+++ lldb/trunk/cmake/modules/AddLLDB.cmake Wed Oct  9 13:36:29 2019
@@ -27,8 +27,10 @@ function(lldb_tablegen)
   endif()
 endfunction(lldb_tablegen)
 
-function(add_lldb_test_dependency name)
-  add_dependencies(lldb-test-deps ${name})
+function(add_lldb_test_dependency)
+  foreach(dependency ${ARGN})
+add_dependencies(lldb-test-deps ${dependency})
+  endforeach()
 endfunction(add_lldb_test_dependency)
 
 function(add_lldb_library name)

Modified: lldb/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=374216&r1=374215&r2=374216&view=diff
==
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Wed Oct  9 13:36:29 2019
@@ -70,6 +70,14 @@ else()
   endif()
 endif()
 
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(
+FileCheck
+count
+not
+  )
+endif()
+
 # the value is not canonicalized within LLVM
 llvm_canonicalize_cmake_booleans(
   LLDB_DISABLE_PYTHON
@@ -100,14 +108,6 @@ configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/Shell/lit-lldb-init.in
   ${CMAKE_CURRENT_BINARY_DIR}/Shell/lit-lldb-init)
 
-if(NOT LLDB_BUILT_STANDALONE)
-  add_lldb_test_dependency(
-FileCheck
-count
-not
-  )
-endif()
-
 
 add_lit_testsuites(LLDB
   ${CMAKE_CURRENT_SOURCE_DIR}


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


[Lldb-commits] [lldb] r374217 - Skip Apple simulator test for all remote testing scenarios.

2019-10-09 Thread Frederic Riss via lldb-commits
Author: friss
Date: Wed Oct  9 13:39:04 2019
New Revision: 374217

URL: http://llvm.org/viewvc/llvm-project?rev=374217&view=rev
Log:
Skip Apple simulator test for all remote testing scenarios.

The test makes no sense to run remotely, period. The architecture of
the target is not the discriminant here.

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=374217&r1=374216&r2=374217&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
 Wed Oct  9 13:39:04 2019
@@ -103,21 +103,21 @@ class TestAppleSimulatorOSType(gdbremote
 
 @apple_simulator_test('iphone')
 @debugserver_test
-@skipIfDarwinEmbedded
+@skipIfRemote
 def test_simulator_ostype_ios(self):
 self.check_simulator_ostype(sdk='iphonesimulator',
 platform='ios')
 
 @apple_simulator_test('appletv')
 @debugserver_test
-@skipIfDarwinEmbedded
+@skipIfRemote
 def test_simulator_ostype_tvos(self):
 self.check_simulator_ostype(sdk='appletvsimulator',
 platform='tvos')
 
 @apple_simulator_test('watch')
 @debugserver_test
-@skipIfDarwinEmbedded
+@skipIfRemote
 def test_simulator_ostype_watchos(self):
 self.check_simulator_ostype(sdk='watchsimulator',
 platform='watchos', arch='i386')


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


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

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

This change broek the`TestDataFormatterInvalidStdUniquePtr.py` test, see: 
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2411/testReport/

I verified that reverting this commit fixes the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-09 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 224145.

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

https://reviews.llvm.org/D68678

Files:
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,18 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
+  // When searching for "std::vector::const_iterator", reject any
+  // files without "vector" early, since there will be many other
+  // "const_iterators".
+  if (context.GetSize() > 1 && (context[1].tag == DW_TAG_class_type ||
+context[1].tag == DW_TAG_structure_type)) {
+DIEArray class_matches;
+m_apple_types_up->FindByName(context[1].name, class_matches);
+if (class_matches.empty())
+  return;
+  }
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME) \
+  class NAME {  \
+public: \
+class Inner {   \
+  int j = #NAME[0]; \
+};  \
+Inner *i = nullptr; \
+  };\
+\
+  static NAME::Inner inner; \
+  static NAME obj;  \
+  NAME::Inner &getInner##NAME() { return inner; }
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME) \
+  class NAME {  \
+  public:   \
+struct Inner;   \
+Inner *i = nullptr; \
+  };\
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+  A::Inner &inner_a = getInnerA();
+  B::Inner &inner_b = getInnerB();
+  C::Inner &inner_c = getInnerC();
+  D::Inner &inner_d = getInnerD();
+  E::Inner &inner_e = getInnerE();
+  F::Inner &inner_f = getInnerF();
+  G::Inner &inner_g = getInnerG();
+
+  return 0; // break here
+}
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(G)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(F)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(E)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(D)
Index: lldb/

[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-09 Thread Gwen Mittertreiner via Phabricator via lldb-commits
gmittert updated this revision to Diff 224147.
gmittert added a comment.

Updated/Rebased for the rename of lit->test


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68614

Files:
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -58,9 +58,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(llvm-stirp)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 else()


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -58,9 +58,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(llvm-stirp)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 else()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-09 Thread Gwen Mittertreiner via Phabricator via lldb-commits
gmittert updated this revision to Diff 224148.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68614

Files:
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -58,9 +58,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(llvm-strip)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 else()


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -58,9 +58,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(llvm-strip)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 else()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68727: Allow pexpect tests to work in remote testsuite runs

2019-10-09 Thread Frederic Riss via Phabricator via lldb-commits
friss created this revision.
friss added reviewers: teemperor, labath.
Herald added a project: LLDB.

This commit adds platform selection/connection commands to the base
PExpectTest class. I doesn't look like any of the current tests are
really interesting to test remotely, but it's easy enough to get
them to work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68727

Files:
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py


Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -11,6 +11,7 @@
 import lldb
 from .lldbtest import *
 from . import lldbutil
+from lldbsuite.test import configuration
 
 if sys.platform.startswith('win32'):
 # llvm.org/pr22274: need a pexpect replacement for windows
@@ -33,8 +34,6 @@
 args = ['--no-lldbinit', '--no-use-colors']
 for cmd in self.setUpCommands():
 args += ['-O', cmd]
-if executable is not None:
-args += ['--file', executable]
 if extra_args is not None:
 args.extend(extra_args)
 self.child = pexpect.spawn(
@@ -44,8 +43,23 @@
 for cmd in self.setUpCommands():
 self.child.expect_exact(cmd)
 self.expect_prompt()
+
+if configuration.lldb_platform_name:
+self.child.sendline("platform select " + 
configuration.lldb_platform_name)
+self.child.expect_exact("Platform: " + 
configuration.lldb_platform_name)
+self.expect_prompt()
+self.child.sendline("platform connect " + 
configuration.lldb_platform_url)
+self.child.expect_exact("Connected: yes")
+self.expect_prompt()
+
+if configuration.lldb_platform_working_dir:
+self.child.sendline("platform mkdir " + 
configuration.lldb_platform_working_dir)
+self.expect_prompt()
+self.child.sendline("platform settings -w " + 
configuration.lldb_platform_working_dir)
+self.expect_prompt()
+
 if executable is not None:
-self.child.expect_exact("target create")
+self.child.sendline("target create " + executable)
 self.child.expect_exact("Current executable set to")
 self.expect_prompt()
 


Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -11,6 +11,7 @@
 import lldb
 from .lldbtest import *
 from . import lldbutil
+from lldbsuite.test import configuration
 
 if sys.platform.startswith('win32'):
 # llvm.org/pr22274: need a pexpect replacement for windows
@@ -33,8 +34,6 @@
 args = ['--no-lldbinit', '--no-use-colors']
 for cmd in self.setUpCommands():
 args += ['-O', cmd]
-if executable is not None:
-args += ['--file', executable]
 if extra_args is not None:
 args.extend(extra_args)
 self.child = pexpect.spawn(
@@ -44,8 +43,23 @@
 for cmd in self.setUpCommands():
 self.child.expect_exact(cmd)
 self.expect_prompt()
+
+if configuration.lldb_platform_name:
+self.child.sendline("platform select " + configuration.lldb_platform_name)
+self.child.expect_exact("Platform: " + configuration.lldb_platform_name)
+self.expect_prompt()
+self.child.sendline("platform connect " + configuration.lldb_platform_url)
+self.child.expect_exact("Connected: yes")
+self.expect_prompt()
+
+if configuration.lldb_platform_working_dir:
+self.child.sendline("platform mkdir " + configuration.lldb_platform_working_dir)
+self.expect_prompt()
+self.child.sendline("platform settings -w " + configuration.lldb_platform_working_dir)
+self.expect_prompt()
+
 if executable is not None:
-self.child.expect_exact("target create")
+self.child.sendline("target create " + executable)
 self.child.expect_exact("Current executable set to")
 self.expect_prompt()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374225 - allow arbitrary python streams to be converted to SBFile

2019-10-09 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Wed Oct  9 13:56:17 2019
New Revision: 374225

URL: http://llvm.org/viewvc/llvm-project?rev=374225&view=rev
Log:
allow arbitrary python streams to be converted to SBFile

Summary:
This patch adds SWIG typemaps that can convert arbitrary python
file objects into lldb_private::File.

A SBFile may be initialized from a python file using the
constructor.   There are also alternate, tagged constructors
that allow python files to be borrowed, and for the caller
to control whether or not the python I/O methods will be
called even when a file descriptor is available.I

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: zturner, amccarth, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/API/SBFile.h

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
lldb/trunk/scripts/Python/python-typemaps.swig
lldb/trunk/scripts/interface/SBFile.i
lldb/trunk/source/API/SBFile.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Modified: lldb/trunk/include/lldb/API/SBFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFile.h?rev=374225&r1=374224&r2=374225&view=diff
==
--- lldb/trunk/include/lldb/API/SBFile.h (original)
+++ lldb/trunk/include/lldb/API/SBFile.h Wed Oct  9 13:56:17 2019
@@ -18,6 +18,7 @@ class LLDB_API SBFile {
 
 public:
   SBFile();
+  SBFile(FileSP file_sp);
   SBFile(FILE *file, bool transfer_ownership);
   SBFile(int fd, const char *mode, bool transfer_ownership);
   ~SBFile();
@@ -33,7 +34,6 @@ public:
 
 private:
   FileSP m_opaque_sp;
-  SBFile(FileSP file_sp);
 };
 
 } // namespace lldb

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py?rev=374225&r1=374224&r2=374225&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 Wed Oct  9 13:56:17 2019
@@ -13,8 +13,53 @@ from contextlib import contextmanager
 import lldb
 from lldbsuite.test import  lldbtest
 from lldbsuite.test.decorators import (
-add_test_categories, no_debug_info_test, skipIf)
+add_test_categories, skipIf, skipIfWindows)
 
+class OhNoe(Exception):
+pass
+
+class BadIO(io.TextIOBase):
+@property
+def closed(self):
+return False
+def writable(self):
+return True
+def readable(self):
+return True
+def write(self, s):
+raise OhNoe('OH NOE')
+def read(self, n):
+raise OhNoe("OH NOE")
+def flush(self):
+raise OhNoe('OH NOE')
+
+# This class will raise an exception while it's being
+# converted into a C++ object by swig
+class ReallyBadIO(io.TextIOBase):
+def fileno(self):
+return 999
+def writable(self):
+raise OhNoe("OH NOE!!!")
+
+class MutableBool():
+def __init__(self, value):
+self.value = value
+def set(self, value):
+self.value = bool(value)
+def __bool__(self):
+return self.value
+
+class FlushTestIO(io.StringIO):
+def __init__(self, mutable_flushed, mutable_closed):
+super(FlushTestIO, self).__init__()
+self.mut_flushed = mutable_flushed
+self.mut_closed = mutable_closed
+def close(self):
+self.mut_closed.set(True)
+return super(FlushTestIO, self).close()
+def flush(self):
+self.mut_flushed.set(True)
+return super(FlushTestIO, self).flush()
 
 @contextmanager
 def replace_stdout(new):
@@ -36,6 +81,7 @@ def readStrippedLines(f):
 
 class FileHandleTestCase(lldbtest.TestBase):
 
+NO_DEBUG_INFO_TESTCASE = True
 mydir = lldbtest.Base.compute_mydir(__file__)
 
 # The way this class interacts with the debugger is different
@@ -84,7 +130,8 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@no_debug_info_test
+@skipIfWindows # FIXME pre-existing bug, should be fixed
+   # when we delete the FILE* typemaps.
 def test_legacy_file_out_script(self):
 with open(self.out_filename, 'w') as f:
 self.debugger.SetOutputFileHandle(f, False)
@@ -100,7 +147,6 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
-@no_debug_info_test
 def test_legacy_file_out(self):
 with open(self.out_filename, 'w') as f:
 self.debugger.SetOutputFileHandle(f, False)
@@ -110,7 +156,8 @@ class FileHandleTestCase(lldbtest.TestBa
 self.assertIn('deadbeef', f.read())
 
 @add_test_categories(['pyapi'])
-@no_de

[Lldb-commits] [lldb] r374226 - Revert "[lldb] Calculate relative path for symbol links"

2019-10-09 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Wed Oct  9 13:56:43 2019
New Revision: 374226

URL: http://llvm.org/viewvc/llvm-project?rev=374226&view=rev
Log:
Revert "[lldb] Calculate relative path for symbol links"

This reverts commit 958091c209d0a92e38b9cb27fb77a0ff7da11853.

This commit incorrectly sets the _lldb.so symlink (at least it does when
building in Stefans' two build directory mode, where you build llvm with
cmake/ninja and lldb with cmake/Xcode, using a cmake generated project.

The _lldb.so link is SUPPOSED to point to:

bin/LLDB.framework/Versions/A/LLDB

but instead it points to

bin/LLDB

which is where LLDB was staged to before constructing the framework.  This
causes all sorts of problems when we then build the lldb driver into bin -
remember that MacOS is a case-preserving but case insensitive filesystem -
so when we later go to dlopen _lldb.so, we dlopen the main executable instead.

Modified:
lldb/trunk/scripts/Python/finishSwigPythonLLDB.py

Modified: lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finishSwigPythonLLDB.py?rev=374226&r1=374225&r2=374226&view=diff
==
--- lldb/trunk/scripts/Python/finishSwigPythonLLDB.py (original)
+++ lldb/trunk/scripts/Python/finishSwigPythonLLDB.py Wed Oct  9 13:56:43 2019
@@ -365,6 +365,7 @@ def make_symlink_native(vDictArgs, strSr
 # Throws:   None.
 #--
 
+
 def make_symlink(
 vDictArgs,
 vstrFrameworkPythonDir,
@@ -373,13 +374,27 @@ def make_symlink(
 dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink()")
 strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile)
 strTarget = os.path.normcase(strTarget)
-strPrefix = vDictArgs['--prefix']
+strSrc = ""
 
 os.chdir(vstrFrameworkPythonDir)
+bMakeFileCalled = "-m" in vDictArgs
+eOSType = utilsOsType.determine_os_type()
+if not bMakeFileCalled:
+strBuildDir = os.path.join("..", "..", "..")
+else:
+# Resolve vstrSrcFile path relatively the build directory
+if eOSType == utilsOsType.EnumOsType.Windows:
+# On a Windows platform the vstrFrameworkPythonDir looks like:
+# llvm\\build\\Lib\\site-packages\\lldb
+strBuildDir = os.path.join("..", "..", "..")
+else:
+# On a UNIX style platform the vstrFrameworkPythonDir looks like:
+# llvm/build/lib/python2.7/site-packages/lldb
+strBuildDir = os.path.join("..", "..", "..", "..")
+strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile))
+
+return make_symlink_native(vDictArgs, strSrc, strTarget)
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
-return make_symlink_native(vDictArgs, strRelSrc, strTarget)
 
 #++---
 # Details:  Make the symbolic that the script bridge for Python will need in


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


[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG21b8a8ae27f3: allow arbitrary python streams to be converted 
to SBFile (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68188

Files:
  lldb/include/lldb/API/SBFile.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig
  lldb/scripts/interface/SBFile.i
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1028,22 +1028,23 @@
   // first-class object type anymore.  `PyFile_FromFd` is just a thin wrapper
   // over `io.open()`, which returns some object derived from `io.IOBase`. As a
   // result, the only way to detect a file in Python 3 is to check whether it
-  // inherits from `io.IOBase`.  Since it is possible for non-files to also
-  // inherit from `io.IOBase`, we additionally verify that it has the `fileno`
-  // attribute, which should guarantee that it is backed by the file system.
-  PythonObject io_module(PyRefType::Owned, PyImport_ImportModule("io"));
-  PythonDictionary io_dict(PyRefType::Borrowed,
-   PyModule_GetDict(io_module.get()));
-  PythonObject io_base_class = io_dict.GetItemForKey(PythonString("IOBase"));
-
-  PythonObject object_type(PyRefType::Owned, PyObject_Type(py_obj));
-
-  if (1 != PyObject_IsSubclass(object_type.get(), io_base_class.get()))
+  // inherits from `io.IOBase`.
+  auto io_module = PythonModule::Import("io");
+  if (!io_module) {
+llvm::consumeError(io_module.takeError());
 return false;
-  if (!object_type.HasAttribute("fileno"))
+  }
+  auto iobase = io_module.get().Get("IOBase");
+  if (!iobase) {
+llvm::consumeError(iobase.takeError());
 return false;
-
-  return true;
+  }
+  int r = PyObject_IsInstance(py_obj, iobase.get().get());
+  if (r < 0) {
+llvm::consumeError(exception()); // clear the exception and log it.
+return false;
+  }
+  return !!r;
 #endif
 }
 
@@ -1096,6 +1097,20 @@
   return file;
 }
 
+namespace {
+class GIL {
+public:
+  GIL() {
+m_state = PyGILState_Ensure();
+assert(!PyErr_Occurred());
+  }
+  ~GIL() { PyGILState_Release(m_state); }
+
+protected:
+  PyGILState_STATE m_state;
+};
+} // namespace
+
 const char *PythonException::toCString() const {
   if (!m_repr_bytes)
 return "unknown exception";
@@ -1150,4 +1165,376 @@
 
 char PythonException::ID = 0;
 
+llvm::Expected GetOptionsForPyObject(const PythonObject &obj) {
+  uint32_t options = 0;
+#if PY_MAJOR_VERSION >= 3
+  auto readable = As(obj.CallMethod("readable"));
+  if (!readable)
+return readable.takeError();
+  auto writable = As(obj.CallMethod("writable"));
+  if (!writable)
+return writable.takeError();
+  if (readable.get())
+options |= File::eOpenOptionRead;
+  if (writable.get())
+options |= File::eOpenOptionWrite;
+#else
+  PythonString py_mode = obj.GetAttributeValue("mode").AsType();
+  options = File::GetOptionsFromMode(py_mode.GetString());
+#endif
+  return options;
+}
+
+// Base class template for python files.   All it knows how to do
+// is hold a reference to the python object and close or flush it
+// when the File is closed.
+namespace {
+template  class OwnedPythonFile : public Base {
+public:
+  template 
+  OwnedPythonFile(const PythonFile &file, bool borrowed, Args... args)
+  : Base(args...), m_py_obj(file), m_borrowed(borrowed) {
+assert(m_py_obj);
+  }
+
+  ~OwnedPythonFile() override {
+assert(m_py_obj);
+GIL takeGIL;
+Close();
+m_py_obj.Reset();
+  }
+
+  bool IsPythonSideValid() const {
+GIL takeGIL;
+auto closed = As(m_py_obj.GetAttribute("closed"));
+if (!closed) {
+  llvm::consumeError(closed.takeError());
+  return false;
+}
+return !closed.get();
+  }
+
+  bool IsValid() const override {
+return IsPythonSideValid() && Base::IsValid();
+  }
+
+  Status Close() override {
+assert(m_py_obj);
+Status py_error, base_error;
+GIL takeGIL;
+if (!m_borrowed) {
+  auto r = m_py_obj.CallMethod("close");
+  if (!r)
+py_error = Status(r.takeError());
+}
+base_error = Base::Close();
+if (py_error.Fail())
+  return py_error;
+return base_error;
+  };
+
+protected:
+  PythonFile m_py_obj;
+  bool m_borrowed;
+};
+} // namespace
+
+// A SimplePythonFile is a OwnedPythonFile that just does all I/O as
+// a NativeFile
+namespace {
+class SimplePythonFile : public OwnedPythonFile {
+public:
+  SimplePythonFile(const PythonFile &file, bool borrowed, int fd,
+   uint32_t opti

[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:114
+
+  // When searching for "std::vector::const_iterator", reject any
+  // files without "vector" early, since there will be many other

This comment gives the impression that this heuristic only applies to 
std::vector, maybe reword it to make it clear that this is just an example?


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

https://reviews.llvm.org/D68678



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


[Lldb-commits] [lldb] r374229 - [LLDB] Remove standalone build dep on llvm-strip

2019-10-09 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Oct  9 14:06:03 2019
New Revision: 374229

URL: http://llvm.org/viewvc/llvm-project?rev=374229&view=rev
Log:
[LLDB] Remove standalone build dep on llvm-strip

When building standalone, since llvm-strip is a symlink, it is created
using add_custom_command/add_custom_target which cannot be exported, and
thus cannot be depended on by lldb.

Patch by: Gwen Mittertreiner

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

Modified:
lldb/trunk/test/CMakeLists.txt

Modified: lldb/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=374229&r1=374228&r2=374229&view=diff
==
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Wed Oct  9 14:06:03 2019
@@ -58,9 +58,14 @@ add_lldb_test_dependency(
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(llvm-strip)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 else()


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


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224159.
hhb added a comment.

Fix format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68728

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68614: [LLDB] Remove standalone build dep on llvm-strip

2019-10-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG988ad4194848: [LLDB] Remove standalone build dep on 
llvm-strip (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D68614?vs=224148&id=224160#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68614

Files:
  lldb/test/CMakeLists.txt


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -58,9 +58,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(llvm-strip)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 else()


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -58,9 +58,14 @@
   llvm-mc
   llvm-objcopy
   llvm-readobj
-  llvm-strip
   )
 
+# Since llvm-strip is a symlink created by add_custom_target, it
+# doesn't expose an export target when building standalone.
+if(NOT LLDB_BUILT_STANDALONE)
+  add_lldb_test_dependency(llvm-strip)
+endif()
+
 if(TARGET lld)
   add_lldb_test_dependency(lld)
 else()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: tatyana-krasnukha.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.
hhb updated this revision to Diff 224159.
hhb added a comment.

Fix format


Fixes issue like D68719 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68728

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68719: Fix build with Visual Studio

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

I think this is caused by D68442 . Can you 
check whether D68728  fixes it?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68719



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


[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

2019-10-09 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 224161.

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

https://reviews.llvm.org/D68678

Files:
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/Makefile
  
lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/TestCPPAccelerator.py
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/a.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/b.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/c.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -110,6 +110,18 @@
   const bool has_qualified_name_hash =
   m_apple_types_up->GetHeader().header_data.ContainsAtom(
   DWARFMappedHash::eAtomTypeQualNameHash);
+
+  // When searching for "std::vector::const_iterator", reject any
+  // files without "vector" early, since there will be many other
+  // "const_iterators".
+  if (context.GetSize() > 1 && (context[1].tag == DW_TAG_class_type ||
+context[1].tag == DW_TAG_structure_type)) {
+DIEArray class_matches;
+m_apple_types_up->FindByName(context[1].name, class_matches);
+if (class_matches.empty())
+  return;
+  }
+
   const ConstString type_name(context[0].name);
   const dw_tag_t tag = context[0].tag;
   if (has_tag && has_qualified_name_hash) {
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/source.h
@@ -0,0 +1,12 @@
+#define CLASS(NAME) \
+  class NAME {  \
+public: \
+class Inner {   \
+  int j = #NAME[0]; \
+};  \
+Inner *i = nullptr; \
+  };\
+\
+  static NAME::Inner inner; \
+  static NAME obj;  \
+  NAME::Inner &getInner##NAME() { return inner; }
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/main.cpp
@@ -0,0 +1,28 @@
+#define CLASS(NAME) \
+  class NAME {  \
+  public:   \
+struct Inner;   \
+Inner *i = nullptr; \
+  };\
+NAME::Inner &getInner##NAME();
+
+CLASS(A)
+CLASS(B)
+CLASS(C)
+CLASS(D)
+CLASS(E)
+CLASS(F)
+CLASS(G)
+
+int main()
+{
+  A::Inner &inner_a = getInnerA();
+  B::Inner &inner_b = getInnerB();
+  C::Inner &inner_c = getInnerC();
+  D::Inner &inner_d = getInnerD();
+  E::Inner &inner_e = getInnerE();
+  F::Inner &inner_f = getInnerF();
+  G::Inner &inner_g = getInnerG();
+
+  return 0; // break here
+}
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/g.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(G)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/f.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(F)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/e.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(E)
Index: lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/cpp/accelerator-table/d.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+CLASS(D)
Index: lldb/

[Lldb-commits] [PATCH] D68731: Remove CC autodetection from Makefile.rules

2019-10-09 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: friss, JDevlieghere, labath.

Auto-detecting CC in Makefile.rules is no longer useful. Every since 
out-of-tree builds you are better off just running lldb-dotest which sets it 
directly. This also makes it harder to accidentally unset CC in a Makefile.


https://reviews.llvm.org/D68731

Files:
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -171,15 +171,8 @@
 #   o cxx_compiler
 #   o cxx_linker
 #--
-CC ?= clang
-ifeq "$(CC)" "cc"
-   ifneq "$(shell which clang)" ""
-   CC = clang
-   else ifneq "$(shell which clang-3.5)" ""
-   CC = clang-3.5
-   else ifneq "$(shell which gcc)" ""
-   CC = gcc
-   endif
+ifeq "$(CC)" ""
+$(error "C compiler is not specified. Please run tests through lldb-dotest or 
lit")
 endif
 
 #--


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -171,15 +171,8 @@
 #   o cxx_compiler
 #   o cxx_linker
 #--
-CC ?= clang
-ifeq "$(CC)" "cc"
-	ifneq "$(shell which clang)" ""
-		CC = clang
-	else ifneq "$(shell which clang-3.5)" ""
-		CC = clang-3.5
-	else ifneq "$(shell which gcc)" ""
-		CC = gcc
-	endif
+ifeq "$(CC)" ""
+$(error "C compiler is not specified. Please run tests through lldb-dotest or lit")
 endif
 
 #--
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-09 Thread Cameron via Phabricator via lldb-commits
cameron314 added a comment.

I've committed a fix in rG745e57c5939e 
. Sorry 
about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68641



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


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224166.
hhb added a comment.

Simplify the path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68728

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,8 +202,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
+get_filename_component(lldb_python_build_path ${lldb_python_build_path} 
ABSOLUTE)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows).


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,8 +202,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
+get_filename_component(lldb_python_build_path ${lldb_python_build_path} ABSOLUTE)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows).
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r374195 - [LLDB] Fix for synthetic children memory leak

2019-10-09 Thread Cameron Desrochers via lldb-commits
Author: cameron314
Date: Wed Oct  9 11:27:33 2019
New Revision: 374195

URL: http://llvm.org/viewvc/llvm-project?rev=374195&view=rev
Log:
[LLDB] Fix for synthetic children memory leak

The lifetime of a ValueObject and all its derivative ValueObjects (children, 
clones, etc.) is managed by a ClusterManager. These objects are only destroyed 
when every shared pointer to any of the managed objects in the cluster is 
destroyed. This means that no object in the cluster can store a shared pointer 
to another object in the cluster without creating a memory leak of the entire 
cluster. However, some of the synthetic children front-end implementations do 
exactly this; this patch fixes that.

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

Modified:
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp?rev=374195&r1=374194&r2=374195&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp Wed Oct  9 
11:27:33 2019
@@ -30,8 +30,15 @@ public:
   ValueObjectSP GetChildAtIndex(size_t idx) override;
 
 private:
+  // The lifetime of a ValueObject and all its derivative ValueObjects
+  // (children, clones, etc.) is managed by a ClusterManager. These
+  // objects are only destroyed when every shared pointer to any of them
+  // is destroyed, so we must not store a shared pointer to any ValueObject
+  // derived from our backend ValueObject (since we're in the same cluster).
+  // Value objects created from raw data (i.e. in a different cluster) must
+  // be referenced via shared pointer to keep them alive, however.
   std::vector m_elements;
-  ValueObjectSP m_first;
+  ValueObject* m_first = nullptr;
   CompilerType m_bool_type;
   ByteOrder m_byte_order = eByteOrderInvalid;
   uint8_t m_byte_size = 0;
@@ -50,7 +57,7 @@ BitsetFrontEnd::BitsetFrontEnd(ValueObje
 
 bool BitsetFrontEnd::Update() {
   m_elements.clear();
-  m_first.reset();
+  m_first = nullptr;
 
   TargetSP target_sp = m_backend.GetTargetSP();
   if (!target_sp)
@@ -63,7 +70,7 @@ bool BitsetFrontEnd::Update() {
 
   m_elements.assign(size, ValueObjectSP());
 
-  m_first = m_backend.GetChildMemberWithName(ConstString("__first_"), true);
+  m_first = m_backend.GetChildMemberWithName(ConstString("__first_"), 
true).get();
   return false;
 }
 
@@ -86,7 +93,7 @@ ValueObjectSP BitsetFrontEnd::GetChildAt
 chunk = m_first->GetChildAtIndex(idx / *bit_size, true);
   } else {
 type = m_first->GetCompilerType();
-chunk = m_first;
+chunk = m_first->GetSP();
   }
   if (!type || !chunk)
 return {};

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp?rev=374195&r1=374194&r2=374195&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp Wed Oct  9 
11:27:33 2019
@@ -31,7 +31,6 @@ public:
 
 private:
   size_t m_size = 0;
-  ValueObjectSP m_base_sp;
 };
 } // namespace
 

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp?rev=374195&r1=374194&r2=374195&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp Wed Oct  9 
11:27:33 2019
@@ -38,16 +38,21 @@ public:
   }
 
 private:
-  ValueObjectSP m_container_sp;
+  // The lifetime of a ValueObject and all its derivative ValueObjects
+  // (children, clones, etc.) is managed by a ClusterManager. These
+  // objects are only destroyed when every shared pointer to any of them
+  // is destroyed, so we must not store a shared pointer to any ValueObject
+  // derived from our backend ValueObject (since we're in the same cluster).
+  ValueObject* m_container_sp = nullptr;
 };
 } // namespace
 
 bool QueueFrontEnd::Update() {
-  m_container_sp.reset();
+  m_container_sp = nullptr;
   ValueObjectSP c_sp = m_backend.GetChildMemberWithName(ConstStrin

Re: [Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Jonas Devlieghere via lldb-commits
Can you try a clean build as opposed to incremental? Before landing I
checked that it worked for me for both a clean and incremental build,
but it seems like at least GreenDragon had some issues with the
incremental one.

On Wed, Oct 9, 2019 at 10:27 AM Jan Kratochvil via Phabricator
 wrote:
>
> jankratochvil added a comment.
>
> Before this patch I was getting :
>
>   #rm -rf *
>   cmake ~/redhat/llvm-monorepo2/llvm/ -DCMAKE_BUILD_TYPE=Release  
> -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_PROJECTS="lldb;clang;lld"  
> -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ 
> -DLLVM_ENABLE_ASSERTIONS=ON
>   make check-lldb
>   ...
>   llvm-lit: 
> /home/jkratoch/redhat/llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:134: 
> fatal: Did not find count in 
> /home/jkratoch/redhat/llvm-monorepo2-clangassert/./bin
>
> After this patch I am getting:
>
>   [100%] Running lldb lit test suite
>   llvm-lit: 
> /home/jkratoch/redhat/llvm-monorepo2/llvm/utils/lit/lit/discovery.py:133: 
> warning: unable to find test suite for 
> '/home/jkratoch/redhat/llvm-monorepo2-clangassert/tools/lldb/test'
>   llvm-lit: 
> /home/jkratoch/redhat/llvm-monorepo2/llvm/utils/lit/lit/discovery.py:244: 
> warning: input 
> '/home/jkratoch/redhat/llvm-monorepo2-clangassert/tools/lldb/test' contained 
> no tests
>   Testing Time: 0.00s
>   2 warning(s) in tests.
>   [100%] Built target check-lldb-lit
>   Scanning dependencies of target check-lldb
>   [100%] Built target check-lldb
>
> A Fedora buildbot has not yet built this release: 
> http://lab.llvm.org:8014/builders/lldb-x86_64-fedora?numbuilds=1000
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D68606/new/
>
> https://reviews.llvm.org/D68606
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Before this patch I was getting :

  #rm -rf *
  cmake ~/redhat/llvm-monorepo2/llvm/ -DCMAKE_BUILD_TYPE=Release  
-DLLVM_USE_LINKER=gold -DLLVM_ENABLE_PROJECTS="lldb;clang;lld"  
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ 
-DLLVM_ENABLE_ASSERTIONS=ON
  make check-lldb
  ...
  llvm-lit: 
/home/jkratoch/redhat/llvm-monorepo2/llvm/utils/lit/lit/llvm/subst.py:134: 
fatal: Did not find count in 
/home/jkratoch/redhat/llvm-monorepo2-clangassert/./bin

After this patch I am getting:

  [100%] Running lldb lit test suite
  llvm-lit: 
/home/jkratoch/redhat/llvm-monorepo2/llvm/utils/lit/lit/discovery.py:133: 
warning: unable to find test suite for 
'/home/jkratoch/redhat/llvm-monorepo2-clangassert/tools/lldb/test'
  llvm-lit: 
/home/jkratoch/redhat/llvm-monorepo2/llvm/utils/lit/lit/discovery.py:244: 
warning: input 
'/home/jkratoch/redhat/llvm-monorepo2-clangassert/tools/lldb/test' contained no 
tests
  Testing Time: 0.00s
  2 warning(s) in tests.
  [100%] Built target check-lldb-lit
  Scanning dependencies of target check-lldb
  [100%] Built target check-lldb

A Fedora buildbot has not yet built this release: 
http://lab.llvm.org:8014/builders/lldb-x86_64-fedora?numbuilds=1000


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68606



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


[Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 224072.
JDevlieghere added a comment.
Herald added a reviewer: alexshap.

Rename `lit` to `test` to decrease the number of renames in the git history.


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

https://reviews.llvm.org/D68606

Files:
  lldb/CMakeLists.txt
  lldb/lit/Breakpoint/Inputs/case-sensitive.c
  lldb/lit/Breakpoint/Inputs/debug_addrx.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml
  lldb/lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lldb/lit/Breakpoint/Inputs/jitbp.cpp
  lldb/lit/Breakpoint/Inputs/ppc64-localentry.s
  lldb/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
  lldb/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml
  lldb/lit/Breakpoint/case-insensitive.test
  lldb/lit/Breakpoint/case-sensitive.test
  lldb/lit/Breakpoint/debug_addrx.test
  lldb/lit/Breakpoint/debug_rnglist_basic.test
  lldb/lit/Breakpoint/debug_rnglist_offset_pair.test
  lldb/lit/Breakpoint/debug_rnglist_rlestartend.test
  lldb/lit/Breakpoint/debug_rnglistx_rlex.test
  lldb/lit/Breakpoint/implicit_const_form_support.test
  lldb/lit/Breakpoint/jitbp_elf.test
  lldb/lit/Breakpoint/ppc64-localentry.test
  lldb/lit/Breakpoint/single-file-split-dwarf.test
  lldb/lit/Breakpoint/split-dwarf-5-addrbase.test
  lldb/lit/Breakpoint/split-dwarf5-debug-stroffsets.test
  lldb/lit/BuildScript/compiler-full-path.test
  lldb/lit/BuildScript/modes.test
  lldb/lit/BuildScript/script-args.test
  lldb/lit/BuildScript/toolchain-clang-cl.test
  lldb/lit/BuildScript/toolchain-clang.test
  lldb/lit/BuildScript/toolchain-msvc.test
  lldb/lit/CMakeLists.txt
  
lldb/lit/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputConsole.test
  
lldb/lit/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputFile.test
  lldb/lit/Commands/CommandScriptImmediateOutput/Inputs/custom_command.py
  lldb/lit/Commands/CommandScriptImmediateOutput/lit.local.cfg
  lldb/lit/Commands/Inputs/frame.py
  lldb/lit/Commands/Inputs/main.c
  lldb/lit/Commands/command-backtrace.test
  lldb/lit/Commands/command-regex-delete.test
  lldb/lit/Commands/command-regex-unalias.test
  lldb/lit/Commands/command-script-import.test
  lldb/lit/Commands/command-source.test
  lldb/lit/Driver/Inputs/.lldbinit
  lldb/lit/Driver/Inputs/Print0.in
  lldb/lit/Driver/Inputs/Print2.in
  lldb/lit/Driver/Inputs/Print4.in
  lldb/lit/Driver/Inputs/Print6.in
  lldb/lit/Driver/Inputs/convenience.in
  lldb/lit/Driver/Inputs/hello.c
  lldb/lit/Driver/Inputs/hello.cpp
  lldb/lit/Driver/Inputs/process_attach_pid.in
  lldb/lit/Driver/Inputs/syntax_error.py
  lldb/lit/Driver/LocalLLDBInit.test
  lldb/lit/Driver/TestCommands.test
  lldb/lit/Driver/TestConvenienceVariables.test
  lldb/lit/Driver/TestCore.test
  lldb/lit/Driver/TestFile.test
  lldb/lit/Driver/TestNoUseColor.test
  lldb/lit/Driver/TestProcessAttach.test
  lldb/lit/Driver/TestRepl.test
  lldb/lit/Driver/TestSingleQuote.test
  lldb/lit/Driver/TestTarget.test
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-1.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook.c
  lldb/lit/ExecControl/StopHook/stop-hook-threads.test
  lldb/lit/ExecControl/StopHook/stop-hook.test
  lldb/lit/Expr/Inputs/call-function.cpp
  lldb/lit/Expr/Inputs/ir-memory-map-basic
  lldb/lit/Expr/Inputs/ir-memory-map-mix-malloc-free
  lldb/lit/Expr/Inputs/ir-memory-map-overlap1
  lldb/lit/Expr/TestIRMemoryMap.test
  lldb/lit/Expr/TestIRMemoryMapWindows.test
  lldb/lit/Expr/TestMultilineExpr.test
  lldb/lit/Expr/TestTypeOfDeclTypeExpr.test
  lldb/lit/Heap/Inputs/cstr.c
  lldb/lit/Heap/heap-cstr.test
  lldb/lit/Host/Inputs/simple.c
  lldb/lit/Host/TestCustomShell.test
  lldb/lit/Minidump/Inputs/linux-x86_64.syms
  lldb/lit/Minidump/Inputs/linux-x86_64.yaml
  lldb/lit/Minidump/Windows/Inputs/find-module.dmp.yaml
  lldb/lit/Minidump/Windows/Inputs/find-module.exe.yaml
  lldb/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp
  lldb/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.dmp
  lldb/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.lldbinit
  lldb/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.pdb
  lldb/lit/Minidump/Windows/Sigsegv/sigsegv.test
  lldb/lit/Minidump/W

Re: [Lldb-commits] [PATCH] D68641: [LLDB] Fix for synthetic children memory leak

2019-10-09 Thread Cameron via lldb-commits
I'll have a look, sorry about that.

On Wed, Oct 9, 2019 at 4:37 PM Shafik Yaghmour via Phabricator <
revi...@reviews.llvm.org> wrote:

> shafik added a comment.
>
> This change broek the`TestDataFormatterInvalidStdUniquePtr.py` test, see:
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2411/testReport/
>
> I verified that reverting this commit fixes the test.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D68641/new/
>
> https://reviews.llvm.org/D68641
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Jonas Devlieghere via lldb-commits
I finally managed to reproduce and check-lldb was indeed broken. I've
fixed it when re-landing the patch in r374201.

On Wed, Oct 9, 2019 at 11:16 AM Jan Kratochvil
 wrote:
>
> On Wed, 09 Oct 2019 19:58:35 +0200, Jonas Devlieghere wrote:
> > Can you try a clean build as opposed to incremental?
>
> This is what I do, indicated by that:
> #rm -rf *
>
> (I did put there a # so that someone does not accidentally delete his whole
> world during a copy-paste.)
>
> It rather worked before in incremental builds until I made a from-scratch
> build.
>
>
> Thanks,
> Jan
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Jan Kratochvil via lldb-commits
On Wed, 09 Oct 2019 19:58:35 +0200, Jonas Devlieghere wrote:
> Can you try a clean build as opposed to incremental?

This is what I do, indicated by that:
#rm -rf *

(I did put there a # so that someone does not accidentally delete his whole
world during a copy-paste.)

It rather worked before in incremental builds until I made a from-scratch
build.


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


[Lldb-commits] [lldb] r374231 - [LLDB] Fix for regression of test 'TestDataFormatterInvalidStdUniquePtr.py' introduced in r374195

2019-10-09 Thread Cameron Desrochers via lldb-commits
Author: cameron314
Date: Wed Oct  9 14:15:48 2019
New Revision: 374231

URL: http://llvm.org/viewvc/llvm-project?rev=374231&view=rev
Log:
[LLDB] Fix for regression of test 'TestDataFormatterInvalidStdUniquePtr.py' 
introduced in r374195

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

Modified:
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp?rev=374231&r1=374230&r2=374231&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp Wed Oct  9 
14:15:48 2019
@@ -79,7 +79,9 @@ ValueObjectSP TupleFrontEnd::GetChildAtI
 m_elements[idx] =
 elem_sp->Clone(ConstString(llvm::formatv("[{0}]", idx).str())).get();
 
-  return m_elements[idx]->GetSP();
+  if (m_elements[idx])
+return m_elements[idx]->GetSP();
+  return ValueObjectSP();
 }
 
 SyntheticChildrenFrontEnd *

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp?rev=374231&r1=374230&r2=374231&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp Wed Oct  9 
14:15:48 2019
@@ -90,7 +90,7 @@ bool LibStdcppTupleSyntheticFrontEnd::Mi
 
 lldb::ValueObjectSP
 LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
-  if (idx < m_members.size())
+  if (idx < m_members.size() && m_members[idx])
 return m_members[idx]->GetSP();
   return lldb::ValueObjectSP();
 }

Modified: 
lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp?rev=374231&r1=374230&r2=374231&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp 
(original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Wed 
Oct  9 14:15:48 2019
@@ -118,11 +118,11 @@ bool LibStdcppUniquePtrSyntheticFrontEnd
 
 lldb::ValueObjectSP
 LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
-  if (idx == 0)
+  if (idx == 0 && m_ptr_obj)
 return m_ptr_obj->GetSP();
-  if (idx == 1)
+  if (idx == 1 && m_del_obj)
 return m_del_obj->GetSP();
-  if (idx == 2)
+  if (idx == 2 && m_obj_obj)
 return m_obj_obj->GetSP();
   return lldb::ValueObjectSP();
 }


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


[Lldb-commits] [PATCH] D68606: [test] Split LLDB tests into filecheck, unittest and dotest.

2019-10-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22314179f066: [test] Split LLDB tests into API, Shell & 
Unit (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D68606?vs=224072&id=224087#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68606

Files:
  lldb/CMakeLists.txt
  lldb/lit/Breakpoint/Inputs/case-sensitive.c
  lldb/lit/Breakpoint/Inputs/debug_addrx.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_basic.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_offset_pair.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglist_rlestartend.yaml
  lldb/lit/Breakpoint/Inputs/debug_rnglistx_rlex.yaml
  lldb/lit/Breakpoint/Inputs/implicit_const_form_support.yaml
  lldb/lit/Breakpoint/Inputs/jitbp.cpp
  lldb/lit/Breakpoint/Inputs/ppc64-localentry.s
  lldb/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
  lldb/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf-5-addrbase.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file1.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-file2.dwo.yaml
  lldb/lit/Breakpoint/Inputs/split-dwarf5-debug-stroffsets-main.yaml
  lldb/lit/Breakpoint/case-insensitive.test
  lldb/lit/Breakpoint/case-sensitive.test
  lldb/lit/Breakpoint/debug_addrx.test
  lldb/lit/Breakpoint/debug_rnglist_basic.test
  lldb/lit/Breakpoint/debug_rnglist_offset_pair.test
  lldb/lit/Breakpoint/debug_rnglist_rlestartend.test
  lldb/lit/Breakpoint/debug_rnglistx_rlex.test
  lldb/lit/Breakpoint/implicit_const_form_support.test
  lldb/lit/Breakpoint/jitbp_elf.test
  lldb/lit/Breakpoint/ppc64-localentry.test
  lldb/lit/Breakpoint/single-file-split-dwarf.test
  lldb/lit/Breakpoint/split-dwarf-5-addrbase.test
  lldb/lit/Breakpoint/split-dwarf5-debug-stroffsets.test
  lldb/lit/BuildScript/compiler-full-path.test
  lldb/lit/BuildScript/modes.test
  lldb/lit/BuildScript/script-args.test
  lldb/lit/BuildScript/toolchain-clang-cl.test
  lldb/lit/BuildScript/toolchain-clang.test
  lldb/lit/BuildScript/toolchain-msvc.test
  lldb/lit/CMakeLists.txt
  
lldb/lit/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputConsole.test
  
lldb/lit/Commands/CommandScriptImmediateOutput/CommandScriptImmediateOutputFile.test
  lldb/lit/Commands/CommandScriptImmediateOutput/Inputs/custom_command.py
  lldb/lit/Commands/CommandScriptImmediateOutput/lit.local.cfg
  lldb/lit/Commands/Inputs/frame.py
  lldb/lit/Commands/Inputs/main.c
  lldb/lit/Commands/command-backtrace.test
  lldb/lit/Commands/command-regex-delete.test
  lldb/lit/Commands/command-regex-unalias.test
  lldb/lit/Commands/command-script-import.test
  lldb/lit/Commands/command-source.test
  lldb/lit/Driver/Inputs/.lldbinit
  lldb/lit/Driver/Inputs/Print0.in
  lldb/lit/Driver/Inputs/Print2.in
  lldb/lit/Driver/Inputs/Print4.in
  lldb/lit/Driver/Inputs/Print6.in
  lldb/lit/Driver/Inputs/convenience.in
  lldb/lit/Driver/Inputs/hello.c
  lldb/lit/Driver/Inputs/hello.cpp
  lldb/lit/Driver/Inputs/process_attach_pid.in
  lldb/lit/Driver/Inputs/syntax_error.py
  lldb/lit/Driver/LocalLLDBInit.test
  lldb/lit/Driver/TestCommands.test
  lldb/lit/Driver/TestConvenienceVariables.test
  lldb/lit/Driver/TestCore.test
  lldb/lit/Driver/TestFile.test
  lldb/lit/Driver/TestNoUseColor.test
  lldb/lit/Driver/TestProcessAttach.test
  lldb/lit/Driver/TestRepl.test
  lldb/lit/Driver/TestSingleQuote.test
  lldb/lit/Driver/TestTarget.test
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-1.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-2.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-3.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-1.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads-2.lldbinit
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp
  lldb/lit/ExecControl/StopHook/Inputs/stop-hook.c
  lldb/lit/ExecControl/StopHook/stop-hook-threads.test
  lldb/lit/ExecControl/StopHook/stop-hook.test
  lldb/lit/Expr/Inputs/call-function.cpp
  lldb/lit/Expr/Inputs/ir-memory-map-basic
  lldb/lit/Expr/Inputs/ir-memory-map-mix-malloc-free
  lldb/lit/Expr/Inputs/ir-memory-map-overlap1
  lldb/lit/Expr/TestIRMemoryMap.test
  lldb/lit/Expr/TestIRMemoryMapWindows.test
  lldb/lit/Expr/TestMultilineExpr.test
  lldb/lit/Expr/TestTypeOfDeclTypeExpr.test
  lldb/lit/Heap/Inputs/cstr.c
  lldb/lit/Heap/heap-cstr.test
  lldb/lit/Host/Inputs/simple.c
  lldb/lit/Host/TestCustomShell.test
  lldb/lit/Minidump/Inputs/linux-x86_64.syms
  lldb/lit/Minidump/Inputs/linux-x86_64.yaml
  lldb/lit/Minidump/Windows/Inputs/find-module.dmp.yaml
  lldb/lit/Minidump/Windows/Inputs/find-module.exe.yaml
  lldb/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.cpp
  lldb/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.dmp
  lldb/lit/Minidump/Windows/Sigsegv/Inputs/sigsegv.lldbinit
  lldb/lit/Min

[Lldb-commits] [lldb] r374234 - TestHelloWorld: Make compatible with remote testing

2019-10-09 Thread Frederic Riss via lldb-commits
Author: friss
Date: Wed Oct  9 14:41:02 2019
New Revision: 374234

URL: http://llvm.org/viewvc/llvm-project?rev=374234&view=rev
Log:
TestHelloWorld: Make compatible with remote testing

The synchronization token handling was not remote-friendly.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py?rev=374234&r1=374233&r2=374234&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
 Wed Oct  9 14:41:02 2019
@@ -78,17 +78,19 @@ class HelloWorldTestCase(TestBase):
 @expectedFailureNetBSD
 def test_with_attach_to_process_with_id_api(self):
 """Create target, spawn a process, and attach to it with process id."""
-exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid())
+exe = '%s_%d'%(self.testMethodName, os.getpid())
 d = {'EXE': exe}
 self.build(dictionary=d)
 self.setTearDownCleanup(dictionary=d)
-target = self.dbg.CreateTarget(exe)
+target = self.dbg.CreateTarget(self.getBuildArtifact(exe))
 
 # Spawn a new process
 token = exe+'.token'
-if os.path.exists(token):
-os.remove(token)
-popen = self.spawnSubprocess(exe, [token])
+if not lldb.remote_platform:
+token = self.getBuildArtifact(token)
+if os.path.exists(token):
+os.remove(token)
+popen = self.spawnSubprocess(self.getBuildArtifact(exe), [token])
 self.addTearDownHook(self.cleanupSubprocesses)
 lldbutil.wait_for_file_on_target(self, token)
 
@@ -110,17 +112,19 @@ class HelloWorldTestCase(TestBase):
 @expectedFailureNetBSD
 def test_with_attach_to_process_with_name_api(self):
 """Create target, spawn a process, and attach to it with process 
name."""
-exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid())
+exe = '%s_%d'%(self.testMethodName, os.getpid())
 d = {'EXE': exe}
 self.build(dictionary=d)
 self.setTearDownCleanup(dictionary=d)
-target = self.dbg.CreateTarget(exe)
+target = self.dbg.CreateTarget(self.getBuildArtifact(exe))
 
 # Spawn a new process.
 token = exe+'.token'
-if os.path.exists(token):
-os.remove(token)
-popen = self.spawnSubprocess(exe, [token])
+if not lldb.remote_platform:
+token = self.getBuildArtifact(token)
+if os.path.exists(token):
+os.remove(token)
+popen = self.spawnSubprocess(self.getBuildArtifact(exe), [token])
 self.addTearDownHook(self.cleanupSubprocesses)
 lldbutil.wait_for_file_on_target(self, token)
 


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


[Lldb-commits] [lldb] r374236 - [Reproducer] Add convenience methods IsCapturing and IsReplaying.

2019-10-09 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Oct  9 14:47:49 2019
New Revision: 374236

URL: http://llvm.org/viewvc/llvm-project?rev=374236&view=rev
Log:
[Reproducer] Add convenience methods IsCapturing and IsReplaying.

Add convenience methods to the Reproducer class for when you don't need
access to the generator and the loader.

Modified:
lldb/trunk/include/lldb/Utility/Reproducer.h
lldb/trunk/source/Commands/CommandObjectReproducer.cpp

Modified: lldb/trunk/include/lldb/Utility/Reproducer.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Reproducer.h?rev=374236&r1=374235&r2=374236&view=diff
==
--- lldb/trunk/include/lldb/Utility/Reproducer.h (original)
+++ lldb/trunk/include/lldb/Utility/Reproducer.h Wed Oct  9 14:47:49 2019
@@ -313,6 +313,9 @@ public:
 
   FileSpec GetReproducerPath() const;
 
+  bool IsCapturing() { return static_cast(m_generator); };
+  bool IsReplaying() { return static_cast(m_loader); };
+
 protected:
   llvm::Error SetCapture(llvm::Optional root);
   llvm::Error SetReplay(llvm::Optional root);

Modified: lldb/trunk/source/Commands/CommandObjectReproducer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectReproducer.cpp?rev=374236&r1=374235&r2=374236&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectReproducer.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectReproducer.cpp Wed Oct  9 14:47:49 
2019
@@ -88,7 +88,7 @@ protected:
 auto &r = Reproducer::Instance();
 if (auto generator = r.GetGenerator()) {
   generator->Keep();
-} else if (r.GetLoader()) {
+} else if (r.IsReplaying()) {
   // Make this operation a NOP in replay mode.
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
   return result.Succeeded();
@@ -132,9 +132,9 @@ protected:
 }
 
 auto &r = Reproducer::Instance();
-if (r.GetGenerator()) {
+if (r.IsCapturing()) {
   result.GetOutputStream() << "Reproducer is in capture mode.\n";
-} else if (r.GetLoader()) {
+} else if (r.IsReplaying()) {
   result.GetOutputStream() << "Reproducer is in replay mode.\n";
 } else {
   result.GetOutputStream() << "Reproducer is off.\n";


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


[Lldb-commits] [lldb] r374237 - SBFile: add a bunch of tests that should eventually work.

2019-10-09 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Wed Oct  9 14:50:46 2019
New Revision: 374237

URL: http://llvm.org/viewvc/llvm-project?rev=374237&view=rev
Log:
SBFile: add a bunch of tests that should eventually work.

Summary:
It's really annoying and confusing to have to keep referring
back to earlier versions of this SBFile work to find the
tests that need to be added for each patch, and not duplicate
them with new tests.

This patch just imports all my tests.   A bunch of them don't
work yet, so they are marked to be skipped.   They'll be
unmarked as I fix them.

One of these tests will actually trip an assert in the SWIG
code now instead of just failing, so I'm fixing that here too.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
lldb/trunk/scripts/Python/python-typemaps.swig

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py?rev=374237&r1=374236&r2=374237&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
 Wed Oct  9 14:50:46 2019
@@ -13,7 +13,7 @@ from contextlib import contextmanager
 import lldb
 from lldbsuite.test import  lldbtest
 from lldbsuite.test.decorators import (
-add_test_categories, skipIf, skipIfWindows)
+add_test_categories, skipIf, skipIfWindows, expectedFailure)
 
 class OhNoe(Exception):
 pass
@@ -162,7 +162,9 @@ class FileHandleTestCase(lldbtest.TestBa
 with open(self.out_filename, 'w') as f:
 self.debugger.SetErrorFileHandle(f, False)
 self.handleCmd('lolwut', check=False, collect_result=False)
-self.debugger.GetErrorFileHandle().write('FOOBAR\n')
+f2 = self.debugger.GetErrorFileHandle()
+f2.write('FOOBAR\n')
+f2.flush()
 lldb.SBDebugger.Destroy(self.debugger)
 with open(self.out_filename, 'r') as f:
 errors = f.read()
@@ -181,6 +183,16 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
+def test_legacy_file_error(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+debugger.SetErrorFileHandle(f, False)
+self.handleCmd('lolwut', check=False, collect_result=False)
+with open(self.out_filename, 'r') as f:
+errors = f.read()
+self.assertTrue(re.search(r'error:.*lolwut', errors))
+
+@add_test_categories(['pyapi'])
 def test_sbfile_type_errors(self):
 sbf = lldb.SBFile()
 self.assertRaises(TypeError, sbf.Write, None)
@@ -270,6 +282,17 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
+def test_help(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+status = debugger.SetOutputFile(lldb.SBFile(f))
+self.assertTrue(status.Success())
+self.handleCmd("help help", check=False, collect_result=False)
+with open(self.out_filename, 'r') as f:
+self.assertIn('Show a list of all debugger commands', f.read())
+
+
+@add_test_categories(['pyapi'])
 def test_immediate(self):
 with open(self.out_filename, 'w') as f:
 ret = lldb.SBCommandReturnObject()
@@ -278,9 +301,7 @@ class FileHandleTestCase(lldbtest.TestBa
 interpreter.HandleCommand("help help", ret)
 # make sure the file wasn't closed early.
 f.write("\nQUUX\n")
-
 ret = None # call destructor and flush streams
-
 with open(self.out_filename, 'r') as f:
 output = f.read()
 self.assertTrue(re.search(r'Show a list of all debugger commands', 
output))
@@ -288,6 +309,37 @@ class FileHandleTestCase(lldbtest.TestBa
 
 
 @add_test_categories(['pyapi'])
+@expectedFailure # FIXME need SBFile interfaces on SBCommandReturnObject
+def test_immediate_string(self):
+f = io.StringIO()
+ret = lldb.SBCommandReturnObject()
+ret.SetImmediateOutputFile(f)
+interpreter = self.debugger.GetCommandInterpreter()
+interpreter.HandleCommand("help help", ret)
+# make sure the file wasn't closed early.
+f.write("\nQUUX\n")
+ret = None # call destructor and flush streams
+output = f.getvalue()
+self.assertTrue(re.search(r'Show a list of all debugger commands', 
output))
+self.assertTrue(re.search(r'QUUX', output))
+
+
+@add_test_categories(['pyapi'])
+@expectedFail

[Lldb-commits] [lldb] r374239 - remove a smattering of isolated, unnecessary uses of FILE*

2019-10-09 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Wed Oct  9 14:50:52 2019
New Revision: 374239

URL: http://llvm.org/viewvc/llvm-project?rev=374239&view=rev
Log:
remove a smattering of isolated, unnecessary uses of FILE*

Summary:
There a a few call sites that use FILE* which are easy to
fix without disrupting anything else.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Expression/REPL.cpp

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=374239&r1=374238&r2=374239&view=diff
==
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Wed Oct  9 14:50:52 2019
@@ -467,10 +467,8 @@ void SBDebugger::HandleCommand(const cha
 
 sb_interpreter.HandleCommand(command, result, false);
 
-if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFile());
-if (GetOutputFileHandle() != nullptr)
-  result.PutOutput(GetOutputFile());
+result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=374239&r1=374238&r2=374239&view=diff
==
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Wed Oct  9 14:50:52 2019
@@ -329,10 +329,9 @@ bool IOHandlerEditline::GetLine(std::str
   prompt = GetPrompt();
 
 if (prompt && prompt[0]) {
-  FILE *out = GetOutputFILE();
-  if (out) {
-::fprintf(out, "%s", prompt);
-::fflush(out);
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
   }
 }
   }
@@ -491,10 +490,11 @@ bool IOHandlerEditline::GetLines(StringL
   // Show line numbers if we are asked to
   std::string line;
   if (m_base_line_number > 0 && GetIsInteractive()) {
-FILE *out = GetOutputFILE();
-if (out)
-  ::fprintf(out, "%u%s", m_base_line_number + 
(uint32_t)lines.GetSize(),
-GetPrompt() == nullptr ? " " : "");
+if (m_output_sp) {
+  m_output_sp->Printf("%u%s",
+  m_base_line_number + (uint32_t)lines.GetSize(),
+  GetPrompt() == nullptr ? " " : "");
+}
   }
 
   m_curr_line_idx = lines.GetSize();

Modified: lldb/trunk/source/Expression/REPL.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/REPL.cpp?rev=374239&r1=374238&r2=374239&view=diff
==
--- lldb/trunk/source/Expression/REPL.cpp (original)
+++ lldb/trunk/source/Expression/REPL.cpp Wed Oct  9 14:50:52 2019
@@ -423,7 +423,7 @@ void REPL::IOHandlerInputComplete(IOHand
   .SetBaseLineNumber(m_code.GetSize() + 1);
 }
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->Printf("\n");
 }
   }
 }


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


[Lldb-commits] [lldb] r374238 - SBFile support in SBCommandReturnObject

2019-10-09 Thread Lawrence D'Anna via lldb-commits
Author: lawrence_danna
Date: Wed Oct  9 14:50:49 2019
New Revision: 374238

URL: http://llvm.org/viewvc/llvm-project?rev=374238&view=rev
Log:
SBFile support in SBCommandReturnObject

Summary:
This patch add SBFile interfaces to SBCommandReturnObject, and
removes the internal callers of its FILE* interfaces.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/API/SBCommandReturnObject.h
lldb/trunk/include/lldb/API/SBFile.h
lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h

lldb/trunk/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
lldb/trunk/scripts/interface/SBCommandReturnObject.i
lldb/trunk/source/API/SBCommandReturnObject.cpp
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBFile.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=374238&r1=374237&r2=374238&view=diff
==
--- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Wed Oct  9 14:50:49 2019
@@ -44,13 +44,21 @@ public:
 
   const char *GetError();
 
-  size_t PutOutput(FILE *fh);
+  size_t PutOutput(FILE *fh); // DEPRECATED
+
+  size_t PutOutput(SBFile file);
+
+  size_t PutOutput(FileSP file);
 
   size_t GetOutputSize();
 
   size_t GetErrorSize();
 
-  size_t PutError(FILE *fh);
+  size_t PutError(FILE *fh); // DEPRECATED
+
+  size_t PutError(SBFile file);
+
+  size_t PutError(FileSP file);
 
   void Clear();
 
@@ -68,14 +76,21 @@ public:
 
   bool GetDescription(lldb::SBStream &description);
 
-  // deprecated, these two functions do not take ownership of file handle
-  void SetImmediateOutputFile(FILE *fh);
+  void SetImmediateOutputFile(FILE *fh); // DEPRECATED
+
+  void SetImmediateErrorFile(FILE *fh); // DEPRECATED
+
+  void SetImmediateOutputFile(FILE *fh, bool transfer_ownership); // DEPRECATED
+
+  void SetImmediateErrorFile(FILE *fh, bool transfer_ownership); // DEPRECATED
+
+  void SetImmediateOutputFile(SBFile file);
 
-  void SetImmediateErrorFile(FILE *fh);
+  void SetImmediateErrorFile(SBFile file);
 
-  void SetImmediateOutputFile(FILE *fh, bool transfer_ownership);
+  void SetImmediateOutputFile(FileSP file);
 
-  void SetImmediateErrorFile(FILE *fh, bool transfer_ownership);
+  void SetImmediateErrorFile(FileSP file);
 
   void PutCString(const char *string, int len = -1);
 

Modified: lldb/trunk/include/lldb/API/SBFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFile.h?rev=374238&r1=374237&r2=374238&view=diff
==
--- lldb/trunk/include/lldb/API/SBFile.h (original)
+++ lldb/trunk/include/lldb/API/SBFile.h Wed Oct  9 14:50:49 2019
@@ -15,6 +15,7 @@ namespace lldb {
 
 class LLDB_API SBFile {
   friend class SBDebugger;
+  friend class SBCommandReturnObject;
 
 public:
   SBFile();

Modified: lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h?rev=374238&r1=374237&r2=374238&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h Wed Oct  9 
14:50:49 2019
@@ -62,13 +62,13 @@ public:
 return m_err_stream;
   }
 
-  void SetImmediateOutputFile(FILE *fh, bool transfer_fh_ownership = false) {
-lldb::StreamSP stream_sp(new StreamFile(fh, transfer_fh_ownership));
+  void SetImmediateOutputFile(lldb::FileSP file_sp) {
+lldb::StreamSP stream_sp(new StreamFile(file_sp));
 m_out_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp);
   }
 
-  void SetImmediateErrorFile(FILE *fh, bool transfer_fh_ownership = false) {
-lldb::StreamSP stream_sp(new StreamFile(fh, transfer_fh_ownership));
+  void SetImmediateErrorFile(lldb::FileSP file_sp) {
+lldb::StreamSP stream_sp(new StreamFile(file_sp));
 m_err_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp);
   }
 

Modified: lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h?rev=374238&r1=374237&r2=374238&view=diff
==
--- lldb/trunk/include/lldb/Utility/ReproducerInstrumentation.h (original)
+++ lldb/trunk/include/lldb/Utility/ReproducerInstrumenta

[Lldb-commits] [PATCH] D68678: Speed up accelerator table lookups

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

That qualified name hash the Apple tables used to avoid pulling in DWARF for 
stuff that didn't match. Did this functionality stop working when accelerator 
tables got refactored? The .apple_types has a qualified name hash which is the 
hash of the complete type named (demangled).




Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:114
+
+  // When searching for "std::vector::const_iterator", reject any
+  // files without "vector" early, since there will be many other

The "qualified_name_hash" used to avoid pulling in all DWARF for anything that 
didn't match. Is this not working anymore?


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

https://reviews.llvm.org/D68678



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


[Lldb-commits] [PATCH] D68734: update SBDebugger::SetInputFile() etc to work on native Files

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added a project: LLDB.
lawrence_danna added a parent revision: D68433: SBFile: add a bunch of tests 
that should eventually work..

This patch adds FileSP versions of SetInputFile(),
SetOutputFile, and SetErrorFile().   SWIG will convert native
python file objects into FileSP.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68734

Files:
  lldb/include/lldb/API/SBDebugger.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/interface/SBDebugger.i
  lldb/source/API/SBDebugger.cpp

Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -292,6 +292,11 @@
   SetInputFile((FileSP)std::make_shared(fh, transfer_ownership));
 }
 
+SBError SBDebugger::SetInputFile(FileSP file_sp) {
+  LLDB_RECORD_METHOD(SBError, SBDebugger, SetInputFile, (FileSP), file_sp);
+  return SetInputFile(SBFile(file_sp));
+}
+
 // Shouldn't really be settable after initialization as this could cause lots
 // of problems; don't want users trying to switch modes in the middle of a
 // debugging session.
@@ -332,6 +337,11 @@
   return error;
 }
 
+SBError SBDebugger::SetOutputFile(FileSP file_sp) {
+  LLDB_RECORD_METHOD(SBError, SBDebugger, SetOutputFile, (FileSP), file_sp);
+  return SetOutputFile(SBFile(file_sp));
+}
+
 void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
   LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh,
  transfer_ownership);
@@ -359,6 +369,11 @@
   SetErrorFile((FileSP)std::make_shared(fh, transfer_ownership));
 }
 
+SBError SBDebugger::SetErrorFile(FileSP file_sp) {
+  LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (FileSP), file_sp);
+  return SetErrorFile(SBFile(file_sp));
+}
+
 SBError SBDebugger::SetErrorFile(SBFile file) {
   LLDB_RECORD_METHOD(SBError, SBDebugger, SetErrorFile, (SBFile file), file);
   SBError error;
@@ -1601,6 +1616,8 @@
 
 static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); }
 
+static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); }
+
 static bool GetDefaultArchitectureRedirect(char *arch_name,
size_t arch_name_len) {
   // The function is writing to its argument. Without the redirect it would
@@ -1631,6 +1648,16 @@
  SBFile)>::method<&SBDebugger::SetErrorFile>::doit,
  &SetFileRedirect);
 
+  R.Register(&invoke::method<&SBDebugger::SetInputFile>::doit,
+ &SetFileRedirect);
+  R.Register(&invoke::method<&SBDebugger::SetOutputFile>::doit,
+ &SetFileRedirect);
+  R.Register(&invoke::method<&SBDebugger::SetErrorFile>::doit,
+ &SetFileRedirect);
+
   LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ());
   LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &));
   LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));
Index: lldb/scripts/interface/SBDebugger.i
===
--- lldb/scripts/interface/SBDebugger.i
+++ lldb/scripts/interface/SBDebugger.i
@@ -165,21 +165,27 @@
 void
 SkipLLDBInitFiles (bool b);
 
+%feature("autodoc", "DEPRECATED, use SetInputFile");
 void
 SetInputFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use SetOutputFile");
 void
 SetOutputFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use SetErrorFile");
 void
 SetErrorFileHandle (FILE *f, bool transfer_ownership);
 
+%feature("autodoc", "DEPRECATED, use GetInputFile");
 FILE *
 GetInputFileHandle ();
 
+%feature("autodoc", "DEPRECATED, use GetOutputFile");
 FILE *
 GetOutputFileHandle ();
 
+%feature("autodoc", "DEPRECATED, use GetErrorFile");
 FILE *
 GetErrorFileHandle ();
 
@@ -192,6 +198,15 @@
 SBError
 SetErrorFile (SBFile file);
 
+SBError
+SetInputFile (FileSP file);
+
+SBError
+SetOutputFile (FileSP file);
+
+SBError
+SetErrorFile (FileSP file);
+
 SBFile
 GetInputFile ();
 
Index: lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
+++ lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
@@ -551,7 +551,6 @@
 
 @add_test_categories(['pyapi'])
 @skipIf(py_version=['<', (3,)])
-@expectedFailure # fixme multiple problems with this
 def test_string_out(self):
 f = io.StringIO()
 status = self.debugger.SetOutputFile(f)
@@ -561,7 +560,6 @@
 
 
 @add_test_categories(['pyapi'])
-@expectedFailure # FIXME need FileSP

[Lldb-commits] [PATCH] D68433: SBFile: add a bunch of tests that should eventually work.

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb24022cd723f: SBFile: add a bunch of tests that should 
eventually work. (authored by lawrence_danna).

Changed prior to commit:
  https://reviews.llvm.org/D68433?vs=223979&id=224178#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68433

Files:
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/Python/python-typemaps.swig

Index: lldb/scripts/Python/python-typemaps.swig
===
--- lldb/scripts/Python/python-typemaps.swig
+++ lldb/scripts/Python/python-typemaps.swig
@@ -444,19 +444,19 @@
   $1 = nullptr;
else if (!lldb_private::PythonFile::Check($input)) {
   int fd = PyObject_AsFileDescriptor($input);
+  if (fd < 0 || PyErr_Occurred())
+return nullptr;
   PythonObject py_input(PyRefType::Borrowed, $input);
   PythonString py_mode = py_input.GetAttributeValue("mode").AsType();
-
-  if (-1 != fd && py_mode.IsValid()) {
- FILE *f;
- if ((f = fdopen(fd, py_mode.GetString().str().c_str(
-$1 = f;
- else
-PyErr_SetString(PyExc_TypeError, strerror(errno));
-  } else {
- PyErr_SetString(PyExc_TypeError,"not a file-like object");
- return nullptr;
-  }
+  if (!py_mode.IsValid() || PyErr_Occurred())
+return nullptr;
+FILE *f;
+if ((f = fdopen(fd, py_mode.GetString().str().c_str(
+  $1 = f;
+else {
+  PyErr_SetString(PyExc_TypeError, strerror(errno));
+  return nullptr;
+}
}
else
{
Index: lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
+++ lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
@@ -13,7 +13,7 @@
 import lldb
 from lldbsuite.test import  lldbtest
 from lldbsuite.test.decorators import (
-add_test_categories, skipIf, skipIfWindows)
+add_test_categories, skipIf, skipIfWindows, expectedFailure)
 
 class OhNoe(Exception):
 pass
@@ -162,7 +162,9 @@
 with open(self.out_filename, 'w') as f:
 self.debugger.SetErrorFileHandle(f, False)
 self.handleCmd('lolwut', check=False, collect_result=False)
-self.debugger.GetErrorFileHandle().write('FOOBAR\n')
+f2 = self.debugger.GetErrorFileHandle()
+f2.write('FOOBAR\n')
+f2.flush()
 lldb.SBDebugger.Destroy(self.debugger)
 with open(self.out_filename, 'r') as f:
 errors = f.read()
@@ -181,6 +183,16 @@
 
 
 @add_test_categories(['pyapi'])
+def test_legacy_file_error(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+debugger.SetErrorFileHandle(f, False)
+self.handleCmd('lolwut', check=False, collect_result=False)
+with open(self.out_filename, 'r') as f:
+errors = f.read()
+self.assertTrue(re.search(r'error:.*lolwut', errors))
+
+@add_test_categories(['pyapi'])
 def test_sbfile_type_errors(self):
 sbf = lldb.SBFile()
 self.assertRaises(TypeError, sbf.Write, None)
@@ -270,6 +282,17 @@
 
 
 @add_test_categories(['pyapi'])
+def test_help(self):
+debugger = self.debugger
+with open(self.out_filename, 'w') as f:
+status = debugger.SetOutputFile(lldb.SBFile(f))
+self.assertTrue(status.Success())
+self.handleCmd("help help", check=False, collect_result=False)
+with open(self.out_filename, 'r') as f:
+self.assertIn('Show a list of all debugger commands', f.read())
+
+
+@add_test_categories(['pyapi'])
 def test_immediate(self):
 with open(self.out_filename, 'w') as f:
 ret = lldb.SBCommandReturnObject()
@@ -278,9 +301,7 @@
 interpreter.HandleCommand("help help", ret)
 # make sure the file wasn't closed early.
 f.write("\nQUUX\n")
-
 ret = None # call destructor and flush streams
-
 with open(self.out_filename, 'r') as f:
 output = f.read()
 self.assertTrue(re.search(r'Show a list of all debugger commands', output))
@@ -288,6 +309,37 @@
 
 
 @add_test_categories(['pyapi'])
+@expectedFailure # FIXME need SBFile interfaces on SBCommandReturnObject
+def test_immediate_string(self):
+f = io.StringIO()
+ret = lldb.SBCommandReturnObject()
+ret.SetImmediateOutputFile(f)
+interpreter = self.debugger.GetCommandInterpreter()
+interpreter.HandleCommand("help help", ret)
+# make sure the file wasn't closed early.
+f.write("\nQUUX\n")
+   

[Lldb-commits] [PATCH] D68434: SBFile support in SBCommandReturnObject

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9eb137192364: SBFile support in SBCommandReturnObject 
(authored by lawrence_danna).

Changed prior to commit:
  https://reviews.llvm.org/D68434?vs=223980&id=224179#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68434

Files:
  lldb/include/lldb/API/SBCommandReturnObject.h
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/Interpreter/CommandReturnObject.h
  lldb/include/lldb/Utility/ReproducerInstrumentation.h
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/scripts/interface/SBCommandReturnObject.i
  lldb/source/API/SBCommandReturnObject.cpp
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBFile.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -11,6 +11,7 @@
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBFile.h"
 #include "lldb/API/SBHostOS.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBReproducer.h"
@@ -499,16 +500,16 @@
   SBCommandReturnObject result;
   sb_interpreter.SourceInitFileInHomeDirectory(result);
   if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFileHandle());
-result.PutOutput(m_debugger.GetOutputFileHandle());
+result.PutError(m_debugger.GetErrorFile());
+result.PutOutput(m_debugger.GetOutputFile());
   }
 
   // Source the local .lldbinit file if it exists and we're allowed to source.
   // Here we want to always print the return object because it contains the
   // warning and instructions to load local lldbinit files.
   sb_interpreter.SourceInitFileInCurrentWorkingDirectory(result);
-  result.PutError(m_debugger.GetErrorFileHandle());
-  result.PutOutput(m_debugger.GetOutputFileHandle());
+  result.PutError(m_debugger.GetErrorFile());
+  result.PutOutput(m_debugger.GetOutputFile());
 
   // We allow the user to specify an exit code when calling quit which we will
   // return when exiting.
@@ -574,8 +575,8 @@
   }
 
   if (m_option_data.m_debug_mode) {
-result.PutError(m_debugger.GetErrorFileHandle());
-result.PutOutput(m_debugger.GetOutputFileHandle());
+result.PutError(m_debugger.GetErrorFile());
+result.PutOutput(m_debugger.GetOutputFile());
   }
 
   const bool handle_events = true;
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -879,8 +879,9 @@
   ::setbuf(outfile_handle, nullptr);
 
 result->SetImmediateOutputFile(
-debugger.GetOutputFile().GetStream());
-result->SetImmediateErrorFile(debugger.GetErrorFile().GetStream());
+debugger.GetOutputStream().GetFileSP());
+result->SetImmediateErrorFile(
+debugger.GetErrorStream().GetFileSP());
   }
 }
   }
Index: lldb/source/API/SBFile.cpp
===
--- lldb/source/API/SBFile.cpp
+++ lldb/source/API/SBFile.cpp
@@ -23,12 +23,13 @@
 SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); }
 
 SBFile::SBFile(FILE *file, bool transfer_ownership) {
+  LLDB_RECORD_DUMMY(void, SBFile, (FILE *, bool), file, transfer_ownership);
   m_opaque_sp = std::make_shared(file, transfer_ownership);
 }
 
 SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) {
-  LLDB_RECORD_CONSTRUCTOR(SBFile, (int, const char *, bool), fd, mode,
-  transfer_owndership);
+  LLDB_RECORD_DUMMY(void, SBFile, (int, const char *, bool), fd, mode,
+transfer_owndership);
   auto options = File::GetOptionsFromMode(mode);
   m_opaque_sp = std::make_shared(fd, options, transfer_owndership);
 }
@@ -104,9 +105,9 @@
 
 namespace lldb_private {
 namespace repro {
+
 template <> void RegisterMethods(Registry &R) {
-  LLDB_REGISTER_CONSTRUCTOR(SBFile, ());
-  LLDB_REGISTER_CONSTRUCTOR(SBFile, (int, const char *, bool));
+
   LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ());
   LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,());
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -468,9 +468,9 @@
 sb_interpreter.HandleCommand(command, result, false);
 
 if (GetErrorFileHandle() != nul

[Lldb-commits] [PATCH] D68444: remove a smattering of isolated, unnecessary uses of FILE*

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5da2bc22badd: remove a smattering of isolated, unnecessary 
uses of FILE* (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68444

Files:
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -423,7 +423,7 @@
   .SetBaseLineNumber(m_code.GetSize() + 1);
 }
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->Printf("\n");
 }
   }
 }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -329,10 +329,9 @@
   prompt = GetPrompt();
 
 if (prompt && prompt[0]) {
-  FILE *out = GetOutputFILE();
-  if (out) {
-::fprintf(out, "%s", prompt);
-::fflush(out);
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
   }
 }
   }
@@ -491,10 +490,11 @@
   // Show line numbers if we are asked to
   std::string line;
   if (m_base_line_number > 0 && GetIsInteractive()) {
-FILE *out = GetOutputFILE();
-if (out)
-  ::fprintf(out, "%u%s", m_base_line_number + 
(uint32_t)lines.GetSize(),
-GetPrompt() == nullptr ? " " : "");
+if (m_output_sp) {
+  m_output_sp->Printf("%u%s",
+  m_base_line_number + (uint32_t)lines.GetSize(),
+  GetPrompt() == nullptr ? " " : "");
+}
   }
 
   m_curr_line_idx = lines.GetSize();
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -467,10 +467,8 @@
 
 sb_interpreter.HandleCommand(command, result, false);
 
-if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFile());
-if (GetOutputFileHandle() != nullptr)
-  result.PutOutput(GetOutputFile());
+result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -423,7 +423,7 @@
   .SetBaseLineNumber(m_code.GetSize() + 1);
 }
 if (extra_line) {
-  fprintf(output_sp->GetFile().GetStream(), "\n");
+  output_sp->Printf("\n");
 }
   }
 }
Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -329,10 +329,9 @@
   prompt = GetPrompt();
 
 if (prompt && prompt[0]) {
-  FILE *out = GetOutputFILE();
-  if (out) {
-::fprintf(out, "%s", prompt);
-::fflush(out);
+  if (m_output_sp) {
+m_output_sp->Printf("%s", prompt);
+m_output_sp->Flush();
   }
 }
   }
@@ -491,10 +490,11 @@
   // Show line numbers if we are asked to
   std::string line;
   if (m_base_line_number > 0 && GetIsInteractive()) {
-FILE *out = GetOutputFILE();
-if (out)
-  ::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(),
-GetPrompt() == nullptr ? " " : "");
+if (m_output_sp) {
+  m_output_sp->Printf("%u%s",
+  m_base_line_number + (uint32_t)lines.GetSize(),
+  GetPrompt() == nullptr ? " " : "");
+}
   }
 
   m_curr_line_idx = lines.GetSize();
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -467,10 +467,8 @@
 
 sb_interpreter.HandleCommand(command, result, false);
 
-if (GetErrorFileHandle() != nullptr)
-  result.PutError(GetErrorFile());
-if (GetOutputFileHandle() != nullptr)
-  result.PutOutput(GetOutputFile());
+result.PutError(m_opaque_sp->GetErrorStream().GetFileSP());
+result.PutOutput(m_opaque_sp->GetOutputStream().GetFileSP());
 
 if (!m_opaque_sp->GetAsyncExecution()) {
   SBProcess process(GetCommandInterpreter().GetProcess());
___

[Lldb-commits] [lldb] r374242 - Fix a crasher due to an assert when two files have the same UUID but different paths.

2019-10-09 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Wed Oct  9 15:03:15 2019
New Revision: 374242

URL: http://llvm.org/viewvc/llvm-project?rev=374242&view=rev
Log:
Fix a crasher due to an assert when two files have the same UUID but different 
paths.

Summary: The PlaceholderObjectFile has an assert in SetLoadAddress that fires 
if "m_base == value" is not true. To avoid this, we create check that the base 
address matches, and if it doesn't we clear the module that was found using the 
UUID so that we create a new PlaceholderObjectFile. Added a test to cover this 
issue.

Reviewers: labath, aadsm, dvlahovski

Subscribers: lldb-commits

Tags: #lldb

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/linux-arm-same-uuids.yaml
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py?rev=374242&r1=374241&r2=374242&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
 Wed Oct  9 15:03:15 2019
@@ -42,7 +42,7 @@ class MiniDumpUUIDTestCase(TestBase):
 def test_zero_uuid_modules(self):
 """
 Test multiple modules having a MINIDUMP_MODULE.CvRecord that is 
valid,
-but contains a PDB70 value whose age is zero and whose UUID values 
are 
+but contains a PDB70 value whose age is zero and whose UUID values 
are
 all zero. Prior to a fix all such modules would be duplicated to 
the
 first one since the UUIDs claimed to be valid and all zeroes. Now 
we
 ensure that the UUID is not valid for each module and that we have
@@ -56,7 +56,7 @@ class MiniDumpUUIDTestCase(TestBase):
 def test_uuid_modules_no_age(self):
 """
 Test multiple modules having a MINIDUMP_MODULE.CvRecord that is 
valid,
-and contains a PDB70 value whose age is zero and whose UUID values 
are 
+and contains a PDB70 value whose age is zero and whose UUID values 
are
 valid. Ensure we decode the UUID and don't include the age field 
in the UUID.
 """
 modules = self.get_minidump_modules("linux-arm-uuids-no-age.yaml")
@@ -68,7 +68,7 @@ class MiniDumpUUIDTestCase(TestBase):
 def test_uuid_modules_no_age_apple(self):
 """
 Test multiple modules having a MINIDUMP_MODULE.CvRecord that is 
valid,
-and contains a PDB70 value whose age is zero and whose UUID values 
are 
+and contains a PDB70 value whose age is zero and whose UUID values 
are
 valid. Ensure we decode the UUID and don't include the age field 
in the UUID.
 Also ensure that the first uint32_t is byte swapped, along with 
the next
 two uint16_t values. Breakpad incorrectly byte swaps these values 
when it
@@ -83,7 +83,7 @@ class MiniDumpUUIDTestCase(TestBase):
 def test_uuid_modules_with_age(self):
 """
 Test multiple modules having a MINIDUMP_MODULE.CvRecord that is 
valid,
-and contains a PDB70 value whose age is valid and whose UUID 
values are 
+and contains a PDB70 value whose age is valid and whose UUID 
values are
 valid. Ensure we decode the UUID and include the age field in the 
UUID.
 """
 modules = self.get_minidump_modules("linux-arm-uuids-with-age.yaml")
@@ -121,13 +121,31 @@ class MiniDumpUUIDTestCase(TestBase):
 self.verify_module(modules[0], "/not/exist/a", None)
 self.verify_module(modules[1], "/not/exist/b", None)
 
+def test_uuid_modules_elf_build_id_same(self):
+"""
+Test multiple modules having a MINIDUMP_MODULE.CvRecord that is
+valid, and contains a ELF build ID whose value is the same. There
+is an assert in the PlaceholderObjectFile that was firing when we
+encountered this which was crashing the process that was checking
+if PlaceholderObjectFile.m_base was the same as the address this
+fake module was being loaded at. We need to ensure we don't crash
+in such cases and that we add both modules even though they have
+the same UUID.
+"""
+modules = self.get_minidump_modules("linux-arm-same-uuids.yaml")
+self.assertEqual(2, len(modules))
+self.verify_module(modules[0], "/file/does/not/exist/a",
+   

[Lldb-commits] [PATCH] D68738: update TestRunCommandInterpreterAPI to use SBFile

2019-10-09 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added a subscriber: aprantl.
Herald added a project: LLDB.

If you look at what this test is doing, it's actually quite
mysterious why it works at all.   It sets the input file
inside a "with open".   As soon as the with block ends,
that file will be closed.   And yet somehow LLDB reads
commands from it anyway.What's actually happening is that
the file descriptor gets dup'd when something inside LLDB
calls File::GetStream().   I think it's fair to say that
what this test is doing is illegal and it has no right
to expect it to work.

This patch updates the test with two cases.  One uses
the SBFile api, and actually transfers ownership of
the original file descriptor to the debugger.   The other
just uses the old FILE* API, but in a sane way.

I also set NO_DEBUG_INFO_TESTCASE, because this test doesn't
use any debug info and doesn't need to run three times.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68738

Files:
  
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py


Index: 
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
===
--- 
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
+++ 
lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
@@ -5,8 +5,46 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+class CommandRunInterpreterLegacyAPICase(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+self.stdin_path = self.getBuildArtifact("stdin.txt")
+
+with open(self.stdin_path, 'w') as input_handle:
+input_handle.write("nonexistingcommand\nquit")
+
+# Python will close the file descriptor if all references
+# to the filehandle object lapse, so we need to keep one
+# around.
+self.filehandle = open(self.stdin_path, 'r')
+self.dbg.SetInputFileHandle(self.filehandle, False)
+
+# No need to track the output
+self.devnull = open(os.devnull, 'w')
+self.dbg.SetOutputFileHandle(self.devnull, False)
+self.dbg.SetErrorFileHandle (self.devnull, False)
+
+@add_test_categories(['pyapi'])
+def test_run_session_with_error_and_quit(self):
+"""Run non-existing and quit command returns appropriate values"""
+
+n_errors, quit_requested, has_crashed = self.dbg.RunCommandInterpreter(
+True, False, lldb.SBCommandInterpreterRunOptions(), 0, False,
+False)
+
+self.assertGreater(n_errors, 0)
+self.assertTrue(quit_requested)
+self.assertFalse(has_crashed)
+
+
 class CommandRunInterpreterAPICase(TestBase):
 
+NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
@@ -17,13 +55,12 @@
 with open(self.stdin_path, 'w') as input_handle:
 input_handle.write("nonexistingcommand\nquit")
 
-with open(self.stdin_path, 'r') as input_handle:
-self.dbg.SetInputFileHandle(input_handle, False)
+self.dbg.SetInputFile(open(self.stdin_path, 'r'))
 
 # No need to track the output
 devnull = open(os.devnull, 'w')
-self.dbg.SetOutputFileHandle(devnull, False)
-self.dbg.SetErrorFileHandle(devnull, False)
+self.dbg.SetOutputFile(devnull)
+self.dbg.SetErrorFile(devnull)
 
 @add_test_categories(['pyapi'])
 def test_run_session_with_error_and_quit(self):


Index: lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/interpreter/TestRunCommandInterpreterAPI.py
@@ -5,8 +5,46 @@
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 
+class CommandRunInterpreterLegacyAPICase(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+self.stdin_path = self.getBuildArtifact("stdin.txt")
+
+with open(self.stdin_path, 'w') as input_handle:
+input_handle.write("nonexistingcommand\nquit")
+
+# Python will close the file descriptor if all references
+# to the filehandle object lapse, so we need to keep one
+# around.
+self.filehandle = open(self.stdin_path, 'r')
+self.dbg.SetInputFileHandle(self.filehandle, False)
+
+# No need to track the output
+self.devnull = open(os.devnull, 'w')
+self.dbg.SetOutput

[Lldb-commits] [PATCH] D68454: Fix the unwinding plan augmentation from x86 assembly

2019-10-09 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

Hi Jaroslav, I apologize for taking so long to look at this; I've been 
heads-down on a project the past few weeks an my email inbox is a disaster 
right now.

This patch looks good, thanks for doing this.  The fragile thing is that we 
have two methods doing very similar things -- 
GetNonCallSiteUnwindPlanFromAssembly() and AugmentUnwindPlanFromCallSite() -- 
and we've got some divergence between the two that make it harder to spot bugs 
like this.  I can't remember the history well, but I have a feeling that 
AugmentUnwindPlanFromCallSite() is basically an older version of how 
GetNonCallSiteUnwindPlanFromAssembly() was written.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68454



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


[Lldb-commits] [PATCH] D68734: update SBDebugger::SetInputFile() etc to work on native Files

2019-10-09 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/include/lldb/API/SBDebugger.h:97-102
+  SBError SetInputFile(FileSP file);
+
+  SBError SetOutputFile(FileSP file);
+
+  SBError SetErrorFile(FileSP file);
+

Are these really for public consumption? I would hope not, and might add then 
as protected and friend in any code that needs to use them? At the very least a 
comment specifying these are for internal use. Does SBFile not have a way to 
construct with a FileSP? Maybe these are not needed if that is the case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68734



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


  1   2   >