Skip to content

Conversation

root-kidik
Copy link

@root-kidik root-kidik commented Aug 22, 2024

Close: #105705

I build llvm toolchain with linux-headers 4.2, but get error, while compiling lldb

llvm-project/lldb/source/Plugins/Process/Linux/Perf.cpp:345:8: error: 'struct perf_event_attr' has no member named 'context_switch' attr.context_switch = 1%3b

can we replace or disable this functionality in lldb with older linux-headers?

https://man7.org/linux/man-pages/man2/perf_event_open.2.html
context_switch (since Linux 4.3)

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the lldb label Aug 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 22, 2024

@llvm/pr-subscribers-lldb

Author: Nikita (root-kidik)

Changes

Close: #105705


Full diff: https://github.com/llvm/llvm-project/pull/105715.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/Linux/Perf.cpp (+2)
diff --git a/lldb/source/Plugins/Process/Linux/Perf.cpp b/lldb/source/Plugins/Process/Linux/Perf.cpp
index 097c719b9c1d25..8135d092cfdd68 100644
--- a/lldb/source/Plugins/Process/Linux/Perf.cpp
+++ b/lldb/source/Plugins/Process/Linux/Perf.cpp
@@ -342,7 +342,9 @@ lldb_private::process_linux::CreateContextSwitchTracePerfEvent(
   attr.size = sizeof(attr);
   attr.sample_type = PERF_SAMPLE_TID | PERF_SAMPLE_TIME;
   attr.type = PERF_TYPE_SOFTWARE;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
   attr.context_switch = 1;
+#endif
   attr.exclude_kernel = 1;
   attr.sample_id_all = 1;
   attr.exclude_hv = 1;

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks fine, but can you please update the PR description with a meaningful message, preferably with a reference that shows that this was added in 4.3?

@JDevlieghere JDevlieghere changed the title fix: [lldb]: add missing if for smaller linux version [lldb] Conditionalize context_switch attribute based on kernel version Aug 22, 2024
@root-kidik
Copy link
Author

Ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lldb] Conditionalize context_switch attribute based on kernel version
4 participants