[Lldb-commits] [PATCH] D59606: [lldb] [WIP/RFC] Add missing retries on EINTR

2019-03-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 191641.
mgorny added a comment.

Covered more callsites.


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

https://reviews.llvm.org/D59606

Files:
  lldb/source/Host/common/PseudoTerminal.cpp
  lldb/source/Host/common/Socket.cpp
  lldb/source/Host/common/TCPSocket.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Host/posix/DomainSocket.cpp
  lldb/source/Host/posix/FileSystem.cpp
  lldb/source/Host/posix/LockFilePosix.cpp
  lldb/source/Host/posix/PipePosix.cpp
  lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
  lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/tools/darwin-debug/darwin-debug.cpp
  lldb/tools/debugserver/source/DNB.cpp
  lldb/tools/debugserver/source/PseudoTerminal.cpp
  lldb/tools/debugserver/source/RNBRemote.cpp
  lldb/tools/debugserver/source/RNBSocket.cpp
  lldb/tools/debugserver/source/debugserver.cpp
  lldb/tools/lldb-mi/MIUtilFileStd.cpp
  lldb/tools/lldb-server/lldb-platform.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -41,6 +41,7 @@
 #include 
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -90,7 +91,8 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
+  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
+  sockfd, (struct sockaddr *)&cli_addr, &clilen);
   if (newsockfd < 0)
 if (g_vsc.log)
   *g_vsc.log << "error: accept (" << strerror(errno) << ")"
@@ -1074,7 +1076,7 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
-  FILE *out = fopen(dev_null_path, "w");
+  FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
   if (out) {
 // Set the output and error file handles to redirect into nothing otherwise
 // if any code in LLDB prints to the debugger file handles, the output and
Index: lldb/tools/lldb-server/lldb-platform.cpp
===
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -19,6 +19,7 @@
 
 #include 
 
+#include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 
@@ -315,7 +316,8 @@
 printf("Connection established.\n");
 if (g_server) {
   // Collect child zombie processes.
-  while (waitpid(-1, nullptr, WNOHANG) > 0)
+  while (llvm::sys::RetryAfterSignal(-1, waitpid,
+-1, nullptr, WNOHANG) > 0)
 ;
   if (fork()) {
 // Parent doesn't need a connection to the lldb client
Index: lldb/tools/lldb-mi/MIUtilFileStd.cpp
===
--- lldb/tools/lldb-mi/MIUtilFileStd.cpp
+++ lldb/tools/lldb-mi/MIUtilFileStd.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Host/FileSystem.h"
 
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
 
 //++
 //
@@ -83,7 +84,8 @@
 
 #if !defined(_MSC_VER)
   // Open with 'write' and 'binary' mode
-  m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb");
+  m_pFileHandle = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+  vFileNamePath.c_str(), "wb");
 #else
   // Open a file with exclusive write and shared read permissions
   std::wstring path;
@@ -226,7 +228,8 @@
 return false;
 
   FILE *pTmp = nullptr;
-  pTmp = ::fopen(vFileNamePath.c_str(), "wb");
+  pTmp = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+  vFileNamePath.c_str(), "wb");
   if (pTmp != nullptr) {
 ::fclose(pTmp);
 return true;
Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -42,6 +42,8 @@
 #include "RNBSocket.h"
 #include "SysSignal.h"
 
+#include "llvm/Support/Errno.h"
+
 // Global PID in case we get a signal and need to stop the process...
 nub_process_t g_pid = INVALID_NUB_PROCESS;
 
@@ -681,8 +683,9 @@
 saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0';
 saddr_un.sun_len = SUN_LEN(&saddr_un);
 
-if (::connect(s, (struct sockaddr *)&saddr_un,
-  static_cast(SUN_LEN(&saddr_un))) < 0) {
+if (llvm::sys::RetryAfterSignal(-1, ::connect, s,
+ 

[Lldb-commits] [PATCH] D59579: Use list comprehension instead of map/filter to prepare Python2/3 compat

2019-03-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB356647: Use list comprehension instead of map/filter to 
prepare Python2/3 compat (authored by serge_sans_paille, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59579?vs=191441&id=191642#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59579

Files:
  packages/Python/lldbsuite/test/dotest.py
  scripts/analyze-project-deps.py
  scripts/swig_bot_lib/local.py
  utils/lui/lldbutil.py
  utils/vim-lldb/python-vim-lldb/lldb_controller.py

Index: packages/Python/lldbsuite/test/dotest.py
===
--- packages/Python/lldbsuite/test/dotest.py
+++ packages/Python/lldbsuite/test/dotest.py
@@ -524,8 +524,7 @@
 
 # Gather all the dirs passed on the command line.
 if len(args.args) > 0:
-configuration.testdirs = list(
-map(lambda x: os.path.realpath(os.path.abspath(x)), args.args))
+configuration.testdirs = [os.path.realpath(os.path.abspath(x)) for x in args.args]
 # Shut off multiprocessing mode when test directories are specified.
 configuration.no_multiprocess_test_runner = True
 
Index: utils/lui/lldbutil.py
===
--- utils/lui/lldbutil.py
+++ utils/lui/lldbutil.py
@@ -84,7 +84,7 @@
 return None
 
 packed = struct.pack(fmt, val)
-return bytearray(map(ord, packed))
+return bytearray(ord(x) for x in packed)
 
 
 def bytearray_to_int(bytes, bytesize):
@@ -706,7 +706,7 @@
 def GetFuncName(i):
 return thread.GetFrameAtIndex(i).GetFunctionName()
 
-return map(GetFuncName, range(thread.GetNumFrames()))
+return [GetFuncName(i) for i in range(thread.GetNumFrames())]
 
 
 def get_symbol_names(thread):
@@ -716,7 +716,7 @@
 def GetSymbol(i):
 return thread.GetFrameAtIndex(i).GetSymbol().GetName()
 
-return map(GetSymbol, range(thread.GetNumFrames()))
+return [GetSymbol(i) for i in range(thread.GetNumFrames())]
 
 
 def get_pc_addresses(thread):
@@ -726,7 +726,7 @@
 def GetPCAddress(i):
 return thread.GetFrameAtIndex(i).GetPCAddress()
 
-return map(GetPCAddress, range(thread.GetNumFrames()))
+return [GetPCAddress(i) for i in range(thread.GetNumFrames())]
 
 
 def get_filenames(thread):
@@ -737,7 +737,7 @@
 return thread.GetFrameAtIndex(
 i).GetLineEntry().GetFileSpec().GetFilename()
 
-return map(GetFilename, range(thread.GetNumFrames()))
+return [GetFilename(i) for i in range(thread.GetNumFrames())]
 
 
 def get_line_numbers(thread):
@@ -747,7 +747,7 @@
 def GetLineNumber(i):
 return thread.GetFrameAtIndex(i).GetLineEntry().GetLine()
 
-return map(GetLineNumber, range(thread.GetNumFrames()))
+return [GetLineNumber(i) for i in range(thread.GetNumFrames())]
 
 
 def get_module_names(thread):
@@ -758,7 +758,7 @@
 return thread.GetFrameAtIndex(
 i).GetModule().GetFileSpec().GetFilename()
 
-return map(GetModuleName, range(thread.GetNumFrames()))
+return [GetModuleName(i) for i in range(thread.GetNumFrames())]
 
 
 def get_stack_frames(thread):
@@ -768,7 +768,7 @@
 def GetStackFrame(i):
 return thread.GetFrameAtIndex(i)
 
-return map(GetStackFrame, range(thread.GetNumFrames()))
+return [GetStackFrame(i) for i in range(thread.GetNumFrames())]
 
 
 def print_stacktrace(thread, string_buffer=False):
Index: utils/vim-lldb/python-vim-lldb/lldb_controller.py
===
--- utils/vim-lldb/python-vim-lldb/lldb_controller.py
+++ utils/vim-lldb/python-vim-lldb/lldb_controller.py
@@ -102,8 +102,8 @@
 pass
 
 if result.GetSize() > 0:
-results = filter(None, [result.GetStringAtIndex(x)
-for x in range(result.GetSize())])
+results = [_f for _f in [result.GetStringAtIndex(x)
+for x in range(result.GetSize())] if _f]
 return results
 else:
 return []
Index: scripts/analyze-project-deps.py
===
--- scripts/analyze-project-deps.py
+++ scripts/analyze-project-deps.py
@@ -65,7 +65,7 @@
 for (base, dirs, files) in os.walk(inc_dir):
 dir = os.path.basename(base)
 relative = os.path.relpath(base, inc_dir)
-inc_files = filter(lambda x : os.path.splitext(x)[1] in [".h"], files)
+inc_files = [x for x in files if os.path.splitext(x)[1] in [".h"]]
 relative = relative.replace("\\", "/")
 for inc in inc_files:
 inc_path = os.path.join(base, inc)
@@ -74,7 +74,7 @@
 for (base, dirs, files) in os.walk(src_dir):
 dir = os.path.basename(base)
 relative = os.path.relpath(base, src_dir)
-src_files = filter(lambda x : os.path.splitex

[Lldb-commits] [PATCH] D54747: Discard debuginfo for object files empty after GC

2019-03-21 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: lld/ELF/MarkLive.cpp:192
+  Sec->Live = true;
+  if (Sec->kind() != SectionBase::Kind::Regular &&
+  Sec->kind() != SectionBase::Kind::Merge)

This check can be changed to `!isa && !isa`. 
But do you just want to exclude `EhInputSection`?


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D54747



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


[Lldb-commits] [PATCH] D59606: [lldb] [WIP/RFC] Add missing retries on EINTR

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:255-258
+llvm::sys::RetryAfterSignal(-1, ::cfsetospeed,
+&options, B115200);
+llvm::sys::RetryAfterSignal(-1, ::cfsetispeed,
+&options, B115200);

IIUC, these only manipulate the `options` struct, so I don't see how they could 
fail with EINTR. OTOH, the `tcsetattr` call below is documented to return EINTR 
at least on NetBSD 
.



Comment at: lldb/tools/debugserver/source/DNB.cpp:173
   const pid_t pid = (pid_t)death_event.ident;
-  const pid_t child_pid = waitpid(pid, &status, 0);
+  const pid_t child_pid = llvm::sys::RetryAfterSignal(-1, waitpid,
+  pid, &status, 0);

You can't use llvm code from debugserver. I am not really sure what 
`darwin-debug` is, but the same may be true for that as well. If I were you, 
I'd just leave these two alone.



Comment at: lldb/tools/lldb-server/lldb-platform.cpp:319
   // Collect child zombie processes.
-  while (waitpid(-1, nullptr, WNOHANG) > 0)
+  while (llvm::sys::RetryAfterSignal(-1, waitpid,
+-1, nullptr, WNOHANG) > 0)

I don't think this is necessary here with WNOHANG and everything.


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

https://reviews.llvm.org/D59606



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


[Lldb-commits] [PATCH] D59606: [lldb] [WIP/RFC] Add missing retries on EINTR

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

I think this is fine, except for the things I pointed out inline. As for 
`SafelyCloseFileDescriptor` (wow) thing, I think we should use that, given that 
it's already there. I suggest making a separate patch for that.


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

https://reviews.llvm.org/D59606



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


[Lldb-commits] [PATCH] D54747: Discard debuginfo for object files empty after GC

2019-03-21 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

In D54747#1342666 , @rocallahan wrote:

> Here are some results for the rusoto test in 
> https://github.com/rust-lang/rust/issues/56068#issue-382175735:
>
> | LLD   | Binary size in bytes |
> | LLD 6.0.1 | 43,791,192   |
> | LLD 8.0.0 1cfcf404f6b23943405bc3c5bb5940b10b914624   | 
> 43,861,056   |
> | LLD 8.0.0 1cfcf404f6b23943405bc3c5bb5940b10b914624 `--start-lib` | 
> 43,844,760   |
> | LLD 8.0.0 1cfcf404f6b23943405bc3c5bb5940b10b914624 + this patch  | 
> 6,281,488|
> |
>
> For `--start-lib` I wrapped `--start-lib`/`--end-lib` around all object files.
>
> As I expected `--start-lib` didn't make much difference. The dependencies 
> containing debuginfo that I want to be GCed away are already packaged into 
> static libraries before being passed to the final link.


The improvement of this patch looks really promising! Do you have numbers with 
ld.bfd and gold?




Comment at: lld/ELF/MarkLive.cpp:195
+return;
+  if (!Sec->File || !ObjFile::classof(Sec->File))
+return;

> `!ObjFile::classof(Sec->File)`

Can this happen?



Comment at: lld/ELF/MarkLive.cpp:199
+Sec->getFile()->HasLiveCodeOrData = true;
+  }
+}

The brace is redundant.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D54747



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


Re: [Lldb-commits] [lldb] r356643 - [Reproducers] Properly handle QEnvironment packets

2019-03-21 Thread Pavel Labath via lldb-commits

On 21/03/2019 05:08, Jonas Devlieghere via lldb-commits wrote:

Author: jdevlieghere
Date: Wed Mar 20 21:08:31 2019
New Revision: 356643

URL: http://llvm.org/viewvc/llvm-project?rev=356643&view=rev
Log:
[Reproducers] Properly handle QEnvironment packets

On Linux, a QEnvironment packet is sent for every environment variable.
This breaks replay when the number of environment variables is different
then during capture. The solution is to always reply with OK.

Modified:
 lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test
 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp

Modified: lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test?rev=356643&r1=356642&r2=356643&view=diff
==
--- lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test (original)
+++ lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test Wed Mar 20 21:08:31 2019
@@ -9,7 +9,7 @@
  # RUN: rm -rf %t.repro
  # RUN: %clang %S/Inputs/simple.c -g -o %t.out
  # RUN: %lldb -x -b -s %S/Inputs/GDBRemoteCapture.in --capture --capture-path 
%t.repro %t.out | FileCheck %s --check-prefix CHECK --check-prefix CAPTURE
-# RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK 
--check-prefix REPLAY
+# RUN: env FOO=BAR %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK 
--check-prefix REPLAY
  
  # CHECK: Breakpoint 1

  # CHECK: Process {{.*}} stopped

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp?rev=356643&r1=356642&r2=356643&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
 Wed Mar 20 21:08:31 2019
@@ -107,6 +107,13 @@ GDBRemoteCommunicationReplayServer::GetP
  m_send_acks = false;
}
  
+  // A QEnvironment packet is sent for every environment variable. If the

+  // number of environment variables is different during replay, the replies
+  // become out of sync.
+  if (packet.GetStringRef().find("QEnvironment") == 0) {
+return SendRawPacketNoLock("$OK#9a", true);
+  }
+
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
while (!m_packet_history.empty()) {
  // Pop last packet from the history.
@@ -122,6 +129,14 @@ GDBRemoteCommunicationReplayServer::GetP
   "GDBRemoteCommunicationReplayServer actual packet: '{}'\n",
   packet.GetStringRef());
}
+
+  // Ignore QEnvironment packets as they're handled earlier.
+  if (entry.packet.data.find("QEnvironment") == 1) {
+assert(m_packet_history.back().type ==
+   GDBRemoteCommunicationHistory::ePacketTypeRecv);
+m_packet_history.pop_back();
+  }
+
continue;
  }
  



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



It sounds like we should have an "environment provider" which captures 
and reinstates the environment during record and replay respectively.

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


[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 191644.
mgorny marked 5 inline comments as done.
mgorny retitled this revision from "[lldb] [WIP/RFC] Add missing retries on 
EINTR" to "[lldb] Add missing EINTR handling".
mgorny edited the summary of this revision.
mgorny added a comment.

Thanks for the review. Addressed comments.


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

https://reviews.llvm.org/D59606

Files:
  lldb/source/Host/common/PseudoTerminal.cpp
  lldb/source/Host/common/Socket.cpp
  lldb/source/Host/common/TCPSocket.cpp
  lldb/source/Host/posix/DomainSocket.cpp
  lldb/source/Host/posix/FileSystem.cpp
  lldb/source/Host/posix/LockFilePosix.cpp
  lldb/source/Host/posix/PipePosix.cpp
  lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
  lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/tools/lldb-mi/MIUtilFileStd.cpp
  lldb/tools/lldb-server/lldb-platform.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -41,6 +41,7 @@
 #include 
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -90,7 +91,8 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
+  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
+  sockfd, (struct sockaddr *)&cli_addr, &clilen);
   if (newsockfd < 0)
 if (g_vsc.log)
   *g_vsc.log << "error: accept (" << strerror(errno) << ")"
@@ -1074,7 +1076,7 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
-  FILE *out = fopen(dev_null_path, "w");
+  FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
   if (out) {
 // Set the output and error file handles to redirect into nothing otherwise
 // if any code in LLDB prints to the debugger file handles, the output and
Index: lldb/tools/lldb-server/lldb-platform.cpp
===
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -19,6 +19,7 @@
 
 #include 
 
+#include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 
Index: lldb/tools/lldb-mi/MIUtilFileStd.cpp
===
--- lldb/tools/lldb-mi/MIUtilFileStd.cpp
+++ lldb/tools/lldb-mi/MIUtilFileStd.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Host/FileSystem.h"
 
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
 
 //++
 //
@@ -83,7 +84,8 @@
 
 #if !defined(_MSC_VER)
   // Open with 'write' and 'binary' mode
-  m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb");
+  m_pFileHandle = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+  vFileNamePath.c_str(), "wb");
 #else
   // Open a file with exclusive write and shared read permissions
   std::wstring path;
@@ -226,7 +228,8 @@
 return false;
 
   FILE *pTmp = nullptr;
-  pTmp = ::fopen(vFileNamePath.c_str(), "wb");
+  pTmp = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+  vFileNamePath.c_str(), "wb");
   if (pTmp != nullptr) {
 ::fclose(pTmp);
 return true;
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Utility/Stream.h"
 
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
 
 #include 
 
@@ -39,7 +40,7 @@
 
 void PythonObject::Dump(Stream &strm) const {
   if (m_py_obj) {
-FILE *file = ::tmpfile();
+FILE *file = llvm::sys::RetryAfterSignal(nullptr, ::tmpfile);
 if (file) {
   ::PyObject_Print(m_py_obj, file, 0);
   const long length = ftell(file);
Index: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===
--- lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -665,7 +665,8 @@
   int wstatus;
   // Need to use WALLSIG otherwise we receive an error with errno=ECHLD At this
   // point we should have a thread stopped if waitpid succeeds.
-  if ((wstatus = waitpid(m_pid, NULL, WALLSIG)) < 0)
+ 

[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:255-258
+llvm::sys::RetryAfterSignal(-1, ::cfsetospeed,
+&options, B115200);
+llvm::sys::RetryAfterSignal(-1, ::cfsetispeed,
+&options, B115200);

labath wrote:
> IIUC, these only manipulate the `options` struct, so I don't see how they 
> could fail with EINTR. OTOH, the `tcsetattr` call below is documented to 
> return EINTR at least on NetBSD 
> .
Yeah, that's why I covered it, though it looks surprising to me as well. But 
looking at the code, it can't happen really, so I'll just revert this.



Comment at: lldb/tools/lldb-server/lldb-platform.cpp:319
   // Collect child zombie processes.
-  while (waitpid(-1, nullptr, WNOHANG) > 0)
+  while (llvm::sys::RetryAfterSignal(-1, waitpid,
+-1, nullptr, WNOHANG) > 0)

labath wrote:
> I don't think this is necessary here with WNOHANG and everything.
Yep, sorry, missed this one.


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

https://reviews.llvm.org/D59606



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


[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:255-258
+llvm::sys::RetryAfterSignal(-1, ::cfsetospeed,
+&options, B115200);
+llvm::sys::RetryAfterSignal(-1, ::cfsetispeed,
+&options, B115200);

mgorny wrote:
> labath wrote:
> > IIUC, these only manipulate the `options` struct, so I don't see how they 
> > could fail with EINTR. OTOH, the `tcsetattr` call below is documented to 
> > return EINTR at least on NetBSD 
> > .
> Yeah, that's why I covered it, though it looks surprising to me as well. But 
> looking at the code, it can't happen really, so I'll just revert this.
I think we misunderstood each other. My expectation would be that these two 
calls don't need EINTR protection, but the tcsetattr call (line 267) does.



Comment at: lldb/tools/lldb-server/lldb-platform.cpp:22
 
+#include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"

revert this part too?


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

https://reviews.llvm.org/D59606



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


[Lldb-commits] [PATCH] D59291: [Object] Add basic minidump support

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356652: [Object] Add basic minidump support (authored by 
labath, committed by ).

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59291

Files:
  llvm/trunk/include/llvm/BinaryFormat/Magic.h
  llvm/trunk/include/llvm/BinaryFormat/Minidump.h
  llvm/trunk/include/llvm/BinaryFormat/MinidumpConstants.def
  llvm/trunk/include/llvm/Object/Binary.h
  llvm/trunk/include/llvm/Object/Minidump.h
  llvm/trunk/lib/BinaryFormat/CMakeLists.txt
  llvm/trunk/lib/BinaryFormat/Magic.cpp
  llvm/trunk/lib/BinaryFormat/Minidump.cpp
  llvm/trunk/lib/Object/Binary.cpp
  llvm/trunk/lib/Object/CMakeLists.txt
  llvm/trunk/lib/Object/Minidump.cpp
  llvm/trunk/lib/Object/ObjectFile.cpp
  llvm/trunk/lib/Object/SymbolicFile.cpp
  llvm/trunk/unittests/Object/CMakeLists.txt
  llvm/trunk/unittests/Object/MinidumpTest.cpp

Index: llvm/trunk/lib/BinaryFormat/CMakeLists.txt
===
--- llvm/trunk/lib/BinaryFormat/CMakeLists.txt
+++ llvm/trunk/lib/BinaryFormat/CMakeLists.txt
@@ -2,6 +2,7 @@
   AMDGPUMetadataVerifier.cpp
   Dwarf.cpp
   Magic.cpp
+  Minidump.cpp
   MsgPackDocument.cpp
   MsgPackDocumentYAML.cpp
   MsgPackReader.cpp
Index: llvm/trunk/lib/BinaryFormat/Minidump.cpp
===
--- llvm/trunk/lib/BinaryFormat/Minidump.cpp
+++ llvm/trunk/lib/BinaryFormat/Minidump.cpp
@@ -0,0 +1,14 @@
+//===-- Minidump.cpp - Minidump constants and structures -*- 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 "llvm/BinaryFormat/Minidump.h"
+
+using namespace llvm::minidump;
+
+constexpr uint32_t Header::MagicSignature;
+constexpr uint16_t Header::MagicVersion;
Index: llvm/trunk/lib/BinaryFormat/Magic.cpp
===
--- llvm/trunk/lib/BinaryFormat/Magic.cpp
+++ llvm/trunk/lib/BinaryFormat/Magic.cpp
@@ -181,7 +181,8 @@
   return file_magic::coff_object;
 break;
 
-  case 'M': // Possible MS-DOS stub on Windows PE file or MSF/PDB file.
+  case 'M': // Possible MS-DOS stub on Windows PE file, MSF/PDB file or a
+// Minidump file.
 if (startswith(Magic, "MZ") && Magic.size() >= 0x3c + 4) {
   uint32_t off = read32le(Magic.data() + 0x3c);
   // PE/COFF file, either EXE or DLL.
@@ -191,6 +192,8 @@
 }
 if (Magic.startswith("Microsoft C/C++ MSF 7.00\r\n"))
   return file_magic::pdb;
+if (startswith(Magic, "MDMP"))
+  return file_magic::minidump;
 break;
 
   case 0x64: // x86-64 or ARM64 Windows.
Index: llvm/trunk/lib/Object/CMakeLists.txt
===
--- llvm/trunk/lib/Object/CMakeLists.txt
+++ llvm/trunk/lib/Object/CMakeLists.txt
@@ -13,6 +13,7 @@
   IRSymtab.cpp
   MachOObjectFile.cpp
   MachOUniversal.cpp
+  Minidump.cpp
   ModuleSymbolTable.cpp
   Object.cpp
   ObjectFile.cpp
Index: llvm/trunk/lib/Object/Binary.cpp
===
--- llvm/trunk/lib/Object/Binary.cpp
+++ llvm/trunk/lib/Object/Binary.cpp
@@ -16,6 +16,7 @@
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Object/MachOUniversal.h"
+#include "llvm/Object/Minidump.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/WindowsResource.h"
 #include "llvm/Support/Error.h"
@@ -81,6 +82,8 @@
   case file_magic::coff_cl_gl_object:
 // Unrecognized object file format.
 return errorCodeToError(object_error::invalid_file_type);
+  case file_magic::minidump:
+return MinidumpFile::create(Buffer);
   }
   llvm_unreachable("Unexpected Binary File Type");
 }
Index: llvm/trunk/lib/Object/Minidump.cpp
===
--- llvm/trunk/lib/Object/Minidump.cpp
+++ llvm/trunk/lib/Object/Minidump.cpp
@@ -0,0 +1,77 @@
+//===- Minidump.cpp - Minidump object file implementation -===//
+//
+// 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 "llvm/Object/Minidump.h"
+#include "llvm/Object/Error.h"
+
+using namespace llvm;
+using namespace llvm::object;
+using namespace llvm::minidump;
+
+Optional>
+MinidumpFile::getRawStream(minidump::StreamType Type) const {
+  auto It = StreamMap.find(Type);
+  if (It != StreamMap.end())
+return getRawStream(Streams[It->second]);
+  return None;
+}
+
+Expect

[Lldb-commits] [PATCH] D59482: [ObjectYAML] Add basic minidump generation support

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 191653.
labath added a comment.

It occurred to me that the "invalid input" test cases could be easily rewritten
in lit, as they don't require parsing of the generated binary (because there
isn't one).

In this update I just port those tests to lit, which enables us to actually
assert the error message (which isn't possible from the unit test as that
unfortunately goes to stderr).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59482

Files:
  include/llvm/ObjectYAML/MinidumpYAML.h
  include/llvm/ObjectYAML/ObjectYAML.h
  lib/ObjectYAML/CMakeLists.txt
  lib/ObjectYAML/MinidumpYAML.cpp
  lib/ObjectYAML/ObjectYAML.cpp
  test/tools/yaml2obj/minidump-raw-stream-small-size.yaml
  test/tools/yaml2obj/minidump-systeminfo-other-long.yaml
  test/tools/yaml2obj/minidump-systeminfo-other-not-hex.yaml
  test/tools/yaml2obj/minidump-systeminfo-other-short.yaml
  test/tools/yaml2obj/minidump-systeminfo-x86-long.yaml
  test/tools/yaml2obj/minidump-systeminfo-x86-short.yaml
  tools/yaml2obj/CMakeLists.txt
  tools/yaml2obj/yaml2minidump.cpp
  tools/yaml2obj/yaml2obj.cpp
  tools/yaml2obj/yaml2obj.h
  unittests/ObjectYAML/CMakeLists.txt
  unittests/ObjectYAML/MinidumpYAMLTest.cpp

Index: unittests/ObjectYAML/MinidumpYAMLTest.cpp
===
--- /dev/null
+++ unittests/ObjectYAML/MinidumpYAMLTest.cpp
@@ -0,0 +1,137 @@
+//===- MinidumpYAMLTest.cpp - Tests for Minidump<->YAML code --===//
+//
+// 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 "llvm/ObjectYAML/MinidumpYAML.h"
+#include "llvm/Object/Minidump.h"
+#include "llvm/ObjectYAML/ObjectYAML.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace llvm::minidump;
+
+static Expected>
+toBinary(StringRef Yaml) {
+  SmallString<0> Binary;
+  raw_svector_ostream OS(Binary);
+  if (Error E = MinidumpYAML::writeAsBinary(Yaml, OS))
+return std::move(E);
+
+  return object::MinidumpFile::create(MemoryBufferRef(Binary, "Binary"));
+}
+
+TEST(MinidumpYAML, Basic) {
+  auto ExpectedFile = toBinary(R"(
+--- !minidump
+Streams:
+  - Type:SystemInfo
+Processor Arch:  ARM64
+Platform ID: Linux
+CSD Version RVA: 0x01020304
+CPU:
+  CPUID:   0x05060708
+  - Type:LinuxMaps
+Text: |
+  400d9000-400db000 r-xp  b3:04 227/system/bin/app_process
+  400db000-400dc000 r--p 1000 b3:04 227/system/bin/app_process
+
+  - Type:LinuxAuxv
+Content: DEADBEEFBAADF00D)");
+  ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+  object::MinidumpFile &File = **ExpectedFile;
+
+  ASSERT_EQ(3u, File.streams().size());
+
+  EXPECT_EQ(StreamType::SystemInfo, File.streams()[0].Type);
+  auto ExpectedSysInfo = File.getSystemInfo();
+  ASSERT_THAT_EXPECTED(ExpectedSysInfo, Succeeded());
+  const SystemInfo &SysInfo = *ExpectedSysInfo;
+  EXPECT_EQ(ProcessorArchitecture::ARM64, SysInfo.ProcessorArch);
+  EXPECT_EQ(OSPlatform::Linux, SysInfo.PlatformId);
+  EXPECT_EQ(0x01020304u, SysInfo.CSDVersionRVA);
+  EXPECT_EQ(0x05060708u, SysInfo.CPU.Arm.CPUID);
+
+  EXPECT_EQ(StreamType::LinuxMaps, File.streams()[1].Type);
+  EXPECT_EQ("400d9000-400db000 r-xp  b3:04 227"
+"/system/bin/app_process\n"
+"400db000-400dc000 r--p 1000 b3:04 227"
+"/system/bin/app_process\n",
+toStringRef(*File.getRawStream(StreamType::LinuxMaps)));
+
+  EXPECT_EQ(StreamType::LinuxAuxv, File.streams()[2].Type);
+  EXPECT_EQ((ArrayRef{0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xAD, 0xF0, 0x0D}),
+File.getRawStream(StreamType::LinuxAuxv));
+}
+
+TEST(MinidumpYAML, RawContent) {
+  ExpectedFile = toBinary(R"(
+--- !minidump
+Streams:
+  - Type:LinuxAuxv
+Size:9
+Content: DEADBEEFBAADF00D)");
+  ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+  object::MinidumpFile &File = **ExpectedFile;
+
+  EXPECT_EQ(
+  (ArrayRef{0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xAD, 0xF0, 0x0D, 0x00}),
+  File.getRawStream(StreamType::LinuxAuxv));
+}
+
+TEST(MinidumpYAML, X86SystemInfo) {
+  ExpectedFile = toBinary(R"(
+--- !minidump
+Streams:
+  - Type:SystemInfo
+Processor Arch:  X86
+Platform ID: Linux
+CPU:
+  Vendor ID:   LLVMLLVMLLVM
+  Version Info:0x01020304
+  Feature Info:0x05060708
+  AMD Extended Features: 0x09000102)");
+  ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+  object::MinidumpFile &File = **ExpectedFile;
+
+  ASSERT_EQ(1u, File.streams().size());
+
+  auto ExpectedSysInfo = Fil

[Lldb-commits] [PATCH] D59482: [ObjectYAML] Add basic minidump generation support

2019-03-21 Thread James Henderson via Phabricator via lldb-commits
jhenderson accepted this revision.
jhenderson added a comment.

Test updates LGTM.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59482



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


[Lldb-commits] [PATCH] D59634: Add minidump support to obj2yaml

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jhenderson, zturner, clayborg.
Herald added a subscriber: mgorny.
Herald added a project: LLVM.

This patch adds the code needed to parse a minidump file into the
MinidumpYAML model, and the necessary glue code so that obj2yaml can
recognise the minidump files and process them.


Repository:
  rL LLVM

https://reviews.llvm.org/D59634

Files:
  include/llvm/ObjectYAML/MinidumpYAML.h
  lib/ObjectYAML/MinidumpYAML.cpp
  test/tools/obj2yaml/basic-minidump.yaml
  tools/obj2yaml/CMakeLists.txt
  tools/obj2yaml/minidump2yaml.cpp
  tools/obj2yaml/obj2yaml.cpp
  tools/obj2yaml/obj2yaml.h

Index: tools/obj2yaml/obj2yaml.h
===
--- tools/obj2yaml/obj2yaml.h
+++ tools/obj2yaml/obj2yaml.h
@@ -13,6 +13,7 @@
 #define LLVM_TOOLS_OBJ2YAML_OBJ2YAML_H
 
 #include "llvm/Object/COFF.h"
+#include "llvm/Object/Minidump.h"
 #include "llvm/Object/Wasm.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -23,6 +24,8 @@
  const llvm::object::ObjectFile &Obj);
 std::error_code macho2yaml(llvm::raw_ostream &Out,
const llvm::object::Binary &Obj);
+llvm::Error minidump2yaml(llvm::raw_ostream &Out,
+  const llvm::object::MinidumpFile &Obj);
 std::error_code wasm2yaml(llvm::raw_ostream &Out,
   const llvm::object::WasmObjectFile &Obj);
 
Index: tools/obj2yaml/obj2yaml.cpp
===
--- tools/obj2yaml/obj2yaml.cpp
+++ tools/obj2yaml/obj2yaml.cpp
@@ -10,6 +10,7 @@
 #include "Error.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/COFF.h"
+#include "llvm/Object/Minidump.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
 
@@ -40,6 +41,8 @@
   // TODO: If this is an archive, then burst it and dump each entry
   if (ObjectFile *Obj = dyn_cast(&Binary))
 return errorCodeToError(dumpObject(*Obj));
+  if (MinidumpFile *Minidump = dyn_cast(&Binary))
+return minidump2yaml(outs(), *Minidump);
 
   return Error::success();
 }
Index: tools/obj2yaml/minidump2yaml.cpp
===
--- /dev/null
+++ tools/obj2yaml/minidump2yaml.cpp
@@ -0,0 +1,24 @@
+//===- minidump2yaml.cpp - Minidump to yaml conversion tool -*- 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 "Error.h"
+#include "obj2yaml.h"
+#include "llvm/Object/Minidump.h"
+#include "llvm/ObjectYAML/MinidumpYAML.h"
+#include "llvm/Support/YAMLTraits.h"
+
+using namespace llvm;
+
+Error minidump2yaml(raw_ostream &Out, const object::MinidumpFile &Obj) {
+  auto ExpectedObject = MinidumpYAML::Object::create(Obj);
+  if (!ExpectedObject)
+return ExpectedObject.takeError();
+  yaml::Output Output(Out);
+  Output << *ExpectedObject;
+  return llvm::Error::success();
+}
Index: tools/obj2yaml/CMakeLists.txt
===
--- tools/obj2yaml/CMakeLists.txt
+++ tools/obj2yaml/CMakeLists.txt
@@ -13,6 +13,7 @@
   dwarf2yaml.cpp
   elf2yaml.cpp
   macho2yaml.cpp
+  minidump2yaml.cpp
   wasm2yaml.cpp
   Error.cpp
   )
Index: test/tools/obj2yaml/basic-minidump.yaml
===
--- /dev/null
+++ test/tools/obj2yaml/basic-minidump.yaml
@@ -0,0 +1,35 @@
+# RUN: yaml2obj %s | obj2yaml - | FileCheck %s
+
+--- !minidump
+Streams: 
+  - Type:SystemInfo
+Processor Arch:  ARM64
+Platform ID: Linux
+CSD Version RVA: 0x01020304
+CPU: 
+  CPUID:   0x05060708
+  - Type:LinuxAuxv
+Content: DEADBEEFBAADF00D
+  - Type:LinuxMaps
+Text: |
+  400d9000-400db000 r-xp  b3:04 227/system/bin/app_process
+  400db000-400dc000 r--p 1000 b3:04 227/system/bin/app_process
+
+...
+
+# CHECK:  --- !minidump
+# CHECK-NEXT: Streams: 
+# CHECK-NEXT:   - Type:SystemInfo
+# CHECK-NEXT: Processor Arch:  ARM64
+# CHECK-NEXT: Platform ID: Linux
+# CHECK-NEXT: CSD Version RVA: 0x01020304
+# CHECK-NEXT: CPU: 
+# CHECK-NEXT:   CPUID:   0x05060708
+# CHECK-NEXT:   - Type:LinuxAuxv
+# CHECK-NEXT: Content: DEADBEEFBAADF00D
+# CHECK-NEXT:   - Type:LinuxMaps
+# CHECK-NEXT: Text: |
+# CHECK-NEXT:   400d9000-400db000 r-xp  b3:04 227/system/bin/app_process
+# CHECK-NEXT:   400db000-400dc000 r--p 1000 b3:04 227/system/bin/app_process
+# CHECK-EMPTY:
+# CHECK-NEXT: ...
Index: lib/ObjectYAML/MinidumpYAML.cpp
===

[Lldb-commits] [PATCH] D58975: Introduce MinidumpEnums.def textual header

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath abandoned this revision.
labath added a comment.

This code will be in llvm now, so this cl is dead.


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

https://reviews.llvm.org/D58975



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


[Lldb-commits] [PATCH] D58973: Move the minidump parser into the Formats module

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath abandoned this revision.
labath added a comment.

minidump parser will go into llvm/Object instead.


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

https://reviews.llvm.org/D58973



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


[Lldb-commits] [PATCH] D58976: Introduce core2yaml tool

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath abandoned this revision.
labath added a comment.

instead of a fresh tool, minidump support will be added to obj2yaml.


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

https://reviews.llvm.org/D58976



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


[Lldb-commits] [PATCH] D58972: Introduce the "Formats" module and move LinuxProcMaps parser to it

2019-03-21 Thread Pavel Labath via Phabricator via lldb-commits
labath abandoned this revision.
labath added a comment.

minidump parser will go into llvm, which removes the main incentive for 
creating this new module. It's possible we may need something like this in the 
future, but should wait until there is a real use case for it.


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

https://reviews.llvm.org/D58972



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


[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Now, the curious thing is that so far I have 2 more test failures with this. 
I'll investigate closer, maybe it's just flakiness.


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

https://reviews.llvm.org/D59606



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


[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked 3 inline comments as done.
mgorny added inline comments.



Comment at: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp:255-258
+llvm::sys::RetryAfterSignal(-1, ::cfsetospeed,
+&options, B115200);
+llvm::sys::RetryAfterSignal(-1, ::cfsetispeed,
+&options, B115200);

labath wrote:
> mgorny wrote:
> > labath wrote:
> > > IIUC, these only manipulate the `options` struct, so I don't see how they 
> > > could fail with EINTR. OTOH, the `tcsetattr` call below is documented to 
> > > return EINTR at least on NetBSD 
> > > .
> > Yeah, that's why I covered it, though it looks surprising to me as well. 
> > But looking at the code, it can't happen really, so I'll just revert this.
> I think we misunderstood each other. My expectation would be that these two 
> calls don't need EINTR protection, but the tcsetattr call (line 267) does.
I'm not sure if it can happen with `TCSANOW` but I guess better safe than sorry.


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

https://reviews.llvm.org/D59606



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


[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 191657.
mgorny marked an inline comment as done.
mgorny added a comment.

Applied requested changes.


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

https://reviews.llvm.org/D59606

Files:
  lldb/source/Host/common/PseudoTerminal.cpp
  lldb/source/Host/common/Socket.cpp
  lldb/source/Host/common/TCPSocket.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Host/posix/DomainSocket.cpp
  lldb/source/Host/posix/FileSystem.cpp
  lldb/source/Host/posix/LockFilePosix.cpp
  lldb/source/Host/posix/PipePosix.cpp
  lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
  lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/tools/lldb-mi/MIUtilFileStd.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -41,6 +41,7 @@
 #include 
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -90,7 +91,8 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
+  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
+  sockfd, (struct sockaddr *)&cli_addr, &clilen);
   if (newsockfd < 0)
 if (g_vsc.log)
   *g_vsc.log << "error: accept (" << strerror(errno) << ")"
@@ -1074,7 +1076,7 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
-  FILE *out = fopen(dev_null_path, "w");
+  FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
   if (out) {
 // Set the output and error file handles to redirect into nothing otherwise
 // if any code in LLDB prints to the debugger file handles, the output and
Index: lldb/tools/lldb-mi/MIUtilFileStd.cpp
===
--- lldb/tools/lldb-mi/MIUtilFileStd.cpp
+++ lldb/tools/lldb-mi/MIUtilFileStd.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Host/FileSystem.h"
 
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
 
 //++
 //
@@ -83,7 +84,8 @@
 
 #if !defined(_MSC_VER)
   // Open with 'write' and 'binary' mode
-  m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb");
+  m_pFileHandle = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+  vFileNamePath.c_str(), "wb");
 #else
   // Open a file with exclusive write and shared read permissions
   std::wstring path;
@@ -226,7 +228,8 @@
 return false;
 
   FILE *pTmp = nullptr;
-  pTmp = ::fopen(vFileNamePath.c_str(), "wb");
+  pTmp = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+  vFileNamePath.c_str(), "wb");
   if (pTmp != nullptr) {
 ::fclose(pTmp);
 return true;
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Utility/Stream.h"
 
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
 
 #include 
 
@@ -39,7 +40,7 @@
 
 void PythonObject::Dump(Stream &strm) const {
   if (m_py_obj) {
-FILE *file = ::tmpfile();
+FILE *file = llvm::sys::RetryAfterSignal(nullptr, ::tmpfile);
 if (file) {
   ::PyObject_Print(m_py_obj, file, 0);
   const long length = ftell(file);
Index: lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===
--- lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -665,7 +665,8 @@
   int wstatus;
   // Need to use WALLSIG otherwise we receive an error with errno=ECHLD At this
   // point we should have a thread stopped if waitpid succeeds.
-  if ((wstatus = waitpid(m_pid, NULL, WALLSIG)) < 0)
+  if ((wstatus = llvm::sys::RetryAfterSignal(-1, waitpid,
+  m_pid, NULL, WALLSIG)) < 0)
 return Status(errno, eErrorTypePOSIX);
 
   /* Initialize threads */
Index: lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
===
--- lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
+++ lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
@@ -51,8 +51,10 @@
 
   ~ChildDeleter() {
 int status;
-kill(pid, SIGKILL);// Kill the

[Lldb-commits] [PATCH] D59583: python2/3 compat: exceptions

2019-03-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356670: Portable exception value access across Python 2 / 
Python 3 (authored by serge_sans_paille, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59583?vs=191445&id=191688#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59583

Files:
  lldb/trunk/examples/python/crashlog.py


Index: lldb/trunk/examples/python/crashlog.py
===
--- lldb/trunk/examples/python/crashlog.py
+++ lldb/trunk/examples/python/crashlog.py
@@ -284,7 +284,7 @@
 try:
 plist_root = plistlib.readPlistFromString(s)
 except:
-print(("Got exception: ", sys.exc_value, " handling 
dsymForUUID output: \n", s)) 
+print(("Got exception: ", sys.exc_info()[1], " 
handling dsymForUUID output: \n", s))
 raise
 if plist_root:
 plist = plist_root[uuid_str]


Index: lldb/trunk/examples/python/crashlog.py
===
--- lldb/trunk/examples/python/crashlog.py
+++ lldb/trunk/examples/python/crashlog.py
@@ -284,7 +284,7 @@
 try:
 plist_root = plistlib.readPlistFromString(s)
 except:
-print(("Got exception: ", sys.exc_value, " handling dsymForUUID output: \n", s)) 
+print(("Got exception: ", sys.exc_info()[1], " handling dsymForUUID output: \n", s))
 raise
 if plist_root:
 plist = plist_root[uuid_str]
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59585: python 2/3 compat: int vs long

2019-03-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB356671: Portable int/long conversion across Python 2 / 
Python 3 (authored by serge_sans_paille, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59585?vs=191447&id=191689#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59585

Files:
  examples/python/jump.py


Index: examples/python/jump.py
===
--- examples/python/jump.py
+++ examples/python/jump.py
@@ -78,7 +78,7 @@
 if (mo is not None):
 matched = True
 # print "Matched "
-address = long(mo.group(1), base=0)
+address = int(mo.group(1), base=0)
 breakpoint = target.BreakpointCreateByAddress(address)
 
 if (not matched):


Index: examples/python/jump.py
===
--- examples/python/jump.py
+++ examples/python/jump.py
@@ -78,7 +78,7 @@
 if (mo is not None):
 matched = True
 # print "Matched "
-address = long(mo.group(1), base=0)
+address = int(mo.group(1), base=0)
 breakpoint = target.BreakpointCreateByAddress(address)
 
 if (not matched):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59587: Use explicit loop instead of map for Python 2/3 compat

2019-03-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356672: Workaround Python's map difference between 
Python2/3 (authored by serge_sans_paille, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59587?vs=191449&id=191691#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59587

Files:
  lldb/trunk/scripts/Xcode/build-llvm.py


Index: lldb/trunk/scripts/Xcode/build-llvm.py
===
--- lldb/trunk/scripts/Xcode/build-llvm.py
+++ lldb/trunk/scripts/Xcode/build-llvm.py
@@ -239,7 +239,8 @@
 
 
 def all_check_out_if_needed():
-map(check_out_if_needed, XCODE_REPOSITORIES())
+for r in XCODE_REPOSITORIES():
+check_out_if_needed(r)
 
 
 def should_build_llvm():
@@ -263,7 +264,8 @@
 
 
 def setup_source_symlinks():
-map(setup_source_symlink, XCODE_REPOSITORIES())
+for r in XCODE_REPOSITORIES():
+setup_source_symlink(r)
 
 
 def setup_build_symlink():


Index: lldb/trunk/scripts/Xcode/build-llvm.py
===
--- lldb/trunk/scripts/Xcode/build-llvm.py
+++ lldb/trunk/scripts/Xcode/build-llvm.py
@@ -239,7 +239,8 @@
 
 
 def all_check_out_if_needed():
-map(check_out_if_needed, XCODE_REPOSITORIES())
+for r in XCODE_REPOSITORIES():
+check_out_if_needed(r)
 
 
 def should_build_llvm():
@@ -263,7 +264,8 @@
 
 
 def setup_source_symlinks():
-map(setup_source_symlink, XCODE_REPOSITORIES())
+for r in XCODE_REPOSITORIES():
+setup_source_symlink(r)
 
 
 def setup_build_symlink():
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59588: Python 2/3 compat: iteritems vs items

2019-03-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB356673: Workaround items/iteritems difference between 
Python2 and Python3 (authored by serge_sans_paille, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59588?vs=191452&id=191693#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59588

Files:
  examples/python/pytracer.py


Index: examples/python/pytracer.py
===
--- examples/python/pytracer.py
+++ examples/python/pytracer.py
@@ -335,7 +335,7 @@
 
 def print_keyword_args(**kwargs):
 # kwargs is a dict of the keyword args passed to the function
-for key, value in kwargs.iteritems():
+for key, value in kwargs.items():
 print "%s = %s" % (key, value)
 
 


Index: examples/python/pytracer.py
===
--- examples/python/pytracer.py
+++ examples/python/pytracer.py
@@ -335,7 +335,7 @@
 
 def print_keyword_args(**kwargs):
 # kwargs is a dict of the keyword args passed to the function
-for key, value in kwargs.iteritems():
+for key, value in kwargs.items():
 print "%s = %s" % (key, value)
 
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59580: Use compatible print statements for Python2/3

2019-03-21 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

I didn't run the `check-lldb` target though, I'm doing that right now.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59580



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


[Lldb-commits] [PATCH] D59580: Use compatible print statements for Python2/3

2019-03-21 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

@davide I first applied 2to3 systematically, then manually edited the diff so 
that it remains backward compatible with python2.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59580



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


[Lldb-commits] [PATCH] D59580: Use compatible print statements for Python2/3

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

This looks good to me as long as it doesn't break check-lldb (and from I quick 
look at the patch I doubt it does). Thanks for helping with this!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59580



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


[Lldb-commits] [PATCH] D59291: [Object] Add basic minidump support

2019-03-21 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Looks like this uncovered some UB:

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-sanitized/2050/testReport/junit/lldb-Suite/functionalities_postmortem_minidump-new/TestMiniDumpUUID_py/


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59291



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


Re: [Lldb-commits] [lldb] r356643 - [Reproducers] Properly handle QEnvironment packets

2019-03-21 Thread Jonas Devlieghere via lldb-commits
Since we don't execute the binary we don't have to, but I agree it would
the right thing to do, as something else could depend on it during replay.
I'll address this once I figure out what's causing the flakiness on Linux.

On Thu, Mar 21, 2019 at 1:32 AM Pavel Labath  wrote:

> On 21/03/2019 05:08, Jonas Devlieghere via lldb-commits wrote:
> > Author: jdevlieghere
> > Date: Wed Mar 20 21:08:31 2019
> > New Revision: 356643
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=356643&view=rev
> > Log:
> > [Reproducers] Properly handle QEnvironment packets
> >
> > On Linux, a QEnvironment packet is sent for every environment variable.
> > This breaks replay when the number of environment variables is different
> > then during capture. The solution is to always reply with OK.
> >
> > Modified:
> >  lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test
> >
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
> >
> > Modified: lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test?rev=356643&r1=356642&r2=356643&view=diff
> >
> ==
> > --- lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test (original)
> > +++ lldb/trunk/lit/Reproducer/TestGDBRemoteRepro.test Wed Mar 20
> 21:08:31 2019
> > @@ -9,7 +9,7 @@
> >   # RUN: rm -rf %t.repro
> >   # RUN: %clang %S/Inputs/simple.c -g -o %t.out
> >   # RUN: %lldb -x -b -s %S/Inputs/GDBRemoteCapture.in --capture
> --capture-path %t.repro %t.out | FileCheck %s --check-prefix CHECK
> --check-prefix CAPTURE
> > -# RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix CHECK
> --check-prefix REPLAY
> > +# RUN: env FOO=BAR %lldb --replay %t.repro | FileCheck %s
> --check-prefix CHECK --check-prefix REPLAY
> >
> >   # CHECK: Breakpoint 1
> >   # CHECK: Process {{.*}} stopped
> >
> > Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp?rev=356643&r1=356642&r2=356643&view=diff
> >
> ==
> > ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
> (original)
> > +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
> Wed Mar 20 21:08:31 2019
> > @@ -107,6 +107,13 @@ GDBRemoteCommunicationReplayServer::GetP
> >   m_send_acks = false;
> > }
> >
> > +  // A QEnvironment packet is sent for every environment variable. If
> the
> > +  // number of environment variables is different during replay, the
> replies
> > +  // become out of sync.
> > +  if (packet.GetStringRef().find("QEnvironment") == 0) {
> > +return SendRawPacketNoLock("$OK#9a", true);
> > +  }
> > +
> > Log
> *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
> > while (!m_packet_history.empty()) {
> >   // Pop last packet from the history.
> > @@ -122,6 +129,14 @@ GDBRemoteCommunicationReplayServer::GetP
> >"GDBRemoteCommunicationReplayServer actual packet:
> '{}'\n",
> >packet.GetStringRef());
> > }
> > +
> > +  // Ignore QEnvironment packets as they're handled earlier.
> > +  if (entry.packet.data.find("QEnvironment") == 1) {
> > +assert(m_packet_history.back().type ==
> > +   GDBRemoteCommunicationHistory::ePacketTypeRecv);
> > +m_packet_history.pop_back();
> > +  }
> > +
> > continue;
> >   }
> >
> >
> >
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> >
>
> It sounds like we should have an "environment provider" which captures
> and reinstates the environment during record and replay respectively.
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r356682 - Move the rest of the sections over to DWARFContext.

2019-03-21 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Mar 21 09:34:58 2019
New Revision: 356682

URL: http://llvm.org/viewvc/llvm-project?rev=356682&view=rev
Log:
Move the rest of the sections over to DWARFContext.

This is mostly mechanical, and just moves the remaining non-DWO
related sections over to DWARFContext.

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

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=356682&r1=356681&r2=356682&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Mar 21 
09:34:58 2019
@@ -15,17 +15,18 @@
 using namespace lldb;
 using namespace lldb_private;
 
-DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data)
-: DWARFUnit(dwarf2Data) {}
+DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data,
+   DWARFContext &dwarf_context)
+: DWARFUnit(dwarf2Data, dwarf_context) {}
 
-llvm::Expected
-DWARFCompileUnit::extract(SymbolFileDWARF *dwarf2Data,
-  const DWARFDataExtractor &debug_info,
-  lldb::offset_t *offset_ptr) {
+llvm::Expected DWARFCompileUnit::extract(
+SymbolFileDWARF *dwarf2Data, DWARFContext &dwarf_context,
+const DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr) {
   assert(debug_info.ValidOffset(*offset_ptr));
 
   // std::make_shared would require the ctor to be public.
-  std::shared_ptr cu_sp(new DWARFCompileUnit(dwarf2Data));
+  std::shared_ptr cu_sp(
+  new DWARFCompileUnit(dwarf2Data, dwarf_context));
 
   cu_sp->m_offset = *offset_ptr;
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=356682&r1=356681&r2=356682&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Thu Mar 21 
09:34:58 2019
@@ -12,10 +12,15 @@
 #include "DWARFUnit.h"
 #include "llvm/Support/Error.h"
 
+namespace lldb_private {
+class DWARFContext;
+}
+
 class DWARFCompileUnit : public DWARFUnit {
 public:
   static llvm::Expected
   extract(SymbolFileDWARF *dwarf2Data,
+  lldb_private::DWARFContext &dwarf_context,
   const lldb_private::DWARFDataExtractor &debug_info,
   lldb::offset_t *offset_ptr);
   void Dump(lldb_private::Stream *s) const override;
@@ -39,7 +44,8 @@ public:
   uint32_t GetHeaderByteSize() const override;
 
 private:
-  DWARFCompileUnit(SymbolFileDWARF *dwarf2Data);
+  DWARFCompileUnit(SymbolFileDWARF *dwarf2Data,
+   lldb_private::DWARFContext &dwarf_context);
   DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit);
 };
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp?rev=356682&r1=356681&r2=356682&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp Thu Mar 21 
09:34:58 2019
@@ -14,6 +14,13 @@ using namespace lldb;
 using namespace lldb_private;
 
 static const DWARFDataExtractor *
+GetPointerOrNull(const llvm::Optional &extractor) {
+  if (!extractor.hasValue())
+return nullptr;
+  return extractor.getPointer();
+}
+
+static const DWARFDataExtractor *
 LoadOrGetSection(Module &module, SectionType section_type,
 

[Lldb-commits] [PATCH] D59611: Move the rest of the section loading over to DWARFContext

2019-03-21 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment.

In D59611#1437044 , @clayborg wrote:

> Use reference to DWARFContext instead of pointers? Apply to entire patch and 
> good to go


Done.  Since you conditionally LGTM'ed it based on that and I made that change 
I'll go ahead and submit


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

https://reviews.llvm.org/D59611



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


[Lldb-commits] [PATCH] D59611: Move the rest of the section loading over to DWARFContext

2019-03-21 Thread Zachary Turner via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356682: Move the rest of the sections over to DWARFContext. 
(authored by zturner, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59611?vs=191575&id=191722#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59611

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -147,7 +147,7 @@
 }
 
 DWARFExpression::LocationListFormat
-SymbolFileDWARFDwo::GetLocationListFormat() const {
+SymbolFileDWARFDwo::GetLocationListFormat() {
   return DWARFExpression::SplitDwarfLocationList;
 }
 
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -54,6 +54,7 @@
 #include "AppleDWARFIndex.h"
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFContext.h"
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
@@ -357,11 +358,8 @@
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(NULL),
   m_context(*objfile->GetModule()), m_data_debug_abbrev(),
-  m_data_debug_frame(), m_data_debug_info(), m_data_debug_line(),
-  m_data_debug_macro(), m_data_debug_loc(), m_data_debug_ranges(),
-  m_data_debug_rnglists(), m_data_debug_str(), m_data_apple_names(),
-  m_data_apple_types(), m_data_apple_namespaces(), m_abbr(), m_info(),
-  m_line(), m_fetched_external_modules(false),
+  m_data_debug_info(), m_data_debug_str(), m_abbr(), m_info(), m_line(),
+  m_fetched_external_modules(false),
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
   m_unique_ast_type_map() {}
 
@@ -561,52 +559,10 @@
   return GetCachedSectionData(eSectionTypeDWARFDebugAddr, m_data_debug_addr);
 }
 
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_frame_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugFrame, m_data_debug_frame);
-}
-
 const DWARFDataExtractor &SymbolFileDWARF::get_debug_info_data() {
   return GetCachedSectionData(eSectionTypeDWARFDebugInfo, m_data_debug_info);
 }
 
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_str_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugLineStr, m_data_debug_line_str);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() {
-  const DWARFDataExtractor &debugLocData = get_debug_loc_data();
-  if (debugLocData.GetByteSize() > 0)
-return debugLocData;
-  return get_debug_loclists_data();
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_loc_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugLoc, m_data_debug_loc);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_loclists_data() {
-  return GetCachedSectionData(eSectionTypeDWARFDebugLocLists,
-  m_data_debug_loclists);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_ranges_data() {
-  return GetCachedSe

[Lldb-commits] [PATCH] D59651: Move DebugRanges() function from SymbolFileDWARF to DWARFContext

2019-03-21 Thread Zachary Turner via Phabricator via lldb-commits
zturner created this revision.
zturner added reviewers: JDevlieghere, clayborg, labath, aprantl.

This should be the last non-dwo dependent piece to get over to `DWARFContext`.  
After this there will need to be some careful refactoring to get all knowledge 
of DWO-ness into the `DWARFContext`, ultimately culminating in probably 
deleting `SymbolFileDWARFDwo` and friends.  That's for later though, just 
trying to give a preview into where this is going.

Eventually the goal is that `SymbolFileDWARF` depends on the low level parser, 
but not the other way around, at which point we can start the //real// process 
of merging with LLVM's.


https://reviews.llvm.org/D59651

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -240,10 +240,6 @@
 
   const DWARFDebugInfo *DebugInfo() const;
 
-  DWARFDebugRangesBase *DebugRanges();
-
-  const DWARFDebugRangesBase *DebugRanges() const;
-
   static bool SupportedVersion(uint16_t version);
 
   DWARFDIE
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -633,27 +633,6 @@
   return NULL;
 }
 
-DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() {
-  if (m_ranges == NULL) {
-static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
-Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
-   static_cast(this));
-
-if (m_context.getOrLoadDebugRangesData())
-  m_ranges = llvm::make_unique();
-else if (m_context.getOrLoadDebugRnglistsData())
-  m_ranges = llvm::make_unique();
-
-if (m_ranges)
-  m_ranges->Extract(this, m_context);
-  }
-  return m_ranges.get();
-}
-
-const DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() const {
-  return m_ranges.get();
-}
-
 lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFUnit *dwarf_cu,
uint32_t cu_idx) {
   CompUnitSP cu_sp;
@@ -3269,7 +3248,8 @@
   case DW_AT_start_scope: {
 if (form_value.Form() == DW_FORM_sec_offset) {
   DWARFRangeList dwarf_scope_ranges;
-  const DWARFDebugRangesBase *debug_ranges = DebugRanges();
+  const DWARFDebugRangesBase *debug_ranges =
+  m_context.getOrLoadRangeInfo();
   debug_ranges->FindRanges(die.GetCU(),
form_value.Unsigned(),
dwarf_scope_ranges);
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -436,8 +436,8 @@
   const dw_offset_t cu_offset = GetOffset();
   if (die) {
 DWARFRangeList ranges;
-const size_t num_ranges =
-die->GetAttributeAddressRanges(dwarf, this, ranges, false);
+const size_t num_ranges = die->GetAttributeAddressRanges(
+dwarf, GetDWARFContext(), this, ranges, false);
 if (num_ranges > 0) {
   // This compile unit has DW_AT_ranges, assume this is correct if it is
   // present since clang no longer makes .debug_aranges by default and it
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -22,8 +22,7 @@
 public:
   virtual ~DWARFDebugRangesBase(){};
 
-  virtual void Extract(SymbolFileDWARF *dwarf2Data,
-   lldb_private::DWARFContext &dwarf_context) = 0;
+  virtual void Extract(lldb_private::DWARFContext &dwarf_context) = 0;
   virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
   DWARFRangeList &range_list) const = 0;
   virtual uint64_t GetOffset(size_t Index) const = 0;
@@ -33,8 +32,7 @@
 public:
   DWARFDebugRanges();
 
-  void

[Lldb-commits] [PATCH] D59433: Fix UUID decoding from minidump files.

2019-03-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.
Herald added a subscriber: ormris.

It looks like this commit introduced undefined behavior via a misaligned load 
see this log from lldb sanitized bot on green dragon

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-sanitized/2050/testReport/junit/lldb-Suite/functionalities_postmortem_minidump-new/TestMiniDumpUUID_py/

Summary:

/Users/buildslave/jenkins/workspace/lldb-sanitized/llvm/lib/Support/ConvertUTF.cpp:259:14:
 runtime error: load of misaligned address 0x61700018f671 for type 'const 
llvm::UTF16' (aka 'const unsigned short'), which requires 2 byte alignment
0x61700018f671: note: pointer points here

  0c 00 00  00 2f 00 74 00 6d 00 70  00 2f 00 62 00 52 53 44  53 0a 14 1e 28 32 
3c 46  50 5a 64 6e 78
   ^ 

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
/Users/buildslave/jenkins/workspace/lldb-sanitized/llvm/lib/Support/ConvertUTF.cpp:259:14
 in


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59433



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


[Lldb-commits] [PATCH] D59291: [Object] Add basic minidump support

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

In D59291#1438053 , @aprantl wrote:

> Looks like this uncovered some UB:
>
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb-sanitized/2050/testReport/junit/lldb-Suite/functionalities_postmortem_minidump-new/TestMiniDumpUUID_py/


I'm pretty sure this was caused by https://reviews.llvm.org/D59433 and not by 
this patch because LLDB does not use this code (yet).

Incidentally, just today I was working on adding string reading to the llvm 
parser, and noticed this potential misaligned access in lldb code. I don't 
think it can ever occur in practice for real (valid) minidumps, because those 
will have those fields correctly aligned, but I believe the reason that patch 
caught this problem is that the hand-crafted minidumps Greg created did not 
respect the natural alignment of the types. I think the fix is to regenerate 
the minidump binaries to correctly align the string fields, and also teach the 
lldb string reader to reject misaligned strings. The second part may not be so 
important, as I am going to delete that code soon anyway.

Alternatively, we could teach the lldb string reader to handle the misaligned 
strings correctly (most likely by memcpying them into aligned storage)...


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59291



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


[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 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/Host/posix/ConnectionFileDescriptorPosix.cpp:255-258
+llvm::sys::RetryAfterSignal(-1, ::cfsetospeed,
+&options, B115200);
+llvm::sys::RetryAfterSignal(-1, ::cfsetispeed,
+&options, B115200);

mgorny wrote:
> labath wrote:
> > mgorny wrote:
> > > labath wrote:
> > > > IIUC, these only manipulate the `options` struct, so I don't see how 
> > > > they could fail with EINTR. OTOH, the `tcsetattr` call below is 
> > > > documented to return EINTR at least on NetBSD 
> > > > .
> > > Yeah, that's why I covered it, though it looks surprising to me as well. 
> > > But looking at the code, it can't happen really, so I'll just revert this.
> > I think we misunderstood each other. My expectation would be that these two 
> > calls don't need EINTR protection, but the tcsetattr call (line 267) does.
> I'm not sure if it can happen with `TCSANOW` but I guess better safe than 
> sorry.
Ah, OK, I see. I am not really familiar with this syscall, so if you are 
reasonably confident that this particular combo of arguments cannot block (and 
be interrupted), then I'm fine with leaving the EINTR loop out.


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

https://reviews.llvm.org/D59606



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


[Lldb-commits] [PATCH] D59580: Use compatible print statements for Python2/3

2019-03-21 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

validates fine on my side with py3


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59580



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


[Lldb-commits] [PATCH] D59580: Use compatible print statements for Python2/3

2019-03-21 Thread serge via Phabricator via lldb-commits
serge-sans-paille added a comment.

@davide : is that ok if I add you to a few other python compat related reviews?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59580



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


[Lldb-commits] [lldb] r356703 - [lldb] Add missing EINTR handling

2019-03-21 Thread Michal Gorny via lldb-commits
Author: mgorny
Date: Thu Mar 21 12:35:55 2019
New Revision: 356703

URL: http://llvm.org/viewvc/llvm-project?rev=356703&view=rev
Log:
[lldb] Add missing EINTR handling

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

Modified:
lldb/trunk/source/Host/common/PseudoTerminal.cpp
lldb/trunk/source/Host/common/Socket.cpp
lldb/trunk/source/Host/common/TCPSocket.cpp
lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/trunk/source/Host/posix/DomainSocket.cpp
lldb/trunk/source/Host/posix/FileSystem.cpp
lldb/trunk/source/Host/posix/LockFilePosix.cpp
lldb/trunk/source/Host/posix/PipePosix.cpp
lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp
lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp

Modified: lldb/trunk/source/Host/common/PseudoTerminal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/PseudoTerminal.cpp?rev=356703&r1=356702&r2=356703&view=diff
==
--- lldb/trunk/source/Host/common/PseudoTerminal.cpp (original)
+++ lldb/trunk/source/Host/common/PseudoTerminal.cpp Thu Mar 21 12:35:55 2019
@@ -147,7 +147,7 @@ bool PseudoTerminal::OpenSlave(int oflag
   if (slave_name == nullptr)
 return false;
 
-  m_slave_fd = ::open(slave_name, oflag);
+  m_slave_fd = llvm::sys::RetryAfterSignal(-1, ::open, slave_name, oflag);
 
   if (m_slave_fd < 0) {
 if (error_str)

Modified: lldb/trunk/source/Host/common/Socket.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=356703&r1=356702&r2=356703&view=diff
==
--- lldb/trunk/source/Host/common/Socket.cpp (original)
+++ lldb/trunk/source/Host/common/Socket.cpp Thu Mar 21 12:35:55 2019
@@ -18,6 +18,7 @@
 #include "lldb/Utility/RegularExpression.h"
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Errno.h"
 
 #ifndef LLDB_DISABLE_POSIX
 #include "lldb/Host/posix/DomainSocket.h"
@@ -450,9 +451,11 @@ NativeSocket Socket::AcceptSocket(Native
   if (!child_processes_inherit) {
 flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = ::accept4(sockfd, addr, addrlen, flags);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
+  sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = ::accept(sockfd, addr, addrlen);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
+  sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)
 SetLastError(error);

Modified: lldb/trunk/source/Host/common/TCPSocket.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=356703&r1=356702&r2=356703&view=diff
==
--- lldb/trunk/source/Host/common/TCPSocket.cpp (original)
+++ lldb/trunk/source/Host/common/TCPSocket.cpp Thu Mar 21 12:35:55 2019
@@ -17,6 +17,7 @@
 #include "lldb/Utility/Log.h"
 
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Errno.h"
 #include "llvm/Support/raw_ostream.h"
 
 #ifndef LLDB_DISABLE_POSIX
@@ -150,8 +151,8 @@ Status TCPSocket::Connect(llvm::StringRe
 
 address.SetPort(port);
 
-if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(),
-address.GetLength())) {
+if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect,
+  GetNativeSocket(), &address.sockaddr(), address.GetLength())) {
   CLOSE_SOCKET(GetNativeSocket());
   continue;
 }

Modified: lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp?rev=356703&r1=356702&r2=356703&view=diff
==
--- lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp (original)
+++ lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp Thu Mar 21 
12:35:55 2019
@@ -262,7 +262,7 @@ ConnectionStatus ConnectionFileDescripto
 options.c_cc[VMIN] = 1;
 options.c_cc[VTIME] = 0;
 
-::tcsetattr(fd, TCSANOW, &options);
+llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
   }
 
   int flags = ::fcntl(fd, F_GETFL, 0);

Modified: lldb/trunk/source/Host/posix/DomainSocket.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/DomainSocket.cpp?rev=356703&r1=356702&r2=356703&view=diff
==
--- lldb/trunk/source/Host/posix/DomainSocket.cpp (original)
+++ lldb/trunk/source/Host/posix/Doma

[Lldb-commits] [PATCH] D59606: [lldb] Add missing EINTR handling

2019-03-21 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356703: [lldb] Add missing EINTR handling (authored by 
mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59606?vs=191657&id=191764#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59606

Files:
  lldb/trunk/source/Host/common/PseudoTerminal.cpp
  lldb/trunk/source/Host/common/Socket.cpp
  lldb/trunk/source/Host/common/TCPSocket.cpp
  lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/trunk/source/Host/posix/DomainSocket.cpp
  lldb/trunk/source/Host/posix/FileSystem.cpp
  lldb/trunk/source/Host/posix/LockFilePosix.cpp
  lldb/trunk/source/Host/posix/PipePosix.cpp
  lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp
  lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
  lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/trunk/tools/lldb-mi/MIUtilFileStd.cpp
  lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
===
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -1387,7 +1387,8 @@
 
 bool ProcessMonitor::DupDescriptor(const FileSpec &file_spec, int fd,
int flags) {
-  int target_fd = open(file_spec.GetCString(), flags, 0666);
+  int target_fd = llvm::sys::RetryAfterSignal(-1, open,
+  file_spec.GetCString(), flags, 0666);
 
   if (target_fd == -1)
 return false;
Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -665,7 +665,8 @@
   int wstatus;
   // Need to use WALLSIG otherwise we receive an error with errno=ECHLD At this
   // point we should have a thread stopped if waitpid succeeds.
-  if ((wstatus = waitpid(m_pid, NULL, WALLSIG)) < 0)
+  if ((wstatus = llvm::sys::RetryAfterSignal(-1, waitpid,
+  m_pid, NULL, WALLSIG)) < 0)
 return Status(errno, eErrorTypePOSIX);
 
   /* Initialize threads */
Index: lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp
===
--- lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp
+++ lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp
@@ -51,8 +51,10 @@
 
   ~ChildDeleter() {
 int status;
-kill(pid, SIGKILL);// Kill the child.
-waitpid(pid, &status, __WALL); // Pick up the remains.
+// Kill the child.
+kill(pid, SIGKILL);
+// Pick up the remains.
+llvm::sys::RetryAfterSignal(-1, waitpid, pid, &status, __WALL);
   }
 };
 
@@ -81,7 +83,8 @@
   }
 
   int status;
-  ::pid_t wpid = waitpid(child_pid, &status, __WALL);
+  ::pid_t wpid = llvm::sys::RetryAfterSignal(-1, waitpid,
+  child_pid, &status, __WALL);
   if (wpid != child_pid || !WIFSTOPPED(status)) {
 LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status,
  Status(errno, eErrorTypePOSIX));
@@ -110,7 +113,8 @@
   break;
 }
 
-wpid = waitpid(child_pid, &status, __WALL);
+wpid = llvm::sys::RetryAfterSignal(-1, waitpid,
+child_pid, &status, __WALL);
 if (wpid != child_pid || !WIFSTOPPED(status)) {
   LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status,
Status(errno, eErrorTypePOSIX));
Index: lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -21,6 +21,7 @@
 #include "lldb/Utility/Stream.h"
 
 #include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
 
 #include 
 
@@ -39,7 +40,7 @@
 
 void PythonObject::Dump(Stream &strm) const {
   if (m_py_obj) {
-FILE *file = ::tmpfile();
+FILE *file = llvm::sys::RetryAfterSignal(nullptr, ::tmpfile);
 if (file) {
   ::PyObject_Print(m_py_obj, file, 0);
   const long length = ftell(file);
Index: lldb/trunk/source/Host/posix/LockFilePosix.cpp
===
--- lldb/trunk/source/Host/posix/LockFilePosix.cpp
+++ lldb/trunk/source/Host/posix/LockFilePosix.cpp
@@ -8,6 +8,8 @@
 
 #include "lldb/Host/posix/LockFilePosix.h"
 
+#include "llvm/Support/Errno.h"
+
 #include 
 #include 
 
@@ -27,7 +29,7 @@
   fl.l_pid = ::getpid(

[Lldb-commits] [PATCH] D59485: [ASTImporter] Add an ImportInternal method to allow customizing Import behavior.

2019-03-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 191765.
teemperor retitled this revision from "[ASTImporter] Allow adding a import 
strategy to the ASTImporter" to "[ASTImporter] Add an ImportInternal method to 
allow customizing Import behavior.".
teemperor edited the summary of this revision.
teemperor added a comment.

So I replaced the whole Strategy/Shim thing with a simple `ImportInternal` 
method that we can overwrite and is also no longer public. That also gets rid 
of all the boilerplate code from the first patches and also makes the follow-up 
LLDB patch nicer.

@martong It's not related to lookup or anything like that, it's just that we 
don't have enough information in our debug info AST to allow people to use meta 
programming. The custom logic we have in LLDB looks into the std C++ module to 
fill out these gaps in the AST by hand when they are used in an expression.

The remark about the alternative being slow just means that fixing all the 
templates we have in our debug info AST seems like a costly approach. I'm also 
not sure how well it would work, as I never tried mixing a C++ module in an 
ASTContext that isn't currently being parsed by Clang.


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

https://reviews.llvm.org/D59485

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -304,6 +304,14 @@
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
+public:
+  /// Allocates an ASTImporter (or one of its subclasses).
+  typedef std::function
+  ImporterConstructor;
+
+private:
   // Buffer for the To context, must live in the test scope.
   std::string ToCode;
 
@@ -316,22 +324,37 @@
 std::unique_ptr Unit;
 TranslationUnitDecl *TUDecl = nullptr;
 std::unique_ptr Importer;
-TU(StringRef Code, StringRef FileName, ArgVector Args)
+// The lambda that constructs the ASTImporter we use in this test.
+ImporterConstructor Creator;
+TU(StringRef Code, StringRef FileName, ArgVector Args,
+   ImporterConstructor C = ImporterConstructor())
 : Code(Code), FileName(FileName),
   Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
  this->FileName)),
-  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {
+  TUDecl(Unit->getASTContext().getTranslationUnitDecl()), Creator(C) {
   Unit->enableSourceFileDiagnostics();
+
+  // If the test doesn't need a specific ASTImporter, we just create a
+  // normal ASTImporter with it.
+  if (!Creator)
+Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
+ ASTContext &FromContext, FileManager &FromFileManager,
+ bool MinimalImport, ASTImporterLookupTable *LookupTable) {
+  return new ASTImporter(ToContext, ToFileManager, FromContext,
+ FromFileManager, MinimalImport, LookupTable);
+};
+}
+
+void setImporter(std::unique_ptr I) {
+  Importer = std::move(I);
 }
 
 void lazyInitImporter(ASTImporterLookupTable &LookupTable, ASTUnit *ToAST) {
   assert(ToAST);
-  if (!Importer) {
-Importer.reset(
-new ASTImporter(ToAST->getASTContext(), ToAST->getFileManager(),
-Unit->getASTContext(), Unit->getFileManager(),
-false, &LookupTable));
-  }
+  if (!Importer)
+Importer.reset(Creator(ToAST->getASTContext(), ToAST->getFileManager(),
+   Unit->getASTContext(), Unit->getFileManager(),
+   false, &LookupTable));
   assert(&ToAST->getASTContext() == &Importer->getToContext());
   createVirtualFileIfNeeded(ToAST, FileName, Code);
 }
@@ -401,11 +424,12 @@
   // Must not be called more than once within the same test.
   std::tuple
   getImportedDecl(StringRef FromSrcCode, Language FromLang, StringRef ToSrcCode,
-  Language ToLang, StringRef Identifier = DeclToImportID) {
+  Language ToLang, StringRef Identifier = DeclToImportID,
+  ImporterConstructor Creator = ImporterConstructor()) {
 ArgVector FromArgs = getArgVectorForLanguage(FromLang),
   ToArgs = getArgVectorForLanguage(ToLang);
 
-FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs);
+FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs, Creator);
 TU &FromTU = FromTUs.back();
 
 assert(!ToAST);
@@ -455,6 +479,12 @@
 return ToAST->getASTContext().getTranslationUnitDecl();
   }
 
+  ASTImporter &getImporter(Decl *From, Language ToLang) {
+lazyInitToAST(ToLang, "", OutputFileNam

[Lldb-commits] [lldb] r356711 - Makefile.rules: Normalize use of trailing slashes in path variables.

2019-03-21 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Mar 21 13:36:23 2019
New Revision: 356711

URL: http://llvm.org/viewvc/llvm-project?rev=356711&view=rev
Log:
Makefile.rules: Normalize use of trailing slashes in path variables.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=356711&r1=356710&r2=356711&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Thu Mar 21 
13:36:23 2019
@@ -28,10 +28,10 @@
 # Uncomment line below for debugging shell commands
 # SHELL = /bin/sh -x
 
-SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))/
+SRCDIR := $(shell dirname $(firstword $(MAKEFILE_LIST)))
 BUILDDIR := $(shell pwd)
-THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/
-LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../
+THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))
+LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 
 #--
 # If OS is not defined, use 'uname -s' to determine the OS name.
@@ -275,7 +275,7 @@ endif
 CFLAGS += -I$(SRCDIR) -I$(THIS_FILE_DIR)
 
 ifndef NO_TEST_COMMON_H
-  CFLAGS += -include $(THIS_FILE_DIR)test_common.h
+  CFLAGS += -include $(THIS_FILE_DIR)/test_common.h
 endif
 
 CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS) $(CFLAGS_EXTRAS)


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


[Lldb-commits] [PATCH] D59537: Instantiate 'std' templates explicitly in the expression evaluator

2019-03-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked 2 inline comments as done.
teemperor added inline comments.



Comment at: lldb/source/Symbol/StdModuleHandler.cpp:220
+case TemplateArgument::Type: {
+  QualType our_type = m_importer.Import(arg.getAsType());
+  imported_args.push_back(TemplateArgument(our_type));

balazske wrote:
> For long-term (but it should be not so long) the `ASTImporter::Import_New` 
> should be used (later the Import_New will become the Import). By using the 
> existing Import_New the code will be prepared for this change. For this to 
> work the error handling (ignore error, return it from Import or something 
> else) must be implemented here.
Thanks, fixed! I currently just return nothing, which will bring us back to 
LLDB's normal importing logic (which then maybe does better).



Comment at: lldb/source/Symbol/StdModuleHandler.cpp:221
+  QualType our_type = m_importer.Import(arg.getAsType());
+  imported_args.push_back(TemplateArgument(our_type));
+  break;

balazske wrote:
> I do not know if it is possible that the type to be imported here can have 
> back-references to the template object that is currently imported (for 
> example a vector of vectors?). If yes this case may not work correctly.
We first import the argument and then do a lookup, so that works fine. I added 
a test for this now. Thanks a lot for heads up!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59537



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


[Lldb-commits] [PATCH] D59537: Instantiate 'std' templates explicitly in the expression evaluator

2019-03-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 191770.
teemperor added a comment.

- Added more tests (contents from debug info for containers, vectors of vectors)
- Import -> Import_New
- Rebased on top of the updated parent commit, which means the StdModuleHandler 
is now much simpler.


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

https://reviews.llvm.org/D59537

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/ClangASTImporter.h
  lldb/include/lldb/Symbol/StdModuleHandler.h
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-basic/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-basic/TestBasicDeque.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-basic/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-basic/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-basic/TestBasicForwardList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-basic/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-basic/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-basic/TestBasicList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-basic/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-dbg-info-content/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-dbg-info-content/TestDbgInfoContentList.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-dbg-info-content/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr-dbg-info-content/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContent.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr-dbg-info-content/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr/TestSharedPtr.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr-dbg-info-content/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr-dbg-info-content/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr/TestUniquePtr.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-basic/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-basic/TestBasicVector.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-basic/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-bool/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-bool/TestBoolVector.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-bool/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-dbg-info-content/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-dbg-info-content/TestDbgInfoContentVector.py
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-dbg-info-content/main.cpp
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-of-vectors/Makefile
  
lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-of-vectors/TestVectorOfVectors.py
  
lldb/packages

[Lldb-commits] [PATCH] D59667: Regression test to ensure that we handling importing of anonymous enums correctly

2019-03-21 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added reviewers: aprantl, teemperor, jingham.
Herald added a reviewer: serge-sans-paille.
Herald added a subscriber: jdoerfert.

https://reviews.llvm.org/D51633 added error handling in the ASTImporter.cpp 
which uncovered an underlying bug in which we used the wrong name when handling 
naming conflicts. This could cause a segmentation fault when attempting to cast 
an int to an enum during expression parsing.

This test should pass once https://reviews.llvm.org/D59665 is committed.


https://reviews.llvm.org/D59667

Files:
  
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
  
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
  
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp


Index: 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
@@ -0,0 +1,12 @@
+#include 
+
+typedef enum {
+A=0,
+} flow_e;
+
+int main() {
+   flow_e f;
+
+   printf( "%d\n", (flow_e)0);
+   return 0; // break here
+}
Index: 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
@@ -0,0 +1,22 @@
+"""
+Test Expression Parser regression text to ensure that we handle anonymous
+enums importing correctly.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCastIntToAnonymousEnum(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_cast_int_to_anonymous_enum(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])
Index: 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


Index: packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/main.cpp
@@ -0,0 +1,12 @@
+#include 
+
+typedef enum {
+A=0,
+} flow_e;
+
+int main() {
+   flow_e f;
+
+   printf( "%d\n", (flow_e)0);
+   return 0; // break here
+}
Index: packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py
@@ -0,0 +1,22 @@
+"""
+Test Expression Parser regression text to ensure that we handle anonymous
+enums importing correctly.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCastIntToAnonymousEnum(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_cast_int_to_anonymous_enum(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, '// break here',
+lldb.SBFileSpec("main.cpp", False))
+
+self.expect("expr (flow_e)0", substrs=['(flow_e) $0 = A'])
Index: packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/cast_int_to_anonymous_enum/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59667: Regression test to ensure that we handling importing of anonymous enums correctly

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

LGTM, just clang format `main.cpp` before committing.


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

https://reviews.llvm.org/D59667



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


[Lldb-commits] [PATCH] D59651: Move DebugRanges() function from SymbolFileDWARF to DWARFContext

2019-03-21 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Be nice to move DWARFContext out of the lldb_private namespace at some point, 
but I didn't catch this on other patches so this won't hold up this patch.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h:23-26
+namespace lldb_private {
+class DWARFContext;
+}
+

Why are we defining DWARFContext in the lldb_private namespace? I missed prior 
patches doing this, but we should start putting plug-in code in plug-in 
specific namespace at some point.


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

https://reviews.llvm.org/D59651



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


[Lldb-commits] [lldb] r356725 - [Reproducers] Fix log statements

2019-03-21 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu Mar 21 16:58:51 2019
New Revision: 356725

URL: http://llvm.org/viewvc/llvm-project?rev=356725&view=rev
Log:
[Reproducers] Fix log statements

This isn't python where you can omit the index inside `{}`.

Modified:

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp?rev=356725&r1=356724&r2=356725&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
 Thu Mar 21 16:58:51 2019
@@ -123,10 +123,10 @@ GDBRemoteCommunicationReplayServer::GetP
 if (entry.type == GDBRemoteCommunicationHistory::ePacketTypeSend) {
   if (unexpected(entry.packet.data, packet.GetStringRef())) {
 LLDB_LOG(log,
- "GDBRemoteCommunicationReplayServer expected packet: '{}'\n",
+ "GDBRemoteCommunicationReplayServer expected packet: '{0}'",
  entry.packet.data);
 LLDB_LOG(log,
- "GDBRemoteCommunicationReplayServer actual packet: '{}'\n",
+ "GDBRemoteCommunicationReplayServer actual packet: '{0}'",
  packet.GetStringRef());
   }
 
@@ -143,7 +143,7 @@ GDBRemoteCommunicationReplayServer::GetP
 if (entry.type == GDBRemoteCommunicationHistory::ePacketTypeInvalid) {
   LLDB_LOG(
   log,
-  "GDBRemoteCommunicationReplayServer skipped invalid packet: '{}'\n",
+  "GDBRemoteCommunicationReplayServer skipped invalid packet: '{0}'",
   packet.GetStringRef());
   continue;
 }


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


[Lldb-commits] [PATCH] D59681: Update the lldb driver to support the -O and -S options when passing --repl

2019-03-21 Thread Nathan Hawes via Phabricator via lldb-commits
nathawes created this revision.
nathawes added reviewers: aprantl, jingham.
Herald added a subscriber: abidh.
Herald added a project: LLDB.

At the moment when `--repl` is passed to `lldb` it silently ignores any 
commands passed via the options below:

  --one-line-before-file 
   Tells the debugger to execute this one-line lldb command 
before any file provided on the command line has been loaded.
  --one-line  
   Tells the debugger to execute this one-line lldb command 
after any file provided on the command line has been loaded.  
  --source-before-file 
   Tells the debugger to read in and execute the lldb 
commands in the given file, before any file has been loaded.
  --source 
   Tells the debugger to read in and execute the lldb 
commands in the given file, after any file has been loaded.
  -OAlias for --one-line-before-file
  -oAlias for --one-line
  -SAlias for --source-before-file
  -sAlias for --source

The `-O` and `-S` options are quite useful when writing tests for the REPL 
though, e.g. to change settings prior to entering REPL mode. This patch updates 
the driver to still respect the commands supplied via `-O` and `-S` when 
passing `--repl` instead of silently ignoring them. As `-s` and `-o` don't 
really make sense in REPL mode, commands supplied via those options are still 
ignored, but the driver now emits a warning to make that clear to the user.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D59681

Files:
  lldb/lit/Driver/TestRepl.test
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -609,47 +609,55 @@
   // are processed.
   WriteCommandsForSourcing(eCommandPlacementBeforeFile, commands_stream);
 
-  const size_t num_args = m_option_data.m_args.size();
-  if (num_args > 0) {
-char arch_name[64];
-if (lldb::SBDebugger::GetDefaultArchitecture(arch_name, sizeof(arch_name)))
-  commands_stream.Printf("target create --arch=%s %s", arch_name,
- EscapeString(m_option_data.m_args[0]).c_str());
-else
-  commands_stream.Printf("target create %s",
- EscapeString(m_option_data.m_args[0]).c_str());
-
-if (!m_option_data.m_core_file.empty()) {
-  commands_stream.Printf(" --core %s",
- EscapeString(m_option_data.m_core_file).c_str());
-}
-commands_stream.Printf("\n");
+  // If we're not in --repl mode, add the commands to process the file
+  // arguments, and the commands specified to run afterwards.
+  if (!m_option_data.m_repl) {
+const size_t num_args = m_option_data.m_args.size();
+if (num_args > 0) {
+  char arch_name[64];
+  if (lldb::SBDebugger::GetDefaultArchitecture(arch_name, sizeof(arch_name)))
+commands_stream.Printf("target create --arch=%s %s", arch_name,
+   EscapeString(m_option_data.m_args[0]).c_str());
+  else
+commands_stream.Printf("target create %s",
+   EscapeString(m_option_data.m_args[0]).c_str());
 
-if (num_args > 1) {
-  commands_stream.Printf("settings set -- target.run-args ");
-  for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
-commands_stream.Printf(
-" %s", EscapeString(m_option_data.m_args[arg_idx]).c_str());
+  if (!m_option_data.m_core_file.empty()) {
+commands_stream.Printf(" --core %s",
+   EscapeString(m_option_data.m_core_file).c_str());
+  }
   commands_stream.Printf("\n");
-}
-  } else if (!m_option_data.m_core_file.empty()) {
-commands_stream.Printf("target create --core %s\n",
-   EscapeString(m_option_data.m_core_file).c_str());
-  } else if (!m_option_data.m_process_name.empty()) {
-commands_stream.Printf("process attach --name %s",
-   EscapeString(m_option_data.m_process_name).c_str());
 
-if (m_option_data.m_wait_for)
-  commands_stream.Printf(" --waitfor");
+  if (num_args > 1) {
+commands_stream.Printf("settings set -- target.run-args ");
+for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
+  commands_stream.Printf(
+  " %s", EscapeString(m_option_data.m_args[arg_idx]).c_str());
+commands_stream.Printf("\n");
+  }
+} else if (!m_option_data.m_core_file.empty()) {
+  commands_stream.Printf("target create --core %s\n",
+ EscapeString(m_option_data.m_core_file).c_str());
+} else if (!m_option_data.m_process_name.empty()) {
+  commands_stream.Printf("process attach --name %s",
+ EscapeString(m_option_data.m_process_name).c_str());
+
+  if (m_option_data.m_wait_for)
+