[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: emaste, krytarowski, labath.
Herald added a subscriber: arichardson.
mgorny requested review of this revision.

Add a new FreeBSD Process plugin using client/server model.  This plugin
is based on the one used by NetBSD.  It currently supports a subset
of functionality for amd64.  It is automatically used when spawning
lldb-server.  It can also be used by lldb client by setting
FREEBSD_REMOTE_PLUGIN environment variable (to any value).

The code is capable of debugging simple single-threaded programs.  It
supports general purpose, debug and FPU registers (up to XMM) of amd64,
basic signalling, software breakpoints.

Adding the support for the plugin involves removing some dead code
from FreeBSDPlatform plugin (that was not ever used because
CanDebugProcess() returned false), and replacing it with appropriate
code from NetBSD platform support.


https://reviews.llvm.org/D88796

Files:
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Process/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/tools/lldb-server/CMakeLists.txt
  lldb/tools/lldb-server/lldb-gdbserver.cpp

Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -38,6 +38,8 @@
 
 #if defined(__linux__)
 #include "Plugins/Process/Linux/NativeProcessLinux.h"
+#elif defined(__FreeBSD__)
+#include "Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h"
 #elif defined(__NetBSD__)
 #include "Plugins/Process/NetBSD/NativeProcessNetBSD.h"
 #elif defined(_WIN32)
@@ -61,6 +63,8 @@
 namespace {
 #if defined(__linux__)
 typedef process_linux::NativeProcessLinux::Factory NativeProcessFactory;
+#elif defined(__FreeBSD__)
+typedef process_freebsd::NativeProcessFreeBSD::Factory NativeProcessFactory;
 #elif defined(__NetBSD__)
 typedef process_netbsd::NativeProcessNetBSD::Factory NativeProcessFactory;
 #elif defined(_WIN32)
Index: lldb/tools/lldb-server/CMakeLists.txt
===
--- lldb/tools/lldb-server/CMakeLists.txt
+++ lldb/tools/lldb-server/CMakeLists.txt
@@ -4,6 +4,12 @@
   list(APPEND LLDB_PLUGINS lldbPluginProcessLinux)
 endif()
 
+if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+  list(APPEND LLDB_PLUGINS
+lldbPluginProcessFreeBSDRemote
+lldbPluginProcessFreeBSD)
+endif()
+
 if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND LLDB_PLUGINS lldbPluginProcessNetBSD)
 endif()
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -133,3 +133,6 @@
 can_set_dbregs = False
 if can_set_dbregs:
 config.available_features.add('dbregs-set')
+
+# pass control variable through
+llvm_config.with_system_environment('FREEBSD_REMOTE_PLUGIN')
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -843,7 +843,7 @@
   response.PutCString(";QListThreadsInStopReply+");
   response.PutCString(";qEcho+");
   response.PutCString(";qXfer:features:read+");
-#if defined(__linux__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
   response.PutCString(";QPassSignals+");
   response.PutCString(";qXfer:auxv:read+");
   response.PutCString(";qXfer:libraries-svr4:read+");
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -0,0 +1,83 @@
+//===-- NativeThreadFreeBSD.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

[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:22
+
+//#include "Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"

Why this line?



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:487
+  int count, i;
+  vm = kinfo_getvmmap(GetID(), &count);
+  if (vm == NULL) {

Maybe here and in other places: `struct kinfo_vmentry *vm =  
kinfo_getvmmap(GetID(), &count);`


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

https://reviews.llvm.org/D88796

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


[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 296051.
mgorny added a comment.

Cleaned up unused includes + clang-format.


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

https://reviews.llvm.org/D88796

Files:
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Process/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/tools/lldb-server/CMakeLists.txt
  lldb/tools/lldb-server/lldb-gdbserver.cpp

Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -38,6 +38,8 @@
 
 #if defined(__linux__)
 #include "Plugins/Process/Linux/NativeProcessLinux.h"
+#elif defined(__FreeBSD__)
+#include "Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h"
 #elif defined(__NetBSD__)
 #include "Plugins/Process/NetBSD/NativeProcessNetBSD.h"
 #elif defined(_WIN32)
@@ -61,6 +63,8 @@
 namespace {
 #if defined(__linux__)
 typedef process_linux::NativeProcessLinux::Factory NativeProcessFactory;
+#elif defined(__FreeBSD__)
+typedef process_freebsd::NativeProcessFreeBSD::Factory NativeProcessFactory;
 #elif defined(__NetBSD__)
 typedef process_netbsd::NativeProcessNetBSD::Factory NativeProcessFactory;
 #elif defined(_WIN32)
Index: lldb/tools/lldb-server/CMakeLists.txt
===
--- lldb/tools/lldb-server/CMakeLists.txt
+++ lldb/tools/lldb-server/CMakeLists.txt
@@ -4,6 +4,12 @@
   list(APPEND LLDB_PLUGINS lldbPluginProcessLinux)
 endif()
 
+if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+  list(APPEND LLDB_PLUGINS
+lldbPluginProcessFreeBSDRemote
+lldbPluginProcessFreeBSD)
+endif()
+
 if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND LLDB_PLUGINS lldbPluginProcessNetBSD)
 endif()
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -133,3 +133,6 @@
 can_set_dbregs = False
 if can_set_dbregs:
 config.available_features.add('dbregs-set')
+
+# pass control variable through
+llvm_config.with_system_environment('FREEBSD_REMOTE_PLUGIN')
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -843,7 +843,7 @@
   response.PutCString(";QListThreadsInStopReply+");
   response.PutCString(";qEcho+");
   response.PutCString(";qXfer:features:read+");
-#if defined(__linux__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
   response.PutCString(";QPassSignals+");
   response.PutCString(";qXfer:auxv:read+");
   response.PutCString(";qXfer:libraries-svr4:read+");
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -0,0 +1,83 @@
+//===-- NativeThreadFreeBSD.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_NativeThreadFreeBSD_H_
+#define liblldb_NativeThreadFreeBSD_H_
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+#include "Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_private {
+namespace process_freebsd {
+
+class NativeProcessFreeBSD;
+
+class NativeThreadFreeBSD : public NativeThreadProtocol {
+  friend class NativeProcessFreeBSD;
+
+public:
+  NativeThreadFreeBSD(NativeProcessFreeBSD &process, lldb::tid_t tid);
+
+  // NativeThreadProtocol Interface
+  std::string GetName() override;
+

[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:22
+
+//#include "Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"

krytarowski wrote:
> Why this line?
Because otherwise it fails to compile? ;-)



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:487
+  int count, i;
+  vm = kinfo_getvmmap(GetID(), &count);
+  if (vm == NULL) {

krytarowski wrote:
> Maybe here and in other places: `struct kinfo_vmentry *vm =  
> kinfo_getvmmap(GetID(), &count);`
You've mentioned previously that you'd prefer for us not to use `-lutil`. 
Should I inline the sysctls instead?


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

https://reviews.llvm.org/D88796

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


[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:22
+
+//#include "Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"

mgorny wrote:
> krytarowski wrote:
> > Why this line?
> Because otherwise it fails to compile? ;-)
OK, you have removed the unused include.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:487
+  int count, i;
+  vm = kinfo_getvmmap(GetID(), &count);
+  if (vm == NULL) {

mgorny wrote:
> krytarowski wrote:
> > Maybe here and in other places: `struct kinfo_vmentry *vm =  
> > kinfo_getvmmap(GetID(), &count);`
> You've mentioned previously that you'd prefer for us not to use `-lutil`. 
> Should I inline the sysctls instead?
Yes, please.


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

https://reviews.llvm.org/D88796

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


[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Alexander Richardson via Phabricator via lldb-commits
arichardson added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:492
+  }
+  for (i = 0; i < count; i++) {
+MemoryRegionInfo info;

This code is C++ so using for-loop initializers is fine.


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

https://reviews.llvm.org/D88796

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


[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 296059.
mgorny added a comment.

Inlined memory map getting via sysctl.


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

https://reviews.llvm.org/D88796

Files:
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Process/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/test/Shell/lit.cfg.py
  lldb/tools/lldb-server/CMakeLists.txt
  lldb/tools/lldb-server/lldb-gdbserver.cpp

Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -38,6 +38,8 @@
 
 #if defined(__linux__)
 #include "Plugins/Process/Linux/NativeProcessLinux.h"
+#elif defined(__FreeBSD__)
+#include "Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h"
 #elif defined(__NetBSD__)
 #include "Plugins/Process/NetBSD/NativeProcessNetBSD.h"
 #elif defined(_WIN32)
@@ -61,6 +63,8 @@
 namespace {
 #if defined(__linux__)
 typedef process_linux::NativeProcessLinux::Factory NativeProcessFactory;
+#elif defined(__FreeBSD__)
+typedef process_freebsd::NativeProcessFreeBSD::Factory NativeProcessFactory;
 #elif defined(__NetBSD__)
 typedef process_netbsd::NativeProcessNetBSD::Factory NativeProcessFactory;
 #elif defined(_WIN32)
Index: lldb/tools/lldb-server/CMakeLists.txt
===
--- lldb/tools/lldb-server/CMakeLists.txt
+++ lldb/tools/lldb-server/CMakeLists.txt
@@ -4,6 +4,12 @@
   list(APPEND LLDB_PLUGINS lldbPluginProcessLinux)
 endif()
 
+if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+  list(APPEND LLDB_PLUGINS
+lldbPluginProcessFreeBSDRemote
+lldbPluginProcessFreeBSD)
+endif()
+
 if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND LLDB_PLUGINS lldbPluginProcessNetBSD)
 endif()
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -133,3 +133,6 @@
 can_set_dbregs = False
 if can_set_dbregs:
 config.available_features.add('dbregs-set')
+
+# pass control variable through
+llvm_config.with_system_environment('FREEBSD_REMOTE_PLUGIN')
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -843,7 +843,7 @@
   response.PutCString(";QListThreadsInStopReply+");
   response.PutCString(";qEcho+");
   response.PutCString(";qXfer:features:read+");
-#if defined(__linux__) || defined(__NetBSD__)
+#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
   response.PutCString(";QPassSignals+");
   response.PutCString(";qXfer:auxv:read+");
   response.PutCString(";qXfer:libraries-svr4:read+");
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.h
@@ -0,0 +1,83 @@
+//===-- NativeThreadFreeBSD.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_NativeThreadFreeBSD_H_
+#define liblldb_NativeThreadFreeBSD_H_
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+#include "Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h"
+
+#include 
+#include 
+#include 
+
+namespace lldb_private {
+namespace process_freebsd {
+
+class NativeProcessFreeBSD;
+
+class NativeThreadFreeBSD : public NativeThreadProtocol {
+  friend class NativeProcessFreeBSD;
+
+public:
+  NativeThreadFreeBSD(NativeProcessFreeBSD &process, lldb::tid_t tid);
+
+  // NativeThreadProtocol Interface
+  std::string GetName() override;
+
+  l

[Lldb-commits] [PATCH] D88796: [lldb] Initial version of FreeBSD remote process plugin

2020-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked 5 inline comments as done.
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:492
+  }
+  for (i = 0; i < count; i++) {
+MemoryRegionInfo info;

arichardson wrote:
> This code is C++ so using for-loop initializers is fine.
I'm sorry but the underlying code is gone already ;-).


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

https://reviews.llvm.org/D88796

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


[Lldb-commits] [lldb] 8036cf7 - llvm-dwarfdump: Skip tombstoned address ranges

2020-10-04 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2020-10-04T13:43:29-07:00
New Revision: 8036cf7f5402ea7fc8564a9a2beae512c324bf3d

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

LOG: llvm-dwarfdump: Skip tombstoned address ranges

Make the dumper & API a bit more informative by using the new tombstone
addresses to filter out or otherwise render more explicitly dead code
ranges.

Added: 
llvm/test/tools/llvm-dwarfdump/X86/tombstone.s

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
llvm/include/llvm/BinaryFormat/Dwarf.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index dfa40759a7ff..b70beb501946 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -946,7 +946,7 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
   llvm::Expected llvm_ranges =
   range_list_or_error->getAbsoluteRanges(
   llvm::object::SectionedAddress{GetBaseAddress()},
-  [&](uint32_t index) {
+  GetAddressByteSize(), [&](uint32_t index) {
 uint32_t index_size = GetAddressByteSize();
 dw_offset_t addr_base = GetAddrBase();
 lldb::offset_t offset = addr_base + index * index_size;

diff  --git a/llvm/include/llvm/BinaryFormat/Dwarf.h 
b/llvm/include/llvm/BinaryFormat/Dwarf.h
index 6558a74b6411..75b8b2647b95 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -27,6 +27,8 @@
 #include "llvm/Support/FormatVariadicDetails.h"
 #include "llvm/ADT/Triple.h"
 
+#include 
+
 namespace llvm {
 class StringRef;
 
@@ -745,6 +747,11 @@ template <> struct EnumTraits : public 
std::true_type {
   static constexpr char Type[3] = "OP";
   static constexpr StringRef (*StringFn)(unsigned) = &OperationEncodingString;
 };
+
+inline uint64_t computeTombstoneAddress(uint8_t AddressByteSize) {
+  return std::numeric_limits::max() >> (8 - AddressByteSize) * 8;
+}
+
 } // End of namespace dwarf
 
 /// Dwarf constants format_provider

diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h 
b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
index 78a018ff482b..4d28bdcde2e4 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
@@ -48,6 +48,7 @@ class DWARFDebugRnglist : public 
DWARFListType {
   /// Build a DWARFAddressRangesVector from a rangelist.
   DWARFAddressRangesVector
   getAbsoluteRanges(Optional BaseAddr,
+uint8_t AddressByteSize,
 function_ref(uint32_t)>
 LookupPooledAddress) const;
 

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 427d25f5011a..ab3022955cdb 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -783,6 +783,18 @@ Error DWARFDebugLine::LineTable::parse(
 *OS << '\n';
 Row::dumpTableHeader(*OS, /*Indent=*/Verbose ? 12 : 0);
   }
+  bool TombstonedAddress = false;
+  auto EmitRow = [&] {
+if (!TombstonedAddress) {
+  if (Verbose) {
+*OS << "\n";
+OS->indent(12);
+  }
+  if (OS)
+State.Row.dump(*OS);
+  State.appendRowToMatrix();
+}
+  };
   while (*OffsetPtr < EndOffset) {
 DataExtractor::Cursor Cursor(*OffsetPtr);
 
@@ -834,13 +846,7 @@ Error DWARFDebugLine::LineTable::parse(
 // No need to test the Cursor is valid here, since it must be to get
 // into this code path - if it were invalid, the default case would be
 // followed.
-if (Verbose) {
-  *OS << "\n";
-  OS->indent(12);
-}
-if (OS)
-  State.Row.dump(*OS);
-State.appendRowToMatrix();
+EmitRow();
 State.resetRowAndSequence();
 break;
 
@@ -882,6 +888,10 @@ Error DWARFDebugLine::LineTable::parse(
 State.Row.Address.Address = TableData.getRelocatedAddress(
 Cursor, &State.Row.Address.SectionIndex);
 
+uint64_t Tombstone =
+dwarf::computeTombstoneAddress(OpcodeAddressSize);
+TombstonedAddress = State.Row.Address.Address == Tombstone;
+
 // Restore the address size if the extractor already had it.
 if (ExtractorAddressSize != 0)
   TableData.setAddressSize(ExtractorAddressSize);
@@ -981,13 +991,7 @@ Err

[Lldb-commits] [lldb] e8beb69 - [lldb] [test/Register] Attempt to fix x86-fp-read.test on Darwin

2020-10-04 Thread Jonas Devlieghere via lldb-commits

Author: Michał Górny
Date: 2020-10-04T23:04:40-07:00
New Revision: e8beb6988bab71ee4917288f07674b4982736109

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

LOG: [lldb] [test/Register] Attempt to fix x86-fp-read.test on Darwin

Darwin seems to use stmmN instead of stN. Use a regex to accept both.

Also try to actually clear st(7).

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

Added: 


Modified: 
lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
lldb/test/Shell/Register/x86-fp-read.test

Removed: 




diff  --git a/lldb/test/Shell/Register/Inputs/x86-fp-read.cpp 
b/lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
index 1bd2d60affa2..63971e20b62f 100644
--- a/lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
+++ b/lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
@@ -14,7 +14,8 @@ int main() {
 {0x8000, 0x7fff},  // +inf
 {0x8000, 0x},  // -inf
 {0xc000, 0x},  // nan
-// leave st7 empty to test tag word better
+// st7 will be freed to test tag word better
+{0x, 0x},  // +0
   };
 
   // unmask divide-by-zero exception
@@ -26,6 +27,7 @@ int main() {
 "finit\n\t"
 "fldcw %1\n\t"
 // load on stack in reverse order to make the result easier to read
+"fldt 0x70(%0)\n\t"
 "fldt 0x60(%0)\n\t"
 "fldt 0x50(%0)\n\t"
 "fldt 0x40(%0)\n\t"
@@ -33,6 +35,8 @@ int main() {
 "fldt 0x20(%0)\n\t"
 "fldt 0x10(%0)\n\t"
 "fldt 0x00(%0)\n\t"
+// free st7
+"ffree %%st(7)\n\t"
 // this should trigger a divide-by-zero
 "fdivs (%2)\n\t"
 "int3\n\t"

diff  --git a/lldb/test/Shell/Register/x86-fp-read.test 
b/lldb/test/Shell/Register/x86-fp-read.test
index eac942f5989c..f0c35c726c7c 100644
--- a/lldb/test/Shell/Register/x86-fp-read.test
+++ b/lldb/test/Shell/Register/x86-fp-read.test
@@ -1,5 +1,4 @@
 # XFAIL: system-windows
-# XFAIL: system-darwin
 # REQUIRES: native && (target-x86 || target-x86_64)
 # RUN: %clangxx_host -g %p/Inputs/x86-fp-read.cpp -o %t
 # RUN: %lldb -b -s %s %t | FileCheck %s
@@ -8,20 +7,20 @@ process launch
 
 register read --all
 # CHECK-DAG: fctrl = 0x037b
-# CHECK-DAG: fstat = 0x8884
+# CHECK-DAG: fstat = 0x8084
 # TODO: the following value is incorrect, it's a bug in the way
-# FXSAVE/XSAVE is interpreted; it should be 0xa963 once fixed
-# CHECK-DAG: ftag = 0x00fe
+# FXSAVE/XSAVE is interpreted
+# CHECK-DAG: ftag = 0x007f
 # CHECK-DAG: fop = 0x0033
 
-# CHECK-DAG: st0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40}
-# CHECK-DAG: st1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x3f 0x00 0x00}
-# CHECK-DAG: st2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
-# CHECK-DAG: st3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80}
-# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x7f}
-# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0xff}
-# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0xff 0xff}
-# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
+# CHECK-DAG: st{{(mm)?}}0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40}
+# CHECK-DAG: st{{(mm)?}}1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x3f 0x00 0x00}
+# CHECK-DAG: st{{(mm)?}}2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
+# CHECK-DAG: st{{(mm)?}}3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80}
+# CHECK-DAG: st{{(mm)?}}4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x7f}
+# CHECK-DAG: st{{(mm)?}}5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0xff}
+# CHECK-DAG: st{{(mm)?}}6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0xff 0xff}
+# CHECK-DAG: st{{(mm)?}}7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
 
 # fdiv (%rbx) gets encoded into 2 bytes, int3 into 1 byte
 print (void*)($pc-3)



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


[Lldb-commits] [PATCH] D88795: [lldb] [test/Register] Attempt to fix x86-fp-read.test on Darwin

2020-10-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8beb6988bab: [lldb] [test/Register] Attempt to fix 
x86-fp-read.test on Darwin (authored by mgorny, committed by JDevlieghere).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88795

Files:
  lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
  lldb/test/Shell/Register/x86-fp-read.test


Index: lldb/test/Shell/Register/x86-fp-read.test
===
--- lldb/test/Shell/Register/x86-fp-read.test
+++ lldb/test/Shell/Register/x86-fp-read.test
@@ -1,5 +1,4 @@
 # XFAIL: system-windows
-# XFAIL: system-darwin
 # REQUIRES: native && (target-x86 || target-x86_64)
 # RUN: %clangxx_host -g %p/Inputs/x86-fp-read.cpp -o %t
 # RUN: %lldb -b -s %s %t | FileCheck %s
@@ -8,20 +7,20 @@
 
 register read --all
 # CHECK-DAG: fctrl = 0x037b
-# CHECK-DAG: fstat = 0x8884
+# CHECK-DAG: fstat = 0x8084
 # TODO: the following value is incorrect, it's a bug in the way
-# FXSAVE/XSAVE is interpreted; it should be 0xa963 once fixed
-# CHECK-DAG: ftag = 0x00fe
+# FXSAVE/XSAVE is interpreted
+# CHECK-DAG: ftag = 0x007f
 # CHECK-DAG: fop = 0x0033
 
-# CHECK-DAG: st0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40}
-# CHECK-DAG: st1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x3f 0x00 0x00}
-# CHECK-DAG: st2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
-# CHECK-DAG: st3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80}
-# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x7f}
-# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0xff}
-# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0xff 0xff}
-# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
+# CHECK-DAG: st{{(mm)?}}0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40}
+# CHECK-DAG: st{{(mm)?}}1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x3f 0x00 0x00}
+# CHECK-DAG: st{{(mm)?}}2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
+# CHECK-DAG: st{{(mm)?}}3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80}
+# CHECK-DAG: st{{(mm)?}}4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x7f}
+# CHECK-DAG: st{{(mm)?}}5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0xff}
+# CHECK-DAG: st{{(mm)?}}6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0xff 0xff}
+# CHECK-DAG: st{{(mm)?}}7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
 
 # fdiv (%rbx) gets encoded into 2 bytes, int3 into 1 byte
 print (void*)($pc-3)
Index: lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
+++ lldb/test/Shell/Register/Inputs/x86-fp-read.cpp
@@ -14,7 +14,8 @@
 {0x8000, 0x7fff},  // +inf
 {0x8000, 0x},  // -inf
 {0xc000, 0x},  // nan
-// leave st7 empty to test tag word better
+// st7 will be freed to test tag word better
+{0x, 0x},  // +0
   };
 
   // unmask divide-by-zero exception
@@ -26,6 +27,7 @@
 "finit\n\t"
 "fldcw %1\n\t"
 // load on stack in reverse order to make the result easier to read
+"fldt 0x70(%0)\n\t"
 "fldt 0x60(%0)\n\t"
 "fldt 0x50(%0)\n\t"
 "fldt 0x40(%0)\n\t"
@@ -33,6 +35,8 @@
 "fldt 0x20(%0)\n\t"
 "fldt 0x10(%0)\n\t"
 "fldt 0x00(%0)\n\t"
+// free st7
+"ffree %%st(7)\n\t"
 // this should trigger a divide-by-zero
 "fdivs (%2)\n\t"
 "int3\n\t"


Index: lldb/test/Shell/Register/x86-fp-read.test
===
--- lldb/test/Shell/Register/x86-fp-read.test
+++ lldb/test/Shell/Register/x86-fp-read.test
@@ -1,5 +1,4 @@
 # XFAIL: system-windows
-# XFAIL: system-darwin
 # REQUIRES: native && (target-x86 || target-x86_64)
 # RUN: %clangxx_host -g %p/Inputs/x86-fp-read.cpp -o %t
 # RUN: %lldb -b -s %s %t | FileCheck %s
@@ -8,20 +7,20 @@
 
 register read --all
 # CHECK-DAG: fctrl = 0x037b
-# CHECK-DAG: fstat = 0x8884
+# CHECK-DAG: fstat = 0x8084
 # TODO: the following value is incorrect, it's a bug in the way
-# FXSAVE/XSAVE is interpreted; it should be 0xa963 once fixed
-# CHECK-DAG: ftag = 0x00fe
+# FXSAVE/XSAVE is interpreted
+# CHECK-DAG: ftag = 0x007f
 # CHECK-DAG: fop = 0x0033
 
-# CHECK-DAG: st0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40}
-# CHECK-DAG: st1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x3f 0x00 0x00}
-# CHECK-DAG: st2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
-# CHECK-DAG: st3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80}
-# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x7f}
-# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0xff}
-# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0xff 0xff}
-# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x0

[Lldb-commits] [PATCH] D88795: [lldb] [test/Register] Attempt to fix x86-fp-read.test on Darwin

2020-10-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D88795#2311096 , @mgorny wrote:

> Thanks. I won't be at a computer for the next 8 hours, so feel free to push 
> it for me.

Done. Thanks a lot for following up on this so quickly!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88795

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


[Lldb-commits] [PATCH] D88795: [lldb] [test/Register] Attempt to fix x86-fp-read.test on Darwin

2020-10-04 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

No problem. If you could send me logs for other tests xfailing on Darwin 
(particularly mm-related), I'd also be happy to take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88795

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