[Lldb-commits] [PATCH] D130939: [LLDB][NFC] Fix potential div by 0 "count" can be zero potentially causing div by 0

2022-08-04 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Thanks for these fixes! I'll fix up the 0 packets sent behaviour when I find 
some spare time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130939

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


[Lldb-commits] [PATCH] D130939: [LLDB][NFC] Fix potential div by 0 "count" can be zero potentially causing div by 0

2022-08-04 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon added a comment.

In D130939#3698800 , @DavidSpickett 
wrote:

> Thanks for these fixes! I'll fix up the 0 packets sent behaviour when I find 
> some spare time.

Sounds great. Thanks for the review and suggestions!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130939

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


[Lldb-commits] [PATCH] D130985: [lldb] Fix TestDeletedExecutable on linux

2022-08-04 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

This broke LLDB AArch64 buildbot: 
https://lab.llvm.org/buildbot/#/builders/96/builds/27004


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130985

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


[Lldb-commits] [PATCH] D130985: [lldb] Fix TestDeletedExecutable on linux

2022-08-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D130985#3699095 , @omjavaid wrote:

> This broke LLDB AArch64 buildbot: 
> https://lab.llvm.org/buildbot/#/builders/96/builds/27004

I see it. Looking now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130985

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


[Lldb-commits] [lldb] b8985ba - [lldb] Fix arm breakages from D130985

2022-08-04 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2022-08-04T13:55:35+02:00
New Revision: b8985ba0adb5fd881bb301fbc79370b86396e658

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

LOG: [lldb] Fix arm breakages from D130985

The kernel was rejecting sizeof(struct GPR) as it was not a multiple of
8. Add a padding field to fix that.

One also wonders whether "cpsr" is right register name for aarch64.

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h 
b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
index 3e992acb1f002..7f7c3ee90c6b8 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -47,6 +47,7 @@ class RegisterInfoPOSIX_arm64
 uint64_t sp;// x31
 uint64_t pc;// pc
 uint32_t cpsr;  // cpsr
+uint32_t pad;
   };
   LLVM_PACKED_END
 



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


[Lldb-commits] [PATCH] D131159: [WIP][lldb] Use WSAEventSelect for MainLoop polling

2022-08-04 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added a reviewer: mgorny.
Herald added a project: All.
labath requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131159

Files:
  lldb/source/Host/common/MainLoop.cpp


Index: lldb/source/Host/common/MainLoop.cpp
===
--- lldb/source/Host/common/MainLoop.cpp
+++ lldb/source/Host/common/MainLoop.cpp
@@ -69,6 +69,67 @@
 }
 #endif
 
+#ifdef _WIN32
+class MainLoop::RunImpl {
+public:
+  RunImpl(MainLoop &loop);
+  ~RunImpl();
+
+  Status Poll();
+
+  void ProcessEvents();
+
+private:
+  MainLoop &loop;
+  llvm::Optional signaled_event;
+};
+
+MainLoop::RunImpl::RunImpl(MainLoop &loop) : loop(loop) {
+}
+
+MainLoop::RunImpl::~RunImpl() {
+}
+
+Status MainLoop::RunImpl::Poll() {
+  std::vector read_events;
+  read_events.reserve(loop.m_read_fds.size());
+  for(auto &fd : loop.m_read_fds) {
+WSAEVENT event = WSACreateEvent();
+assert(event != WSA_INVALID_EVENT);
+
+int result = WSAEventSelect(fd.first, event, FD_READ | FD_ACCEPT | 
FD_CLOSE);
+assert(result == 0);
+
+read_events.push_back(event);
+  }
+
+  DWORD result = WSAWaitForMultipleEvents(read_events.size(),
+  read_events.data(), FALSE, WSA_INFINITE, FALSE);
+
+  for(auto &fd : loop.m_read_fds) {
+int result = WSAEventSelect(fd.first, WSA_INVALID_EVENT, 0);
+assert(result == 0);
+  }
+
+  for (auto &event: read_events) {
+BOOL result = WSACloseEvent(event);
+assert(result == TRUE);
+  }
+
+  if (result >= WSA_WAIT_EVENT_0 && result < WSA_WAIT_EVENT_0 + 
read_events.size()) {
+signaled_event = result - WSA_WAIT_EVENT_0;
+return Status();
+  }
+  return Status("WSAWaitForMultipleEvents failed");
+}
+
+void MainLoop::RunImpl::ProcessEvents() {
+  assert(signaled_event);
+  auto &fd_info = *std::next(loop.m_read_fds.begin(), *signaled_event);
+
+  loop.ProcessReadObject(fd_info.first);
+}
+#else
 class MainLoop::RunImpl {
 public:
   RunImpl(MainLoop &loop);
@@ -254,6 +315,7 @@
   }
 }
 #endif
+#endif
 
 MainLoop::MainLoop() : m_terminate_request(false) {
 #if HAVE_SYS_EVENT_H


Index: lldb/source/Host/common/MainLoop.cpp
===
--- lldb/source/Host/common/MainLoop.cpp
+++ lldb/source/Host/common/MainLoop.cpp
@@ -69,6 +69,67 @@
 }
 #endif
 
+#ifdef _WIN32
+class MainLoop::RunImpl {
+public:
+  RunImpl(MainLoop &loop);
+  ~RunImpl();
+
+  Status Poll();
+
+  void ProcessEvents();
+
+private:
+  MainLoop &loop;
+  llvm::Optional signaled_event;
+};
+
+MainLoop::RunImpl::RunImpl(MainLoop &loop) : loop(loop) {
+}
+
+MainLoop::RunImpl::~RunImpl() {
+}
+
+Status MainLoop::RunImpl::Poll() {
+  std::vector read_events;
+  read_events.reserve(loop.m_read_fds.size());
+  for(auto &fd : loop.m_read_fds) {
+WSAEVENT event = WSACreateEvent();
+assert(event != WSA_INVALID_EVENT);
+
+int result = WSAEventSelect(fd.first, event, FD_READ | FD_ACCEPT | FD_CLOSE);
+assert(result == 0);
+
+read_events.push_back(event);
+  }
+
+  DWORD result = WSAWaitForMultipleEvents(read_events.size(),
+  read_events.data(), FALSE, WSA_INFINITE, FALSE);
+
+  for(auto &fd : loop.m_read_fds) {
+int result = WSAEventSelect(fd.first, WSA_INVALID_EVENT, 0);
+assert(result == 0);
+  }
+
+  for (auto &event: read_events) {
+BOOL result = WSACloseEvent(event);
+assert(result == TRUE);
+  }
+
+  if (result >= WSA_WAIT_EVENT_0 && result < WSA_WAIT_EVENT_0 + read_events.size()) {
+signaled_event = result - WSA_WAIT_EVENT_0;
+return Status();
+  }
+  return Status("WSAWaitForMultipleEvents failed");
+}
+
+void MainLoop::RunImpl::ProcessEvents() {
+  assert(signaled_event);
+  auto &fd_info = *std::next(loop.m_read_fds.begin(), *signaled_event);
+
+  loop.ProcessReadObject(fd_info.first);
+}
+#else
 class MainLoop::RunImpl {
 public:
   RunImpl(MainLoop &loop);
@@ -254,6 +315,7 @@
   }
 }
 #endif
+#endif
 
 MainLoop::MainLoop() : m_terminate_request(false) {
 #if HAVE_SYS_EVENT_H
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131160: [WIP][lldb] Add "event" capability to the MainLoop class

2022-08-04 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added a reviewer: mgorny.
Herald added a project: All.
labath requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131160

Files:
  lldb/include/lldb/Host/MainLoop.h
  lldb/source/Host/common/MainLoop.cpp
  lldb/unittests/Host/MainLoopTest.cpp

Index: lldb/unittests/Host/MainLoopTest.cpp
===
--- lldb/unittests/Host/MainLoopTest.cpp
+++ lldb/unittests/Host/MainLoopTest.cpp
@@ -148,6 +148,18 @@
   ASSERT_EQ(3u, callback_count);
 }
 
+TEST_F(MainLoopTest, Event) {
+  MainLoop loop;
+  bool event_called = false;
+  auto handle = loop.RegisterEvent([&](MainLoopBase &loop) {
+event_called = true;
+loop.RequestTermination();
+  });
+  handle->Notify();
+  ASSERT_THAT_ERROR(loop.Run().ToError(), llvm::Succeeded());
+  ASSERT_TRUE(event_called);
+}
+
 #ifdef LLVM_ON_UNIX
 TEST_F(MainLoopTest, DetectsEOF) {
 
Index: lldb/source/Host/common/MainLoop.cpp
===
--- lldb/source/Host/common/MainLoop.cpp
+++ lldb/source/Host/common/MainLoop.cpp
@@ -91,8 +91,8 @@
 }
 
 Status MainLoop::RunImpl::Poll() {
-  std::vector read_events;
-  read_events.reserve(loop.m_read_fds.size());
+  std::vector events;
+  events.reserve(loop.m_read_fds.size() + 1);
   for(auto &fd : loop.m_read_fds) {
 WSAEVENT event = WSACreateEvent();
 assert(event != WSA_INVALID_EVENT);
@@ -100,23 +100,25 @@
 int result = WSAEventSelect(fd.first, event, FD_READ | FD_ACCEPT | FD_CLOSE);
 assert(result == 0);
 
-read_events.push_back(event);
+events.push_back(event);
   }
+  events.push_back(loop.m_event_event);
 
-  DWORD result = WSAWaitForMultipleEvents(read_events.size(),
-  read_events.data(), FALSE, WSA_INFINITE, FALSE);
+  DWORD result = WSAWaitForMultipleEvents(events.size(),
+  events.data(), FALSE, WSA_INFINITE, FALSE);
 
   for(auto &fd : loop.m_read_fds) {
 int result = WSAEventSelect(fd.first, WSA_INVALID_EVENT, 0);
 assert(result == 0);
   }
 
-  for (auto &event: read_events) {
+  events.pop_back();
+  for (auto &event: events) {
 BOOL result = WSACloseEvent(event);
 assert(result == TRUE);
   }
 
-  if (result >= WSA_WAIT_EVENT_0 && result < WSA_WAIT_EVENT_0 + read_events.size()) {
+  if (result >= WSA_WAIT_EVENT_0 && result <= WSA_WAIT_EVENT_0 + events.size()) {
 signaled_event = result - WSA_WAIT_EVENT_0;
 return Status();
   }
@@ -125,9 +127,14 @@
 
 void MainLoop::RunImpl::ProcessEvents() {
   assert(signaled_event);
-  auto &fd_info = *std::next(loop.m_read_fds.begin(), *signaled_event);
-
-  loop.ProcessReadObject(fd_info.first);
+  if (*signaled_event < loop.m_read_fds.size()) {
+auto &fd_info = *std::next(loop.m_read_fds.begin(), *signaled_event);
+loop.ProcessReadObject(fd_info.first);
+  } else {
+// Must be called before events are processed.
+WSAResetEvent(loop.m_event_event);
+loop.ProcessEvents();
+  }
 }
 #else
 class MainLoop::RunImpl {
@@ -317,11 +324,27 @@
 #endif
 #endif
 
+void MainLoop::NotifyEvent(std::list::iterator info_it) {
+  // This must be set before we notify the event.
+  info_it->notified.store(true, std::memory_order_release);
+#ifdef _WIN32
+  WSASetEvent(m_event_event);
+#else
+  ...
+#endif
+}
+
 MainLoop::MainLoop() : m_terminate_request(false) {
 #if HAVE_SYS_EVENT_H
   m_kqueue = kqueue();
   assert(m_kqueue >= 0);
 #endif
+#ifdef _WIN32
+  m_event_event = WSACreateEvent();
+  assert(m_event_event != WSA_INVALID_EVENT);
+#else
+  ...
+#endif
 }
 MainLoop::~MainLoop() {
 #if HAVE_SYS_EVENT_H
@@ -409,6 +432,10 @@
 #endif
 }
 
+MainLoop::EventHandleUP MainLoop::RegisterEvent(const Callback &callback) {
+  return EventHandleUP(new EventHandle(*this, m_events.emplace(m_events.end(), callback)));
+}
+
 void MainLoop::AddPendingCallback(const Callback &callback) {
   m_pending_callbacks.push_back(callback);
 }
@@ -419,6 +446,10 @@
   assert(erased);
 }
 
+void MainLoop::UnregisterEvent(std::list::iterator info_it) {
+  m_events.erase(info_it);
+}
+
 void MainLoop::UnregisterSignal(int signo,
 std::list::iterator callback_it) {
 #if SIGNAL_POLLING_UNSUPPORTED
@@ -460,7 +491,7 @@
   RunImpl impl(*this);
 
   // run until termination or until we run out of things to listen to
-  while (!m_terminate_request && (!m_read_fds.empty() || !m_signals.empty())) {
+  while (!m_terminate_request && (!m_read_fds.empty() || !m_signals.empty() || !m_events.empty())) {
 
 error = impl.Poll();
 if (error.Fail())
@@ -492,3 +523,14 @@
   if (it != m_read_fds.end())
 it->second(*this); // Do the work
 }
+
+void MainLoop::ProcessEvents() {
+  // Create a copy as some events may become unregistered by the callbacks.
+  llvm::SmallVector callbacks_to_run;
+  for (auto &info : m_events) {
+if (info.notified.exchange(false, std::

[Lldb-commits] [PATCH] D131075: [lldb] [gdb-remote] Send interrupt packets from async thread

2022-08-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Ok, I was able to concoct D131159  and 
D131160  this morning. They need some more 
cleanup, but I tried them on windows, and it worked. The general idea is to add 
a platform-neutral way to wait on "events" and FDs (unfortunately, this is 
still limited to sockets on windows) at the same time. This could then be used 
instead of the pipe+select interruption implementation in the Connection class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131075

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


[Lldb-commits] [PATCH] D131081: [lldb] Prevent race condition when fetching /proc/cpuinfo

2022-08-04 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It's not clear to me why you're insisting on `call_once`, when c++ guarantees 
that the function-local statics will only be initialized once (atomically). And 
with the new version, we don't even need the lambda..




Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:12
 #include "lldb/Host/linux/Support.h"
+
 #include "llvm/Support/MemoryBuffer.h"

btw, llvm does not generally put blank lines between include headers. omitting 
those lets clang format reorder everything according to the [[ 
https://llvm.org/docs/CodingStandards.html#include-style | official style ]].



Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:22-26
+  static Optional>> cpu_info_or_err;
+  static llvm::once_flag g_once_flag;
+
+  llvm::call_once(g_once_flag,
+  [] { cpu_info_or_err = getProcFile("cpuinfo"); });

And why not this?



Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:30
+
+  MemoryBuffer &buffer = ***cpu_info_or_err;
+  return ArrayRef(

lol


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131081

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


[Lldb-commits] [lldb] bcf6ffb - Reland "[lldb/Fuzzer] Add fuzzer for expression evaluator"

2022-08-04 Thread Chelsea Cassanova via lldb-commits

Author: Chelsea Cassanova
Date: 2022-08-04T11:47:06-04:00
New Revision: bcf6ffb87ec67ba41daeaab905b2c57a50568aa0

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

LOG: Reland "[lldb/Fuzzer] Add fuzzer for expression evaluator"

This reverts commit d959324e1efec12c3924c17b7d90db0b37eb84c3.

The target_include_directories in the clang-fuzzer CMake files
are set to PRIVATE instead of PUBLIC to prevent the clang buildbots
from breaking when symlinking clang into llvm.

The expression evaluator fuzzer itself has been modified to prevent a
bug that occurs when running it without a target.

Added: 
lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp

Modified: 
clang/cmake/modules/ProtobufMutator.cmake
clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
lldb/tools/lldb-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/ProtobufMutator.cmake 
b/clang/cmake/modules/ProtobufMutator.cmake
index 15fe95ed6e8e9..071f11bc343de 100644
--- a/clang/cmake/modules/ProtobufMutator.cmake
+++ b/clang/cmake/modules/ProtobufMutator.cmake
@@ -1,5 +1,9 @@
 include(ExternalProject)
-set(PBM_PREFIX protobuf_mutator)
+
+if (NOT PBM_PREFIX)
+  set (PBM_PREFIX protobuf_mutator)
+endif()
+
 set(PBM_PATH ${CMAKE_CURRENT_BINARY_DIR}/${PBM_PREFIX}/src/${PBM_PREFIX})
 set(PBM_LIB_PATH ${PBM_PATH}-build/src/libprotobuf-mutator.a)
 set(PBM_FUZZ_LIB_PATH 
${PBM_PATH}-build/src/libfuzzer/libprotobuf-mutator-libfuzzer.a)

diff  --git a/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt 
b/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
index 6d62421d9a69a..184d467b9c365 100644
--- a/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
@@ -11,3 +11,5 @@ add_clang_library(clangHandleCXX
   clangSerialization
   clangTooling
   )
+
+target_include_directories(clangHandleCXX PRIVATE .)

diff  --git a/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt 
b/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
index 339959b81af0c..baefc8a301410 100644
--- a/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
@@ -14,6 +14,8 @@ add_clang_library(clangLoopProtoToCXX loop_proto_to_cxx.cpp
   DEPENDS clangCXXLoopProto
   LINK_LIBS clangCXXLoopProto ${PROTOBUF_LIBRARIES}
   )
+target_include_directories(clangProtoToCXX PRIVATE .)
+target_include_directories(clangLoopProtoToCXX PRIVATE .)
 
 add_clang_executable(clang-proto-to-cxx proto_to_cxx_main.cpp)
 add_clang_executable(clang-loop-proto-to-cxx loop_proto_to_cxx_main.cpp)

diff  --git a/lldb/tools/lldb-fuzzer/CMakeLists.txt 
b/lldb/tools/lldb-fuzzer/CMakeLists.txt
index 867a41961c13c..4c081a9de53e2 100644
--- a/lldb/tools/lldb-fuzzer/CMakeLists.txt
+++ b/lldb/tools/lldb-fuzzer/CMakeLists.txt
@@ -1,3 +1,4 @@
 add_subdirectory(lldb-commandinterpreter-fuzzer)
+add_subdirectory(lldb-expression-fuzzer)
 add_subdirectory(lldb-target-fuzzer)
 add_subdirectory(utils)

diff  --git a/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt 
b/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
new file mode 100644
index 0..1850e8e0ce352
--- /dev/null
+++ b/lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
@@ -0,0 +1,60 @@
+if(CLANG_ENABLE_PROTO_FUZZER)
+  set(LLVM_LINK_COMPONENTS
+Support
+)
+
+  add_llvm_fuzzer(lldb-expression-fuzzer
+EXCLUDE_FROM_ALL
+lldb-expression-fuzzer.cpp
+)
+
+  if(TARGET lldb-expression-fuzzer)
+target_include_directories(lldb-expression-fuzzer PRIVATE ..)
+find_package(Protobuf REQUIRED)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+include_directories(${PROTOBUF_INCLUDE_DIRS})
+
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../../clang/tools/clang-fuzzer
 PRIVATE ..)
+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/tools/clang-fuzzer)
+
+set(CLANG_CMAKE_MODULE_PATH
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/cmake/modules)
+
+set(CMAKE_MODULE_PATH
+  ${CMAKE_MODULE_PATH}
+  ${CLANG_CMAKE_MODULE_PATH})
+
+
+set (PBM_PREFIX lldb_protobuf_mutator)
+include(ProtobufMutator)
+include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+target_link_libraries(lldb-expression-fuzzer
+  PRIVATE
+  ${ProtobufMutator_LIBRARIES}
+  ${LLVM_LIB_FUZZING_ENGINE}
+  clangHandleCXX
+  clangCXXProto
+  clangProtoToCXX
+  liblldb
+  )
+
+add_custom_command(TARGET lldb-expression-fuzzer PRE_BUILD
+  COMMAND ${CMAKE_COMMAND} -E make_directory 
${CMAKE_BINARY_DIR}/fuzzer-art

[Lldb-commits] [PATCH] D131159: [WIP][lldb] Use WSAEventSelect for MainLoop polling

2022-08-04 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This is a WIP, presumably in the final version there won't be prominent #ifdef 
_WIN32 in a file in the "Host/common" directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131159

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


[Lldb-commits] [PATCH] D124314: lldb: Disable unittests if llvm_gtest target does not exist

2022-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124314

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


[Lldb-commits] [lldb] b06da9c - Remove the check for eStateConnected in remote testing sessions.

2022-08-04 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2022-08-04T09:19:55-07:00
New Revision: b06da9c18390f84950e1d8f70ef2bb0efb433075

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

LOG: Remove the check for eStateConnected in remote testing sessions.

This check is clearly incorrect, there's no way you should have an
eStateConnected event left on the queue if you've already launched
and hit a breakpoint in the program.  This check fails running remotely
on Darwin systems and on one remote Linux platform.  And if we do
find this failing somewhere, we should fix the bogus eStateConnected,
not the test.

Added: 


Modified: 
lldb/test/API/functionalities/signal/TestSendSignal.py

Removed: 




diff  --git a/lldb/test/API/functionalities/signal/TestSendSignal.py 
b/lldb/test/API/functionalities/signal/TestSendSignal.py
index 5808ca17e566c..be74f00aa10a3 100644
--- a/lldb/test/API/functionalities/signal/TestSendSignal.py
+++ b/lldb/test/API/functionalities/signal/TestSendSignal.py
@@ -70,10 +70,6 @@ def test_with_run_command(self):
 # Now continue:
 process.Continue()
 
-# If running remote test, there should be a connected event
-if lldb.remote_platform:
-self.match_state(process_listener, lldb.eStateConnected)
-
 self.match_state(process_listener, lldb.eStateRunning)
 
 # Now signal the process, and make sure it stops:



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


[Lldb-commits] [PATCH] D131085: [lldb/crashlog] Refactor the CrashLogParser logic

2022-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/examples/python/crashlog.py:417
+class CrashLogParser(object):
+"Base class and factory."
+def __new__(cls, debugger, path, verbose, *args, **kwargs):

JDevlieghere wrote:
> 
This is not done (yet)


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

https://reviews.llvm.org/D131085

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


[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

2022-08-04 Thread Tiancheng Zhang via Phabricator via lldb-commits
tzb99 added a comment.

In D128250#3698652 , @Emmmer wrote:

>> Hello:
>>
>> Thank you so much for sharing the patch files. One thing I am still curious 
>> is what the ABISysv file you are using. Would you mind also sharing the 
>> remaining patches added for the lldb-server support?
>
> I didn't add any ABISysV code before uploading this patch, and now I'm 
> struggling with the breakpoints not hit problem, and it may be related to 
> ABISysV.
> After I solve this problem, I would love to share all patches added for the 
> lldb-server support.

Cool! There is one thread talking about the RISCV ABI support: 
https://reviews.llvm.org/D62732. I tried that ABI in the RISCV file but it 
seems like the same issue happened as yours, the breakpoint cannot be stopped, 
and the lldb-server cannot show the reasonable stack frame pointer address. So 
I think the ABI support should be modified.


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

https://reviews.llvm.org/D128250

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


[Lldb-commits] [PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-04 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

In D130689#3696186 , @thieta wrote:

> @nikic @thakis I fixed this issue in https://reviews.llvm.org/D131063 and it 
> can be built with CXX_STANDARD=17 and OSX_DEPLOYMENT_TARGET=10.11.

Thanks! We took this opportunity to bump our clang deployment target from 10.7 
to 10.12 (which makes a few other minor things easier too), so we don't need 
this change any more. But it's a good change anyways :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[Lldb-commits] [PATCH] D131032: [lldb/crashlog] Update frame regex matcher

2022-08-04 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 450053.
mib added a comment.

Add test


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

https://reviews.llvm.org/D131032

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
@@ -9,4 +9,5 @@
 # CHECK: [  0] {{.*}}out`foo + 16 at test.c
 # CHECK: [  1] {{.*}}out`bar + 8 at test.c
 # CHECK: [  2] {{.*}}out`main + 19 at test.c
+# CHECK: [  3] 0x{{[0]+}}100 start + 1
 # CHECK: rbp = 0x7ffee42d8020
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
@@ -31,7 +31,7 @@
 0   a.out  @foo@ foo + 16 (test.c:3)
 1   a.out  @bar@ bar + 9 (test.c:6)
 2   a.out  @main@ main + 20 (test.c:8)
-3   libdyld.dylib  0x0001 start + 1
+3   libdyld.dylib  0x100 start + 1
 
 Thread 0 crashed with X86 Thread State (64-bit):
   rax: 0x  rbx: 0x  rcx: 0x7ffee42d81d0  
rdx: 0x7ffee42d8080
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -600,11 +600,11 @@
 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
 app_backtrace_regex = re.compile('^Application Specific Backtrace 
([0-9]+)([^:]*):(.*)')
 version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
-frame_regex = re.compile(r'^([0-9]+)' r'\s'# id
- r'+(.+?)'r'\s+'   # img_name
- r'(' +version+ r')?'  # img_version
- r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
- r' +(.*)' # offs
+frame_regex = re.compile(r'^([0-9]+)' r'\s+'# id
+ r'(.+?)' r'\s+'# img_name
+ r'(' +version+ r')?'   # img_version
+ r'(0x[0-9a-fA-F]{7,})' # addr (7 
chars or more)
+ r' +(.*)'  # offs
 )
 null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
 image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/text.test
@@ -9,4 +9,5 @@
 # CHECK: [  0] {{.*}}out`foo + 16 at test.c
 # CHECK: [  1] {{.*}}out`bar + 8 at test.c
 # CHECK: [  2] {{.*}}out`main + 19 at test.c
+# CHECK: [  3] 0x{{[0]+}}100 start + 1
 # CHECK: rbp = 0x7ffee42d8020
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.crash
@@ -31,7 +31,7 @@
 0   a.out 	@foo@ foo + 16 (test.c:3)
 1   a.out 	@bar@ bar + 9 (test.c:6)
 2   a.out 	@main@ main + 20 (test.c:8)
-3   libdyld.dylib 	0x0001 start + 1
+3   libdyld.dylib 	0x100 start + 1
 
 Thread 0 crashed with X86 Thread State (64-bit):
   rax: 0x  rbx: 0x  rcx: 0x7ffee42d81d0  rdx: 0x7ffee42d8080
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -600,11 +600,11 @@
 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
 app_backtrace_regex = re.compile('^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
 version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
-frame_regex = re.compile(r'^([0-9]+)' r'\s'# id
- r'+(.+?)'r'\s+'   # img_name
- r'(' +version+ r')?'  # img_version
- r'(0x[0-9a-fA-F]{7}[0-9a-fA-F]+)' # addr
- r' +(.*)' 

[Lldb-commits] [PATCH] D131036: [lldb/crashlog] Add `-s|--skip-status` option to interactive mode

2022-08-04 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib marked 2 inline comments as done.
mib added inline comments.



Comment at: lldb/examples/python/crashlog.py:1198-1204
+option_parser.add_option(
+'--skip-status',
+'-s',
+dest='skip_status',
+action='store_true',
+help='prevent the interactive crashlog to dump the process status 
and thread backtrace at launch',
+default=False)

JDevlieghere wrote:
> jingham wrote:
> > JDevlieghere wrote:
> > > Is there another way to detect that we're running in this kind of 
> > > environment? For example, could we check if we're in an interactive lldb 
> > > session? I imagine you'd like to have the same behavior as the IDE case 
> > > if you imported the crashlog module in another Python file for example. 
> > > One easy way to determine this is to check if `lldb.debugger` exists, but 
> > > I'm not sure if that will cover the IDE case you're trying to solve. 
> > I don't think we should be in the business of trying to auto-detect what 
> > the caller's intentions are in this regard.  For instance, I can easily 
> > imagine a python utility that wants to get the crashlog, show it to the 
> > user, and also do some logic on it, and having us dump it is really 
> > convenient.  Plus the development experience here would be bad.  Someone 
> > would try out the crashlog command in lldb and see the dump.  Then they 
> > would run it in their program and not see it.  Then I think they would take 
> > our names in vain...
> The reason I brought it up is because we have another patch that adds another 
> flag for Xcode. Each flag makes sense by itself, but if there's a way to 
> detect this more generally and avoid a sprawl of flags I would prefer that. 
> But I don't feel strongly about it as this more of a "slippery slope 
> argument". 
As @jingham mentioned, I don't think we should be in the business of inferring 
what the user wants to show. I think it's better to make this choice clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131036

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


[Lldb-commits] [PATCH] D131081: [lldb] Prevent race condition when fetching /proc/cpuinfo

2022-08-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:12
 #include "lldb/Host/linux/Support.h"
+
 #include "llvm/Support/MemoryBuffer.h"

labath wrote:
> btw, llvm does not generally put blank lines between include headers. 
> omitting those lets clang format reorder everything according to the [[ 
> https://llvm.org/docs/CodingStandards.html#include-style | official style ]].
oh, i didn't know that clang-format ensures that style guideline. Thanks!



Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:22-26
+  static Optional>> cpu_info_or_err;
+  static llvm::once_flag g_once_flag;
+
+  llvm::call_once(g_once_flag,
+  [] { cpu_info_or_err = getProcFile("cpuinfo"); });

labath wrote:
> And why not this?
i didn't know that local static initializations are ensured by the compiler not 
to have race conditions. TIL
I'll just do what you are suggesting here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131081

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


[Lldb-commits] [PATCH] D131038: [lldb/crashlog] Skip null image dsym fetching on interactive mode

2022-08-04 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib marked 2 inline comments as done.
mib added inline comments.



Comment at: 
lldb/examples/python/scripted_process/crashlog_scripted_process.py:28
 if image not in self.loaded_images:
+if image.uuid == uuid.UUID(int=0):
+print(f"Note: Skipping null image")

JDevlieghere wrote:
> jasonmolenda wrote:
> > One of the things I noticed working on https://reviews.llvm.org/D130813 was 
> > that our UUID class's IsValid() method detects if the object has any bytes 
> > or not, and I wonder if it should check for a null uuid value (all zeroes) 
> > and return IsValid()==false in that case. In my patch, I was reading a UUID 
> > out of a corefile and I needed to check if it was a null uuid before I 
> > copied the bytes into a UUID object to work around it.
> According to the spec [1], the all-zero UUID is indeed a special case called 
> the "Nil UUID". I think it makes sense to have IsValid return false for that. 
> 
> [1] https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.7
Sounds good to me but I think that change is unrelated to this patch: The 
problem here that we call `dsymForUUID` from `crashlog.py -> 
DarwinImage:locate_module_and_debug_symbols` with a nil UUID, so the issue is 
external to lldb. I'll make the UUID::IsValid change on a follow-up patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131038

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


[Lldb-commits] [PATCH] D129682: [lldb] Filter DIEs based on qualified name when possible

2022-08-04 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbefa77e59a77: [lldb] Filter DIEs based on qualified name 
where possible (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129682

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Symbol/SymbolFileOnDemand.h
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/ModuleList.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/source/Symbol/SymbolFile.cpp
  lldb/source/Symbol/SymbolFileOnDemand.cpp
  lldb/tools/lldb-test/lldb-test.cpp

Index: lldb/tools/lldb-test/lldb-test.cpp
===
--- lldb/tools/lldb-test/lldb-test.cpp
+++ lldb/tools/lldb-test/lldb-test.cpp
@@ -505,8 +505,9 @@
 ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
 List.Clear();
-Symfile.FindFunctions(ConstString(Name), ContextPtr, getFunctionNameFlags(),
- true, List);
+Module::LookupInfo lookup_info(ConstString(Name), getFunctionNameFlags(),
+   eLanguageTypeUnknown);
+Symfile.FindFunctions(lookup_info, ContextPtr, true, List);
   }
   outs() << formatv("Found {0} functions:\n", List.GetSize());
   StreamString Stream;
Index: lldb/source/Symbol/SymbolFileOnDemand.cpp
===
--- lldb/source/Symbol/SymbolFileOnDemand.cpp
+++ lldb/source/Symbol/SymbolFileOnDemand.cpp
@@ -375,9 +375,11 @@
 }
 
 void SymbolFileOnDemand::FindFunctions(
-ConstString name, const CompilerDeclContext &parent_decl_ctx,
-FunctionNameType name_type_mask, bool include_inlines,
+const Module::LookupInfo &lookup_info,
+const CompilerDeclContext &parent_decl_ctx, bool include_inlines,
 SymbolContextList &sc_list) {
+  ConstString name = lookup_info.GetLookupName();
+  FunctionNameType name_type_mask = lookup_info.GetNameTypeMask();
   if (!m_debug_info_enabled) {
 Log *log = GetLog();
 
@@ -402,7 +404,7 @@
 // allow the FindFucntions to go through.
 SetLoadDebugInfoEnabled();
   }
-  return m_sym_file_impl->FindFunctions(name, parent_decl_ctx, name_type_mask,
+  return m_sym_file_impl->FindFunctions(lookup_info, parent_decl_ctx,
 include_inlines, sc_list);
 }
 
Index: lldb/source/Symbol/SymbolFile.cpp
===
--- lldb/source/Symbol/SymbolFile.cpp
+++ lldb/source/Symbol/SymbolFile.cpp
@@ -120,9 +120,8 @@
  uint32_t max_matches,
  VariableList &variables) {}
 
-void SymbolFile::FindFunctions(ConstString name,
+void SymbolFile::FindFunctions(const Module::LookupInfo &lookup_info,
const CompilerDeclContext &parent_decl_ctx,
-   lldb::FunctionNameType name_type_mask,
bool include_inlines,
SymbolContextList &sc_list) {}
 
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -119,9 +119,8 @@
uint32_t max_matches,
lldb_private::VariableList &variables) override;
 
-  void FindFunctions(lldb_private::ConstString name,
+  void FindFunctions(const lldb_private::Modu

[Lldb-commits] [lldb] befa77e - [lldb] Filter DIEs based on qualified name where possible

2022-08-04 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2022-08-04T11:18:08-07:00
New Revision: befa77e59a7760d8c4fdd177b234e4a59500f61c

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

LOG: [lldb] Filter DIEs based on qualified name where possible

Context:
When setting a breakpoint by name, we invoke Module::FindFunctions to
find the function(s) in question. However, we use a Module::LookupInfo
to first process the user-provided name and figure out exactly what
we're looking for. When we actually perform the function lookup, we
search for the basename. After performing the search, we then filter out
the results using Module::LookupInfo::Prune. For example, given
a::b::foo we would first search for all instances of foo and then filter
out the results to just names that have a::b::foo in them. As one can
imagine, this involves a lot of debug info processing that we do not
necessarily need to be doing. Instead of doing one large post-processing
step after finding each instance of `foo`, we can filter them as we go
to save time.

Some numbers:
Debugging LLDB and placing a breakpoint on
llvm::itanium_demangle::StringView::begin without this change takes
approximately 70 seconds and resolves 31,920 DIEs. With this change,
placing the breakpoint takes around 30 seconds and resolves 8 DIEs.

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

Added: 


Modified: 
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Symbol/SymbolFileOnDemand.h
lldb/source/Breakpoint/BreakpointResolverName.cpp
lldb/source/Core/Module.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Symbol/SymbolFile.cpp
lldb/source/Symbol/SymbolFileOnDemand.cpp
lldb/tools/lldb-test/lldb-test.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 117b14c586cf3..e877a14dcda10 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -85,6 +85,7 @@ struct ModuleFunctionSearchOptions {
 class Module : public std::enable_shared_from_this,
public SymbolContextScope {
 public:
+  class LookupInfo;
   // Static functions that can track the lifetime of module objects. This is
   // handy because we might have Module objects that are in shared pointers
   // that aren't in the global module list (from ModuleList). If this is the
@@ -294,6 +295,23 @@ class Module : public std::enable_shared_from_this,
   /// matches.
   void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list);
 
+  /// Find functions by lookup info.
+  ///
+  /// If the function is an inlined function, it will have a block,
+  /// representing the inlined function, and the function will be the
+  /// containing function.  If it is not inlined, then the block will be NULL.
+  ///
+  /// \param[in] lookup_info
+  /// The lookup info of the function we are looking for.
+  ///
+  /// \param[out] sc_list
+  /// A symbol context list that gets filled in with all of the
+  /// matches.
+  void FindFunctions(const LookupInfo &lookup_info,
+ const CompilerDeclContext &parent_decl_ctx,
+ const ModuleFunctionSearchOptions &options,
+ SymbolContextList &sc_list);
+
   /// Find functions by name.
   ///
   /// If the function is an inlined function, it will have a block,
@@ -931,6 +949,12 @@ class Module : pu

[Lldb-commits] [lldb] 967df65 - Revert "[lldb] Filter DIEs based on qualified name where possible"

2022-08-04 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2022-08-04T11:52:30-07:00
New Revision: 967df65a3610f98a3bc0ec0f2303641d7bad176c

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

LOG: Revert "[lldb] Filter DIEs based on qualified name where possible"

This reverts commit befa77e59a7760d8c4fdd177b234e4a59500f61c.

Looks like this broke a SymbolFileNativePDB test. I'll investigate and
resubmit with a fix soon.

Added: 


Modified: 
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Symbol/SymbolFileOnDemand.h
lldb/source/Breakpoint/BreakpointResolverName.cpp
lldb/source/Core/Module.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Symbol/SymbolFile.cpp
lldb/source/Symbol/SymbolFileOnDemand.cpp
lldb/tools/lldb-test/lldb-test.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index e877a14dcda10..117b14c586cf3 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -85,7 +85,6 @@ struct ModuleFunctionSearchOptions {
 class Module : public std::enable_shared_from_this,
public SymbolContextScope {
 public:
-  class LookupInfo;
   // Static functions that can track the lifetime of module objects. This is
   // handy because we might have Module objects that are in shared pointers
   // that aren't in the global module list (from ModuleList). If this is the
@@ -295,23 +294,6 @@ class Module : public std::enable_shared_from_this,
   /// matches.
   void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list);
 
-  /// Find functions by lookup info.
-  ///
-  /// If the function is an inlined function, it will have a block,
-  /// representing the inlined function, and the function will be the
-  /// containing function.  If it is not inlined, then the block will be NULL.
-  ///
-  /// \param[in] lookup_info
-  /// The lookup info of the function we are looking for.
-  ///
-  /// \param[out] sc_list
-  /// A symbol context list that gets filled in with all of the
-  /// matches.
-  void FindFunctions(const LookupInfo &lookup_info,
- const CompilerDeclContext &parent_decl_ctx,
- const ModuleFunctionSearchOptions &options,
- SymbolContextList &sc_list);
-
   /// Find functions by name.
   ///
   /// If the function is an inlined function, it will have a block,
@@ -949,12 +931,6 @@ class Module : public std::enable_shared_from_this,
   m_name_type_mask = mask;
 }
 
-lldb::LanguageType GetLanguageType() const { return m_language; }
-
-bool NameMatchesLookupInfo(
-ConstString function_name,
-lldb::LanguageType language_type = lldb::eLanguageTypeUnknown) const;
-
 void Prune(SymbolContextList &sc_list, size_t start_idx) const;
 
   protected:

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 6d34e4cdc20fe..ed0de1b5bce6b 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -9,7 +9,6 @@
 #ifndef LLDB_SYMBOL_SYMBOLFILE_H
 #define LLDB_SYMBOL_SYMBOLFILE_H
 
-#include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/Core/SourceLocationSpec.h"
@@ -235,8 +234,9 @@ class SymbolFile : public PluginInterface {
   virtual void FindGlobalVariables(c

[Lldb-commits] [PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-04 Thread Tobias Hieta via Phabricator via lldb-commits
thieta added a comment.

All right! Last call - I am going fix the spelling error and merge this 
tomorrow EU time unless someone objects. Thanks for all reviews so far!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[Lldb-commits] [PATCH] D131038: [lldb/crashlog] Skip null image dsym fetching on interactive mode

2022-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM module the inline comment.




Comment at: 
lldb/examples/python/scripted_process/crashlog_scripted_process.py:27-29
 if image not in self.loaded_images:
+if image.uuid == uuid.UUID(int=0):
+print(f"Note: Skipping null image")

Sounds good. I would remove the print and just ignore the null images. There's 
nothing actionable there for the user.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131038

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


[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

almost there!




Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp:104-108
 std::vector tids;
 for (const JSONProcess &process : bundle_description.processes)
   for (const JSONThread &thread : process.threads)
 tids.push_back(thread.tid);
 

why did you remove this?



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp:305
 - "tscPerfZeroConversion" must be provided if "cpus" is provided.
+- "processes" is provided if and only if "kernel" is not provided.
+- If "kernel" is provided, then the "processes" section must be empty and the 
"cpus" section must be provided. This configuration indicates that the kernel 
was traced and user processes weren't. Besides that, the kernel is treated as a 
single process with one thread per CPU core. This doesn't handle actual kernel 
threads, but instead treats all the instructions executed by the kernel on each 
core as an individual thread.

remove this line. We should allow the user to pass an empty array for 
"processes" or not passing it at all. This will make the json easier to work 
with



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp:306
+- "processes" is provided if and only if "kernel" is not provided.
+- If "kernel" is provided, then the "processes" section must be empty and the 
"cpus" section must be provided. This configuration indicates that the kernel 
was traced and user processes weren't. Besides that, the kernel is treated as a 
single process with one thread per CPU core. This doesn't handle actual kernel 
threads, but instead treats all the instructions executed by the kernel on each 
core as an individual thread.
  })";

please break this into multiple lines of at most 80 chars each



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp:376
 
-  JSONTraceBundleDescription json_intel_pt_bundle_desc{"intel-pt", *cpu_info, 
*json_processes,
- *json_cpus,
- trace_ipt.GetPerfZeroTscConversion()};
+  Optional> json_processes = llvm::None;
+  Optional json_kernel = llvm::None;

that is enough



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp:377
+  Optional> json_processes = llvm::None;
+  Optional json_kernel = llvm::None;
+

that is enough



Comment at: lldb/test/API/commands/trace/TestTraceLoad.py:273
+
+self.expect("image list", substrs=["modules/m.out"])
+self.expect("image list", substrs=["0x8100"])





Comment at: lldb/test/API/commands/trace/TestTraceLoad.py:274
+self.expect("image list", substrs=["modules/m.out"])
+self.expect("image list", substrs=["0x8100"])
+

remove this one



Comment at: lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json:26
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out"
+  },

write another test with a custom load address


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

https://reviews.llvm.org/D130805

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


[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread Sujin Park via Phabricator via lldb-commits
persona0220 updated this revision to Diff 450137.
persona0220 marked 6 inline comments as done.

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

https://reviews.llvm.org/D130805

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceSave.py
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
  
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json

Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
@@ -0,0 +1,30 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": "0x40"
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
@@ -0,0 +1,20 @@
+{
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": 4194304
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
@@ -0,0 +1,53 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+{
+  "modules": [
+{
+  "file": "../intelpt-multi-core-trace/modules/m.out",
+  "systemPath": "/tmp/m.out",
+  "loadAddress": 4194304,
+  "uuid": "AEFB0D59-233F-80FF-6D3C-4DED498534CF-11017B3B"
+}
+  ],
+  "pid": 3497234,
+  "threads": [
+{
+  "tid": 3497234
+},
+{
+  "tid": 3497496
+},
+{
+  "tid": 3497497
+}
+  ]
+}
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "type": "intel-pt",
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out"
+  }
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
@@ -0,0 +1,29 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"fa

[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp:306
+- "processes" is provided if and only if "kernel" is not provided.
+- If "kernel" is provided, then the "processes" section must be empty and the 
"cpus" section must be provided. This configuration indicates that the kernel 
was traced and user processes weren't. Besides that, the kernel is treated as a 
single process with one thread per CPU core. This doesn't handle actual kernel 
threads, but instead treats all the instructions executed by the kernel on each 
core as an individual thread.
  })";

wallace wrote:
> please break this into multiple lines of at most 80 chars each
you didn't apply these suggestions:
 - add `or not passed at all, `
 - break into multiple lines


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

https://reviews.llvm.org/D130805

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


[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread Sujin Park via Phabricator via lldb-commits
persona0220 updated this revision to Diff 450144.

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

https://reviews.llvm.org/D130805

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceSave.py
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
  
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json

Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
@@ -0,0 +1,30 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": "0x40"
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
@@ -0,0 +1,20 @@
+{
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": 4194304
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
@@ -0,0 +1,53 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+{
+  "modules": [
+{
+  "file": "../intelpt-multi-core-trace/modules/m.out",
+  "systemPath": "/tmp/m.out",
+  "loadAddress": 4194304,
+  "uuid": "AEFB0D59-233F-80FF-6D3C-4DED498534CF-11017B3B"
+}
+  ],
+  "pid": 3497234,
+  "threads": [
+{
+  "tid": 3497234
+},
+{
+  "tid": 3497496
+},
+{
+  "tid": 3497497
+}
+  ]
+}
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "type": "intel-pt",
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out"
+  }
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
@@ -0,0 +1,29 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4

[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread Sujin Park via Phabricator via lldb-commits
persona0220 marked an inline comment as done.
persona0220 added inline comments.



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp:104-108
 std::vector tids;
 for (const JSONProcess &process : bundle_description.processes)
   for (const JSONThread &thread : process.threads)
 tids.push_back(thread.tid);
 

wallace wrote:
> why did you remove this?
Because it seems that tids vector is not used anywhere


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

https://reviews.llvm.org/D130805

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


[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.

nice job! Now you just need to connect it with the collector :)


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

https://reviews.llvm.org/D130805

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


[Lldb-commits] [PATCH] D131212: Allow host platform to use sdk sysroot directory option when resolving shared modules

2022-08-04 Thread Trevor Joynson via Phabricator via lldb-commits
trevorj created this revision.
Herald added a project: All.
trevorj requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Hi!  We noticed recently that when using the host platform with an sdk sysroot 
set, modules are not resolved using a path prefixed by the set sysroot path.

If I'm just doing something wrong let me know too :)

Thanks!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131212

Files:
  lldb/source/Target/Platform.cpp


Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -201,11 +201,6 @@
 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
 const FileSpecList *module_search_paths_ptr,
 llvm::SmallVectorImpl *old_modules, bool *did_create_ptr) {
-  if (IsHost())
-return ModuleList::GetSharedModule(module_spec, module_sp,
-   module_search_paths_ptr, old_modules,
-   did_create_ptr, false);
-
   // Module resolver lambda.
   auto resolver = [&](const ModuleSpec &spec) {
 Status error(eErrorTypeGeneric);


Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -201,11 +201,6 @@
 const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
 const FileSpecList *module_search_paths_ptr,
 llvm::SmallVectorImpl *old_modules, bool *did_create_ptr) {
-  if (IsHost())
-return ModuleList::GetSharedModule(module_spec, module_sp,
-   module_search_paths_ptr, old_modules,
-   did_create_ptr, false);
-
   // Module resolver lambda.
   auto resolver = [&](const ModuleSpec &spec) {
 Status error(eErrorTypeGeneric);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1d2a62a - Re-submit "[lldb] Filter DIEs based on qualified name where possible"

2022-08-04 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2022-08-04T15:52:27-07:00
New Revision: 1d2a62afaf7561e331e2f3daf3937d14225b21bf

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

LOG: Re-submit "[lldb] Filter DIEs based on qualified name where possible"

This reverts commit 967df65a3610f98a3bc0ec0f2303641d7bad176c.

This fixes test/Shell/SymbolFile/NativePDB/find-functions.cpp. When
looking up functions with the PDB plugins, if we are looking for a
full function name, we should use `GetName` to populate the `name`
field instead of `GetLookupName` since `GetName` has the more
complete information.

Added: 


Modified: 
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Symbol/SymbolFileOnDemand.h
lldb/source/Breakpoint/BreakpointResolverName.cpp
lldb/source/Core/Module.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Symbol/SymbolFile.cpp
lldb/source/Symbol/SymbolFileOnDemand.cpp
lldb/tools/lldb-test/lldb-test.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 117b14c586cf3..e877a14dcda10 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -85,6 +85,7 @@ struct ModuleFunctionSearchOptions {
 class Module : public std::enable_shared_from_this,
public SymbolContextScope {
 public:
+  class LookupInfo;
   // Static functions that can track the lifetime of module objects. This is
   // handy because we might have Module objects that are in shared pointers
   // that aren't in the global module list (from ModuleList). If this is the
@@ -294,6 +295,23 @@ class Module : public std::enable_shared_from_this,
   /// matches.
   void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list);
 
+  /// Find functions by lookup info.
+  ///
+  /// If the function is an inlined function, it will have a block,
+  /// representing the inlined function, and the function will be the
+  /// containing function.  If it is not inlined, then the block will be NULL.
+  ///
+  /// \param[in] lookup_info
+  /// The lookup info of the function we are looking for.
+  ///
+  /// \param[out] sc_list
+  /// A symbol context list that gets filled in with all of the
+  /// matches.
+  void FindFunctions(const LookupInfo &lookup_info,
+ const CompilerDeclContext &parent_decl_ctx,
+ const ModuleFunctionSearchOptions &options,
+ SymbolContextList &sc_list);
+
   /// Find functions by name.
   ///
   /// If the function is an inlined function, it will have a block,
@@ -931,6 +949,12 @@ class Module : public std::enable_shared_from_this,
   m_name_type_mask = mask;
 }
 
+lldb::LanguageType GetLanguageType() const { return m_language; }
+
+bool NameMatchesLookupInfo(
+ConstString function_name,
+lldb::LanguageType language_type = lldb::eLanguageTypeUnknown) const;
+
 void Prune(SymbolContextList &sc_list, size_t start_idx) const;
 
   protected:

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index ed0de1b5bce6b..6d34e4cdc20fe 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_SYMBOL_SYMBOLFILE_H
 #define LLDB_SYMBOL_SYMBOLFILE_H
 
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Module

[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread Sujin Park via Phabricator via lldb-commits
persona0220 updated this revision to Diff 450163.
persona0220 added a comment.

rebasing to the upstream


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

https://reviews.llvm.org/D130805

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceSave.py
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
  
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json

Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
@@ -0,0 +1,30 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": "0x40"
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
@@ -0,0 +1,20 @@
+{
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": 4194304
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
@@ -0,0 +1,53 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+{
+  "modules": [
+{
+  "file": "../intelpt-multi-core-trace/modules/m.out",
+  "systemPath": "/tmp/m.out",
+  "loadAddress": 4194304,
+  "uuid": "AEFB0D59-233F-80FF-6D3C-4DED498534CF-11017B3B"
+}
+  ],
+  "pid": 3497234,
+  "threads": [
+{
+  "tid": 3497234
+},
+{
+  "tid": 3497496
+},
+{
+  "tid": 3497497
+}
+  ]
+}
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "type": "intel-pt",
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out"
+  }
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
@@ -0,0 +1,29 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": 

[Lldb-commits] [lldb] 6fb744b - [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2022-08-04T17:15:08-07:00
New Revision: 6fb744be76704f075a4edc753916e0e475d10f20

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

LOG: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle 
schema

Add a new "kernel" section with following schema.

```
"kernel": {
  "loadAddress"?: decimal | hex string | string decimal
  # This is optional. If it's not specified, use default address 
0x8100.
  "file": string
  # path to the kernel image
}
```

Here's more details of the diff:
- If "kernel" section exist, it means current tracing mode is //KernelMode//.
- If tracing mode is //KernelMode//, the "processes" section must be empty and 
the "kernel" and "cpus" section must be provided. This is tested with 
`TestTraceLoad`.
- "kernel" section is parsed and turned into a new process with a single module 
which is the kernel image. The kernel process has N fake threads, one for each 
cpu.

Reviewed By: wallace

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

Added: 
lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json

lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json

lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json

Modified: 
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h
lldb/test/API/commands/trace/TestTraceLoad.py
lldb/test/API/commands/trace/TestTraceSave.py

Removed: 




diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
index 029f1b3c70ebf..a3c9064505af2 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -79,12 +79,14 @@ TraceIntelPTSP TraceIntelPT::GetSharedPtr() {
   return std::static_pointer_cast(shared_from_this());
 }
 
+TraceIntelPT::TraceMode TraceIntelPT::GetTraceMode() { return trace_mode; }
+
 TraceIntelPTSP TraceIntelPT::CreateInstanceForPostmortemTrace(
 JSONTraceBundleDescription &bundle_description,
 ArrayRef traced_processes,
-ArrayRef traced_threads) {
+ArrayRef traced_threads, TraceMode trace_mode) {
   TraceIntelPTSP trace_sp(
-  new TraceIntelPT(bundle_description, traced_processes));
+  new TraceIntelPT(bundle_description, traced_processes, trace_mode));
   trace_sp->m_storage.tsc_conversion =
   bundle_description.tsc_perf_zero_conversion;
 
@@ -101,11 +103,6 @@ TraceIntelPTSP 
TraceIntelPT::CreateInstanceForPostmortemTrace(
   cpus.push_back(cpu.id);
 }
 
-std::vector tids;
-for (const JSONProcess &process : bundle_description.processes)
-  for (const JSONThread &thread : process.threads)
-tids.push_back(thread.tid);
-
 trace_sp->m_storage.multicpu_decoder.emplace(trace_sp);
   } else {
 for (const ThreadPostMortemTraceSP &thread : traced_threads) {
@@ -124,9 +121,10 @@ TraceIntelPTSP 
TraceIntelPT::CreateInstanceForPostmortemTrace(
 }
 
 TraceIntelPT::TraceIntelPT(JSONTraceBundleDescription &bundle_description,
-   ArrayRef traced_processes)
+   ArrayRef traced_processes,
+   TraceMode trace_mode)
 : Trace(traced_processes, bundle_description.GetCpuIds()),
-  m_cpu_info(bundle_description.cpu_info) {}
+  m_cpu_info(bundle_description.cpu_info), trace_mode(trace_mode) {}
 
 Expected TraceIntelPT::Decode(Thread &thread) {
   if (const char *error = RefreshLiveProcessState())

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h 
b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
index 7e8f030958f11..82034b0bfbc63 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
@@ -172,6 +172,10 @@ class TraceIntelPT : public Trace {
 
   TraceIntelPTSP GetSharedPtr();
 
+  enum class TraceMode { UserMode, KernelMode };
+
+  TraceMode GetTraceMode();
+
 private:
   friend class TraceIntelPTBundleLoader;
 
@@ -183,28 +187,34 @@ class TraceIntelPT : public Trace {
   /// The definition file for the postmortem bundle.
   ///
   /// \param[in] traced_processes
-  /// The processes traced in the live session.
+  /// The pr

[Lldb-commits] [PATCH] D130805: [trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

2022-08-04 Thread Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6fb744be7670: [trace][intel pt] Support a new kernel section 
in LLDB’s trace bundle schema (authored by Walter Erquinigo 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130805

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceSave.py
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
  
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
  lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json

Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json
@@ -0,0 +1,30 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": "0x40"
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json
@@ -0,0 +1,20 @@
+{
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out",
+"loadAddress": 4194304
+  },
+  "type": "intel-pt"
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json
@@ -0,0 +1,53 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace/cores/45.intelpt_trace"
+},
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/51.perf_context_switch_trace",
+  "id": 51,
+  "iptTrace": "../intelpt-multi-core-trace/cores/51.intelpt_trace"
+}
+  ],
+  "cpuInfo": {
+"family": 6,
+"model": 85,
+"stepping": 4,
+"vendor": "GenuineIntel"
+  },
+  "processes": [
+{
+  "modules": [
+{
+  "file": "../intelpt-multi-core-trace/modules/m.out",
+  "systemPath": "/tmp/m.out",
+  "loadAddress": 4194304,
+  "uuid": "AEFB0D59-233F-80FF-6D3C-4DED498534CF-11017B3B"
+}
+  ],
+  "pid": 3497234,
+  "threads": [
+{
+  "tid": 3497234
+},
+{
+  "tid": 3497496
+},
+{
+  "tid": 3497497
+}
+  ]
+}
+  ],
+  "tscPerfZeroConversion": {
+"timeMult": 1076264588,
+"timeShift": 31,
+"timeZero": 18433473881008870804
+  },
+  "type": "intel-pt",
+  "kernel": {
+"file": "../intelpt-multi-core-trace/modules/m.out"
+  }
+}
Index: lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json
@@ -0,0 +1,29 @@
+{
+  "cpus": [
+{
+  "contextSwitchTrace": "../intelpt-multi-core-trace/cores/45.perf_context_switch_trace",
+  "id": 45,
+  "iptTrace": "../intelpt-multi-core-trace

[Lldb-commits] [PATCH] D131212: Allow host platform to use sdk sysroot directory option when resolving shared modules

2022-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Hey Trevor,

Thank you for your patch. Please[[ 
https://llvm.org/docs/DeveloperPolicy.html#making-and-submitting-a-patch |  
include as much context ]] as possible when uploading a patch. It makes it a 
lot easier for the reviewers to see the surrounding code.

Could you please describe the issue you're seeing in a little more detail? 
Preferably with an example or steps to reproduce, even better if it's in the 
form of a test, which we'll definitely need for a change like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131212

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


[Lldb-commits] [PATCH] D131212: Allow host platform to use sdk sysroot directory option when resolving shared modules

2022-08-04 Thread Trevor Joynson via Phabricator via lldb-commits
trevorj added a comment.

@JDevlieghere Sure I can provide more context, let me know if you want me to 
clarify anything!

I'm trying to debug production coredumps on a development machine using a 
sysroot folder tree that contains the required shared objects required.

In gdb, I use this via `set sysroot`.
In LLDB, I assume I should do something like `platform select host -S 
/path/to/sysroot`.

After doing either of these I would expect the attempted paths for loading 
shared objects will be prefixed by the configured sysroot.
Unfortunately, when using the `host` platform, it currently ignores the sysroot 
configuration option when trying to load shared objects.
This breaks the `sysroot` setting on the `host` platform.

If I'm doing something wrong feel free to correct me!

Side note, I believe these lines would be okay to remove because it falls back 
to normal resolution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131212

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


[Lldb-commits] [PATCH] D131081: [lldb] Prevent race condition when fetching /proc/cpuinfo

2022-08-04 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 450226.
wallace added a comment.

simplify this diff following @labath's advice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131081

Files:
  lldb/source/Plugins/Process/Linux/Procfs.cpp


Index: lldb/source/Plugins/Process/Linux/Procfs.cpp
===
--- lldb/source/Plugins/Process/Linux/Procfs.cpp
+++ lldb/source/Plugins/Process/Linux/Procfs.cpp
@@ -7,9 +7,9 @@
 
//===--===//
 
 #include "Procfs.h"
-
 #include "lldb/Host/linux/Support.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Threading.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -17,17 +17,16 @@
 using namespace llvm;
 
 Expected> lldb_private::process_linux::GetProcfsCpuInfo() {
-  static Optional> cpu_info;
-  if (!cpu_info) {
-auto buffer_or_error = errorOrToExpected(getProcFile("cpuinfo"));
-if (!buffer_or_error)
-  return buffer_or_error.takeError();
-MemoryBuffer &buffer = **buffer_or_error;
-cpu_info = std::vector(
-reinterpret_cast(buffer.getBufferStart()),
-reinterpret_cast(buffer.getBufferEnd()));
-  }
-  return *cpu_info;
+  static ErrorOr> cpu_info_or_err =
+  getProcFile("cpuinfo");
+
+  if (!*cpu_info_or_err)
+cpu_info_or_err.getError();
+
+  MemoryBuffer &buffer = **cpu_info_or_err;
+  return ArrayRef(
+  reinterpret_cast(buffer.getBufferStart()),
+  reinterpret_cast(buffer.getBufferEnd()));
 }
 
 Expected>


Index: lldb/source/Plugins/Process/Linux/Procfs.cpp
===
--- lldb/source/Plugins/Process/Linux/Procfs.cpp
+++ lldb/source/Plugins/Process/Linux/Procfs.cpp
@@ -7,9 +7,9 @@
 //===--===//
 
 #include "Procfs.h"
-
 #include "lldb/Host/linux/Support.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Threading.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -17,17 +17,16 @@
 using namespace llvm;
 
 Expected> lldb_private::process_linux::GetProcfsCpuInfo() {
-  static Optional> cpu_info;
-  if (!cpu_info) {
-auto buffer_or_error = errorOrToExpected(getProcFile("cpuinfo"));
-if (!buffer_or_error)
-  return buffer_or_error.takeError();
-MemoryBuffer &buffer = **buffer_or_error;
-cpu_info = std::vector(
-reinterpret_cast(buffer.getBufferStart()),
-reinterpret_cast(buffer.getBufferEnd()));
-  }
-  return *cpu_info;
+  static ErrorOr> cpu_info_or_err =
+  getProcFile("cpuinfo");
+
+  if (!*cpu_info_or_err)
+cpu_info_or_err.getError();
+
+  MemoryBuffer &buffer = **cpu_info_or_err;
+  return ArrayRef(
+  reinterpret_cast(buffer.getBufferStart()),
+  reinterpret_cast(buffer.getBufferEnd()));
 }
 
 Expected>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131160: [WIP][lldb] Add "event" capability to the MainLoop class

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

To be honest, I'm not sure if "event" is the best name for it. I get it's a WSA 
name but it's a bit non-obvious to outsiders (I mean, technically everything is 
an event). Not that I have a better name in mind.




Comment at: lldb/include/lldb/Host/MainLoop.h:66
 
+  EventHandleUP RegisterEvent(const Callback &callback);
+

Could you include a short comment explaining how it's used? I suppose something 
like "will be executed upon being explicitly signaled via `NotifyEvent()` from 
any thread".



Comment at: lldb/source/Host/common/MainLoop.cpp:121
 
-  if (result >= WSA_WAIT_EVENT_0 && result < WSA_WAIT_EVENT_0 + 
read_events.size()) {
+  if (result >= WSA_WAIT_EVENT_0 && result <= WSA_WAIT_EVENT_0 + 
events.size()) {
 signaled_event = result - WSA_WAIT_EVENT_0;

I think the reliance on `<` vs `<=` here could be confusing. Perhaps add a note 
that we popped the "event event" above, or maybe add a `last_event` const-var 
prior to popping it.



Comment at: lldb/source/Host/common/MainLoop.cpp:133
+loop.ProcessReadObject(fd_info.first);
+  } else {
+// Must be called before events are processed.

Let's make sure something didn't corrupt the state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131160

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