[Lldb-commits] [PATCH] D133763: WIP strawman building perf.cpp on an older kernel

2022-09-13 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett abandoned this revision.
DavidSpickett added a comment.

For https://github.com/llvm/llvm-project/issues/57594, succeeded by 
https://reviews.llvm.org/D133778.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133763

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


[Lldb-commits] [PATCH] D133763: WIP strawman building perf.cpp on an older kernel

2022-09-13 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

(This file is only used for the processor trace feature, and one can debug just 
fine without it. So, I'd just conditionally compile out the processor trace 
support on older kernels -- it's highly questionable whether this works there 
anyway).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133763

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


[Lldb-commits] [PATCH] D133763: WIP strawman building perf.cpp on an older kernel

2022-09-13 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett planned changes to this revision.
DavidSpickett added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: lldb/source/Plugins/Process/Linux/Perf.cpp:28
 lldb_private::process_linux::LoadPerfTscConversionParameters() {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
   lldb::pid_t pid = getpid();

Use this sort of thing, or an ifdef set by cmake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133763

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


[Lldb-commits] [PATCH] D133763: WIP strawman building perf.cpp on an older kernel

2022-09-13 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett 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/D133763

Files:
  lldb/source/Plugins/Process/Linux/Perf.cpp
  lldb/source/Plugins/Process/Linux/Perf.h

Index: lldb/source/Plugins/Process/Linux/Perf.h
===
--- lldb/source/Plugins/Process/Linux/Perf.h
+++ lldb/source/Plugins/Process/Linux/Perf.h
@@ -22,6 +22,21 @@
 #include 
 #include 
 
+struct perf_event_mmap_page_custom {
+  int cap_user_time;
+  int cap_user_time_zero;
+  uint32_t time_mult;
+  uint16_t time_shift;
+  uint64_t time_zero;
+
+  //uint64_t aux_head;
+  //int aux_offset;
+  //unsigned long aux_size;
+  //uint64_t data_head;
+  //int data_offset;
+  //unsigned long data_size;
+};
+
 namespace lldb_private {
 namespace process_linux {
 namespace resource_handle {
@@ -142,7 +157,7 @@
   /// \param[in] num_data_pages
   /// Number of pages in the data buffer to mmap, must be a power of 2.
   /// A value of 0 is useful for "dummy" events that only want to access
-  /// the metadata, \a perf_event_mmap_page, or the aux buffer.
+  /// the metadata, \a perf_event_mmap_page_custom, or the aux buffer.
   ///
   /// \param[in] num_aux_pages
   /// Number of pages in the aux buffer to mmap, must be a power of 2.
@@ -171,8 +186,8 @@
   /// otherwise a failure might happen.
   ///
   /// \return
-  ///   The data section's \a perf_event_mmap_page.
-  perf_event_mmap_page () const;
+  ///   The data section's \a perf_event_mmap_page_custom.
+  perf_event_mmap_page_custom () const;
 
   /// Get the data buffer from the data section's mmap buffer.
   ///
@@ -278,7 +293,7 @@
   /// \param[in] num_data_pages
   /// Number of pages in the data buffer to mmap, must be a power of 2.
   /// A value of 0 is useful for "dummy" events that only want to access
-  /// the metadata, \a perf_event_mmap_page, or the aux buffer.
+  /// the metadata, \a perf_event_mmap_page_custom, or the aux buffer.
   ///
   /// \param[in] data_buffer_write
   /// Whether to mmap the data buffer with WRITE permissions. This changes
@@ -317,7 +332,7 @@
 CreateContextSwitchTracePerfEvent(lldb::cpu_id_t cpu_id,
   const PerfEvent *parent_perf_event = nullptr);
 
-/// Load \a PerfTscConversionParameters from \a perf_event_mmap_page, if
+/// Load \a PerfTscConversionParameters from \a perf_event_mmap_page_custom, if
 /// available.
 llvm::Expected LoadPerfTscConversionParameters();
 
Index: lldb/source/Plugins/Process/Linux/Perf.cpp
===
--- lldb/source/Plugins/Process/Linux/Perf.cpp
+++ lldb/source/Plugins/Process/Linux/Perf.cpp
@@ -42,7 +42,7 @@
  /*data_buffer_write=*/false))
 return std::move(mmap_err);
 
-  perf_event_mmap_page _metada = perf_event->GetMetadataPage();
+  perf_event_mmap_page_custom _metada = perf_event->GetMetadataPage();
   if (mmap_metada.cap_user_time && mmap_metada.cap_user_time_zero) {
 return LinuxPerfZeroTscConversion{
 mmap_metada.time_mult, mmap_metada.time_shift, {mmap_metada.time_zero}};
@@ -128,19 +128,22 @@
   if (num_aux_pages == 0)
 return Error::success();
 
-  perf_event_mmap_page _page = GetMetadataPage();
+  return llvm::createStringError(
+llvm::inconvertibleErrorCode(), "foo");
 
-  metadata_page.aux_offset =
-  metadata_page.data_offset + metadata_page.data_size;
-  metadata_page.aux_size = num_aux_pages * getpagesize();
-
-  if (Expected mmap_aux =
-  DoMmap(nullptr, metadata_page.aux_size, PROT_READ, MAP_SHARED,
- metadata_page.aux_offset, "aux buffer")) {
-m_aux_base = std::move(mmap_aux.get());
-return Error::success();
-  } else
-return mmap_aux.takeError();
+//  perf_event_mmap_page_custom _page = GetMetadataPage();
+//
+//  metadata_page.aux_offset =
+//  metadata_page.data_offset + metadata_page.data_size;
+//  metadata_page.aux_size = num_aux_pages * getpagesize();
+//
+//  if (Expected mmap_aux =
+//  DoMmap(nullptr, metadata_page.aux_size, PROT_READ, MAP_SHARED,
+// metadata_page.aux_offset, "aux buffer")) {
+//m_aux_base = std::move(mmap_aux.get());
+//return Error::success();
+//  } else
+//return mmap_aux.takeError();
 }
 
 llvm::Error PerfEvent::MmapMetadataAndBuffers(size_t num_data_pages,
@@ -165,21 +168,24 @@
 
 long PerfEvent::GetFd() const { return *(m_fd.get()); }
 
-perf_event_mmap_page ::GetMetadataPage() const {
-  return *reinterpret_cast(m_metadata_data_base.get());
+perf_event_mmap_page_custom ::GetMetadataPage() const {
+  return *reinterpret_cast(m_metadata_data_base.get());
 }
 
 ArrayRef PerfEvent::GetDataBuffer() const {
-  perf_event_mmap_page _metadata = GetMetadataPage();