summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
AgeCommit message (Collapse)Author
2023-12-16[lldb] Use StringRef::{starts,ends}_with (NFC)Kazu Hirata
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-02-10[NFC][TargetParser] Replace uses of llvm/Support/Host.hArchibald Elliott
The forwarding header is left in place because of its use in `polly/lib/External/isl/interface/extract_interface.cc`, but I have added a GCC warning about the fact it is deprecated, because it is used in `isl` from where it is included by Polly.
2023-01-28[llvm] Use llvm::bit_floor instead of llvm::PowerOf2Floor (NFC)Kazu Hirata
2022-12-16[trace] Migrate uses of operator<<(raw_ostream &OS, const Optional<T> &O) to ↵Fangrui Song
std::optional
2022-12-16[trace] Change /sys/bus const char * variables to const char []Fangrui Song
2022-12-16JSON: llvm::Optional => std::optionalFangrui Song
Many files are from language servers. https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-14[lldb] Use llvm::transformOptional (NFC)Kazu Hirata
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-08-19[lldb] Use Optional::transform instead of Optional::map (NFC)Kazu Hirata
2022-08-11[NFC][lldb][trace] Fix formatting of tracing filesWalter Erquinigo
Pavel Labath taught me that clang-format sorts headers automatically using llvm's rules, and it's better not to have spaces between So in this diff I'm removing those spaces and formatting them as well. I used `clang-format -i` to format these files.
2022-07-13[trace][intel pt] Add a cgroup filterGaurav Gaur
It turns out that cgroup filtering is relatively trivial and works really nicely. Thid diffs adds automatic cgroup filtering when in per-cpu mode, unless a new --disable-cgroup-filtering flag is passed in the start command. At least on Meta machines, all processes are spawned inside a cgroup by default, which comes super handy, because per cpu tracing is now much more precise. A manual test gave me this result - Without filtering: Total number of trace items: 36083 Total number of continuous executions found: 229 Number of continuous executions for this thread: 2 Total number of PSB blocks found: 98 Number of PSB blocks for this thread 2 Total number of unattributed PSB blocks found: 38 - With filtering: Total number of trace items: 87756 Total number of continuous executions found: 123 Number of continuous executions for this thread: 2 Total number of PSB blocks found: 10 Number of PSB blocks for this thread 3 Total number of unattributed PSB blocks found: 2 Filtering gives us great results. The number of instructions collected more than double (probalby because we have less noise in the trace), and we have much less unattributed PSBs blocks and unrelated PSBs in general. The ones that are unrelated probably belong to other processes in the same cgroup. Differential Revision: https://reviews.llvm.org/D129257
2022-06-16[trace][intelpt] Support system-wide tracing [20] - Rename some fields in ↵Walter Erquinigo
the schema As discusses offline with @jj10305, we are updating some naming used throughout the code, specially in the json schema - traceBuffer -> iptTrace - core -> cpu Differential Revision: https://reviews.llvm.org/D127817
2022-06-16[trace][intelpt] Support system-wide tracing [18] - some more improvementsWalter Erquinigo
This applies the changes requested for diff 12. - use DenseMap<ConstString, _> instead of std::unordered_map<ConstString, _>, which is more idiomatic and possibly performant. - deduplicate some code in Trace.cpp by using helper functions for fetching in maps - stop using size and offset when fetching binary data, because we in fact read the entire buffers all the time. If we ever need streaming, we can implement it then. Now, the size is used only to check that we are getting the correct amount of data. This is useful because in some cases determining the size doesn't involve fetching the actual data. - added back the x86_64 macro to the perf tests - added more documentation - simplified some file handling - fixed some comments Differential Revision: https://reviews.llvm.org/D127752
2022-06-15[trace][intelpt] Support system-wide tracing [12] - Support multi-core trace ↵Walter Erquinigo
load and save :q! This diff is massive, but it's because it connects the client with lldb-server and also ensures that the postmortem case works. - Flatten the postmortem trace schema. The reason is that the schema has become quite complex due to the new multicore case, which defeats the original purpose of having a schema that could work for every trace plug-in. At this point, it's better that each trace plug-in defines it's own full schema. This means that the only common field is "type". -- Because of this new approach, I merged the "common" trace load and saving functionalities into the IntelPT one. This simplified the code quite a bit. If we eventually implement another trace plug-in, we can see then what we could reuse. -- The new schema, which is flattened, has now better comments and is parsed better. A change I did was to disallow hex addresses, because they are a bit error prone. I'm asking now to print the address in decimal. -- Renamed "intel" to "GenuineIntel" in the schema because that's what you see in /proc/cpuinfo. - Implemented reading the context switch trace data buffer. I had to do some refactors to do that cleanly. -- A major change that I did here was to simplify the perf_event circular buffer reading logic. It was too complex. Maybe the original Intel author had something different in mind. - Implemented all the necessary bits to read trace.json files with per-core data. - Implemented all the necessary bits to save to disk per-core trace session. - Added a test that ensures that parsing and saving to disk works. Differential Revision: https://reviews.llvm.org/D126015
2022-06-15[trace][intelpt] Support system-wide tracing [9] - Collect and return ↵Walter Erquinigo
context switch traces - Add collection of context switches per cpu grouped with the per-cpu intel pt traces. - Move the state handling from the interl pt trace class to the PerfEvent one. - Add support for stopping and enabling perf event groups. - Return context switch entries as part of the jLLDBTraceGetState response. - Move the triggers of whenever the process stopped or resumed. Now the will-resume notification is in a better location, which will ensure that we'll capture the instructions that will be executed. - Remove IntelPTSingleBufferTraceUP. The unique pointer was useless. - Add unit tests Differential Revision: https://reviews.llvm.org/D125897
2022-06-15[trace][intelpt] Support system-wide tracing [8] - Improve the single buffer ↵Walter Erquinigo
perf_event configuration We were setting some events to be written in the data buffer of the perf_event, but we don't need that. Besides that, we don't need the data buffer to be larger than 1, so we can reduce its size. Differential Revision: https://reviews.llvm.org/D125850
2022-05-25Fix conversion error to ExpectedThomas Preud'homme
On Ubuntu 18.04 with GCC 7.5 Intel trace code fails to build due to failure to convert from lldb_private::process_linux::IntelPTPerThreadProcessTraceUP to Expected<lldb_private::process_linux::IntelPTPerThreadProcessTraceUP>. This commit explicitely marks those unique_ptr values as being moved which fixes the conversion error. Reviewed By: wallace Differential Revision: https://reviews.llvm.org/D126402
2022-05-17[trace][intelpt] Support system-wide tracing [5] - Disable/enable per-core ↵Walter Erquinigo
tracing based on the process state When tracing on per-core mode, we are tracing all processes, which means that after hitting a breakpoint, our process will stop running (thus producing no more tracing data) but other processes will continue writing to our trace buffers. This causes a big data loss for our trace. As a way to remediate this, I'm adding some logic to pause and unpause tracing based on the target's state. The earlier we do it the better, however, I'm not adding the trigger at the earliest possible point for simplicity of this diff. Later we can improve that part. Differential Revision: https://reviews.llvm.org/D124962
2022-05-17[trace][intelpt] Support system-wide tracing [4] - Support per core tracing ↵Walter Erquinigo
on lldb-server This diffs implements per-core tracing on lldb-server. It also includes tests that ensure that tracing can be initiated from the client and that the jLLDBGetState ppacket returns the list of trace buffers per core. This doesn't include any decoder changes. Finally, this makes some little changes here and there improving the existing code. A specific piece of code that can't reliably be tested is when tracing per core fails due to permissions. In this case we add a troubleshooting message and this is the manual test: ``` /proc/sys/kernel/perf_event_paranoid set to 1 (lldb) process trace start --per-core-tracing error: perf event syscall failed: Permission denied You might need that /proc/sys/kernel/perf_event_paranoid has a value of 0 or -1. `` Differential Revision: https://reviews.llvm.org/D124858
2022-05-09[lldb] Fix 7b73de9ec2b19df040c919d3004dfbead9b6ac59Walter Erquinigo
It turns out that the issue in https://lab.llvm.org/buildbot/#/builders/17/builds/21754 is that a size_t is attempted to be used interchangeably with uint64_t.
2022-05-09[lldb] Fix 7b73de9ec2b19df040c919d3004dfbead9b6ac59Walter Erquinigo
It turns out that the issue in https://lab.llvm.org/buildbot/#/builders/17/builds/21754 is that a size_t is attempted to be used interchangeably with uint64_t.
2022-05-09[lldb] Fix 7b73de9ec2b19df040c919d3004dfbead9b6ac59Walter Erquinigo
This commit causes https://lab.llvm.org/buildbot/#/builders/17/builds/21743 to fail seemingly because of bad handling of the PERF_ATTR_SIZE_VER5 symbol. This patch tries to handle better the absence of this symbol.
2022-05-09[trace][intelpt] Support system-wide tracing [3] - Refactor IntelPTThreadTraceWalter Erquinigo
I'm refactoring IntelPTThreadTrace into IntelPTSingleBufferTrace so that it can both single threads or single cores. In this diff I'm basically renaming the class, moving it to its own file, and removing all the pieces that are not used along with some basic cleanup. Differential Revision: https://reviews.llvm.org/D124648