[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-03 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a reviewer: zturner.
mstorsjo added a comment.

As context (I haven't followed lldb almost at all), what's the general status 
of lldb on windows - generally working, or still a work in progress? Does it 
work with dwarf debug info in COFF (as commonly used in mingw environments), in 
addition to PDB? I.e. is the existing dwarf support tied to the ELF/MachO 
formats, or is it decoupled?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65691



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


[Lldb-commits] [PATCH] D67858: [LLDB] Check for the GCC/MinGW compatible arch defines for windows, in addition to MSVC defines

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: compnerd, hhb, labath.
Herald added subscribers: JDevlieghere, abidh.
Herald added a project: LLDB.

This matches how it is done in all other similar ifdefs throughout lldb (modulo 
inconsistencies between `_M_AMD64` and `_M_X64`); both MSVC and GCC style arch 
defines are checked together.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67858

Files:
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -21,9 +21,9 @@
 #include "TargetThreadWindows.h"
 
 // TODO support _M_ARM and _M_ARM64
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 #include "x64/RegisterContextWindows_x64.h"
-#elif defined(_M_IX86)
+#elif defined(__i386__) || defined(_M_IX86)
 #include "x86/RegisterContextWindows_x86.h"
 #endif
 
@@ -77,7 +77,7 @@
 break;
 
   case llvm::Triple::x86:
-#if defined(_M_IX86)
+#if defined(__i386__) || defined(_M_IX86)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x86(*this, concrete_frame_idx));
 #else
@@ -86,7 +86,7 @@
 break;
 
   case llvm::Triple::x86_64:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x64(*this, concrete_frame_idx));
 #else
Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
   case 8:
 #endif
 break;


Index: lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -21,9 +21,9 @@
 #include "TargetThreadWindows.h"
 
 // TODO support _M_ARM and _M_ARM64
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 #include "x64/RegisterContextWindows_x64.h"
-#elif defined(_M_IX86)
+#elif defined(__i386__) || defined(_M_IX86)
 #include "x86/RegisterContextWindows_x86.h"
 #endif
 
@@ -77,7 +77,7 @@
 break;
 
   case llvm::Triple::x86:
-#if defined(_M_IX86)
+#if defined(__i386__) || defined(_M_IX86)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x86(*this, concrete_frame_idx));
 #else
@@ -86,7 +86,7 @@
 break;
 
   case llvm::Triple::x86_64:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x64(*this, concrete_frame_idx));
 #else
Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
   case 8:
 #endif
 break;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67856: [LLDB] Fix compilation for MinGW, remove redundant class name on inline member

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D67856#1677356 , @davide wrote:

> If this doesn't break clang and gcc, fine.


FWIW, it was with clang that I ran into it, haven't tested building lldb with 
gcc.

But the issue can be tested with a snippet like this:

  class Foo {
  public: 
  Foo::Foo() {}
  };

With MSVC, this passes fine without any warnings. With clang-cl (or plain clang 
with an msvc target), it builds but warns (`-Wmicrosoft-extra-qualification`), 
with gcc it's an error (that can be waived with `-fpermissive`), and with clang 
a non-msvc target, it's an unrecoverable error.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67856



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


[Lldb-commits] [PATCH] D67860: [LLDB] Use LLVM_FALLTHROUGH instead of a custom comment

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: asmith, hhb, labath.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

This fixes a warning when built with Clang instead of MSVC.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67860

Files:
  lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -479,7 +479,7 @@
   return ExceptionResult::BreakInDebugger;
 }
 
-// Fall through
+LLVM_FALLTHROUGH;
   default:
 LLDB_LOG(log,
  "Debugger thread reported exception {0:x} at address {1:x} "


Index: lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -479,7 +479,7 @@
   return ExceptionResult::BreakInDebugger;
 }
 
-// Fall through
+LLVM_FALLTHROUGH;
   default:
 LLDB_LOG(log,
  "Debugger thread reported exception {0:x} at address {1:x} "
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67861: [LLDB] Check for the __MINGW32__ define instead of __MINGW64

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: hhb, xen2, labath.
Herald added subscribers: JDevlieghere, abidh.
Herald added a project: LLDB.

`__MINGW64__` is only defined for 64 bit targets, and the define without 
trailing underscores is never defined automatically (neither by clang nor by 
gcc), while `__MINGW32__` is defined for any MinGW target, both 32 and 64 bit.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67861

Files:
  lldb/source/Host/windows/Windows.cpp


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -48,7 +48,7 @@
   size_t buflen;
   va_list ap2;
 
-#if defined(_MSC_VER) || defined(__MINGW64)
+#if defined(_MSC_VER) || defined(__MINGW32__)
   ap2 = ap;
   len = _vscprintf(fmt, ap2);
 #else


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -48,7 +48,7 @@
   size_t buflen;
   va_list ap2;
 
-#if defined(_MSC_VER) || defined(__MINGW64)
+#if defined(_MSC_VER) || defined(__MINGW32__)
   ap2 = ap;
   len = _vscprintf(fmt, ap2);
 #else
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67856: [LLDB] Fix compilation for MinGW, remove redundant class name on inline member

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: asmith, labath, hhb.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

This fixes build errors like these:

  NativeRegisterContextWindows.h:22:33: error: extra qualification on member 
'NativeRegisterContextWindows'
NativeRegisterContextWindows::NativeRegisterContextWindows(
~~^


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67856

Files:
  lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h


Index: lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
===
--- lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
+++ lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
@@ -19,7 +19,7 @@
 
 class NativeRegisterContextWindows : public NativeRegisterContextRegisterInfo {
 public:
-  NativeRegisterContextWindows::NativeRegisterContextWindows(
+  NativeRegisterContextWindows(
   NativeThreadProtocol _thread,
   RegisterInfoInterface *reg_info_interface_p);
 


Index: lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
===
--- lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
+++ lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
@@ -19,7 +19,7 @@
 
 class NativeRegisterContextWindows : public NativeRegisterContextRegisterInfo {
 public:
-  NativeRegisterContextWindows::NativeRegisterContextWindows(
+  NativeRegisterContextWindows(
   NativeThreadProtocol _thread,
   RegisterInfoInterface *reg_info_interface_p);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67857: [LLDB] Include lldb/Host/windows/windows.h on any windows target

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: lanza, hhb, labath.
Herald added subscribers: JDevlieghere, abidh.
Herald added a project: LLDB.

This fixes MinGW builds, that otherwise fail due to use of undeclared 
`GetLastError()` and `ERROR_OPERATION_ABORTED`.

The use of `GetLastError()` was added in SVN r366520 (within an `#ifdef 
_WIN32`), while the existing include of `lldb/Host/windows/windows.h` was 
within `#ifdef _MSC_VER`. Change the include ifdef to `#ifdef _WIN32`.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67857

Files:
  lldb/source/Core/IOHandler.cpp


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -52,7 +52,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 #include "lldb/Host/windows/windows.h"
 #endif
 


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -52,7 +52,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 #include "lldb/Host/windows/windows.h"
 #endif
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67859: [LLDB] Use the Windows SOCKET type on all windows targets, not only MSVC

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: hhb, labath, amccarth.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67859

Files:
  lldb/include/lldb/Host/Socket.h


Index: lldb/include/lldb/Host/Socket.h
===
--- lldb/include/lldb/Host/Socket.h
+++ lldb/include/lldb/Host/Socket.h
@@ -31,7 +31,7 @@
 
 namespace lldb_private {
 
-#if defined(_MSC_VER)
+#if defined(_WIN32)
 typedef SOCKET NativeSocket;
 #else
 typedef int NativeSocket;


Index: lldb/include/lldb/Host/Socket.h
===
--- lldb/include/lldb/Host/Socket.h
+++ lldb/include/lldb/Host/Socket.h
@@ -31,7 +31,7 @@
 
 namespace lldb_private {
 
-#if defined(_MSC_VER)
+#if defined(_WIN32)
 typedef SOCKET NativeSocket;
 #else
 typedef int NativeSocket;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67863: [LLDB] Cast -1 (as invalid socket) to the socket type before comparing

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: hhb, labath, compnerd.
Herald added subscribers: JDevlieghere, abidh.
Herald added a project: LLDB.

This silences warnings about comparison of integers between unsigned long long 
(which is what the Windows SOCKET type is) and signed int when building in 
MinGW mode.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67863

Files:
  lldb/source/Host/common/Socket.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
@@ -93,7 +93,7 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
+  newsockfd = llvm::sys::RetryAfterSignal((SOCKET) -1, accept,
   sockfd, (struct sockaddr *)_addr, );
   if (newsockfd < 0)
 if (g_vsc.log)
Index: lldb/source/Host/common/Socket.cpp
===
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -476,10 +476,10 @@
   if (!child_processes_inherit) {
 flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
+  NativeSocket fd = llvm::sys::RetryAfterSignal((NativeSocket) -1, ::accept4,
   sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
+  NativeSocket fd = llvm::sys::RetryAfterSignal((NativeSocket) -1, ::accept,
   sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -93,7 +93,7 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
+  newsockfd = llvm::sys::RetryAfterSignal((SOCKET) -1, accept,
   sockfd, (struct sockaddr *)_addr, );
   if (newsockfd < 0)
 if (g_vsc.log)
Index: lldb/source/Host/common/Socket.cpp
===
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -476,10 +476,10 @@
   if (!child_processes_inherit) {
 flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
+  NativeSocket fd = llvm::sys::RetryAfterSignal((NativeSocket) -1, ::accept4,
   sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
+  NativeSocket fd = llvm::sys::RetryAfterSignal((NativeSocket) -1, ::accept,
   sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67862: [LLDB] Use SetErrorStringWithFormatv for cases that use LLVM style format strings

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: asmith, hhb, labath, compnerd.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

SetErrorStringWithFormat only supports normal printf style format strings.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67862

Files:
  lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -170,9 +170,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), private_state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), private_state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;
Index: lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -177,9 +177,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;


Index: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -170,9 +170,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), private_state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), private_state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;
Index: lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -177,9 +177,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67863: [LLDB] Cast -1 (as invalid socket) to the socket type before comparing

2019-09-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 221122.
mstorsjo added a comment.

Use static_cast.


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

https://reviews.llvm.org/D67863

Files:
  lldb/source/Host/common/Socket.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
@@ -93,8 +93,9 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
-  sockfd, (struct sockaddr *)_addr, );
+  newsockfd =
+  llvm::sys::RetryAfterSignal(static_cast(-1), accept, sockfd,
+  (struct sockaddr *)_addr, );
   if (newsockfd < 0)
 if (g_vsc.log)
   *g_vsc.log << "error: accept (" << strerror(errno) << ")"
Index: lldb/source/Host/common/Socket.cpp
===
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -476,11 +476,11 @@
   if (!child_processes_inherit) {
 flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
-  sockfd, addr, addrlen, flags);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept4, sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
-  sockfd, addr, addrlen);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept, sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)
 SetLastError(error);


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -93,8 +93,9 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
-  sockfd, (struct sockaddr *)_addr, );
+  newsockfd =
+  llvm::sys::RetryAfterSignal(static_cast(-1), accept, sockfd,
+  (struct sockaddr *)_addr, );
   if (newsockfd < 0)
 if (g_vsc.log)
   *g_vsc.log << "error: accept (" << strerror(errno) << ")"
Index: lldb/source/Host/common/Socket.cpp
===
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -476,11 +476,11 @@
   if (!child_processes_inherit) {
 flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
-  sockfd, addr, addrlen, flags);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept4, sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
-  sockfd, addr, addrlen);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept, sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)
 SetLastError(error);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67860: [LLDB] Use LLVM_FALLTHROUGH instead of a custom comment

2019-09-21 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372484: [LLDB] Use LLVM_FALLTHROUGH instead of a custom 
comment (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67860?vs=221105=221194#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67860

Files:
  lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp


Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -479,7 +479,7 @@
   return ExceptionResult::BreakInDebugger;
 }
 
-// Fall through
+LLVM_FALLTHROUGH;
   default:
 LLDB_LOG(log,
  "Debugger thread reported exception {0:x} at address {1:x} "


Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -479,7 +479,7 @@
   return ExceptionResult::BreakInDebugger;
 }
 
-// Fall through
+LLVM_FALLTHROUGH;
   default:
 LLDB_LOG(log,
  "Debugger thread reported exception {0:x} at address {1:x} "
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67862: [LLDB] Use SetErrorStringWithFormatv for cases that use LLVM style format strings

2019-09-21 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372485: [LLDB] Use SetErrorStringWithFormatv for cases that 
use LLVM style format… (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67862?vs=221108=221195#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67862

Files:
  lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp


Index: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -170,9 +170,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), private_state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), private_state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;
Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -177,9 +177,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;


Index: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -170,9 +170,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), private_state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), private_state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;
Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeProcessWindows.cpp
@@ -177,9 +177,9 @@
 else
   LLDB_LOG(log, "Detaching process error: {0}", error);
   } else {
-error.SetErrorStringWithFormat("error: process {0} in state = {1}, but "
-   "cannot detach it in this state.",
-   GetID(), state);
+error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
+"cannot detach it in this state.",
+GetID(), state);
 LLDB_LOG(log, "error: {0}", error);
   }
   return error;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67863: [LLDB] Cast -1 (as invalid socket) to the socket type before comparing

2019-09-21 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372486: [LLDB] Cast -1 (as invalid socket) to the socket 
type before comparing (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67863?vs=221122=221196#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67863

Files:
  lldb/trunk/source/Host/common/Socket.cpp
  lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/trunk/source/Host/common/Socket.cpp
===
--- lldb/trunk/source/Host/common/Socket.cpp
+++ lldb/trunk/source/Host/common/Socket.cpp
@@ -476,11 +476,11 @@
   if (!child_processes_inherit) {
 flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
-  sockfd, addr, addrlen, flags);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept4, sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
-  sockfd, addr, addrlen);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept, sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)
 SetLastError(error);
Index: lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
@@ -93,8 +93,9 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
-  sockfd, (struct sockaddr *)_addr, );
+  newsockfd =
+  llvm::sys::RetryAfterSignal(static_cast(-1), accept, sockfd,
+  (struct sockaddr *)_addr, );
   if (newsockfd < 0)
 if (g_vsc.log)
   *g_vsc.log << "error: accept (" << strerror(errno) << ")"


Index: lldb/trunk/source/Host/common/Socket.cpp
===
--- lldb/trunk/source/Host/common/Socket.cpp
+++ lldb/trunk/source/Host/common/Socket.cpp
@@ -476,11 +476,11 @@
   if (!child_processes_inherit) {
 flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
-  sockfd, addr, addrlen, flags);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept4, sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
-  sockfd, addr, addrlen);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+  static_cast(-1), ::accept, sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)
 SetLastError(error);
Index: lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
@@ -93,8 +93,9 @@
 } else {
   listen(sockfd, 5);
   socklen_t clilen = sizeof(cli_addr);
-  newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
-  sockfd, (struct sockaddr *)_addr, );
+  newsockfd =
+  llvm::sys::RetryAfterSignal(static_cast(-1), accept, sockfd,
+  (struct sockaddr *)_addr, );
   if (newsockfd < 0)
 if (g_vsc.log)
   *g_vsc.log << "error: accept (" << strerror(errno) << ")"
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67856: [LLDB] Fix compilation for MinGW, remove redundant class name on inline member

2019-09-21 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372482: [LLDB] Fix compilation for MinGW, remove redundant 
class name on inline member (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67856?vs=221098=221192#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67856

Files:
  
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h


Index: 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
===
--- 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
+++ 
lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
@@ -19,7 +19,7 @@
 
 class NativeRegisterContextWindows : public NativeRegisterContextRegisterInfo {
 public:
-  NativeRegisterContextWindows::NativeRegisterContextWindows(
+  NativeRegisterContextWindows(
   NativeThreadProtocol _thread,
   RegisterInfoInterface *reg_info_interface_p);
 


Index: lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows.h
@@ -19,7 +19,7 @@
 
 class NativeRegisterContextWindows : public NativeRegisterContextRegisterInfo {
 public:
-  NativeRegisterContextWindows::NativeRegisterContextWindows(
+  NativeRegisterContextWindows(
   NativeThreadProtocol _thread,
   RegisterInfoInterface *reg_info_interface_p);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67858: [LLDB] Check for the GCC/MinGW compatible arch defines for windows, in addition to MSVC defines

2019-09-21 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372483: [LLDB] Check for the GCC/MinGW compatible arch 
defines for windows, in addition… (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67858?vs=221102=221193#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67858

Files:
  lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp


Index: 
lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
   case 8:
 #endif
 break;
Index: lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -21,9 +21,9 @@
 #include "TargetThreadWindows.h"
 
 // TODO support _M_ARM and _M_ARM64
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 #include "x64/RegisterContextWindows_x64.h"
-#elif defined(_M_IX86)
+#elif defined(__i386__) || defined(_M_IX86)
 #include "x86/RegisterContextWindows_x86.h"
 #endif
 
@@ -77,7 +77,7 @@
 break;
 
   case llvm::Triple::x86:
-#if defined(_M_IX86)
+#if defined(__i386__) || defined(_M_IX86)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x86(*this, concrete_frame_idx));
 #else
@@ -86,7 +86,7 @@
 break;
 
   case llvm::Triple::x86_64:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x64(*this, concrete_frame_idx));
 #else


Index: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
   case 8:
 #endif
 break;
Index: lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -21,9 +21,9 @@
 #include "TargetThreadWindows.h"
 
 // TODO support _M_ARM and _M_ARM64
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 #include "x64/RegisterContextWindows_x64.h"
-#elif defined(_M_IX86)
+#elif defined(__i386__) || defined(_M_IX86)
 #include "x86/RegisterContextWindows_x86.h"
 #endif
 
@@ -77,7 +77,7 @@
 break;
 
   case llvm::Triple::x86:
-#if defined(_M_IX86)
+#if defined(__i386__) || defined(_M_IX86)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x86(*this, concrete_frame_idx));
 #else
@@ -86,7 +86,7 @@
 break;
 
   case llvm::Triple::x86_64:
-#if defined(_M_AMD64)
+#if defined(__x86_64__) || defined(_M_AMD64)
 m_thread_reg_ctx_sp.reset(
 new RegisterContextWindows_x64(*this, concrete_frame_idx));
 #else
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67885: [LLDB] Add a missing specification of linking against dbghelp

2019-09-21 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: amccarth, compnerd, hhb.
Herald added subscribers: JDevlieghere, abidh, mgorny.
Herald added a project: LLDB.

The PECOFF object file plugin uses the dbghelp API, but doesn't specify that it 
has to be linked in anywhere.

Current MSVC based builds have probably succeeded, as other parts in LLDB have 
had a "#pragma comment(lib, "dbghelp.lib")", but there's currently no such 
pragma in the PECOFF plugin.

The "#pragma comment(lib, ...)" approach doesn't work in MinGW mode (unless the 
compiler is given the -fms-extensions option, and even then, it's only 
supported by clang/lld, not by GCC/binutils), thus add it to be linked via 
CMake. (The other parts of LLDB that use dbghelp are within _MSC_VER ifdefs.)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67885

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt


Index: lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
===
--- lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
+++ lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
@@ -1,3 +1,9 @@
+if(WIN32)
+  set(DBGHELP_LINK_FILES dbghelp)
+else()
+  set(DBGHELP_LINK_FILES "")
+endif()
+
 add_lldb_library(lldbPluginObjectFilePECOFF PLUGIN
   ObjectFilePECOFF.cpp
   WindowsMiniDump.cpp
@@ -7,6 +13,7 @@
 lldbHost
 lldbSymbol
 lldbTarget
+${DBGHELP_LINK_FILES}
   LINK_COMPONENTS
 BinaryFormat
 Support


Index: lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
===
--- lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
+++ lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
@@ -1,3 +1,9 @@
+if(WIN32)
+  set(DBGHELP_LINK_FILES dbghelp)
+else()
+  set(DBGHELP_LINK_FILES "")
+endif()
+
 add_lldb_library(lldbPluginObjectFilePECOFF PLUGIN
   ObjectFilePECOFF.cpp
   WindowsMiniDump.cpp
@@ -7,6 +13,7 @@
 lldbHost
 lldbSymbol
 lldbTarget
+${DBGHELP_LINK_FILES}
   LINK_COMPONENTS
 BinaryFormat
 Support
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-09-28 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373144: [LLDB] Use the llvm microsoft demangler instead of 
the windows dbghelp api. NFC. (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68134?vs=222151=88#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68134

Files:
  lldb/trunk/source/Core/Mangled.cpp


Index: lldb/trunk/source/Core/Mangled.cpp
===
--- lldb/trunk/source/Core/Mangled.cpp
+++ lldb/trunk/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
 
 #include "lldb/Core/Mangled.h"
 
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -218,28 +192,16 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+  char *demangled_cstr = llvm::microsoftDemangle(M, nullptr, nullptr, nullptr);
 
   if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) 
{
 if (demangled_cstr && demangled_cstr[0])
   LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
 else
-  LLDB_LOGF(log, "demangled msvc: %s -> error: 0x%lu", M, result);
+  LLDB_LOGF(log, "demangled msvc: %s -> error", M);
   }
 
-  if (result != 0) {
-return demangled_cstr;
-  } else {
-::free(demangled_cstr);
-return nullptr;
-  }
-#else
-  return nullptr;
-#endif
+  return demangled_cstr;
 }
 
 static char *GetItaniumDemangledStr(const char *M) {


Index: lldb/trunk/source/Core/Mangled.cpp
===
--- lldb/trunk/source/Core/Mangled.cpp
+++ lldb/trunk/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
 
 #include "lldb/Core/Mangled.h"
 
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -218,28 +192,16 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, 

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

2019-09-28 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D68134#1686970 , @thakis wrote:

> We can add flags for omitting access specifiers etc if it's critical for 
> lldb. Or maybe we can just change the test that caused the revert.


Yeah I doubt it's critical to maintain the exact same form as before, but I 
need to get the tests running in my cross compile setup to verify exactly how 
to update them.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68134



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


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

2019-10-01 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D68134#1687865 , @labath wrote:

> In D68134#1687518 , @mstorsjo wrote:
>
> > In D68134#1687500 , @labath wrote:
> >
> > > I'm not sure what failed here exactly, but there are some places in lldb 
> > > that parse the demangled names. These might get confused by additional 
> > > things appearing in the name. Though it's possible to also fix that, so 
> > > the main question might be: what is the name we want to display to the 
> > > users? I guess it would be the best if this matched what is displayed by 
> > > other tools ?
> >
> >
> > In this case, the output becomes the same as what has been chosen to be 
> > used by the common llvm demangler, which probably should be a good choice 
> > in general.
>
>
> That makes sense to me, but I am not really a windows person. Maybe wait a 
> while to see if any of the real "windows people" have any thoughts.


@thakis - Do you happen to have an opinion here on what's the best course 
forward? I guess you're the one currently most familiar with the MS demangler.

>>> As for tests, you should at least be able to run the tests in the regular 
>>> "host" setup, right ?
>> 
>> In principle, but I normally don't run windows except in a very underpowered 
>> VM for testing things, and building there is no fun. I can spin up some more 
>> powerful VMs for some better testing though.
>> 
>> In this case, much of the functionality of these tests require having the MS 
>> DIA SDK available (which also implies building in MSVC/clang-cl mode, not 
>> mingw mode), for reading PDB files. Probably just another step to do, but I 
>> don't have it set up right now.
> 
> So, you're developing windows arm64 support, without even a real windows x86 
> around? That's brave. :)

That's nothing; I brought up most of the windows arm64 support in 
llvm/clang/lld before I even had a real windows arm64 device to test on (and 
without access to MSVC targeting arm64 as well for most of the time), just 
testing in wine, which was capable of running a handful of binaries that were 
available :-)


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

https://reviews.llvm.org/D68134



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


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

2019-09-27 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth, rnk, compnerd.
Herald added subscribers: JDevlieghere, erik.pilkington.
Herald added a project: LLDB.

I'm unsure if there's any lldb testcase which exercise this directly (I didn't 
find any); such testcases could be made available for all platforms now.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68134

Files:
  lldb/source/Core/Mangled.cpp


Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -10,9 +10,6 @@
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
 #endif
 
 #include "lldb/Core/RichManglingContext.h"
@@ -39,25 +36,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER) // TODO: Use this if linking to dbghelp
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -218,28 +196,16 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+  char *demangled_cstr = llvm::microsoftDemangle(M, nullptr, nullptr, nullptr);
 
   if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) 
{
 if (demangled_cstr && demangled_cstr[0])
   LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
 else
-  LLDB_LOGF(log, "demangled msvc: %s -> error: 0x%lu", M, result);
+  LLDB_LOGF(log, "demangled msvc: %s -> error", M);
   }
 
-  if (result != 0) {
-return demangled_cstr;
-  } else {
-::free(demangled_cstr);
-return nullptr;
-  }
-#else
-  return nullptr;
-#endif
+  return demangled_cstr;
 }
 
 static char *GetItaniumDemangledStr(const char *M) {


Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -10,9 +10,6 @@
 
 #if defined(_WIN32)
 #include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
 #endif
 
 #include "lldb/Core/RichManglingContext.h"
@@ -39,25 +36,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER) // TODO: Use this if linking to dbghelp
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -218,28 +196,16 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+  char *demangled_cstr = llvm::microsoftDemangle(M, nullptr, nullptr, nullptr);
 
   if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
 if (demangled_cstr && demangled_cstr[0])
   LLDB_LOGF(log, 

[Lldb-commits] [PATCH] D67954: [LLDB] [Windows] Initial support for ARM64 debugging

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, compnerd, amccarth, hhb, asmith.
Herald added subscribers: JDevlieghere, abidh, kristof.beyls, mgorny.
Herald added a project: LLDB.

This seems to be enough for getting a backtrace and variable values for 
MinGW-built binaries for ARM64.

This doesn't implement the intended future setup (if I understand things 
correctly) of using NativeRegisterContexts.

What's a suitable testcase for this? So far I've just built LLDB and tested 
debugging a real binary with it. I don't have the full llvm build environment 
available on the arm64 windows machine yet, so running the full testsuite isn't 
really easily feasible. (Perhaps it would be doable via WSL?)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67954

Files:
  lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
  
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
  
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.h

Index: lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.h
@@ -0,0 +1,47 @@
+//===-- RegisterContextWindows_arm64.h --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_RegisterContextWindows_arm64_H_
+#define liblldb_RegisterContextWindows_arm64_H_
+
+#if defined(__aarch64__) || defined(_M_ARM64)
+
+#include "RegisterContextWindows.h"
+#include "lldb/lldb-forward.h"
+
+namespace lldb_private {
+
+class Thread;
+
+class RegisterContextWindows_arm64 : public RegisterContextWindows {
+public:
+  // Constructors and Destructors
+  RegisterContextWindows_arm64(Thread , uint32_t concrete_frame_idx);
+
+  virtual ~RegisterContextWindows_arm64();
+
+  // Subclasses must override these functions
+  size_t GetRegisterCount() override;
+
+  const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
+
+  size_t GetRegisterSetCount() override;
+
+  const RegisterSet *GetRegisterSet(size_t reg_set) override;
+
+  bool ReadRegister(const RegisterInfo *reg_info,
+RegisterValue _value) override;
+
+  bool WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue _value) override;
+};
+} // namespace lldb_private
+
+#endif // defined(__aarch64__) || defined(_M_ARM64)
+
+#endif // #ifndef liblldb_RegisterContextWindows_arm64_H_
Index: lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
===
--- /dev/null
+++ lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
@@ -0,0 +1,423 @@
+//===-- RegisterContextWindows_arm64.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#if defined(__aarch64__) || defined(_M_ARM64)
+
+#include "lldb/Host/windows/HostThreadWindows.h"
+#include "lldb/Host/windows/windows.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/lldb-private-types.h"
+
+#include "RegisterContextWindows_arm64.h"
+#include "TargetThreadWindows.h"
+
+#include "llvm/ADT/STLExtras.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+#define GPR_OFFSET(idx) 0
+#define GPR_OFFSET_NAME(reg) 0
+
+#define FPU_OFFSET(idx) 0
+#define FPU_OFFSET_NAME(reg) 0
+
+#define EXC_OFFSET_NAME(reg) 0
+#define DBG_OFFSET_NAME(reg) 0
+
+#define DEFINE_DBG(reg, i) \
+  #reg, NULL,  \
+  0, DBG_OFFSET_NAME(reg[i]), eEncodingUint, eFormatHex,   \
+  {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,   \
+   LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,   \
+   LLDB_INVALID_REGNUM },  \
+   NULL, NULL, NULL, 0
+
+// Include RegisterInfos_arm64 to declare our g_register_infos_arm64 structure.
+#define DECLARE_REGISTER_INFOS_ARM64_STRUCT
+#include "Plugins/Process/Utility/RegisterInfos_arm64.h"
+#undef DECLARE_REGISTER_INFOS_ARM64_STRUCT
+
+static size_t k_num_register_infos =
+

[Lldb-commits] [PATCH] D67953: [LLDB] [test] Allow differing order of some matches

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, compnerd, amccarth, hhb.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

These can appear in a different order depending on the relative layout of the 
source and build trees.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67953

Files:
  lldb/lit/Reproducer/TestDump.test


Index: lldb/lit/Reproducer/TestDump.test
===
--- lldb/lit/Reproducer/TestDump.test
+++ lldb/lit/Reproducer/TestDump.test
@@ -8,8 +8,8 @@
 # RUN: %lldb -x -b -s %S/Inputs/FileCapture.in -o 'reproducer dump -p files' 
--capture --capture-path %t.repro %t/reproducer.out
 
 # RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s 
--check-prefix FILES
-# FILES: 'reproducer.out'
-# FILES: 'FileCapture.in'
+# FILES-DAG: 'reproducer.out'
+# FILES-DAG: 'FileCapture.in'
 
 # RUN: %lldb -b -o 'reproducer dump -p version -f %t.repro' | FileCheck %s 
--check-prefix VERSION
 # VERSION: lldb version


Index: lldb/lit/Reproducer/TestDump.test
===
--- lldb/lit/Reproducer/TestDump.test
+++ lldb/lit/Reproducer/TestDump.test
@@ -8,8 +8,8 @@
 # RUN: %lldb -x -b -s %S/Inputs/FileCapture.in -o 'reproducer dump -p files' --capture --capture-path %t.repro %t/reproducer.out
 
 # RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s --check-prefix FILES
-# FILES: 'reproducer.out'
-# FILES: 'FileCapture.in'
+# FILES-DAG: 'reproducer.out'
+# FILES-DAG: 'FileCapture.in'
 
 # RUN: %lldb -b -o 'reproducer dump -p version -f %t.repro' | FileCheck %s --check-prefix VERSION
 # VERSION: lldb version
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67951: [LLDB] Add tests for PECOFF arm architecture identification

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, compnerd, amccarth, hhb.
Herald added subscribers: JDevlieghere, abidh, kristof.beyls.
Herald added a project: LLDB.

Add a test case for the change from SVN r372657, and for the preexisting ARM 
identification.

Add a missing ArchDefinitionEntry for PECOFF/arm64, and tweak the ArmNt case to 
set the architecture to armv7 (ArmNt never ran on anything lower than that). 
(This avoids a case where ArchSpec::MergeFrom would override the arch from arm 
to armv7 and ArchSpec::CoreUpdated would reset the OS to unknown at the same 
time.)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67951

Files:
  lldb/lit/Modules/PECOFF/basic-info-arm.yaml
  lldb/lit/Modules/PECOFF/basic-info-arm64.yaml
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Utility/ArchSpec.cpp

Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -459,7 +459,9 @@
 {ArchSpec::eCore_thumb, llvm::COFF::IMAGE_FILE_MACHINE_THUMB,
  LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARMv7
 {ArchSpec::eCore_x86_64_x86_64, llvm::COFF::IMAGE_FILE_MACHINE_AMD64,
- LLDB_INVALID_CPUTYPE, 0xu, 0xu} // AMD64
+ LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // AMD64
+{ArchSpec::eCore_arm_arm64, llvm::COFF::IMAGE_FILE_MACHINE_ARM64,
+ LLDB_INVALID_CPUTYPE, 0xu, 0xu} // ARM64
 };
 
 static const ArchDefinition g_coff_arch_def = {
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -195,7 +195,7 @@
 specs.Append(module_spec);
 break;
   case MachineArmNt:
-spec.SetTriple("arm-pc-windows");
+spec.SetTriple("armv7-pc-windows");
 specs.Append(module_spec);
 break;
   case MachineArm64:
Index: lldb/lit/Modules/PECOFF/basic-info-arm64.yaml
===
--- /dev/null
+++ lldb/lit/Modules/PECOFF/basic-info-arm64.yaml
@@ -0,0 +1,86 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: Plugin name: pe-coff
+# CHECK: Architecture: aarch64-unknown-windows-msvc
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: false
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0x4000
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:   1073741824
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ImportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:
+RelativeVirtualAddress: 0
+Size:0
+  CertificateTable:
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable:
+RelativeVirtualAddress: 0
+Size:0
+  Debug:
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable:
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport:
+RelativeVirtualAddress: 0
+Size:0
+  IAT:
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor:
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader:
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_ARM64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 4
+SectionData: C0035FD6
+symbols: []
+...
Index: lldb/lit/Modules/PECOFF/basic-info-arm.yaml
===
--- /dev/null
+++ lldb/lit/Modules/PECOFF/basic-info-arm.yaml
@@ -0,0 +1,86 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# 

[Lldb-commits] [PATCH] D67952: [LLDB] [test] Add a few missing cases of REQUIRES: python

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, compnerd, amccarth, hhb.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D67952

Files:
  lldb/lit/Commands/command-script-import.test
  lldb/lit/Reproducer/TestSynchronous.test


Index: lldb/lit/Reproducer/TestSynchronous.test
===
--- lldb/lit/Reproducer/TestSynchronous.test
+++ lldb/lit/Reproducer/TestSynchronous.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # Ensure that replay happens in synchronous mode.
 
 # RUN: rm -rf %t.repro
Index: lldb/lit/Commands/command-script-import.test
===
--- lldb/lit/Commands/command-script-import.test
+++ lldb/lit/Commands/command-script-import.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # RUN: echo 'b main' > %t.in
 # RUN: echo 'run' >> %t.in
 # RUN: echo 'command script import %S/Inputs/frame.py' >> %t.in


Index: lldb/lit/Reproducer/TestSynchronous.test
===
--- lldb/lit/Reproducer/TestSynchronous.test
+++ lldb/lit/Reproducer/TestSynchronous.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # Ensure that replay happens in synchronous mode.
 
 # RUN: rm -rf %t.repro
Index: lldb/lit/Commands/command-script-import.test
===
--- lldb/lit/Commands/command-script-import.test
+++ lldb/lit/Commands/command-script-import.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # RUN: echo 'b main' > %t.in
 # RUN: echo 'run' >> %t.in
 # RUN: echo 'command script import %S/Inputs/frame.py' >> %t.in
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67954: [LLDB] [Windows] Initial support for ARM64 debugging

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

> This seems to be enough for getting a backtrace and variable values for 
> MinGW-built binaries for ARM64.

To clarify; this is binaries that use DWARF debug info.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67954



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


[Lldb-commits] [PATCH] D67910: [LLDB] Avoid warnings about redefining posix mode defines on MinGW

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372700: [LLDB] Avoid warnings about redefining posix mode 
defines on MinGW (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67910?vs=221298=221481#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67910

Files:
  lldb/trunk/include/lldb/Host/windows/PosixApi.h


Index: lldb/trunk/include/lldb/Host/windows/PosixApi.h
===
--- lldb/trunk/include/lldb/Host/windows/PosixApi.h
+++ lldb/trunk/include/lldb/Host/windows/PosixApi.h
@@ -31,20 +31,30 @@
 #define SIGKILL 9
 #define SIGSTOP 20
 
-#if defined(_MSC_VER)
+#ifndef S_IRUSR
 #define S_IRUSR S_IREAD  /* read, user */
 #define S_IWUSR S_IWRITE /* write, user */
 #define S_IXUSR 0/* execute, user */
 #endif
+#ifndef S_IRGRP
 #define S_IRGRP 0 /* read, group */
 #define S_IWGRP 0 /* write, group */
 #define S_IXGRP 0 /* execute, group */
+#endif
+#ifndef S_IROTH
 #define S_IROTH 0 /* read, others */
 #define S_IWOTH 0 /* write, others */
 #define S_IXOTH 0 /* execute, others */
+#endif
+#ifndef S_IRWXU
 #define S_IRWXU 0
+#endif
+#ifndef S_IRWXG
 #define S_IRWXG 0
+#endif
+#ifndef S_IRWXO
 #define S_IRWXO 0
+#endif
 
 #if HAVE_SYS_TYPES_H
 // pyconfig.h typedefs this.  We require python headers to be included before


Index: lldb/trunk/include/lldb/Host/windows/PosixApi.h
===
--- lldb/trunk/include/lldb/Host/windows/PosixApi.h
+++ lldb/trunk/include/lldb/Host/windows/PosixApi.h
@@ -31,20 +31,30 @@
 #define SIGKILL 9
 #define SIGSTOP 20
 
-#if defined(_MSC_VER)
+#ifndef S_IRUSR
 #define S_IRUSR S_IREAD  /* read, user */
 #define S_IWUSR S_IWRITE /* write, user */
 #define S_IXUSR 0/* execute, user */
 #endif
+#ifndef S_IRGRP
 #define S_IRGRP 0 /* read, group */
 #define S_IWGRP 0 /* write, group */
 #define S_IXGRP 0 /* execute, group */
+#endif
+#ifndef S_IROTH
 #define S_IROTH 0 /* read, others */
 #define S_IWOTH 0 /* write, others */
 #define S_IXOTH 0 /* execute, others */
+#endif
+#ifndef S_IRWXU
 #define S_IRWXU 0
+#endif
+#ifndef S_IRWXG
 #define S_IRWXG 0
+#endif
+#ifndef S_IRWXO
 #define S_IRWXO 0
+#endif
 
 #if HAVE_SYS_TYPES_H
 // pyconfig.h typedefs this.  We require python headers to be included before
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67911: [LLDB] [Windows] Add missing ifdefs to fix building for non-x86 architectures

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372699: [LLDB] [Windows] Add missing ifdefs to fix building 
for non-x86 architectures (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67911?vs=221406=221480#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67911

Files:
  lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp


Index: 
lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(__x86_64__) || defined(_M_AMD64)
+#if defined(_WIN64)
   case 8:
 #endif
 break;
@@ -95,6 +95,7 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || 
defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 |= 1ULL << shift;
 
@@ -109,6 +110,12 @@
   m_context.Dr7 |= (read ? 3ULL : (write ? 1ULL : 0)) << shift;
 
   return ApplyAllRegisterValues();
+
+#else
+  Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+  LLDB_LOG(log, "hardware breakpoints not currently supported on this arch");
+  return false;
+#endif
 }
 
 bool RegisterContextWindows::RemoveHardwareBreakpoint(uint32_t slot) {
@@ -118,19 +125,25 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || 
defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 &= ~(1ULL << shift);
 
   return ApplyAllRegisterValues();
+#else
+  return false;
+#endif
 }
 
 uint32_t RegisterContextWindows::GetTriggeredHardwareBreakpointSlotId() {
   if (!CacheAllRegisterValues())
 return LLDB_INVALID_INDEX32;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || 
defined(_M_AMD64)
   for (unsigned i = 0UL; i < NUM_HARDWARE_BREAKPOINT_SLOTS; i++)
 if (m_context.Dr6 & (1ULL << i))
   return i;
+#endif
 
   return LLDB_INVALID_INDEX32;
 }


Index: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(__x86_64__) || defined(_M_AMD64)
+#if defined(_WIN64)
   case 8:
 #endif
 break;
@@ -95,6 +95,7 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 |= 1ULL << shift;
 
@@ -109,6 +110,12 @@
   m_context.Dr7 |= (read ? 3ULL : (write ? 1ULL : 0)) << shift;
 
   return ApplyAllRegisterValues();
+
+#else
+  Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+  LLDB_LOG(log, "hardware breakpoints not currently supported on this arch");
+  return false;
+#endif
 }
 
 bool RegisterContextWindows::RemoveHardwareBreakpoint(uint32_t slot) {
@@ -118,19 +125,25 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 &= ~(1ULL << shift);
 
   return ApplyAllRegisterValues();
+#else
+  return false;
+#endif
 }
 
 uint32_t RegisterContextWindows::GetTriggeredHardwareBreakpointSlotId() {
   if (!CacheAllRegisterValues())
 return LLDB_INVALID_INDEX32;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
   for (unsigned i = 0UL; i < NUM_HARDWARE_BREAKPOINT_SLOTS; i++)
 if (m_context.Dr6 & (1ULL << i))
   return i;
+#endif
 
   return LLDB_INVALID_INDEX32;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67861: [LLDB] Remove a now redundant windows specific workaround

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 221276.
mstorsjo retitled this revision from "[LLDB] Check for the __MINGW32__ define 
instead of __MINGW64" to "[LLDB] Remove a now redundant windows specific 
workaround".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Updated the patch to simply remove the now redundant workaround.


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

https://reviews.llvm.org/D67861

Files:
  lldb/source/Host/windows/Windows.cpp


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -48,13 +48,8 @@
   size_t buflen;
   va_list ap2;
 
-#if defined(_MSC_VER) || defined(__MINGW64)
-  ap2 = ap;
-  len = _vscprintf(fmt, ap2);
-#else
   va_copy(ap2, ap);
   len = vsnprintf(NULL, 0, fmt, ap2);
-#endif
 
   if (len >= 0 &&
   (buf = (char *)malloc((buflen = (size_t)(len + 1 != NULL) {


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -48,13 +48,8 @@
   size_t buflen;
   va_list ap2;
 
-#if defined(_MSC_VER) || defined(__MINGW64)
-  ap2 = ap;
-  len = _vscprintf(fmt, ap2);
-#else
   va_copy(ap2, ap);
   len = vsnprintf(NULL, 0, fmt, ap2);
-#endif
 
   if (len >= 0 &&
   (buf = (char *)malloc((buflen = (size_t)(len + 1 != NULL) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67885: [LLDB] Add a missing specification of linking against dbghelp

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D67885#1678701 , @MyDeveloperDay 
wrote:

> Just as a drive by comment, there is code in  
> DebugInfo/Symbolize/Symbolize.cpp that loads dbghelp via #pragma 
> comment(lib... trick


Yes, but as I mentioned in the patch description here, #pragma comment(lib) 
only works in MSVC mode, it isn't supported when targeting MinGW unless 
-fms-extensions is specified (and if building with GCC and/or linking with GNU 
ld, it's not supported at all).

> There is also code to load dbghelp dynamically in 
> lib\Support\Windows\Signal.inc including loading MiniDumpWriteDump

I guess that could be an option as well, for a slightly larger change instead.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67885



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


[Lldb-commits] [PATCH] D67861: [LLDB] Check for the __MINGW32__ define instead of __MINGW64

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D67861#1678618 , @labath wrote:

> Judging by the microsoft docs 
> ,
>  `vsnprintf` is avaliable at least since VS 2017 (the lowest version 
> supported by llvm). Is it possible that we can just delete this `#ifdef` ?


Yes, it would seem so.

With MSVC, you got an MSVC-specific version of the CRT, and with the versions 
of MSVC we require, it is a C99 compliant one.

With MinGW, you can link either against the UCRT (the same modern CRT as MSVC 
uses these days) or msvcrt.dll (the old legacy one, shipped as a part of the 
OS). But I checked that this use of `vsnprintf(NULL, 0, ...)` does seem to work 
with the old msvcrt.dll since at least XP (and llvm requires a much newer 
version of Windows anyway), so I would say that it should be safe.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67861



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


[Lldb-commits] [PATCH] D67911: [LLDB] [Windows] Add missing ifdefs to fix building for non-x86 architectures

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

In D67911#1679333 , @compnerd wrote:

> What do you think of adding some sort of notification that hardware 
> breakpoints are currently unsupported and that we are falling back to 
> software breakpoints for the `#else` case?


I guess it could make sense. What kind of notification do you have in mind?




Comment at: 
lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp:87
   case 4:
 #if defined(__x86_64__) || defined(_M_AMD64)
   case 8:

compnerd wrote:
> Should this line not also include `|| defined(__aarch64__) || 
> defined(_M_ARM64)`?
I guess it should. Or this might be one of the few places where checking for 
just `_WIN64` might be easiest?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67911



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


[Lldb-commits] [PATCH] D67894: [LLDB] Rework a MinGW build fix from D65691

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372656: [LLDB] Rework a MinGW build fix from D65691 
(authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67894?vs=221225=221402#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67894

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


Index: lldb/trunk/tools/lldb-vscode/VSCode.cpp
===
--- lldb/trunk/tools/lldb-vscode/VSCode.cpp
+++ lldb/trunk/tools/lldb-vscode/VSCode.cpp
@@ -15,10 +15,8 @@
 #include "llvm/Support/FormatVariadic.h"
 
 #if defined(_WIN32)
-#ifndef __MINGW32__
 #define NOMINMAX
-#include 
-#endif // __MINGW32__
+#include 
 #include 
 #include 
 #endif


Index: lldb/trunk/tools/lldb-vscode/VSCode.cpp
===
--- lldb/trunk/tools/lldb-vscode/VSCode.cpp
+++ lldb/trunk/tools/lldb-vscode/VSCode.cpp
@@ -15,10 +15,8 @@
 #include "llvm/Support/FormatVariadic.h"
 
 #if defined(_WIN32)
-#ifndef __MINGW32__
 #define NOMINMAX
-#include 
-#endif // __MINGW32__
+#include 
 #include 
 #include 
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67913: [LLDB] [Windows] Map COFF ARM machine ids to the right triplet architectures

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372658: [LLDB] [Windows] Map COFF ARM machine ids to the 
right triple architectures (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67913?vs=221303=221404#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67913

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


Index: lldb/trunk/source/Host/windows/Host.cpp
===
--- lldb/trunk/source/Host/windows/Host.cpp
+++ lldb/trunk/source/Host/windows/Host.cpp
@@ -56,6 +56,10 @@
 triple.setArch(llvm::Triple::x86_64);
   else if (machineType == 0x14c)
 triple.setArch(llvm::Triple::x86);
+  else if (machineType == 0x1c4)
+triple.setArch(llvm::Triple::arm);
+  else if (machineType == 0xaa64)
+triple.setArch(llvm::Triple::aarch64);
 
   return true;
 }


Index: lldb/trunk/source/Host/windows/Host.cpp
===
--- lldb/trunk/source/Host/windows/Host.cpp
+++ lldb/trunk/source/Host/windows/Host.cpp
@@ -56,6 +56,10 @@
 triple.setArch(llvm::Triple::x86_64);
   else if (machineType == 0x14c)
 triple.setArch(llvm::Triple::x86);
+  else if (machineType == 0x1c4)
+triple.setArch(llvm::Triple::arm);
+  else if (machineType == 0xaa64)
+triple.setArch(llvm::Triple::aarch64);
 
   return true;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67912: [LLDB] [PECOFF] Recognize arm64 executables

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372657: [LLDB] [PECOFF] Recognize arm64 executables 
(authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67912?vs=221302=221403#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67912

Files:
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp


Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -198,6 +198,10 @@
 spec.SetTriple("arm-pc-windows");
 specs.Append(module_spec);
 break;
+  case MachineArm64:
+spec.SetTriple("aarch64-unknown-windows");
+specs.Append(module_spec);
+break;
   default:
 break;
   }
@@ -1200,6 +1204,7 @@
   case llvm::COFF::IMAGE_FILE_MACHINE_ARM:
   case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
   case llvm::COFF::IMAGE_FILE_MACHINE_THUMB:
+  case llvm::COFF::IMAGE_FILE_MACHINE_ARM64:
 ArchSpec arch;
 arch.SetArchitecture(eArchTypeCOFF, machine, LLDB_INVALID_CPUTYPE,
  IsWindowsSubsystem() ? llvm::Triple::Win32


Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -198,6 +198,10 @@
 spec.SetTriple("arm-pc-windows");
 specs.Append(module_spec);
 break;
+  case MachineArm64:
+spec.SetTriple("aarch64-unknown-windows");
+specs.Append(module_spec);
+break;
   default:
 break;
   }
@@ -1200,6 +1204,7 @@
   case llvm::COFF::IMAGE_FILE_MACHINE_ARM:
   case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
   case llvm::COFF::IMAGE_FILE_MACHINE_THUMB:
+  case llvm::COFF::IMAGE_FILE_MACHINE_ARM64:
 ArchSpec arch;
 arch.SetArchitecture(eArchTypeCOFF, machine, LLDB_INVALID_CPUTYPE,
  IsWindowsSubsystem() ? llvm::Triple::Win32
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67911: [LLDB] [Windows] Add missing ifdefs to fix building for non-x86 architectures

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D67911#1679696 , @compnerd wrote:

> I think that `printf` is quite an amazing notification :-)


Ok, I'll make it an `LLDB_LOG` then, as I'd presume using raw printfs isn't 
really allowed :-)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67911



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


[Lldb-commits] [PATCH] D67911: [LLDB] [Windows] Add missing ifdefs to fix building for non-x86 architectures

2019-09-23 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 221406.
mstorsjo added a comment.

Added a log message, changed an `x86_64` ifdef into `_WIN64`.


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

https://reviews.llvm.org/D67911

Files:
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp


Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(__x86_64__) || defined(_M_AMD64)
+#if defined(_WIN64)
   case 8:
 #endif
 break;
@@ -95,6 +95,7 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || 
defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 |= 1ULL << shift;
 
@@ -109,6 +110,11 @@
   m_context.Dr7 |= (read ? 3ULL : (write ? 1ULL : 0)) << shift;
 
   return ApplyAllRegisterValues();
+
+#else
+  LLDB_LOG(log, "hardware breakpoints not currently supported on this arch");
+  return false;
+#endif
 }
 
 bool RegisterContextWindows::RemoveHardwareBreakpoint(uint32_t slot) {
@@ -118,19 +124,25 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || 
defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 &= ~(1ULL << shift);
 
   return ApplyAllRegisterValues();
+#else
+  return false;
+#endif
 }
 
 uint32_t RegisterContextWindows::GetTriggeredHardwareBreakpointSlotId() {
   if (!CacheAllRegisterValues())
 return LLDB_INVALID_INDEX32;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || 
defined(_M_AMD64)
   for (unsigned i = 0UL; i < NUM_HARDWARE_BREAKPOINT_SLOTS; i++)
 if (m_context.Dr6 & (1ULL << i))
   return i;
+#endif
 
   return LLDB_INVALID_INDEX32;
 }


Index: lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -84,7 +84,7 @@
   case 1:
   case 2:
   case 4:
-#if defined(__x86_64__) || defined(_M_AMD64)
+#if defined(_WIN64)
   case 8:
 #endif
 break;
@@ -95,6 +95,7 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 |= 1ULL << shift;
 
@@ -109,6 +110,11 @@
   m_context.Dr7 |= (read ? 3ULL : (write ? 1ULL : 0)) << shift;
 
   return ApplyAllRegisterValues();
+
+#else
+  LLDB_LOG(log, "hardware breakpoints not currently supported on this arch");
+  return false;
+#endif
 }
 
 bool RegisterContextWindows::RemoveHardwareBreakpoint(uint32_t slot) {
@@ -118,19 +124,25 @@
   if (!CacheAllRegisterValues())
 return false;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
   unsigned shift = 2 * slot;
   m_context.Dr7 &= ~(1ULL << shift);
 
   return ApplyAllRegisterValues();
+#else
+  return false;
+#endif
 }
 
 uint32_t RegisterContextWindows::GetTriggeredHardwareBreakpointSlotId() {
   if (!CacheAllRegisterValues())
 return LLDB_INVALID_INDEX32;
 
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
   for (unsigned i = 0UL; i < NUM_HARDWARE_BREAKPOINT_SLOTS; i++)
 if (m_context.Dr6 & (1ULL << i))
   return i;
+#endif
 
   return LLDB_INVALID_INDEX32;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67953: [LLDB] [test] Allow differing order of some matches

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372740: [LLDB] [test] Allow differing order of some matches 
(authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67953?vs=221489=221518#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67953

Files:
  lldb/trunk/lit/Reproducer/TestDump.test


Index: lldb/trunk/lit/Reproducer/TestDump.test
===
--- lldb/trunk/lit/Reproducer/TestDump.test
+++ lldb/trunk/lit/Reproducer/TestDump.test
@@ -8,8 +8,8 @@
 # RUN: %lldb -x -b -s %S/Inputs/FileCapture.in -o 'reproducer dump -p files' 
--capture --capture-path %t.repro %t/reproducer.out
 
 # RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s 
--check-prefix FILES
-# FILES: 'reproducer.out'
-# FILES: 'FileCapture.in'
+# FILES-DAG: 'reproducer.out'
+# FILES-DAG: 'FileCapture.in'
 
 # RUN: %lldb -b -o 'reproducer dump -p version -f %t.repro' | FileCheck %s 
--check-prefix VERSION
 # VERSION: lldb version


Index: lldb/trunk/lit/Reproducer/TestDump.test
===
--- lldb/trunk/lit/Reproducer/TestDump.test
+++ lldb/trunk/lit/Reproducer/TestDump.test
@@ -8,8 +8,8 @@
 # RUN: %lldb -x -b -s %S/Inputs/FileCapture.in -o 'reproducer dump -p files' --capture --capture-path %t.repro %t/reproducer.out
 
 # RUN: %lldb -b -o 'reproducer dump -p files -f %t.repro' | FileCheck %s --check-prefix FILES
-# FILES: 'reproducer.out'
-# FILES: 'FileCapture.in'
+# FILES-DAG: 'reproducer.out'
+# FILES-DAG: 'FileCapture.in'
 
 # RUN: %lldb -b -o 'reproducer dump -p version -f %t.repro' | FileCheck %s --check-prefix VERSION
 # VERSION: lldb version
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67952: [LLDB] [test] Add a few missing cases of REQUIRES: python

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372739: [LLDB] [test] Add a few missing cases of REQUIRES: 
python (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67952?vs=221488=221517#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67952

Files:
  lldb/trunk/lit/Commands/command-script-import.test
  lldb/trunk/lit/Reproducer/TestSynchronous.test


Index: lldb/trunk/lit/Reproducer/TestSynchronous.test
===
--- lldb/trunk/lit/Reproducer/TestSynchronous.test
+++ lldb/trunk/lit/Reproducer/TestSynchronous.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # Ensure that replay happens in synchronous mode.
 
 # RUN: rm -rf %t.repro
Index: lldb/trunk/lit/Commands/command-script-import.test
===
--- lldb/trunk/lit/Commands/command-script-import.test
+++ lldb/trunk/lit/Commands/command-script-import.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # RUN: echo 'b main' > %t.in
 # RUN: echo 'run' >> %t.in
 # RUN: echo 'command script import %S/Inputs/frame.py' >> %t.in


Index: lldb/trunk/lit/Reproducer/TestSynchronous.test
===
--- lldb/trunk/lit/Reproducer/TestSynchronous.test
+++ lldb/trunk/lit/Reproducer/TestSynchronous.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # Ensure that replay happens in synchronous mode.
 
 # RUN: rm -rf %t.repro
Index: lldb/trunk/lit/Commands/command-script-import.test
===
--- lldb/trunk/lit/Commands/command-script-import.test
+++ lldb/trunk/lit/Commands/command-script-import.test
@@ -1,3 +1,4 @@
+# REQUIRES: python
 # RUN: echo 'b main' > %t.in
 # RUN: echo 'run' >> %t.in
 # RUN: echo 'command script import %S/Inputs/frame.py' >> %t.in
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67951: [LLDB] Add tests for PECOFF arm architecture identification

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372741: [LLDB] Add tests for PECOFF arm architecture 
identification (authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67951?vs=221487=221519#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67951

Files:
  lldb/trunk/lit/Modules/PECOFF/basic-info-arm.yaml
  lldb/trunk/lit/Modules/PECOFF/basic-info-arm64.yaml
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/trunk/source/Utility/ArchSpec.cpp

Index: lldb/trunk/source/Utility/ArchSpec.cpp
===
--- lldb/trunk/source/Utility/ArchSpec.cpp
+++ lldb/trunk/source/Utility/ArchSpec.cpp
@@ -459,7 +459,9 @@
 {ArchSpec::eCore_thumb, llvm::COFF::IMAGE_FILE_MACHINE_THUMB,
  LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // ARMv7
 {ArchSpec::eCore_x86_64_x86_64, llvm::COFF::IMAGE_FILE_MACHINE_AMD64,
- LLDB_INVALID_CPUTYPE, 0xu, 0xu} // AMD64
+ LLDB_INVALID_CPUTYPE, 0xu, 0xu}, // AMD64
+{ArchSpec::eCore_arm_arm64, llvm::COFF::IMAGE_FILE_MACHINE_ARM64,
+ LLDB_INVALID_CPUTYPE, 0xu, 0xu} // ARM64
 };
 
 static const ArchDefinition g_coff_arch_def = {
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -195,7 +195,7 @@
 specs.Append(module_spec);
 break;
   case MachineArmNt:
-spec.SetTriple("arm-pc-windows");
+spec.SetTriple("armv7-pc-windows");
 specs.Append(module_spec);
 break;
   case MachineArm64:
Index: lldb/trunk/lit/Modules/PECOFF/basic-info-arm.yaml
===
--- lldb/trunk/lit/Modules/PECOFF/basic-info-arm.yaml
+++ lldb/trunk/lit/Modules/PECOFF/basic-info-arm.yaml
@@ -0,0 +1,86 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: Plugin name: pe-coff
+# CHECK: Architecture: armv7-pc-windows-msvc
+# CHECK: UUID: 
+# CHECK: Executable: true
+# CHECK: Stripped: false
+# CHECK: Type: executable
+# CHECK: Strata: user
+# CHECK: Base VM address: 0x4
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4097
+  ImageBase:   4194304
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ImportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:
+RelativeVirtualAddress: 0
+Size:0
+  CertificateTable:
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable:
+RelativeVirtualAddress: 0
+Size:0
+  Debug:
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable:
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport:
+RelativeVirtualAddress: 0
+Size:0
+  IAT:
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor:
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader:
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_ARMNT
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_32BIT_MACHINE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 2
+SectionData: '7047'
+symbols: []
+...
Index: lldb/trunk/lit/Modules/PECOFF/basic-info-arm64.yaml
===
--- lldb/trunk/lit/Modules/PECOFF/basic-info-arm64.yaml
+++ lldb/trunk/lit/Modules/PECOFF/basic-info-arm64.yaml
@@ -0,0 +1,86 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK: Plugin name: pe-coff
+# CHECK: Architecture: aarch64-unknown-windows-msvc
+# 

[Lldb-commits] [PATCH] D67892: [LLDB] Fix typo in RegisterContextDarwin_arm64

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372738: [LLDB] Fix typo in RegisterContextDarwin_arm64 
(authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67892?vs=221223=221516#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67892

Files:
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp


Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -503,7 +503,7 @@
   case fpu_d31: {
 ProcessSP process_sp(m_thread.GetProcess());
 if (process_sp.get()) {
-  DataExtractor regdata([reg - fpu_s0], 8, 
process_sp->GetByteOrder(),
+  DataExtractor regdata([reg - fpu_d0], 8, 
process_sp->GetByteOrder(),
 process_sp->GetAddressByteSize());
   offset_t offset = 0;
   value.SetDouble(regdata.GetDouble());


Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -503,7 +503,7 @@
   case fpu_d31: {
 ProcessSP process_sp(m_thread.GetProcess());
 if (process_sp.get()) {
-  DataExtractor regdata([reg - fpu_s0], 8, process_sp->GetByteOrder(),
+  DataExtractor regdata([reg - fpu_d0], 8, process_sp->GetByteOrder(),
 process_sp->GetAddressByteSize());
   offset_t offset = 0;
   value.SetDouble(regdata.GetDouble());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67954: [LLDB] [Windows] Initial support for ARM64 debugging

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D67954#1680536 , @labath wrote:

> Have you considered going the "native" route directly? My understanding is 
> that this route is already functional on x86 (modulo watchpoints, which I 
> need to get around to reviewing). It would be great to be able to delete the 
> in-process route soon, as it's not good to have both for a long time, and for 
> that we need to ensure that the lldb-server route does not lag behind in 
> features. I'm not really sure what's needed to enable the lldb-server 
> mechanism, but @aleksandr.urakov should.


I haven't dug in to see what's needed to enable it (if it maybe is enabled 
separately per arch somewhere?) - I just built lldb for arm64, tested using it 
and noting that it crashed due to `m_thread_reg_ctx` being unset, made a first 
proof of concept implementation of the missing class, and noted that it 
actually worked for getting usable debug info from my testcase.

> One of the advantages of lldb-server is that is possible to test it by 
> cross-debugging. The mechanism for doing that is a bit complicated, and I'm 
> not entirely sure how that works after all the lit changes, but it goes 
> approximately like this:
> 
> 1. build lldb for the host
> 2. build lldb-server for the target (either on the target, or via 
> cross-compile)
> 3. run `lldb-server platform --server *:1234` on the target
> 4. run the `dotest` test suite arguments suitable for cross-compilation. This 
> means:
>   - setting the test compiler to be a cross compiler (cmake 
> -DLLDB_TEST_C(XX)_COMPILER)
>   - choosing a suitable test architecture (-DLLDB_TEST_ARCH)
>   - telling it how to connect to the target 
> (-DLLDB_TEST_USER_ARGS=--platform-name remote-windows --platform-url 
> connect://remote:1234 --platform-working-dir=c:\tmp)
>   - crossing your fingers :)

Interesting - sounds sensible but also sounds like a bit more effort to get 
going than just running the usual lit tests. Will look into that at some point.

> But, of course the easiest way to test this would be to build and test 
> natively. The usual obstacle for that is that the arm device is too small to 
> comfortably work on it, but you say you don't have the full build environment 
> *yet*, so it's not clear to me whether that is the problem you're running 
> into...

Well, I cross build as the environment on the target device is a bit bare, and 
as it's a new architecture and all, there's not much available when it comes to 
prebuilt packages (for everything you need for building) - I do have a working 
compiler on that device, but nothing else. The devices do support running i386 
binaries emulated, so I could install such a version of msys2 and do building 
there, but even more slowly... In general as well, I think building llvm/lldb 
on such a device requires quite a bit of patience, and rebuilding after 
fetching newer upstream commits would be pretty painful as well.

I think the most practical setup, at least for lit-style tests that don't 
require any compilation in themselves, is cross-building all the binaries 
needed, moving them over to the target device, and running them with llvm-lit 
there. But that still requires having python available for running llvm-lit.

The alternative is probably to leverage WSL for a mess-free environment with 
python, shells and everything available, but I'm not sure if that messes things 
up (like llvm-lit thinks it runs on linux even though the binaries it should 
execute will run are windows ones).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67954



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


[Lldb-commits] [PATCH] D67857: [LLDB] Include lldb/Host/windows/windows.h on any windows target

2019-09-22 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo abandoned this revision.
mstorsjo added a comment.

D67887  was committed with the same change.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D67857



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


[Lldb-commits] [PATCH] D67887: Use _WIN32 instead of _MSC_VER

2019-09-22 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

Just FTR, this was identical to D67857  that I 
posted a few days ago.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67887



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


[Lldb-commits] [PATCH] D67942: Install python dll to bin

2019-09-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

Sorry, I'm not familiar with how LLDB integrates with python and how all of 
that works on Windows, so I can't really comment on this one for now...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67942



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


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

2019-09-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 222358.
mstorsjo edited the summary of this revision.
mstorsjo added a reviewer: thakis.
mstorsjo added a comment.

I tried to update the testcases based on the log output 
(http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9306/steps/test/logs/stdio).

Even after fudging the tests to somehow run on windows, both of the tests that 
failed seem to require the DIA SDK which I don't have readily available (for 
reading PDB files; there's some native support for PDB files but I'm not sure 
what the state of it is and running those tests with it).


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

https://reviews.llvm.org/D68134

Files:
  lldb/lit/SymbolFile/PDB/udt-layout.test
  lldb/source/Core/Mangled.cpp
  lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Index: lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
===
--- lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -615,6 +615,6 @@
 
   SymbolContext sc;
   EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));
-  EXPECT_STREQ("int foo(int)",
+  EXPECT_STREQ("int __cdecl foo(int)",
sc.GetFunctionName(Mangled::ePreferDemangled).AsCString());
 }
Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
 
 #include "lldb/Core/Mangled.h"
 
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -218,28 +192,16 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+  char *demangled_cstr = llvm::microsoftDemangle(M, nullptr, nullptr, nullptr);
 
   if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
 if (demangled_cstr && demangled_cstr[0])
   LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
 else
-  LLDB_LOGF(log, "demangled msvc: %s -> error: 0x%lu", M, result);
+  LLDB_LOGF(log, "demangled msvc: %s -> error", M);
   }
 
-  if (result != 0) {
-return demangled_cstr;
-  } else {
-::free(demangled_cstr);
-return nullptr;
-  }
-#else
-  return nullptr;
-#endif
+  return demangled_cstr;
 }
 
 static char *GetItaniumDemangledStr(const char *M) {
Index: lldb/lit/SymbolFile/PDB/udt-layout.test
===
--- lldb/lit/SymbolFile/PDB/udt-layout.test
+++ lldb/lit/SymbolFile/PDB/udt-layout.test
@@ -2,7 +2,7 @@
 RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
 RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
 
-CHECK:(int) int C::abc = 123
+CHECK:(int) public: static int C::abc = 123
 CHECK:(List [16]) ls = {
 CHECK:  [15] = {
 CHECK:Prev = 0x
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-09-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo reopened this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

In D68134#1687500 , @labath wrote:

> In D68134#1687031 , @mstorsjo wrote:
>
> > In D68134#1686970 , @thakis wrote:
> >
> > > We can add flags for omitting access specifiers etc if it's critical for 
> > > lldb. Or maybe we can just change the test that caused the revert.
> >
> >
> > Yeah I doubt it's critical to maintain the exact same form as before, but I 
> > need to get the tests running in my cross compile setup to verify exactly 
> > how to update them.
>
>
> I'm not sure what failed here exactly, but there are some places in lldb that 
> parse the demangled names. These might get confused by additional things 
> appearing in the name. Though it's possible to also fix that, so the main 
> question might be: what is the name we want to display to the users? I guess 
> it would be the best if this matched what is displayed by other tools ?


In this case, the output becomes the same as what has been chosen to be used by 
the common llvm demangler, which probably should be a good choice in general. 
In this case, a few more identifiers are added. Or I guess it can be discussed 
if that one should be changed (or add options to it, as @thakis said was 
possible).

> As for tests, you should at least be able to run the tests in the regular 
> "host" setup, right ?

In principle, but I normally don't run windows except in a very underpowered VM 
for testing things, and building there is no fun. I can spin up some more 
powerful VMs for some better testing though.

In this case, much of the functionality of these tests require having the MS 
DIA SDK available (which also implies building in MSVC/clang-cl mode, not mingw 
mode), for reading PDB files. Probably just another step to do, but I don't 
have it set up right now.


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

https://reviews.llvm.org/D68134



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


[Lldb-commits] [PATCH] D69612: [lldb-vscod] fix build with NDEBUG on windows

2019-10-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added reviewers: labath, amccarth.
mstorsjo added a comment.

Good catch, thanks! But would we need to add something like `(void)result;` to 
silence potential compiler warnings about an unused (or set but not read) 
variable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69612



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


[Lldb-commits] [PATCH] D69031: [LLDB] [test] Use %clang_cl instead of build.py in a few tests

2019-10-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D69031#1714143 , @labath wrote:

> In D69031#1714107 , @mstorsjo wrote:
>
> > In D69031#1713900 , @aprantl wrote:
> >
> > > Check out  `lldb/test/Shell/helper/toolchain.py`, you probably need to 
> > > filter out some options for clang_cl specifically.
> >
> >
> > Yeah, I later found that. The issue is that it's passed to usr_clang in i 
> > llvm/utils/lit/lit/llvm/config.py, which sets all the provided additional 
> > flags on both %clang, %clangxx, %clang_cc1 and %clang_cl.
> >
> > Maybe the additional_flags param needs to be split, into one common for 
> > all, one for gcc-style driver, one for clang_cl, and maybe also a separate 
> > one for cc1 (where not all driver level flags may fit either)?
>
>
> Actually, it seems to be that these arguments should not be added to the 
> command line by default. All of the existing tests that do "%clang -target 
> whatever" don't need the arguments, and they "only" work because the 
> arguments do no harm because the tests don't do anything which would depend 
> on them. I think we should leave `additional_flags` argument mostly empty, 
> and instead have a separate way of invoking clang when building for the host. 
> Either %clang_host (achievable with a recursive substitution %clang_host -> 
> %clang ), or using something like %clang %host_cflags.
>
> I can have a stab at that, if you like, but I'm not sure I'll get around to 
> that before the llvm conference is over...


Do you have time to look into this now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69031



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


[Lldb-commits] [PATCH] D69503: [LLDB] [Windows] Don't crash if the debugged process is unable to start up

2019-10-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

Yes, this definitely is a race condition. Without any changes, I triggered this 
condition on arm64, but not on x86_64.

The issue is in the subclass ProcessWindows, where OnExitProcess does this:

  void ProcessWindows::OnDebuggerError(const Status , uint32_t type) {
// [simplified]
if (m_session_data->m_initial_stop_received) {
} else {
  // If we haven't actually launched the process yet, this was an error
  // launching the process.  Set the internal error and signal the initial
  // stop event so that the DoLaunch method wakes up and returns a failure.
  m_session_data->m_launch_error = error;
  ::SetEvent(m_session_data->m_initial_stop_event);
  return;
}
  }   
  
  void ProcessWindows::OnExitProcess(uint32_t exit_code) {
// [irrelevant bits excluded]
  
// If the process exits before any initial stop then notify the debugger
// of the error otherwise WaitForDebuggerConnection() will be blocked.
// An example of this issue is when a process fails to load a dependent DLL.
if (m_session_data && !m_session_data->m_initial_stop_received) {
  Status error(exit_code, eErrorTypeWin32);
  OnDebuggerError(error, 0);
}
  
// Reset the session.
m_session_data.reset();
  }

So `ProcessWindows::OnExitProcess` signals to 
`ProcessDebugger::WaitForDebuggerConnection` to proceed, and then 
`ProcessWindows::OnExitProcess` resets `m_session_data`, which 
`WaitForDebuggerConnection` starts inspecting.

What's the correct course of action here? Remove the `m_session_data.reset()` 
from ProcessWindows::OnExitProcess, concluding that it's up to some other class 
to clear `m_session_data` in this case?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69503



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


[Lldb-commits] [PATCH] D68980: [LLDB] [test] Allow specifying the full arch for msvc/clang-cl in build.py

2019-11-02 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo abandoned this revision.
mstorsjo added a comment.

This is no longer necessary since D69031 .


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

https://reviews.llvm.org/D68980



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


[Lldb-commits] [PATCH] D69031: [LLDB] [test] Use %clang_cl instead of build.py in a few tests

2019-11-02 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

For the record, this was reapplied in 
rG1739c7c10c42748c278b0ea194e32bbfdd04fb98 
 (which 
Phabricator doesn't seem to have picked up on here) .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69031



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


[Lldb-commits] [PATCH] D69612: [lldb-vscod] fix build with NDEBUG on windows

2019-10-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

I presume you applied the patch with `arc patch`? It seems to apply the 
Phabricator username as git user, which is a bit odd, as it is customary to use 
realnames in the git author field. Earlier, when everything ended up mangled by 
svn, everything ended up normalized to the committer's name anyway, but as git 
preserves the author names, it would probably be good if the arc workflow could 
use the realname instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69612



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


[Lldb-commits] [PATCH] D69646: [LLDB] [PECOFF] Fix error handling for executables that object::createBinary error out on

2019-10-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth, aleksandr.urakov.
Herald added subscribers: JDevlieghere, abidh.
Herald added a project: LLDB.

llvm::object::createBinary returns an Expected<>, which requires not only 
checking the object for success, but also requires consuming the Error, if one 
was set.

For another similar existing case, move consuming of the Error object to a 
standalone std::string variable. If the Error only is consumed within a 
LLDB_LOGF() statement, it actually doesn't get consumed unless that log channel 
is enabled.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69646

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/ObjectFile/PECOFF/invalid-export-table.yaml

Index: lldb/test/Shell/ObjectFile/PECOFF/invalid-export-table.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PECOFF/invalid-export-table.yaml
@@ -0,0 +1,80 @@
+## Test that errors in loading an exe doesn't crash lldb.
+
+# RUN: yaml2obj %s > %t.exe
+# RUN: %lldb %t.exe 2>&1 | FileCheck %s
+
+# CHECK: error: '{{.*}}' doesn't contain any {{.*}} platform architectures
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:   1073741824
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+RelativeVirtualAddress: 12345678
+Size:100
+  ImportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:
+RelativeVirtualAddress: 0
+Size:0
+  CertificateTable:
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable:
+RelativeVirtualAddress: 0
+Size:0
+  Debug:
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable:
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport:
+RelativeVirtualAddress: 0
+Size:0
+  IAT:
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor:
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader:
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 1
+SectionData: C3
+symbols: []
+...
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -167,9 +167,18 @@
   if (!data_sp || !ObjectFilePECOFF::MagicBytesMatch(data_sp))
 return initial_count;
 
+  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+
   auto binary = llvm::object::createBinary(file.GetPath());
-  if (!binary)
+
+  if (!binary) {
+std::string msg = errorToErrorCode(binary.takeError()).message();
+LLDB_LOGF(log,
+  "ObjectFilePECOFF::GetModuleSpecifications() - failed to create binary "
+  "for file (%s): %s",
+  file ? file.GetPath().c_str() : "", msg.c_str());
 return initial_count;
+  }
 
   if (!binary->getBinary()->isCOFF() &&
   !binary->getBinary()->isCOFFImportFile())
@@ -242,11 +251,11 @@
 
   auto binary = llvm::object::createBinary(m_file.GetPath());
   if (!binary) {
+std::string msg = errorToErrorCode(binary.takeError()).message();
 LLDB_LOGF(log,
   "ObjectFilePECOFF::CreateBinary() - failed to create binary "
   "for file (%s): %s",
-  m_file ? m_file.GetPath().c_str() : "",
-  errorToErrorCode(binary.takeError()).message().c_str());
+  m_file ? m_file.GetPath().c_str() : "", msg.c_str());
 return false;
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69502: [LLDB] [PECOFF] Don't crash in ReadImageDataByRVA for addresses out of range

2019-10-30 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 227183.
mstorsjo added a comment.

Added a testcase based on @labath 's patch. (Thanks! That managed to trigger 
the condition!)


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

https://reviews.llvm.org/D69502

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/Minidump/Windows/Inputs/broken-unwind.dmp.yaml
  lldb/test/Shell/Minidump/Windows/Inputs/broken-unwind.exe.yaml
  lldb/test/Shell/Minidump/Windows/broken-unwind.test

Index: lldb/test/Shell/Minidump/Windows/broken-unwind.test
===
--- /dev/null
+++ lldb/test/Shell/Minidump/Windows/broken-unwind.test
@@ -0,0 +1,7 @@
+Test that we can cope with broken unwind information that suggests
+reading out of bounds.
+
+RUN: yaml2obj %S/Inputs/broken-unwind.exe.yaml > %T/broken-unwind.exe
+RUN: yaml2obj %S/Inputs/broken-unwind.dmp.yaml > %T/broken-unwind.dmp
+RUN: %lldb -O "settings set target.exec-search-paths %T" \
+RUN:   -c %T/broken-unwind.dmp -o "image show-unwind -a 0xb1000" -o exit
Index: lldb/test/Shell/Minidump/Windows/Inputs/broken-unwind.exe.yaml
===
--- /dev/null
+++ lldb/test/Shell/Minidump/Windows/Inputs/broken-unwind.exe.yaml
@@ -0,0 +1,84 @@
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4224
+  ImageBase:   4194304
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_NO_SEH, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable: 
+RelativeVirtualAddress: 8327
+Size:90
+  ImportTable: 
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:   
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:  
+RelativeVirtualAddress: 12303
+Size:12
+  CertificateTable: 
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable: 
+RelativeVirtualAddress: 0
+Size:0
+  Debug:   
+RelativeVirtualAddress: 8192
+Size:28
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:   
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable: 
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport: 
+RelativeVirtualAddress: 0
+Size:0
+  IAT: 
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor: 
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader: 
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_I386
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_32BIT_MACHINE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 22
+SectionData: 50894C24048B4C24040FAF4C2404890C248B042459C3
+  - Name:.rdata
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  8192
+VirtualSize: 236
+SectionData: A565B65C02006B001C201C0652534453E092B2141AD8F1B44C4C44205044422E0100443A5C757073747265616D5C6275696C645C746F6F6C735C6C6C64625C6C69745C4D6F64756C65735C5045434F46465C4F75747075745C6578706F72742D646C6C66756E632E79616D6C2E746D702E70646200AF2002000100CB20D320D7206578706F72742D646C6C66756E632E79616D6C2E746D702E646C6C10D9200100446C6C46756E63010101000102
+  - Name:.pdata
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  12288
+VirtualSize: 12
+SectionData: '00101610E420'
+symbols: []
+...
Index: lldb/test/Shell/Minidump/Windows/Inputs/broken-unwind.dmp.yaml
===
--- /dev/null
+++ lldb/test/Shell/Minidump/Windows/Inputs/broken-unwind.dmp.yaml
@@ -0,0 +1,35 @@
+--- !minidump
+Streams:
+  - Type:ModuleList
+Modules:
+  - Base of Image:   0x000B
+Size of Image:   0x5000
+Module Name: 'find-module.exe'
+CodeView Record: 

[Lldb-commits] [PATCH] D70387: [LLDB] [Windows] Allow making subprocesses use the debugger's console with LLDB_INHERIT_CONSOLE=true

2019-11-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, zturner, amccarth, aleksandr.urakov.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

When running the lldb command line debugger in a console, it can be convenient 
to get the output of the debuggee inline in the same console.

The same behaviour also seems possible to enable by setting the 
eLaunchFlagDisableSTDIO flag somehow, but I wasn't able to figure out how to 
set that when calling the normal lldb.exe.

Also extend a nearby getenv() call to check for both "true" and "1".

There seems to be a number of different patterns for using getenv() in lldb; 
either just check for a variable being set (most common), or check for a number 
of different values. The check for LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE only 
used to check for the string "true", while e.g. the newly added check for 
LLDB_USE_LLDB_SERVER in 
source/Plugins/Process/Windows/Common/ProcessWindows.cpp checks for any of 
on/yes/1/true.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D70387

Files:
  lldb/source/Host/windows/ProcessLauncherWindows.cpp


Index: lldb/source/Host/windows/ProcessLauncherWindows.cpp
===
--- lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -80,7 +80,8 @@
   const char *hide_console_var =
   getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
   if (hide_console_var &&
-  llvm::StringRef(hide_console_var).equals_lower("true")) {
+  (llvm::StringRef(hide_console_var).equals_lower("true") ||
+   llvm::StringRef(hide_console_var).equals_lower("1"))) {
 startupinfo.dwFlags |= STARTF_USESHOWWINDOW;
 startupinfo.wShowWindow = SW_HIDE;
   }
@@ -89,7 +90,11 @@
   if (launch_info.GetFlags().Test(eLaunchFlagDebug))
 flags |= DEBUG_ONLY_THIS_PROCESS;
 
-  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO))
+  const char *inherit_console_var = getenv("LLDB_INHERIT_CONSOLE");
+  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO) ||
+  (inherit_console_var &&
+   (llvm::StringRef(inherit_console_var).equals_lower("true") ||
+llvm::StringRef(inherit_console_var).equals_lower("1"
 flags &= ~CREATE_NEW_CONSOLE;
 
   LPVOID env_block = nullptr;


Index: lldb/source/Host/windows/ProcessLauncherWindows.cpp
===
--- lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -80,7 +80,8 @@
   const char *hide_console_var =
   getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
   if (hide_console_var &&
-  llvm::StringRef(hide_console_var).equals_lower("true")) {
+  (llvm::StringRef(hide_console_var).equals_lower("true") ||
+   llvm::StringRef(hide_console_var).equals_lower("1"))) {
 startupinfo.dwFlags |= STARTF_USESHOWWINDOW;
 startupinfo.wShowWindow = SW_HIDE;
   }
@@ -89,7 +90,11 @@
   if (launch_info.GetFlags().Test(eLaunchFlagDebug))
 flags |= DEBUG_ONLY_THIS_PROCESS;
 
-  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO))
+  const char *inherit_console_var = getenv("LLDB_INHERIT_CONSOLE");
+  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO) ||
+  (inherit_console_var &&
+   (llvm::StringRef(inherit_console_var).equals_lower("true") ||
+llvm::StringRef(inherit_console_var).equals_lower("1"
 flags &= ~CREATE_NEW_CONSOLE;
 
   LPVOID env_block = nullptr;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70386: [lldb-server] Use LLDB_LOG_ERROR to consume Error<> even if logging is disabled

2019-11-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added a reviewer: labath.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D70386

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3635,9 +3635,9 @@
 llvm::Expected async_thread = ThreadLauncher::LaunchThread(
 "", ProcessGDBRemote::AsyncThread, 
this);
 if (!async_thread) {
-  LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
-   "failed to launch host thread: {}",
-   llvm::toString(async_thread.takeError()));
+  LLDB_LOG_ERROR(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ async_thread.takeError(),
+ "failed to launch host thread: {}");
   return false;
 }
 m_async_thread = *async_thread;
Index: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -669,9 +669,9 @@
 response.PutStringAsRawHex8(unescaped_response.GetData());
 response.PutChar(';');
   } else {
-LLDB_LOG(log, "failed to prepare a jstopinfo field for pid {0}:",
- m_debugged_process_up->GetID(),
- llvm::toString(threads_info.takeError()));
+LLDB_LOG_ERROR(log, threads_info.takeError(),
+   "failed to prepare a jstopinfo field for pid {1}: {0}",
+   m_debugged_process_up->GetID());
   }
 }
 
@@ -3087,9 +3087,9 @@
   llvm::Expected threads_info = GetJSONThreadsInfo(
   *m_debugged_process_up, threads_with_valid_stop_info_only);
   if (!threads_info) {
-LLDB_LOG(log, "failed to prepare a packet for pid {0}: {1}",
- m_debugged_process_up->GetID(),
- llvm::toString(threads_info.takeError()));
+LLDB_LOG_ERROR(log, threads_info.takeError(),
+   "failed to prepare a packet for pid {1}: {0}",
+   m_debugged_process_up->GetID());
 return SendErrorResponse(52);
   }
 
Index: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
===
--- 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
+++ 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
@@ -211,9 +211,9 @@
 "",
 GDBRemoteCommunicationReplayServer::AsyncThread, this);
 if (!async_thread) {
-  LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
-   "failed to launch host thread: {}",
-   llvm::toString(async_thread.takeError()));
+  LLDB_LOG_ERROR(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ async_thread.takeError(),
+ "failed to launch host thread: {}");
   return false;
 }
 m_async_thread = *async_thread;


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3635,9 +3635,9 @@
 llvm::Expected async_thread = ThreadLauncher::LaunchThread(
 "", ProcessGDBRemote::AsyncThread, this);
 if (!async_thread) {
-  LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
-   "failed to launch host thread: {}",
-   llvm::toString(async_thread.takeError()));
+  LLDB_LOG_ERROR(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ async_thread.takeError(),
+ "failed to launch host thread: {}");
   return false;
 }
 m_async_thread = *async_thread;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -669,9 +669,9 @@
 response.PutStringAsRawHex8(unescaped_response.GetData());
 response.PutChar(';');
   } else {
-LLDB_LOG(log, "failed to prepare a jstopinfo field for pid {0}:",
- 

[Lldb-commits] [PATCH] D70387: [LLDB] [Windows] Allow making subprocesses use the debugger's console with LLDB_INHERIT_CONSOLE=true

2019-11-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

Thanks for the excellent explanations of the situation so far. I'll have a look 
at how it behaves with input and other aspects of console sharing. You might be 
right that it can cause some issues, as I did run into cases where the main 
lldb console UI hung if the lldb-server subprocess crashed (due to unchecked 
Error), but I didn't realize and correlate this to the inherited/shared console 
at that time.

When passing flags like `--tty` or `--disable-stdio` to `process launch`, is it 
possible to set a persistent preference for that somehow via e.g. the 
`.lldbinit` file?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D70387



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


[Lldb-commits] [PATCH] D70848: [LLDB] Set the right address size on output DataExtractors from ObjectFile

2019-12-02 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo marked an inline comment as done.
mstorsjo added inline comments.



Comment at: lldb/source/Symbol/ObjectFile.cpp:480-486
+  size_t ret = data.SetData(m_data, offset, length);
+  // DataExtractor::SetData copies the address byte size from m_data, but
+  // m_data's address byte size is only set from sizeof(void*), and we can't
+  // access subclasses GetAddressByteSize() when setting up m_data in the
+  // constructor.
+  data.SetAddressByteSize(GetAddressByteSize());
+  return ret;

clayborg wrote:
> I would vote to make this happen within DataExtractor::SetData(const 
> DataExtractor &...)
Do you mean that we'd extend `DataExtractor::SetData(const DataExtractor &...)` 
to take a byte address size parameter, or that we'd update `m_data`'s byte 
address size before doing `data.SetData()` here?

Ideally I'd set the right byte address size in `m_data` as soon as it is known 
and available. It's not possible to do this in `ObjectFile`'s constructor, as 
that is called before the subclass is constructed and its virtual methods are 
available, but is there a better point in the lifetime where we could update it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70848



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


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-03 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D70840#1765373 , @clayborg wrote:

> So some background on how address masks are handled in LLDB:
>
> Typically the way we have tried to take care of the extra Thumb bit for ARM 
> using:
>
>   lldb::addr_t Address::GetCallableLoadAddress(Target *target, bool 
> is_indirect = false) const;
>   lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class = 
> AddressClass::eInvalid) const;
>   
>
> The first will add the extra bit to an address if needed. The latter will 
> strip the bit if needed. This does require a target though and the target 
> uses the "Architecture" class for ARM to do the work of using the mask. Not 
> sure if we want to try to get an architecture class and use that here for 
> stripping the bit instead of using an address mask?


So, where do I get hold of an Architecture* object instance from within the 
relevant contexts (within SymbolFileDWARF, where we have a reference to the 
object file)? Also within source/Symbol/DWARFCallFrameInfo.cpp where we have 
existing code that does the same.


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D70848: [LLDB] Set the right address size on output DataExtractors from ObjectFile

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

In D70848#1768730 , @labath wrote:

> BTW, I don't know if you've noticed, but the new test is failing on windows: 
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/11217. It 
> looks like a path separator problem. We actually already have code which 
> tries to guess the path style of a compile unit, but it is keyed off of the 
> DW_AT_comp_dir attribute, which it looks like you stripped from the test 
> case. My guess is that adding this attribute back will fix this problem...


I did notice it, and tried to fix it 
(https://reviews.llvm.org/rG7d019d1a3be252a885e8db1ee7af11c90), but I forgot to 
check that it actually worked - sorry about that. Apparently I got the 
backslash escaping wrong (from some clang test). I'll see if DW_AT_comp_dir 
helps (and remove that failed regex fix), or fix the backslash matching.




Comment at: lldb/source/Symbol/ObjectFile.cpp:480-486
+  size_t ret = data.SetData(m_data, offset, length);
+  // DataExtractor::SetData copies the address byte size from m_data, but
+  // m_data's address byte size is only set from sizeof(void*), and we can't
+  // access subclasses GetAddressByteSize() when setting up m_data in the
+  // constructor.
+  data.SetAddressByteSize(GetAddressByteSize());
+  return ret;

labath wrote:
> mstorsjo wrote:
> > clayborg wrote:
> > > I would vote to make this happen within DataExtractor::SetData(const 
> > > DataExtractor &...)
> > Do you mean that we'd extend `DataExtractor::SetData(const DataExtractor 
> > &...)` to take a byte address size parameter, or that we'd update 
> > `m_data`'s byte address size before doing `data.SetData()` here?
> > 
> > Ideally I'd set the right byte address size in `m_data` as soon as it is 
> > known and available. It's not possible to do this in `ObjectFile`'s 
> > constructor, as that is called before the subclass is constructed and its 
> > virtual methods are available, but is there a better point in the lifetime 
> > where we could update it?
> I too would prefer that, but I couldn't see a way to achieve that (which is 
> why I stamped this version).
> 
> Today, with a fresh set of eyes, I think it may be reasonable to have this 
> happen in `ObjectFile::ParseHeader`. After the header has been parsed, all 
> object formats (I hope) should be able to determine their address size and 
> endianness, and the operating invariant would be that the address size is 
> only valid after the ParseHeader has been called. WDYT?
Sounds sensible! I'll give it a shot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70848



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


[Lldb-commits] [PATCH] D70848: [LLDB] Set the right address size on output DataExtractors from ObjectFile

2019-12-04 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo marked an inline comment as done.
mstorsjo added inline comments.



Comment at: lldb/source/Symbol/ObjectFile.cpp:480-486
+  size_t ret = data.SetData(m_data, offset, length);
+  // DataExtractor::SetData copies the address byte size from m_data, but
+  // m_data's address byte size is only set from sizeof(void*), and we can't
+  // access subclasses GetAddressByteSize() when setting up m_data in the
+  // constructor.
+  data.SetAddressByteSize(GetAddressByteSize());
+  return ret;

mstorsjo wrote:
> labath wrote:
> > mstorsjo wrote:
> > > clayborg wrote:
> > > > I would vote to make this happen within DataExtractor::SetData(const 
> > > > DataExtractor &...)
> > > Do you mean that we'd extend `DataExtractor::SetData(const DataExtractor 
> > > &...)` to take a byte address size parameter, or that we'd update 
> > > `m_data`'s byte address size before doing `data.SetData()` here?
> > > 
> > > Ideally I'd set the right byte address size in `m_data` as soon as it is 
> > > known and available. It's not possible to do this in `ObjectFile`'s 
> > > constructor, as that is called before the subclass is constructed and its 
> > > virtual methods are available, but is there a better point in the 
> > > lifetime where we could update it?
> > I too would prefer that, but I couldn't see a way to achieve that (which is 
> > why I stamped this version).
> > 
> > Today, with a fresh set of eyes, I think it may be reasonable to have this 
> > happen in `ObjectFile::ParseHeader`. After the header has been parsed, all 
> > object formats (I hope) should be able to determine their address size and 
> > endianness, and the operating invariant would be that the address size is 
> > only valid after the ParseHeader has been called. WDYT?
> Sounds sensible! I'll give it a shot.
`ObjectFile::ParseHeader` is currently pure virtual, and thus the subclass 
concrete implementations of it don't call the base class version of the method. 
Do you want me to make the base class method non-pure and add calls to it in 
the subclasses, or add calls to 
`m_data.SetAddressByteSize(GetAddressByteSize());` in all of the subclasses 
`ParseHeader`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70848



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


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-03 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D70840#1767049 , @labath wrote:

> In D70840#1767028 , @mstorsjo wrote:
>
> > In D70840#1765373 , @clayborg 
> > wrote:
> >
> > > So some background on how address masks are handled in LLDB:
> > >
> > > Typically the way we have tried to take care of the extra Thumb bit for 
> > > ARM using:
> > >
> > >   lldb::addr_t Address::GetCallableLoadAddress(Target *target, bool 
> > > is_indirect = false) const;
> > >   lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass 
> > > addr_class = AddressClass::eInvalid) const;
> > >   
> > >
> > > The first will add the extra bit to an address if needed. The latter will 
> > > strip the bit if needed. This does require a target though and the target 
> > > uses the "Architecture" class for ARM to do the work of using the mask. 
> > > Not sure if we want to try to get an architecture class and use that here 
> > > for stripping the bit instead of using an address mask?
> >
> >
> > So, where do I get hold of an Architecture* object instance from within the 
> > relevant contexts (within SymbolFileDWARF, where we have a reference to the 
> > object file)? Also within source/Symbol/DWARFCallFrameInfo.cpp where we 
> > have existing code that does the same.
>
>
> Well... that's the tricky part (which I've tried to allude to in  
> D70840#1763639 . Currently the only 
> thing holding an architecture object is the target class, but since one of 
> the goals of the SymbolFile stuff is to be independent of any particular 
> target, you cannot easily get hold of that. That is why I tried to steer this 
> towards having this in the ArchSpec class. If we don't want that, we'll 
> probably have to create one new Architecture instance local to each Module 
> object...


Ah, sorry for overlooking those parts of your comment. @clayborg - what do you 
think of @labath's suggestions here?


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D71108: [LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers

2019-12-10 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0f72441c898: [LLDB] [PECOFF] Make sure to set the address 
byte size in m_data after parsing… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71108

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Symbol/ObjectFile.cpp


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor ) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -315,6 +315,7 @@
   ParseCOFFOptionalHeader();
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor ) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -315,6 +315,7 @@
   ParseCOFFOptionalHeader();
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71108: [LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers

2019-12-10 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

@labath does this one seem sensible and like what you suggested in D70848 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71108



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


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-12 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D70840#1782951 , @clayborg wrote:

> So my idea would be:
>  1 - add all virtual functions to from lldb_private::Architecture as normal 
> members of ArchSpec. 
>  2 - have ArchSpec grap the the lldb_private::Architecture using info in the 
> ArchSpec when it is needed for methods added in step 1 and still call through 
> to the lldb_private::Architecture plug-ins


So ArchSpec would have an Architecture* member which is lazy loaded when needed?

A couple details come to mind:

- This would have to be a shared_ptr, to keep ArchSpec easily copyable
- As those methods where this is used are const, should the shared_ptr 
Architecture be made mutable? Or skip the const on those methods?
- There's a few places (in DWARFDebugInfoEntry) where I fetch a new copy of an 
ArchSpec (almost) each time I use it. In those cases, we'd end up with a new 
lazy load of the plugin each time (if the originating object hasn't needed 
loading the plugin yet). So perhaps it's best to always load it (like in 
ArchSpec::SetTriple) and similar ones, so that there's always an initialized 
shared_ptr that can be copied along cheaply?


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-11 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D70840#1763639 , @labath wrote:

> - I think we ought to have some kind of a utility function to hold the logic 
> for the `&~1` stuff. there is something like that in 
> Architecture::GetOpcodeLoadAddress. The Architecture class is mostly 
> independent of a target, so we may be able create one instance for each 
> module or symbol file, but that feels quite heavy. I might even go for 
> putting something like that into the ArchSpec class. The raison d'être of the 
> Architecture class was to evict some heavy code out of ArchSpec -- this was 
> ArchitectureArm::OverrideStopInfo. That one is definitely too heavy, so still 
> don't thing it belongs in ArchSpec, but the `&~1` thingy seems like it could 
> find a place there.)


I'm trying to dig into this now even if @clayborg hasn't commented on your 
suggestions.

This was moved out from the Target class in D48623 
/rG7aa9e7bc5739f468143b7b97060a9fbbfb94c6d2 
. In 
addition to GetOpcodeLoadAddress and GetCallableLoadAddress, there's also 
GetBreakableLoadAddress in ArchitectureMips, which is a rather big piece of 
code as well, so I guess that can't be motivated to be moved, but as you write, 
the `&~1` bit in itself might be ok.

If we add a GetOpcodeLoadAddress in ArchSpec, which does `&~1` on mips and arm 
- should we try to call this from the Architecture plugins (we don't have an 
ArchSpec stored there right now), or just see it as tolerable and justifiable 
duplication? The existing GetOpcodeLoadAddress takes an AddressClass as well, 
should we keep that, or just make a plain GetOpcodeLoadAddress that assumes 
that the provided address is a code address?


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-12 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 233586.
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Added ArchSpec::GetOpcodeLoadAddress() (didn't refactor Architecture to use it 
yet, so this is still duplicated code with the ArchitectureArm and 
ArchitectureMips plugins, but posting for feedback).

Changed the existing DWARFCallFrameInfo to use it for clearing the lowest bit, 
and added a Finalize pass to both LineTable and DWARFDebugAranges for fixing it 
up.

DWARFDebugInfoEntry still has the calls scattered around, as there's many 
different call paths, and once parsed, the data ends up in many different 
places.


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

https://reviews.llvm.org/D70840

Files:
  lldb/include/lldb/Symbol/LineTable.h
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Symbol/DWARFCallFrameInfo.cpp
  lldb/source/Symbol/LineTable.cpp
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/Shell/SymbolFile/DWARF/thumb-windows.s

Index: lldb/test/Shell/SymbolFile/DWARF/thumb-windows.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/thumb-windows.s
@@ -0,0 +1,183 @@
+# Test that a linked windows executable, with a thumb bit in many address
+# fields, gets the thumb bit stripped out from addresses.
+
+# If the thumb bit isn't stripped out from subprogram ranges, 0x401006 is
+# associated with the function "entry", while it actually is the start of
+# the function "other".
+# If the thumb bit isn't stripped out from line tables, the LineEntry
+# points to the wrong line.
+
+# REQUIRES: lld, arm
+
+# RUN: llvm-mc -triple armv7-windows-gnu %s -filetype=obj > %t.o
+# RUN: lld-link %t.o -out:%t.exe -debug:dwarf -entry:entry -subsystem:console -lldmingw
+# RUN: %lldb %t.exe -o "image lookup -v -a 0x401006" -b | FileCheck %s
+
+# CHECK-LABEL: image lookup -v -a 0x401006
+# CHECK: Function: {{.*}}, name = "other", range = [0x00401006-0x0040100c)
+# CHECK: LineEntry: [0x00401006-0x0040100a): /path/to/src/dwarf-thumb.c:7:12
+
+.text
+.syntax unified
+.file   "dwarf-thumb.c"
+.file   1 "" "dwarf-thumb.c"
+.def entry;
+.scl2;
+.type   32;
+.endef
+.globl  entry   @ -- Begin function entry
+.p2align1
+.code   16  @ @entry
+.thumb_func
+entry:
+.Lfunc_begin0:
+.loc1 2 0   @ dwarf-thumb.c:2:0
+.cfi_sections .debug_frame
+.cfi_startproc
+.loc1 4 9 prologue_end  @ dwarf-thumb.c:4:9
+mov r1, r0
+.Ltmp0:
+b   other
+.Ltmp1:
+.Lfunc_end0:
+.cfi_endproc
+@ -- End function
+.def other;
+.scl2;
+.type   32;
+.endef
+.globl  other   @ -- Begin function other
+.p2align1
+.code   16  @ @other
+.thumb_func
+other:
+.Lfunc_begin1:
+.loc1 6 0   @ dwarf-thumb.c:6:0
+.cfi_startproc
+.loc1 7 12 prologue_end @ dwarf-thumb.c:7:12
+add.w   r0, r1, r1, lsl #1
+.loc1 7 2 is_stmt 0 @ dwarf-thumb.c:7:2
+bx  lr
+.Ltmp2:
+.Lfunc_end1:
+.cfi_endproc
+@ -- End function
+.section.debug_str,"dr"
+.Linfo_string:
+.Linfo_string1:
+.asciz  "dwarf-thumb.c"
+.Linfo_string2:
+.asciz  "/path/to/src"
+.Linfo_string3:
+.asciz  "other"
+.Linfo_string6:
+.asciz  "entry"
+.section.debug_loc,"dr"
+.Lsection_debug_loc:
+.Ldebug_loc0:
+.long   .Lfunc_begin0-.Lfunc_begin0
+.long   .Ltmp0-.Lfunc_begin0
+.short  1   @ Loc expr size
+.byte   80  @ DW_OP_reg0
+.long   .Ltmp0-.Lfunc_begin0
+.long   .Lfunc_end0-.Lfunc_begin0
+.short  1   @ Loc expr size
+.byte   81  @ DW_OP_reg1
+.long   0
+.long   0
+.section.debug_abbrev,"dr"
+.Lsection_abbrev:
+.byte   1   @ Abbreviation Code
+.byte   17  @ DW_TAG_compile_unit
+.byte   1   @ DW_CHILDREN_yes
+.byte   37  @ DW_AT_producer
+.byte   37  @ DW_FORM_strx1
+.byte   19  @ 

[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-06 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D70840#1767611 , @mstorsjo wrote:

> In D70840#1767049 , @labath wrote:
>
> > In D70840#1767028 , @mstorsjo 
> > wrote:
> >
> > > In D70840#1765373 , @clayborg 
> > > wrote:
> > >
> > > > So some background on how address masks are handled in LLDB:
> > > >
> > > > Typically the way we have tried to take care of the extra Thumb bit for 
> > > > ARM using:
> > > >
> > > >   lldb::addr_t Address::GetCallableLoadAddress(Target *target, bool 
> > > > is_indirect = false) const;
> > > >   lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass 
> > > > addr_class = AddressClass::eInvalid) const;
> > > >   
> > > >
> > > > The first will add the extra bit to an address if needed. The latter 
> > > > will strip the bit if needed. This does require a target though and the 
> > > > target uses the "Architecture" class for ARM to do the work of using 
> > > > the mask. Not sure if we want to try to get an architecture class and 
> > > > use that here for stripping the bit instead of using an address mask?
> > >
> > >
> > > So, where do I get hold of an Architecture* object instance from within 
> > > the relevant contexts (within SymbolFileDWARF, where we have a reference 
> > > to the object file)? Also within source/Symbol/DWARFCallFrameInfo.cpp 
> > > where we have existing code that does the same.
> >
> >
> > Well... that's the tricky part (which I've tried to allude to in  
> > D70840#1763639 . Currently the 
> > only thing holding an architecture object is the target class, but since 
> > one of the goals of the SymbolFile stuff is to be independent of any 
> > particular target, you cannot easily get hold of that. That is why I tried 
> > to steer this towards having this in the ArchSpec class. If we don't want 
> > that, we'll probably have to create one new Architecture instance local to 
> > each Module object...
>
>
> Ah, sorry for overlooking those parts of your comment. @clayborg - what do 
> you think of @labath's suggestions here?


Ping @clayborg - can you comment on @labath's suggestions?


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D71108: [LLDB] [PECOFF] Make sure to set the address byte size in m_data after parsing headers

2019-12-06 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, clayborg.
Herald added a project: LLDB.

If not set, the address byte size was implied to be the one of the host process.

This allows reverting the functional change from 31087b2ae9154, since now 
PECOFF does the same as ELF and MachO wrt setting both byte order and address 
size on m_data within ParseHeader.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71108

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Symbol/ObjectFile.cpp


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor ) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -314,6 +314,7 @@
   ParseCOFFOptionalHeader();
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }


Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -477,13 +477,7 @@
DataExtractor ) const {
   // The entire file has already been mmap'ed into m_data, so just copy from
   // there as the back mmap buffer will be shared with shared pointers.
-  size_t ret = data.SetData(m_data, offset, length);
-  // DataExtractor::SetData copies the address byte size from m_data, but
-  // m_data's address byte size is only set from sizeof(void*), and we can't
-  // access subclasses GetAddressByteSize() when setting up m_data in the
-  // constructor.
-  data.SetAddressByteSize(GetAddressByteSize());
-  return ret;
+  return data.SetData(m_data, offset, length);
 }
 
 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -314,6 +314,7 @@
   ParseCOFFOptionalHeader();
 ParseSectionHeaders(offset);
   }
+  m_data.SetAddressByteSize(GetAddressByteSize());
   return true;
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69102: COFF: Set section permissions

2019-10-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo accepted this revision.
mstorsjo added inline comments.
This revision is now accepted and ready to land.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:800
 /*flags*/ 0);
+header_sp->SetPermissions(ePermissionsReadable);
 m_sections_up->AddSection(header_sp);

labath wrote:
> labath wrote:
> > Are these the right permissions for the header?
> I've dug around in some minidumps I have around and this does appear to be 
> correct. It looks like the entire block of memory for the object is first 
> allocated with PAGE_EXECUTE_WRITE_COPY, and the permissions for the header 
> region are later changed to PAGE_READ_ONLY.
I haven't checked, but I certainly would expect it to be readonly.


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

https://reviews.llvm.org/D69102



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


[Lldb-commits] [PATCH] D69226: [LLDB] [Windows] Initial support for ARM register contexts

2019-10-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, compnerd, asmith, amccarth.
Herald added subscribers: llvm-commits, JDevlieghere, teemperor, delcypher, 
kristof.beyls, mgorny.
Herald added projects: LLDB, LLVM.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69226

Files:
  lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
  
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp
  lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.h
  lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/arm/RegisterContextWindows_arm.cpp
  lldb/source/Plugins/Process/Windows/Common/arm/RegisterContextWindows_arm.h
  lldb/test/Shell/Register/Inputs/arm-fp-read.cpp
  lldb/test/Shell/Register/Inputs/arm-gp-read.cpp
  lldb/test/Shell/Register/arm-fp-read.test
  lldb/test/Shell/Register/arm-gp-read.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -99,6 +99,8 @@
 features.add('target-x86_64')
 elif re.match(r'^aarch64.*', target_triple):
 features.add('target-aarch64')
+elif re.match(r'^arm.*', target_triple):
+features.add('target-arm')
 
 use_gmalloc = lit_config.params.get('use_gmalloc', None)
 if lit.util.pythonize_bool(use_gmalloc):
Index: lldb/test/Shell/Register/arm-gp-read.test
===
--- /dev/null
+++ lldb/test/Shell/Register/arm-gp-read.test
@@ -0,0 +1,19 @@
+# REQUIRES: native && target-arm
+# RUN: %clangxx -fomit-frame-pointer %p/Inputs/arm-gp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read --all
+# CHECK-DAG: r0 = 0x00010203
+# CHECK-DAG: r1 = 0x10111213
+# CHECK-DAG: r2 = 0x20212223
+# CHECK-DAG: r3 = 0x30313233
+# CHECK-DAG: r4 = 0x40414243
+# CHECK-DAG: r5 = 0x50515253
+# CHECK-DAG: r6 = 0x60616263
+# CHECK-DAG: r7 = 0x70717273
+
+# CHECK-DAG: q0 = {0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17}
+# CHECK-DAG: q1 = {0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18}
+# CHECK-DAG: q2 = {0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19}
+# CHECK-DAG: q3 = {0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a}
Index: lldb/test/Shell/Register/arm-fp-read.test
===
--- /dev/null
+++ lldb/test/Shell/Register/arm-fp-read.test
@@ -0,0 +1,21 @@
+# REQUIRES: native && target-arm
+# RUN: %clangxx -fomit-frame-pointer %p/Inputs/arm-fp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read d0
+register read d1
+register read d2
+register read d3
+register read s8
+register read s9
+register read s10
+register read s11
+# CHECK-DAG: d0 = 0.5
+# CHECK-DAG: d1 = 1.5
+# CHECK-DAG: d2 = 2.5
+# CHECK-DAG: d3 = 3.5
+# CHECK-DAG: s8 = 4.5
+# CHECK-DAG: s9 = 5.5
+# CHECK-DAG: s10 = 6.5
+# CHECK-DAG: s11 = 7.5
Index: lldb/test/Shell/Register/Inputs/arm-gp-read.cpp
===
--- /dev/null
+++ lldb/test/Shell/Register/Inputs/arm-gp-read.cpp
@@ -0,0 +1,44 @@
+#include 
+
+struct alignas(16) vec_t {
+  uint64_t a, b;
+};
+
+int main() {
+  constexpr uint32_t gprs[] = {
+0x00010203,
+0x10111213,
+0x20212223,
+0x30313233,
+0x40414243,
+0x50515253,
+0x60616263,
+0x70717273,
+  };
+
+  constexpr vec_t vecs[] = {
+{ 0x0F0E0D0C0B0A0908, 0x1716151413121110, },
+{ 0x100F0E0D0C0B0A09, 0x1817161514131211, },
+{ 0x11100F0E0D0C0B0A, 0x1918171615141312, },
+{ 0x1211100F0E0D0C0B, 0x1A19181716151413, },
+  };
+  const vec_t *vec_ptr = vecs;
+
+  asm volatile(
+"ldrd r0,  r1,  [%1]\n\t"
+"ldrd r2,  r3,  [%1, #8]\n\t"
+"ldrd r4,  r5,  [%1, #16]\n\t"
+"ldrd r6,  r7,  [%1, #24]\n\t"
+"\n\t"
+"vld1.64  {q0, q1}, [%0]!\n\t"
+"vld1.64  {q2, q3}, [%0]!\n\t"
+"\n\t"
+"bkpt #0\n\t"
+: "+r"(vec_ptr)
+: "r"(gprs)
+: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+  "q0", "q1", "q2", "q3"
+  );
+
+  return 0;
+}
Index: lldb/test/Shell/Register/Inputs/arm-fp-read.cpp
===
--- /dev/null
+++ lldb/test/Shell/Register/Inputs/arm-fp-read.cpp
@@ -0,0 +1,19 @@
+int main() {
+  asm volatile(
+"vmov.f64 d0,  #0.5\n\t"
+"vmov.f64 d1,  #1.5\n\t"
+"vmov.f64 d2,  #2.5\n\t"
+"vmov.f64 d3,  #3.5\n\t"
+"vmov.f32 s8,  #4.5\n\t"
+"vmov.f32 s9,  #5.5\n\t"
+"vmov.f32 s10, #6.5\n\t"
+"vmov.f32 s11, #7.5\n\t"
+"\n\t"
+"bkpt #0\n\t"
+:
+:
+: "d0", "d1", "d2", "d3", "s8", "s9", 

[Lldb-commits] [PATCH] D69502: [LLDB] [PECOFF] Don't crash in ReadImageDataByRVA for addresses out of range

2019-10-28 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth, aleksandr.urakov.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

This can happen e.g. when unwinding doesn't work perfectly.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69502

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp


Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -564,7 +564,10 @@
 DataExtractor ObjectFilePECOFF::ReadImageDataByRVA(uint32_t rva, size_t size) {
   if (m_file) {
 Address addr = GetAddress(rva);
-rva = addr.GetSection()->GetFileOffset() + addr.GetOffset();
+SectionSP sect = addr.GetSection();
+if (!sect)
+  return {};
+rva = sect->GetFileOffset() + addr.GetOffset();
   }
 
   return ReadImageData(rva, size);


Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -564,7 +564,10 @@
 DataExtractor ObjectFilePECOFF::ReadImageDataByRVA(uint32_t rva, size_t size) {
   if (m_file) {
 Address addr = GetAddress(rva);
-rva = addr.GetSection()->GetFileOffset() + addr.GetOffset();
+SectionSP sect = addr.GetSection();
+if (!sect)
+  return {};
+rva = sect->GetFileOffset() + addr.GetOffset();
   }
 
   return ReadImageData(rva, size);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69503: [LLDB] [Windows] Don't crash if the debugged process is unable to start up

2019-10-28 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth, aleksandr.urakov.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

This can e.g. happen if the debugged executable depends on unavailable DLLs.

One could also return e.g. Status(ERROR_DLL_NOT_FOUND, eErrorTypeWin32) here, 
but I presume that can be overly specific as I'd guess this condition can 
occurr in other cases as well.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69503

Files:
  lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -574,6 +574,8 @@
 LLDB_LOG(log, "hit loader breakpoint, returning.");
 
 process = debugger->GetProcess();
+if (!m_session_data)
+  return Status("The process failed to launch.");
 return m_session_data->m_launch_error;
   } else
 return Status(::GetLastError(), eErrorTypeWin32);


Index: lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
+++ lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp
@@ -574,6 +574,8 @@
 LLDB_LOG(log, "hit loader breakpoint, returning.");
 
 process = debugger->GetProcess();
+if (!m_session_data)
+  return Status("The process failed to launch.");
 return m_session_data->m_launch_error;
   } else
 return Status(::GetLastError(), eErrorTypeWin32);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69502: [LLDB] [PECOFF] Don't crash in ReadImageDataByRVA for addresses out of range

2019-10-28 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D69502#1723385 , @aleksandr.urakov 
wrote:

> LGTM, thank you! Can you send me an example of binary on which unwinding 
> fails with a crash, please? It is a very interesting case...


It is on arm64, so it's not something that is expected to be flawless yet (even 
if it generally works, sometimes).


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69502



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


[Lldb-commits] [PATCH] D69502: [LLDB] [PECOFF] Don't crash in ReadImageDataByRVA for addresses out of range

2019-10-28 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D69502#1723549 , @labath wrote:

> Any way to get a test for this? Maybe creating a object file with a bogus 
> unwind RVA via yaml2obj ?


Do we have a suitable test as basis for it? I'm not quite sure which way is the 
most compact way of achieving that. A small couple function exe with SEH or 
dwarf (eh_frame) unwind info, without debug info, with a crash/int3 in a nested 
function? Or just some image unwind commands so it doesn't need executing?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69502



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


[Lldb-commits] [PATCH] D69031: [LLDB] [test] Use %clang_cl instead of build.py in a few tests

2019-10-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D69031#1713900 , @aprantl wrote:

> Check out  `lldb/test/Shell/helper/toolchain.py`, you probably need to filter 
> out some options for clang_cl specifically.


Yeah, I later found that. The issue is that it's passed to usr_clang in i 
llvm/utils/lit/lit/llvm/config.py, which sets all the provided additional flags 
on both %clang, %clangxx, %clang_cc1 and %clang_cl.

Maybe the additional_flags param needs to be split, into one common for all, 
one for gcc-style driver, one for clang_cl, and maybe also a separate one for 
cc1 (where not all driver level flags may fit either)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69031



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


[Lldb-commits] [PATCH] D69031: [LLDB] [test] Use %clang_cl instead of build.py in a few tests

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



Comment at: lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp:6
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe 
-pdb:%t.pdb
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \

stella.stamenova wrote:
> Why is lld-link not specified as %lld_link?
Because that's how the lit substitutions are set up currently, and that's how 
existing tests write it. The substitutions are defined here:
https://github.com/llvm/llvm-project/blob/master/llvm/utils/lit/lit/llvm/config.py#L410
https://github.com/llvm/llvm-project/blob/master/llvm/utils/lit/lit/llvm/config.py#L492

Not sure if it's just because these have randomly happened to diverge, or if 
the percent for clang indicates that it's not just replaced with a resolved 
path, but also might include a few preset options.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69031



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


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

2019-10-16 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13993a6f8681: [LLDB] Use the llvm microsoft demangler 
instead of the windows dbghelp api. (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68134

Files:
  lldb/source/Core/Mangled.cpp


Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
 
 #include "lldb/Core/Mangled.h"
 
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -200,28 +174,20 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+  char *demangled_cstr = llvm::microsoftDemangle(
+  M, nullptr, nullptr, nullptr,
+  llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier |
+llvm::MSDF_NoCallingConvention |
+llvm::MSDF_NoMemberType));
 
   if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) 
{
 if (demangled_cstr && demangled_cstr[0])
   LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
 else
-  LLDB_LOGF(log, "demangled msvc: %s -> error: 0x%lu", M, result);
+  LLDB_LOGF(log, "demangled msvc: %s -> error", M);
   }
 
-  if (result != 0) {
-return demangled_cstr;
-  } else {
-::free(demangled_cstr);
-return nullptr;
-  }
-#else
-  return nullptr;
-#endif
+  return demangled_cstr;
 }
 
 static char *GetItaniumDemangledStr(const char *M) {


Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
 
 #include "lldb/Core/Mangled.h"
 
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -200,28 +174,20 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, 

[Lldb-commits] [PATCH] D69226: [LLDB] [Windows] Initial support for ARM register contexts

2019-10-21 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa59444a35608: [LLDB] [Windows] Initial support for ARM 
register contexts (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69226

Files:
  lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
  
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.cpp
  lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm.h
  lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/arm/RegisterContextWindows_arm.cpp
  lldb/source/Plugins/Process/Windows/Common/arm/RegisterContextWindows_arm.h
  lldb/test/Shell/Register/Inputs/arm-fp-read.cpp
  lldb/test/Shell/Register/Inputs/arm-gp-read.cpp
  lldb/test/Shell/Register/arm-fp-read.test
  lldb/test/Shell/Register/arm-gp-read.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -99,6 +99,8 @@
 features.add('target-x86_64')
 elif re.match(r'^aarch64.*', target_triple):
 features.add('target-aarch64')
+elif re.match(r'^arm.*', target_triple):
+features.add('target-arm')
 
 use_gmalloc = lit_config.params.get('use_gmalloc', None)
 if lit.util.pythonize_bool(use_gmalloc):
Index: lldb/test/Shell/Register/arm-gp-read.test
===
--- /dev/null
+++ lldb/test/Shell/Register/arm-gp-read.test
@@ -0,0 +1,19 @@
+# REQUIRES: native && target-arm
+# RUN: %clangxx -fomit-frame-pointer %p/Inputs/arm-gp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read --all
+# CHECK-DAG: r0 = 0x00010203
+# CHECK-DAG: r1 = 0x10111213
+# CHECK-DAG: r2 = 0x20212223
+# CHECK-DAG: r3 = 0x30313233
+# CHECK-DAG: r4 = 0x40414243
+# CHECK-DAG: r5 = 0x50515253
+# CHECK-DAG: r6 = 0x60616263
+# CHECK-DAG: r7 = 0x70717273
+
+# CHECK-DAG: q0 = {0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17}
+# CHECK-DAG: q1 = {0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18}
+# CHECK-DAG: q2 = {0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19}
+# CHECK-DAG: q3 = {0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a}
Index: lldb/test/Shell/Register/arm-fp-read.test
===
--- /dev/null
+++ lldb/test/Shell/Register/arm-fp-read.test
@@ -0,0 +1,21 @@
+# REQUIRES: native && target-arm
+# RUN: %clangxx -fomit-frame-pointer %p/Inputs/arm-fp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read d0
+register read d1
+register read d2
+register read d3
+register read s8
+register read s9
+register read s10
+register read s11
+# CHECK-DAG: d0 = 0.5
+# CHECK-DAG: d1 = 1.5
+# CHECK-DAG: d2 = 2.5
+# CHECK-DAG: d3 = 3.5
+# CHECK-DAG: s8 = 4.5
+# CHECK-DAG: s9 = 5.5
+# CHECK-DAG: s10 = 6.5
+# CHECK-DAG: s11 = 7.5
Index: lldb/test/Shell/Register/Inputs/arm-gp-read.cpp
===
--- /dev/null
+++ lldb/test/Shell/Register/Inputs/arm-gp-read.cpp
@@ -0,0 +1,44 @@
+#include 
+
+struct alignas(16) vec_t {
+  uint64_t a, b;
+};
+
+int main() {
+  constexpr uint32_t gprs[] = {
+0x00010203,
+0x10111213,
+0x20212223,
+0x30313233,
+0x40414243,
+0x50515253,
+0x60616263,
+0x70717273,
+  };
+
+  constexpr vec_t vecs[] = {
+{ 0x0F0E0D0C0B0A0908, 0x1716151413121110, },
+{ 0x100F0E0D0C0B0A09, 0x1817161514131211, },
+{ 0x11100F0E0D0C0B0A, 0x1918171615141312, },
+{ 0x1211100F0E0D0C0B, 0x1A19181716151413, },
+  };
+  const vec_t *vec_ptr = vecs;
+
+  asm volatile(
+"ldrd r0,  r1,  [%1]\n\t"
+"ldrd r2,  r3,  [%1, #8]\n\t"
+"ldrd r4,  r5,  [%1, #16]\n\t"
+"ldrd r6,  r7,  [%1, #24]\n\t"
+"\n\t"
+"vld1.64  {q0, q1}, [%0]!\n\t"
+"vld1.64  {q2, q3}, [%0]!\n\t"
+"\n\t"
+"bkpt #0\n\t"
+: "+r"(vec_ptr)
+: "r"(gprs)
+: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+  "q0", "q1", "q2", "q3"
+  );
+
+  return 0;
+}
Index: lldb/test/Shell/Register/Inputs/arm-fp-read.cpp
===
--- /dev/null
+++ lldb/test/Shell/Register/Inputs/arm-fp-read.cpp
@@ -0,0 +1,19 @@
+int main() {
+  asm volatile(
+"vmov.f64 d0,  #0.5\n\t"
+"vmov.f64 d1,  #1.5\n\t"
+"vmov.f64 d2,  #2.5\n\t"
+"vmov.f64 d3,  #3.5\n\t"
+"vmov.f32 s8,  #4.5\n\t"
+"vmov.f32 s9,  #5.5\n\t"
+"vmov.f32 s10, #6.5\n\t"
+"vmov.f32 s11, #7.5\n\t"
+"\n\t"
+"bkpt #0\n\t"
+:
+:
+: 

[Lldb-commits] [PATCH] D69031: [LLDB] [test] Use %clang_cl instead of build.py in a few tests

2019-10-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D69031#1714143 , @labath wrote:

> In D69031#1714107 , @mstorsjo wrote:
>
> > In D69031#1713900 , @aprantl wrote:
> >
> > > Check out  `lldb/test/Shell/helper/toolchain.py`, you probably need to 
> > > filter out some options for clang_cl specifically.
> >
> >
> > Yeah, I later found that. The issue is that it's passed to usr_clang in i 
> > llvm/utils/lit/lit/llvm/config.py, which sets all the provided additional 
> > flags on both %clang, %clangxx, %clang_cc1 and %clang_cl.
> >
> > Maybe the additional_flags param needs to be split, into one common for 
> > all, one for gcc-style driver, one for clang_cl, and maybe also a separate 
> > one for cc1 (where not all driver level flags may fit either)?
>
>
> Actually, it seems to be that these arguments should not be added to the 
> command line by default. All of the existing tests that do "%clang -target 
> whatever" don't need the arguments, and they "only" work because the 
> arguments do no harm because the tests don't do anything which would depend 
> on them. I think we should leave `additional_flags` argument mostly empty, 
> and instead have a separate way of invoking clang when building for the host. 
> Either %clang_host (achievable with a recursive substitution %clang_host -> 
> %clang ), or using something like %clang %host_cflags.
>
> I can have a stab at that, if you like, but I'm not sure I'll get around to 
> that before the llvm conference is over...


Ok, that makes sense.

I'd appreciate if you do that. I have no hurry wrt this patch as it's just a 
collateral fix I picked up along the way :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69031



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


[Lldb-commits] [PATCH] D69100: COFF: Create a separate "section" for the file header

2019-10-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

Looks and sounds good to me, although I'm not familiar with this code and its 
context yet - so I'm not sure if I'm qualified to formally approve it.


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

https://reviews.llvm.org/D69100



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


[Lldb-commits] [PATCH] D69100: COFF: Create a separate "section" for the file header

2019-10-21 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

I've happened to poke around a bit more in this piece of code now recently, and 
it does indeed seem reasonable.


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

https://reviews.llvm.org/D69100



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


[Lldb-commits] [PATCH] D68980: [LLDB] [test] Pass --target=-windows-msvc to clang-cl

2019-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D68980#1709954 , @stella.stamenova 
wrote:

> Both. Again, it's been a long time, but when we use VS for building, the 
> environment already contains a path to clang-cl so regardless of whether the 
> build is standalone or not, the build gets confused about which clang-cl to 
> use. @mstorsjo might want to update the tests to use clang-cl but then make 
> sure that the update works on the Windows Buildbot (or similar environment) 
> before committing.


Is there any way of checking whether it works on this buildbot, other than 
committing (after doing best effort testing of it in whatever comparable 
windows environments I have available)?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68980



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


[Lldb-commits] [PATCH] D68980: [LLDB] [test] Pass --target=-windows-msvc to clang-cl

2019-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D68980#1709931 , @labath wrote:

> In D68980#1709884 , 
> @stella.stamenova wrote:
>
> > The two things that come to mind are the path to clang-cl (which is 
> > sometimes a clang build and sometimes installed on the system as part of a 
> > VS installation or an LLVM installation) as well as the path to the linker 
> > when it is needed. This is most often an issue in the case of a VS install 
> > - I don't remember all the details any more, but I believe that before Zach 
> > added the script, we were often picking up the wrong clang-cl and ending up 
> > not being able to compile the tests at all.
>
>
> Thanks.
>
> Was this during a standalone lldb build? In a non-standalone build, lit 
> should definitely prefer the just-built clang/lld (and if it doesn't, it 
> should be fixed to do that). The situation is more complicated for a 
> standalone build because the clang binary is sort of out of our control. But, 
> in this case, I don't see how having build.py around can help, because the 
> information about which clang to use has to come externally anyway...


How do tests like test/Shell/Register/x86*.test work in such standalone builds 
then? They use lines like these:

  # XFAIL: system-windows
  # REQUIRES: native && target-x86_64
  # RUN: %clangxx -fomit-frame-pointer %p/Inputs/x86-64-gp-read.cpp -o %t
  # RUN: %lldb -b -s %s %t | FileCheck %s

(The XFAIL for system-windows, at least in this test, when I tried it out, 
seemed to relate to the fact that `register read --all` on windows didn't 
include all the 32 bit subregisters.)

If tests already can use such constrcuts, I don't see why we couldn't use `# 
RUN: %clang_cl ..`, as lit sets up `%clang_cl` in the same way as `%clangxx`.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68980



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


[Lldb-commits] [PATCH] D68980: [LLDB] [test] Pass --target=-windows-msvc to clang-cl

2019-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D68980#1710018 , @stella.stamenova 
wrote:

> In D68980#1709967 , @mstorsjo wrote:
>
> > In D68980#1709931 , @labath wrote:
> >
> > > In D68980#1709884 , 
> > > @stella.stamenova wrote:
> > >
> > > > The two things that come to mind are the path to clang-cl (which is 
> > > > sometimes a clang build and sometimes installed on the system as part 
> > > > of a VS installation or an LLVM installation) as well as the path to 
> > > > the linker when it is needed. This is most often an issue in the case 
> > > > of a VS install - I don't remember all the details any more, but I 
> > > > believe that before Zach added the script, we were often picking up the 
> > > > wrong clang-cl and ending up not being able to compile the tests at all.
> > >
> > >
> > > Thanks.
> > >
> > > Was this during a standalone lldb build? In a non-standalone build, lit 
> > > should definitely prefer the just-built clang/lld (and if it doesn't, it 
> > > should be fixed to do that). The situation is more complicated for a 
> > > standalone build because the clang binary is sort of out of our control. 
> > > But, in this case, I don't see how having build.py around can help, 
> > > because the information about which clang to use has to come externally 
> > > anyway...
> >
> >
> > How do tests like test/Shell/Register/x86*.test work in such standalone 
> > builds then? They use lines like these:
> >
> >   # XFAIL: system-windows
> >   # REQUIRES: native && target-x86_64
> >   # RUN: %clangxx -fomit-frame-pointer %p/Inputs/x86-64-gp-read.cpp -o %t
> >   # RUN: %lldb -b -s %s %t | FileCheck %s
> >
> >
> > (The XFAIL for system-windows, at least in this test, when I tried it out, 
> > seemed to relate to the fact that `register read --all` on windows didn't 
> > include all the 32 bit subregisters.)
> >
> > If tests already can use such constrcuts, I don't see why we couldn't use 
> > `# RUN: %clang_cl ..`, as lit sets up `%clang_cl` in the same way as 
> > `%clangxx`.
>
>
> %clang_cl is where we started before we had build.py. It was over a year ago, 
> so it's possible things have improved.


Possible, but I'm getting the feeling that there's cases that at least I'm 
overlooking, so I think it might be safer to just add a `--target` option to 
build.py. Or maybe make it accept an actual architecture name to `--arch`, in 
addition to 32/64/host? For non-clang-cl cases, it should only allow 
32/64/host, but for clang-cl it could accept e.g. `i386`. How does that sound 
to you?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68980



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


[Lldb-commits] [PATCH] D68980: [LLDB] [test] Allow specifying the full arch for msvc/clang-cl in build.py

2019-10-16 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 225171.
mstorsjo retitled this revision from "[LLDB] [test] Pass 
--target=-windows-msvc to clang-cl" to "[LLDB] [test] Allow specifying 
the full arch for msvc/clang-cl in build.py".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Extended the `--arch` option to build.py, to allow it to take a proper 
architecture name instead of just "32" and "64", when used with msvc or 
clang-cl.


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

https://reviews.llvm.org/D68980

Files:
  lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
  lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
  lldb/test/Shell/helper/build.py


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -4,6 +4,7 @@
 
 import argparse
 import os
+import re
 import signal
 import subprocess
 import sys
@@ -26,7 +27,6 @@
 dest='arch',
 required=True,
 default='host',
-choices=['32', '64', 'host'],
 help='Specify the architecture to target.')
 
 parser.add_argument('--compiler',
@@ -277,7 +277,14 @@
 def __init__(self, toolchain_type, args):
 Builder.__init__(self, toolchain_type, args, '.obj')
 
-self.msvc_arch_str = 'x86' if self.arch == '32' else 'x64'
+if self.arch == '32' or re.match(r'i\d86', self.arch):
+self.msvc_arch_str = 'x86'
+elif self.arch == '64' or self.arch == 'host' or self.arch == 'x86_64':
+self.msvc_arch_str = 'x64'
+elif self.arch == 'aarch64' or self.arch == 'arm64':
+self.msvc_arch_str = 'arm64'
+elif re.match(r'^arm', self.arch):
+self.msvc_arch_str = 'arm'
 
 if toolchain_type == 'msvc':
 # Make sure we're using the appropriate toolchain for the desired
@@ -553,7 +560,10 @@
 
 args.append(self.compiler)
 if self.toolchain_type == 'clang-cl':
-args.append('-m' + self.arch)
+if self.arch == '32' or self.arch == '64':
+args.append('-m' + self.arch)
+elif self.arch != 'host':
+args.append('--target=%s-windows-msvc' % (self.arch))
 
 if self.opt == 'none':
 args.append('/Od')
Index: lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
@@ -1,7 +1,7 @@
 // clang-format off
 // REQUIRES: lld
 
-// RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib -o %t.exe -- %s 
+// RUN: %build --compiler=clang-cl --arch=i386 --nodefaultlib -o %t.exe -- %s
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
 // RUN: %p/Inputs/function-types-calling-conv.lldbinit | FileCheck %s
 
Index: lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
@@ -2,7 +2,7 @@
 // REQUIRES: lld
 
 // Test that we can show disassembly and source.
-// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
+// RUN: %build --compiler=clang-cl --arch=x86_64 --nodefaultlib -o %t.exe -- %s
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
 // RUN: %p/Inputs/disassembly.lldbinit | FileCheck %s
 


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -4,6 +4,7 @@
 
 import argparse
 import os
+import re
 import signal
 import subprocess
 import sys
@@ -26,7 +27,6 @@
 dest='arch',
 required=True,
 default='host',
-choices=['32', '64', 'host'],
 help='Specify the architecture to target.')
 
 parser.add_argument('--compiler',
@@ -277,7 +277,14 @@
 def __init__(self, toolchain_type, args):
 Builder.__init__(self, toolchain_type, args, '.obj')
 
-self.msvc_arch_str = 'x86' if self.arch == '32' else 'x64'
+if self.arch == '32' or re.match(r'i\d86', self.arch):
+self.msvc_arch_str = 'x86'
+elif self.arch == '64' or self.arch == 'host' or self.arch == 'x86_64':
+self.msvc_arch_str = 'x64'
+elif self.arch == 'aarch64' or self.arch == 'arm64':
+self.msvc_arch_str = 'arm64'
+elif re.match(r'^arm', self.arch):
+self.msvc_arch_str = 'arm'
 
 if toolchain_type == 'msvc':
 # Make sure we're using the appropriate toolchain for the desired
@@ -553,7 +560,10 

[Lldb-commits] [PATCH] D69031: [LLDB] [test] Use %clang_cl instead of build.py in a few tests

2019-10-16 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, stella.stamenova, aleksandr.urakov, amccarth.
Herald added subscribers: JDevlieghere, teemperor, abidh, kristof.beyls.
Herald added a project: LLDB.

This allows explicitly specifying the intended target architecture, for tests 
that aren't supposed to be executed, and that don't require MSVC headers or 
libraries to be available.

(These tests already implicitly assumed to be built for x86; one didn't specify 
anything, assuming x86_64, while the other specified --arch=32, which only 
picks the 32 bit variant of the default target architecture).

Join two comment lines in disassembly.cpp, to keep row numbers checked in the 
test unchanged.

This fixes running check-lldb on arm linux.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69031

Files:
  lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
  lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp


Index: lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
@@ -1,7 +1,8 @@
 // clang-format off
 // REQUIRES: lld
 
-// RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib -o %t.exe -- %s 
+// RUN: %clang_cl --target=i386-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe 
-pdb:%t.pdb
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
 // RUN: %p/Inputs/function-types-calling-conv.lldbinit | FileCheck %s
 
Index: lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
@@ -2,12 +2,12 @@
 // REQUIRES: lld
 
 // Test that we can show disassembly and source.
-// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe 
-pdb:%t.pdb
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
 // RUN: %p/Inputs/disassembly.lldbinit | FileCheck %s
 
-// Some context lines before
-// the function.
+// Some context lines before the function.
 
 int foo() { return 42; }
 


Index: lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
@@ -1,7 +1,8 @@
 // clang-format off
 // REQUIRES: lld
 
-// RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib -o %t.exe -- %s 
+// RUN: %clang_cl --target=i386-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
 // RUN: %p/Inputs/function-types-calling-conv.lldbinit | FileCheck %s
 
Index: lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
@@ -2,12 +2,12 @@
 // REQUIRES: lld
 
 // Test that we can show disassembly and source.
-// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
 // RUN: %p/Inputs/disassembly.lldbinit | FileCheck %s
 
-// Some context lines before
-// the function.
+// Some context lines before the function.
 
 int foo() { return 42; }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 224969.
mstorsjo added a comment.

Using newly added demangler options to (hopefully) avoid any changes to test 
outputs (at least the differences seen when applied earlier shouldn't be 
present any longer).


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

https://reviews.llvm.org/D68134

Files:
  lldb/source/Core/Mangled.cpp


Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
 
 #include "lldb/Core/Mangled.h"
 
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -200,28 +174,20 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+  char *demangled_cstr = llvm::microsoftDemangle(
+  M, nullptr, nullptr, nullptr,
+  llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier |
+llvm::MSDF_NoCallingConvention |
+llvm::MSDF_NoMemberType));
 
   if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) 
{
 if (demangled_cstr && demangled_cstr[0])
   LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
 else
-  LLDB_LOGF(log, "demangled msvc: %s -> error: 0x%lu", M, result);
+  LLDB_LOGF(log, "demangled msvc: %s -> error", M);
   }
 
-  if (result != 0) {
-return demangled_cstr;
-  } else {
-::free(demangled_cstr);
-return nullptr;
-  }
-#else
-  return nullptr;
-#endif
+  return demangled_cstr;
 }
 
 static char *GetItaniumDemangledStr(const char *M) {


Index: lldb/source/Core/Mangled.cpp
===
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
 
 #include "lldb/Core/Mangled.h"
 
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include 
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
 #include 
 using namespace lldb_private;
 
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
-DWORD DemangledLength) {
-  static std::mutex M;
-  std::lock_guard Lock(M);
-  return ::UnDecorateSymbolName(
-  Mangled, Demangled, DemangledLength,
-  UNDNAME_NO_ACCESS_SPECIFIERS |   // Strip public, private, protected
-   // keywords
-  UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
-   // etc keywords
-  UNDNAME_NO_THROW_SIGNATURES |// Strip throw() specifications
-  UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
-   // specifiers
-  UNDNAME_NO_MS_KEYWORDS   // Strip all MS extension keywords
-  );
-}
-#endif
-
 static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
   if (s) {
 if (s[0] == '?')
@@ -200,28 +174,20 @@
 
 // Local helpers for different demangling implementations.
 static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
-  const size_t demangled_length = 2048;
-  char *demangled_cstr = static_cast(::malloc(demangled_length));
-  ::ZeroMemory(demangled_cstr, demangled_length);
-  DWORD result = safeUndecorateName(M, 

[Lldb-commits] [PATCH] D67954: [LLDB] [Windows] Initial support for ARM64 register contexts

2019-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1f6ba2a2ecd: [LLDB] [Windows] Initial support for ARM64 
register contexts (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67954

Files:
  lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt
  
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.cpp
  
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_arm64.h
  lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
  
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.cpp
  
lldb/source/Plugins/Process/Windows/Common/arm64/RegisterContextWindows_arm64.h
  lldb/test/Shell/Register/Inputs/aarch64-fp-read.cpp
  lldb/test/Shell/Register/Inputs/aarch64-gp-read.cpp
  lldb/test/Shell/Register/aarch64-fp-read.test
  lldb/test/Shell/Register/aarch64-gp-read.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -97,6 +97,8 @@
 features.add('target-x86')
 elif re.match(r'^x86_64.*', target_triple):
 features.add('target-x86_64')
+elif re.match(r'^aarch64.*', target_triple):
+features.add('target-aarch64')
 
 use_gmalloc = lit_config.params.get('use_gmalloc', None)
 if lit.util.pythonize_bool(use_gmalloc):
Index: lldb/test/Shell/Register/aarch64-gp-read.test
===
--- /dev/null
+++ lldb/test/Shell/Register/aarch64-gp-read.test
@@ -0,0 +1,24 @@
+# REQUIRES: native && target-aarch64
+# RUN: %clangxx -fomit-frame-pointer %p/Inputs/aarch64-gp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read --all
+# CHECK-DAG: x0 = 0x0001020304050607
+# CHECK-DAG: x1 = 0x1011121314151617
+# CHECK-DAG: x2 = 0x2021222324252627
+# CHECK-DAG: x3 = 0x3031323334353637
+# CHECK-DAG: x4 = 0x4041424344454647
+# CHECK-DAG: x5 = 0x5051525354555657
+# CHECK-DAG: x6 = 0x6061626364656667
+# CHECK-DAG: x7 = 0x7071727374757677
+# CHECK-DAG: w0 = 0x04050607
+
+# CHECK-DAG: v0 = {0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17}
+# CHECK-DAG: v1 = {0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18}
+# CHECK-DAG: v2 = {0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19}
+# CHECK-DAG: v3 = {0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a}
+# CHECK-DAG: v4 = {0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b}
+# CHECK-DAG: v5 = {0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c}
+# CHECK-DAG: v6 = {0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d}
+# CHECK-DAG: v7 = {0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e}
Index: lldb/test/Shell/Register/aarch64-fp-read.test
===
--- /dev/null
+++ lldb/test/Shell/Register/aarch64-fp-read.test
@@ -0,0 +1,21 @@
+# REQUIRES: native && target-aarch64
+# RUN: %clangxx -fomit-frame-pointer %p/Inputs/aarch64-fp-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+
+register read d0
+register read d1
+register read d2
+register read d3
+register read s4
+register read s5
+register read s6
+register read s7
+# CHECK-DAG: d0 = 0.5
+# CHECK-DAG: d1 = 1.5
+# CHECK-DAG: d2 = 2.5
+# CHECK-DAG: d3 = 3.5
+# CHECK-DAG: s4 = 4.5
+# CHECK-DAG: s5 = 5.5
+# CHECK-DAG: s6 = 6.5
+# CHECK-DAG: s7 = 7.5
Index: lldb/test/Shell/Register/Inputs/aarch64-gp-read.cpp
===
--- /dev/null
+++ lldb/test/Shell/Register/Inputs/aarch64-gp-read.cpp
@@ -0,0 +1,47 @@
+#include 
+
+struct alignas(16) vec_t {
+  uint64_t a, b;
+};
+
+int main() {
+  constexpr uint64_t gprs[] = {
+0x0001020304050607,
+0x1011121314151617,
+0x2021222324252627,
+0x3031323334353637,
+0x4041424344454647,
+0x5051525354555657,
+0x6061626364656667,
+0x7071727374757677,
+  };
+
+  constexpr vec_t vecs[] = {
+{ 0x0F0E0D0C0B0A0908, 0x1716151413121110, },
+{ 0x100F0E0D0C0B0A09, 0x1817161514131211, },
+{ 0x11100F0E0D0C0B0A, 0x1918171615141312, },
+{ 0x1211100F0E0D0C0B, 0x1A19181716151413, },
+{ 0x131211100F0E0D0C, 0x1B1A191817161514, },
+{ 0x14131211100F0E0D, 0x1C1B1A1918171615, },
+{ 0x1514131211100F0E, 0x1D1C1B1A19181716, },
+{ 0x161514131211100F, 0x1E1D1C1B1A191817, },
+  };
+
+  asm volatile(
+"ldp  x0,  x1,  [%0]\n\t"
+"ldp  x2,  x3,  [%0, #16]\n\t"
+"ldp  x4,  x5,  [%0, #32]\n\t"
+"ldp  x6,  x7,  [%0, 

[Lldb-commits] [PATCH] D68939: [LLDB] [PECOFF] Use a "pc" vendor name in aarch64 triples

2019-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG674d55438d25: [LLDB] [PECOFF] Use a pc vendor 
name in aarch64 triples (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68939

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/ObjectFile/PECOFF/basic-info-arm64.yaml


Index: lldb/test/Shell/ObjectFile/PECOFF/basic-info-arm64.yaml
===
--- lldb/test/Shell/ObjectFile/PECOFF/basic-info-arm64.yaml
+++ lldb/test/Shell/ObjectFile/PECOFF/basic-info-arm64.yaml
@@ -2,7 +2,7 @@
 # RUN: lldb-test object-file %t | FileCheck %s
 
 # CHECK: Plugin name: pe-coff
-# CHECK: Architecture: aarch64-unknown-windows-msvc
+# CHECK: Architecture: aarch64-pc-windows-msvc
 # CHECK: UUID: 
 # CHECK: Executable: true
 # CHECK: Stripped: false
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -200,7 +200,7 @@
 specs.Append(module_spec);
 break;
   case MachineArm64:
-spec.SetTriple("aarch64-unknown-windows");
+spec.SetTriple("aarch64-pc-windows");
 specs.Append(module_spec);
 break;
   default:


Index: lldb/test/Shell/ObjectFile/PECOFF/basic-info-arm64.yaml
===
--- lldb/test/Shell/ObjectFile/PECOFF/basic-info-arm64.yaml
+++ lldb/test/Shell/ObjectFile/PECOFF/basic-info-arm64.yaml
@@ -2,7 +2,7 @@
 # RUN: lldb-test object-file %t | FileCheck %s
 
 # CHECK: Plugin name: pe-coff
-# CHECK: Architecture: aarch64-unknown-windows-msvc
+# CHECK: Architecture: aarch64-pc-windows-msvc
 # CHECK: UUID: 
 # CHECK: Executable: true
 # CHECK: Stripped: false
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -200,7 +200,7 @@
 specs.Append(module_spec);
 break;
   case MachineArm64:
-spec.SetTriple("aarch64-unknown-windows");
+spec.SetTriple("aarch64-pc-windows");
 specs.Append(module_spec);
 break;
   default:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2019-10-16 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo requested review of this revision.
mstorsjo added a comment.

Does anyone want to ack this one after updating it to not need changes to tests 
(as far as I know), by using new demangler options?


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

https://reviews.llvm.org/D68134



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


[Lldb-commits] [PATCH] D68980: [LLDB] [test] Pass --target=-windows-msvc to clang-cl

2019-10-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, labath, amccarth, aleksandr.urakov.
Herald added subscribers: JDevlieghere, kristof.beyls.
Herald added a project: LLDB.

This fixes running check-lldb on arm linux.

Previously the helper python scipt only passed -m32/-m64, but some tests assume 
it to be compiling for an x86 architecture, and the -m32/-m64 flags only pick 
the right bitness of the compiler's default target architecture.

Further up in build.py, there's also another case (msvc_arch_str) which assumes 
that the arch setting only picks between i386 and x86_64.

Alternatively, the build.py helper script could get a --target option, to allow 
specifying exactly the intended target (but which only would be usable when 
using clang as the test compiler).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68980

Files:
  lldb/test/Shell/helper/build.py


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -553,7 +553,7 @@
 
 args.append(self.compiler)
 if self.toolchain_type == 'clang-cl':
-args.append('-m' + self.arch)
+args.append('--target=%s-windows-msvc' % ('i386' if self.arch == 
'32' else 'x86_64'))
 
 if self.opt == 'none':
 args.append('/Od')


Index: lldb/test/Shell/helper/build.py
===
--- lldb/test/Shell/helper/build.py
+++ lldb/test/Shell/helper/build.py
@@ -553,7 +553,7 @@
 
 args.append(self.compiler)
 if self.toolchain_type == 'clang-cl':
-args.append('-m' + self.arch)
+args.append('--target=%s-windows-msvc' % ('i386' if self.arch == '32' else 'x86_64'))
 
 if self.opt == 'none':
 args.append('/Od')
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69366: [LLDB] [PECOFF] Fix symbols to refer to the right section

2019-10-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 226216.
mstorsjo added a comment.

Updated the testcase to check for symbols in more than one section.


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

https://reviews.llvm.org/D69366

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml

Index: lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
@@ -0,0 +1,115 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test symbols %t | FileCheck %s
+
+# CHECK: Code 0x40001000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} entry
+# CHECK:  0x40002000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} variable
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:   1073741824
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ImportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:
+RelativeVirtualAddress: 0
+Size:0
+  CertificateTable:
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable:
+RelativeVirtualAddress: 0
+Size:0
+  Debug:
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable:
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport:
+RelativeVirtualAddress: 0
+Size:0
+  IAT:
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor:
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader:
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 1
+SectionData: C3
+  - Name:.data
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+VirtualAddress:  8192
+VirtualSize: 4
+SectionData: ''
+symbols:
+  - Name:.text
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:.data
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:.bss
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:entry
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+StorageClass:IMAGE_SYM_CLASS_EXTERNAL
+  - Name:variable
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_EXTERNAL
+...
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -685,7 +685,10 @@
 symbol.naux = symtab_data.GetU8();
 symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));
 if ((int16_t)symbol.sect >= 1) {
-  Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect - 1),
+  // symbol.sect is indexed starting from 1, but our section
+  // list contains one extra synthetic section at the start,
+  // so we should use section index "symbol.sect - 1 + 1".
+  Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect),
   

[Lldb-commits] [PATCH] D69366: [LLDB] [PECOFF] Fix symbols to refer to the right section

2019-10-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: labath, amccarth.
Herald added a subscriber: JDevlieghere.
Herald added a project: LLDB.

The virtual container/header section causes the section list to be offset by 
one. Previously, symbols in the first section were given addresses in the COFF 
header section.

This depends on D69100 ; before that, one has 
to access the subsections differently.

The testcase uses `lldb-test symbols`, but doesn't really use any SymbolFile 
functionality, but just tries to inspect what the ObjectFile plugin provides in 
the symbol table, hence the testcase is in Shell/ObjectFile/PECOFF.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D69366

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml

Index: lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
@@ -0,0 +1,91 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test symbols %t | FileCheck %s
+
+# CHECK: Code 0x40001000 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} main
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:   1073741824
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ImportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:
+RelativeVirtualAddress: 0
+Size:0
+  CertificateTable:
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable:
+RelativeVirtualAddress: 0
+Size:0
+  Debug:
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable:
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport:
+RelativeVirtualAddress: 0
+Size:0
+  IAT:
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor:
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader:
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 1
+SectionData: C3
+symbols:
+  - Name:.text
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:main
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+StorageClass:IMAGE_SYM_CLASS_EXTERNAL
+...
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -685,7 +685,10 @@
 symbol.naux = symtab_data.GetU8();
 symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));
 if ((int16_t)symbol.sect >= 1) {
-  Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect - 1),
+  // symbol.sect is indexed starting from 1, but our section
+  // list contains one extra synthetic section at the start,
+  // so we should use section index "symbol.sect - 1 + 1".
+  Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect),
   symbol.value);
   symbols[i].GetAddressRef() = symbol_addr;
   symbols[i].SetType(MapSymbolType(symbol.type));
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69366: [LLDB] [PECOFF] Use FindSectionByID to associate symbols to sections

2019-10-24 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo updated this revision to Diff 226321.
mstorsjo retitled this revision from "[LLDB] [PECOFF] Fix symbols to refer to 
the right section" to "[LLDB] [PECOFF] Use FindSectionByID to associate symbols 
to sections".
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Using `FindSectionByID`, added a table header for readability to the test.


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

https://reviews.llvm.org/D69366

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml

Index: lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
@@ -0,0 +1,116 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test symbols %t | FileCheck %s
+
+# CHECK: Type File Address/Value {{.*}} SizeFlags   Name
+# CHECK: Code 0x400010000x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} entry
+# CHECK:  0x400020000x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} variable
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:   1073741824
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ImportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:
+RelativeVirtualAddress: 0
+Size:0
+  CertificateTable:
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable:
+RelativeVirtualAddress: 0
+Size:0
+  Debug:
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable:
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport:
+RelativeVirtualAddress: 0
+Size:0
+  IAT:
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor:
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader:
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 1
+SectionData: C3
+  - Name:.data
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+VirtualAddress:  8192
+VirtualSize: 4
+SectionData: ''
+symbols:
+  - Name:.text
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:.data
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:.bss
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:entry
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+StorageClass:IMAGE_SYM_CLASS_EXTERNAL
+  - Name:variable
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_EXTERNAL
+...
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -685,7 +685,7 @@
 symbol.naux = symtab_data.GetU8();
 symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));
 if ((int16_t)symbol.sect >= 1) {
-  Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect - 1),
+  

[Lldb-commits] [PATCH] D69502: [LLDB] [PECOFF] Don't crash in ReadImageDataByRVA for addresses out of range

2019-10-29 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D69502#1725146 , @labath wrote:

> In D69502#1723715 , @mstorsjo wrote:
>
> > In D69502#1723549 , @labath wrote:
> >
> > > Any way to get a test for this? Maybe creating a object file with a bogus 
> > > unwind RVA via yaml2obj ?
> >
> >
> > Do we have a suitable test as basis for it? I'm not quite sure which way is 
> > the most compact way of achieving that. A small couple function exe with 
> > SEH or dwarf (eh_frame) unwind info, without debug info, with a crash/int3 
> > in a nested function? Or just some image unwind commands so it doesn't need 
> > executing?
>
>
> We have some files that might be usable as a basis for this, but I don't know 
> which one would be the best, as I don't know what you need here. What do you 
> need to do in order to reproduce the crash? Would it be possible to just set 
> the export table RVA to some bogus value? That should be trigerred by just 
> constructing the module symbol table...


Ok, I'll look at it later to see if I can make some broken file to trigger this 
condition.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D69502



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


[Lldb-commits] [PATCH] D69366: [LLDB] [PECOFF] Use FindSectionByID to associate symbols to sections

2019-10-29 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4394b5bee615: [LLDB] [PECOFF] Use FindSectionByID to 
associate symbols to sections (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69366

Files:
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml

Index: lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PECOFF/symbol.yaml
@@ -0,0 +1,116 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test symbols %t | FileCheck %s
+
+# CHECK: Type File Address/Value {{.*}} SizeFlags   Name
+# CHECK: Code 0x400010000x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} entry
+# CHECK:  0x400020000x{{[0-9a-f]+}} 0x{{[0-9a-f]+}} variable
+
+--- !COFF
+OptionalHeader:
+  AddressOfEntryPoint: 4096
+  ImageBase:   1073741824
+  SectionAlignment: 4096
+  FileAlignment:   512
+  MajorOperatingSystemVersion: 6
+  MinorOperatingSystemVersion: 0
+  MajorImageVersion: 0
+  MinorImageVersion: 0
+  MajorSubsystemVersion: 6
+  MinorSubsystemVersion: 0
+  Subsystem:   IMAGE_SUBSYSTEM_WINDOWS_CUI
+  DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
+  SizeOfStackReserve: 1048576
+  SizeOfStackCommit: 4096
+  SizeOfHeapReserve: 1048576
+  SizeOfHeapCommit: 4096
+  ExportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ImportTable:
+RelativeVirtualAddress: 0
+Size:0
+  ResourceTable:
+RelativeVirtualAddress: 0
+Size:0
+  ExceptionTable:
+RelativeVirtualAddress: 0
+Size:0
+  CertificateTable:
+RelativeVirtualAddress: 0
+Size:0
+  BaseRelocationTable:
+RelativeVirtualAddress: 0
+Size:0
+  Debug:
+RelativeVirtualAddress: 0
+Size:0
+  Architecture:
+RelativeVirtualAddress: 0
+Size:0
+  GlobalPtr:
+RelativeVirtualAddress: 0
+Size:0
+  TlsTable:
+RelativeVirtualAddress: 0
+Size:0
+  LoadConfigTable:
+RelativeVirtualAddress: 0
+Size:0
+  BoundImport:
+RelativeVirtualAddress: 0
+Size:0
+  IAT:
+RelativeVirtualAddress: 0
+Size:0
+  DelayImportDescriptor:
+RelativeVirtualAddress: 0
+Size:0
+  ClrRuntimeHeader:
+RelativeVirtualAddress: 0
+Size:0
+header:
+  Machine: IMAGE_FILE_MACHINE_AMD64
+  Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
+sections:
+  - Name:.text
+Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+VirtualAddress:  4096
+VirtualSize: 1
+SectionData: C3
+  - Name:.data
+Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+VirtualAddress:  8192
+VirtualSize: 4
+SectionData: ''
+symbols:
+  - Name:.text
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:.data
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:.bss
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_STATIC
+  - Name:entry
+Value:   0
+SectionNumber:   1
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+StorageClass:IMAGE_SYM_CLASS_EXTERNAL
+  - Name:variable
+Value:   0
+SectionNumber:   2
+SimpleType:  IMAGE_SYM_TYPE_NULL
+ComplexType: IMAGE_SYM_DTYPE_NULL
+StorageClass:IMAGE_SYM_CLASS_EXTERNAL
+...
Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -685,7 +685,7 @@
 symbol.naux = symtab_data.GetU8();
 symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));
 if ((int16_t)symbol.sect >= 1) {
-  Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect - 1),
+  Address symbol_addr(sect_list->FindSectionByID(symbol.sect),
   symbol.value);
   

[Lldb-commits] [PATCH] D69102: COFF: Set section permissions

2019-10-18 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added inline comments.



Comment at: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:800
 /*flags*/ 0);
+header_sp->SetPermissions(ePermissionsReadable);
 m_sections_up->AddSection(header_sp);

mstorsjo wrote:
> labath wrote:
> > labath wrote:
> > > Are these the right permissions for the header?
> > I've dug around in some minidumps I have around and this does appear to be 
> > correct. It looks like the entire block of memory for the object is first 
> > allocated with PAGE_EXECUTE_WRITE_COPY, and the permissions for the header 
> > region are later changed to PAGE_READ_ONLY.
> I haven't checked, but I certainly would expect it to be readonly.
I wrote the last comment before seeing the preceding update, which is why it 
seems odd here.


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

https://reviews.llvm.org/D69102



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


[Lldb-commits] [PATCH] D69031: [LLDB] [test] Use %clang_cl instead of build.py in a few tests

2019-10-17 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D69031#1713532 , @aprantl wrote:

> Probably this commit. Can you please revert or fix?


Sorry about this, reverted it for now.

I think the reason might be that %clang_cl ends up expanding to something 
(maybe `-isysroot`) that clang-cl doesn't parse properly but ends up parsing as 
an input filename, will try to reproduce it locally on macOS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69031



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


  1   2   3   4   5   >