[NFC][lldb][trace] Fix formatting of tracing files

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.
This commit is contained in:
Walter Erquinigo 2022-08-11 09:44:52 -07:00
parent d17de5479c
commit c4fb631cee
31 changed files with 151 additions and 167 deletions

View File

@ -1,4 +1,4 @@
//===-- IntelPTCollector.cpp ------------------------------------------------===//
//===-- IntelPTCollector.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -7,18 +7,14 @@
//===----------------------------------------------------------------------===//
#include "IntelPTCollector.h"
#include "Perf.h"
#include "Procfs.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "Procfs.h"
#include "lldb/Host/linux/Support.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cstddef>
#include <fcntl.h>

View File

@ -9,17 +9,14 @@
#ifndef liblldb_IntelPTCollector_H_
#define liblldb_IntelPTCollector_H_
#include "Perf.h"
#include "IntelPTMultiCoreTrace.h"
#include "IntelPTPerThreadProcessTrace.h"
#include "IntelPTSingleBufferTrace.h"
#include "Perf.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include "lldb/lldb-types.h"
#include <linux/perf_event.h>
#include <sys/mman.h>
#include <unistd.h>

View File

@ -7,10 +7,8 @@
//===----------------------------------------------------------------------===//
#include "IntelPTMultiCoreTrace.h"
#include "Procfs.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "Procfs.h"
using namespace lldb;
using namespace lldb_private;
@ -29,7 +27,8 @@ static Error IncludePerfEventParanoidMessageInError(Error &&error) {
return createStringError(
inconvertibleErrorCode(),
"%s\nYou might need to rerun as sudo or to set "
"/proc/sys/kernel/perf_event_paranoid to a value of 0 or -1. You can use `sudo sysctl -w kernel.perf_event_paranoid=-1` for that.",
"/proc/sys/kernel/perf_event_paranoid to a value of 0 or -1. You can use "
"`sudo sysctl -w kernel.perf_event_paranoid=-1` for that.",
toString(std::move(error)).c_str());
}
@ -110,8 +109,7 @@ TraceIntelPTGetStateResponse IntelPTMultiCoreTrace::GetState() {
state.using_cgroup_filtering = m_using_cgroup_filtering;
for (NativeThreadProtocol &thread : m_process.Threads())
state.traced_threads.push_back(
TraceThreadState{thread.GetID(), {}});
state.traced_threads.push_back(TraceThreadState{thread.GetID(), {}});
state.cpus.emplace();
ForEachCore([&](lldb::cpu_id_t cpu_id,

View File

@ -11,13 +11,10 @@
#include "IntelPTProcessTrace.h"
#include "IntelPTSingleBufferTrace.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include "lldb/lldb-types.h"
#include "llvm/Support/Error.h"
#include <memory>
namespace lldb_private {

View File

@ -10,7 +10,6 @@
#define liblldb_IntelPTProcessTrace_H_
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include <memory>
namespace lldb_private {

View File

@ -7,17 +7,13 @@
//===----------------------------------------------------------------------===//
#include "IntelPTSingleBufferTrace.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
#include <sstream>
#include <linux/perf_event.h>
#include <sstream>
#include <sys/syscall.h>
#include <unistd.h>

View File

@ -10,12 +10,9 @@
#define liblldb_IntelPTSingleBufferTrace_H_
#include "Perf.h"
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include "lldb/lldb-types.h"
#include "llvm/Support/Error.h"
#include <memory>
namespace lldb_private {

View File

@ -10,11 +10,9 @@
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "lldb/Host/linux/Support.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include <linux/version.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@ -27,7 +25,7 @@ using namespace llvm;
Expected<LinuxPerfZeroTscConversion>
lldb_private::process_linux::LoadPerfTscConversionParameters() {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
lldb::pid_t pid = getpid();
perf_event_attr attr;
memset(&attr, 0, sizeof(attr));
@ -175,13 +173,13 @@ ArrayRef<uint8_t> PerfEvent::GetDataBuffer() const {
perf_event_mmap_page &mmap_metadata = GetMetadataPage();
return {reinterpret_cast<uint8_t *>(m_metadata_data_base.get()) +
mmap_metadata.data_offset,
static_cast<size_t>(mmap_metadata.data_size)};
static_cast<size_t>(mmap_metadata.data_size)};
}
ArrayRef<uint8_t> PerfEvent::GetAuxBuffer() const {
perf_event_mmap_page &mmap_metadata = GetMetadataPage();
return {reinterpret_cast<uint8_t *>(m_aux_base.get()),
static_cast<size_t>(mmap_metadata.aux_size)};
static_cast<size_t>(mmap_metadata.aux_size)};
}
Expected<std::vector<uint8_t>> PerfEvent::GetReadOnlyDataBuffer() {

View File

@ -17,9 +17,7 @@
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include "lldb/lldb-types.h"
#include "llvm/Support/Error.h"
#include <chrono>
#include <cstdint>
#include <linux/perf_event.h>

View File

@ -9,12 +9,9 @@
// source/Plugins/Process/Linux/Procfs.h defines the symbols we need from
// sys/procfs.h on Android/Linux for all supported architectures.
#include <sys/ptrace.h>
#include "lldb/lldb-types.h"
#include "llvm/Support/Error.h"
#include <sys/ptrace.h>
#include <vector>
#ifdef __ANDROID__

View File

@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "CommandObjectTraceStartIntelPT.h"
#include "TraceIntelPT.h"
#include "TraceIntelPTConstants.h"
#include "lldb/Host/OptionParser.h"

View File

@ -7,11 +7,8 @@
//===----------------------------------------------------------------------===//
#include "DecodedThread.h"
#include <intel-pt.h>
#include "TraceCursorIntelPT.h"
#include <intel-pt.h>
#include <memory>
using namespace lldb;

View File

@ -9,16 +9,13 @@
#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_DECODEDTHREAD_H
#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_DECODEDTHREAD_H
#include <utility>
#include <vector>
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "intel-pt.h"
#include "lldb/Target/Trace.h"
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include "intel-pt.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include <utility>
#include <vector>
namespace lldb_private {
namespace trace_intel_pt {

View File

@ -6,9 +6,7 @@
//===----------------------------------------------------------------------===//
#include "LibiptDecoder.h"
#include "TraceIntelPT.h"
#include "lldb/Target/Process.h"
using namespace lldb;

View File

@ -12,7 +12,6 @@
#include "DecodedThread.h"
#include "PerfContextSwitchDecoder.h"
#include "forward-declarations.h"
#include "intel-pt.h"
namespace lldb_private {

View File

@ -11,9 +11,7 @@
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include "lldb/lldb-types.h"
#include "llvm/Support/Error.h"
#include <set>
#include <vector>

View File

@ -1,3 +1,11 @@
//===-- TaskTimer.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "TaskTimer.h"
using namespace lldb;

View File

@ -10,10 +10,8 @@
#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TASKTIMER_H
#include "lldb/lldb-types.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
#include <chrono>
#include <functional>
#include <unordered_map>

View File

@ -6,13 +6,10 @@
//===----------------------------------------------------------------------===//
#include "ThreadDecoder.h"
#include "llvm/Support/MemoryBuffer.h"
#include "../common/ThreadPostMortemTrace.h"
#include "LibiptDecoder.h"
#include "TraceIntelPT.h"
#include "llvm/Support/MemoryBuffer.h"
#include <utility>
using namespace lldb;

View File

@ -9,10 +9,9 @@
#ifndef LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H
#define LLDB_SOURCE_PLUGINS_TRACE_THREAD_DECODER_H
#include "intel-pt.h"
#include "DecodedThread.h"
#include "forward-declarations.h"
#include "intel-pt.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/FileSpec.h"

View File

@ -9,7 +9,6 @@
#include "TraceCursorIntelPT.h"
#include "DecodedThread.h"
#include "TraceIntelPT.h"
#include <cstdlib>
using namespace lldb;

View File

@ -8,11 +8,10 @@
#include "TraceIntelPT.h"
#include "TraceCursorIntelPT.h"
#include "../common/ThreadPostMortemTrace.h"
#include "CommandObjectTraceStartIntelPT.h"
#include "DecodedThread.h"
#include "TraceCursorIntelPT.h"
#include "TraceIntelPTBundleLoader.h"
#include "TraceIntelPTBundleSaver.h"
#include "TraceIntelPTConstants.h"

View File

@ -13,7 +13,6 @@
#include "ThreadDecoder.h"
#include "TraceIntelPTBundleLoader.h"
#include "TraceIntelPTMultiCpuDecoder.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-types.h"
#include "llvm/Support/raw_ostream.h"

View File

@ -12,7 +12,6 @@
#include "TraceIntelPT.h"
#include "TraceIntelPTConstants.h"
#include "TraceIntelPTJSONStructs.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Target/Process.h"

View File

@ -7,12 +7,10 @@
//===----------------------------------------------------------------------===//
#include "TraceIntelPTBundleSaver.h"
#include "PerfContextSwitchDecoder.h"
#include "TraceIntelPT.h"
#include "TraceIntelPTConstants.h"
#include "TraceIntelPTJSONStructs.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Target/Process.h"
@ -23,7 +21,6 @@
#include "llvm/ADT/None.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/JSON.h"
#include <fstream>
#include <iostream>
#include <sstream>

View File

@ -10,7 +10,6 @@
#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTBUNDLESAVER_H
#include "TraceIntelPT.h"
#include "TraceIntelPTJSONStructs.h"
namespace lldb_private {

View File

@ -9,8 +9,8 @@
#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_CONSTANTS_H
#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_CONSTANTS_H
#include "lldb/lldb-types.h"
#include <cstddef>
#include <llvm/ADT/Optional.h>
namespace lldb_private {

View File

@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "TraceIntelPTJSONStructs.h"
#include "llvm/Support/JSON.h"
#include <string>

View File

@ -9,13 +9,10 @@
#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H
#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTJSONSTRUCTS_H
#include "lldb/lldb-types.h"
#include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/JSON.h"
#include <intel-pt.h>
#include <vector>

View File

@ -7,9 +7,7 @@
//===----------------------------------------------------------------------===//
#include "TraceIntelPTMultiCpuDecoder.h"
#include "TraceIntelPT.h"
#include "llvm/Support/Error.h"
using namespace lldb;

View File

@ -6,92 +6,127 @@ include "../../../../source/Commands/OptionsBase.td"
// the API help message of TraceIntelPT::GetStartConfigurationHelp().
let Command = "thread trace start intel pt" in {
def thread_trace_start_intel_pt_size: Option<"size", "s">,
Group<1>,
Arg<"Value">,
Desc<"Trace size in bytes per thread. It must be a power of 2 greater "
"than or equal to 4096 (2^12). The trace is circular keeping "
"the most recent data. Defaults to 4096 bytes. It's possible to "
"specify size using multiples of unit bytes, e.g., 4KB, 1MB, 1MiB, "
"where 1K is 1024 bytes and 1M is 1048576 bytes.">;
def thread_trace_start_intel_pt_tsc: Option<"tsc", "t">,
Group<1>,
Desc<"Enable the use of TSC timestamps. This is supported on all devices "
"that support intel-pt.">;
def thread_trace_start_intel_pt_psb_period: Option<"psb-period", "p">,
Group<1>,
Arg<"Value">,
Desc<"This value defines the period in which PSB packets will be "
"generated. A PSB packet is a synchronization packet that contains a "
"TSC timestamp and the current absolute instruction pointer. "
"This parameter can only be used if "
"/sys/bus/event_source/devices/intel_pt/caps/psb_cyc is 1. Otherwise, "
"the PSB period will be defined by the processor. If supported, valid "
"values for this period can be found in "
"/sys/bus/event_source/devices/intel_pt/caps/psb_periods which "
"contains a hexadecimal number, whose bits represent valid values "
"e.g. if bit 2 is set, then value 2 is valid. The psb_period value is "
"converted to the approximate number of raw trace bytes between PSB "
"packets as: 2 ^ (value + 11), e.g. value 3 means 16KiB between PSB "
"packets. Defaults to 0 if supported.">;
def thread_trace_start_intel_pt_size
: Option<"size", "s">,
Group<1>,
Arg<"Value">,
Desc<
"Trace size in bytes per thread. It must be a power of 2 greater "
"than or equal to 4096 (2^12). The trace is circular keeping "
"the most recent data. Defaults to 4096 bytes. It's possible to "
"specify size using multiples of unit bytes, e.g., 4KB, 1MB, 1MiB, "
"where 1K is 1024 bytes and 1M is 1048576 bytes.">;
def thread_trace_start_intel_pt_tsc
: Option<"tsc", "t">,
Group<1>,
Desc<"Enable the use of TSC timestamps. This is supported on all "
"devices "
"that support intel-pt.">;
def thread_trace_start_intel_pt_psb_period
: Option<"psb-period", "p">,
Group<1>,
Arg<"Value">,
Desc<"This value defines the period in which PSB packets will be "
"generated. A PSB packet is a synchronization packet that "
"contains a "
"TSC timestamp and the current absolute instruction pointer. "
"This parameter can only be used if "
"/sys/bus/event_source/devices/intel_pt/caps/psb_cyc is 1. "
"Otherwise, "
"the PSB period will be defined by the processor. If supported, "
"valid "
"values for this period can be found in "
"/sys/bus/event_source/devices/intel_pt/caps/psb_periods which "
"contains a hexadecimal number, whose bits represent valid values "
"e.g. if bit 2 is set, then value 2 is valid. The psb_period "
"value is "
"converted to the approximate number of raw trace bytes between "
"PSB "
"packets as: 2 ^ (value + 11), e.g. value 3 means 16KiB between "
"PSB "
"packets. Defaults to 0 if supported.">;
}
let Command = "process trace start intel pt" in {
def process_trace_start_intel_pt_buffer_size: Option<"buffer-size", "s">,
Group<1>,
Arg<"Value">,
Desc<"Size in bytes used by each individual per-thread or per-cpu trace "
"buffer. It must be a power of 2 greater than or equal to 4096 (2^12) "
"bytes. It's possible to specify a unit for these bytes, like 4KB, "
"16KiB or 1MB. Lower case units are allowed for convenience.">;
def process_trace_start_intel_pt_per_cpu_tracing:
Option<"per-cpu-tracing", "c">,
Group<1>,
Desc<"Instead of having an individual trace buffer per thread, which uses "
"a number trace buffers proportional to the number of running "
"threads, this option triggers the collection on a per cpu core "
"basis. This effectively traces the entire activity on all cpus "
"using a limited amount of trace buffers regardless of the number of "
"threads. This might cause data loss for less frequent threads. This "
"option forces the capture of TSC timestamps (see --tsc). Also, this "
"option can't be used simulatenously with any other trace sessions "
"because of its system-wide nature.">;
def process_trace_start_intel_pt_process_size_limit:
Option<"total-size-limit", "l">,
Group<1>,
Arg<"Value">,
Desc<"Maximum total trace size per process in bytes. This limit applies to "
"the sum of the sizes of all thread and cpu traces of this process, "
"excluding the ones created with the \"thread trace start\" command. "
"Whenever a thread is attempted to be traced due to this command and "
"the limit would be reached, the process is stopped with a "
"\"processor trace\" reason, so that the user can retrace the process "
"if needed. Defaults to 500MB. It's possible to specify a unit for "
"these bytes, like 4KB, 16KiB or 1MB. Lower case units are allowed "
"for convenience.">;
def process_trace_start_intel_pt_tsc: Option<"tsc", "t">,
Group<1>,
Desc<"Enable the use of TSC timestamps. This is supported on all devices "
"that support intel-pt.">;
def process_trace_start_intel_pt_psb_period: Option<"psb-period", "p">,
Group<1>,
Arg<"Value">,
Desc<"This value defines the period in which PSB packets will be "
"generated. A PSB packet is a synchronization packet that contains a "
"TSC timestamp and the current absolute instruction pointer. "
"This parameter can only be used if "
"/sys/bus/event_source/devices/intel_pt/caps/psb_cyc is 1. Otherwise, "
"the PSB period will be defined by the processor. If supported, valid "
"values for this period can be found in "
"/sys/bus/event_source/devices/intel_pt/caps/psb_periods which "
"contains a hexadecimal number, whose bits represent valid values "
"e.g. if bit 2 is set, then value 2 is valid. The psb_period value is "
"converted to the approximate number of raw trace bytes between PSB "
"packets as: 2 ^ (value + 11), e.g. value 3 means 16KiB between PSB "
"packets. Defaults to 0 if supported.">;
def process_trace_start_intel_pt_disable_cgroup_filtering:
Option<"disable-cgroup-filtering", "d">,
Desc<"Disable the automatic cgroup filtering that is applied if --per-cpu "
"is provided. Cgroup filtering allows collecting intel pt data "
"exclusively of processes of the same cgroup as the target.">;
def process_trace_start_intel_pt_buffer_size
: Option<"buffer-size", "s">,
Group<1>,
Arg<"Value">,
Desc<
"Size in bytes used by each individual per-thread or per-cpu trace "
"buffer. It must be a power of 2 greater than or equal to 4096 "
"(2^12) "
"bytes. It's possible to specify a unit for these bytes, like 4KB, "
"16KiB or 1MB. Lower case units are allowed for convenience.">;
def process_trace_start_intel_pt_per_cpu_tracing
: Option<"per-cpu-tracing", "c">,
Group<1>,
Desc<
"Instead of having an individual trace buffer per thread, which "
"uses "
"a number trace buffers proportional to the number of running "
"threads, this option triggers the collection on a per cpu core "
"basis. This effectively traces the entire activity on all cpus "
"using a limited amount of trace buffers regardless of the number "
"of "
"threads. This might cause data loss for less frequent threads. "
"This "
"option forces the capture of TSC timestamps (see --tsc). Also, "
"this "
"option can't be used simulatenously with any other trace sessions "
"because of its system-wide nature.">;
def process_trace_start_intel_pt_process_size_limit
: Option<"total-size-limit", "l">,
Group<1>,
Arg<"Value">,
Desc<
"Maximum total trace size per process in bytes. This limit applies "
"to "
"the sum of the sizes of all thread and cpu traces of this "
"process, "
"excluding the ones created with the \"thread trace start\" "
"command. "
"Whenever a thread is attempted to be traced due to this command "
"and "
"the limit would be reached, the process is stopped with a "
"\"processor trace\" reason, so that the user can retrace the "
"process "
"if needed. Defaults to 500MB. It's possible to specify a unit for "
"these bytes, like 4KB, 16KiB or 1MB. Lower case units are allowed "
"for convenience.">;
def process_trace_start_intel_pt_tsc
: Option<"tsc", "t">,
Group<1>,
Desc<"Enable the use of TSC timestamps. This is supported on all "
"devices "
"that support intel-pt.">;
def process_trace_start_intel_pt_psb_period
: Option<"psb-period", "p">,
Group<1>,
Arg<"Value">,
Desc<"This value defines the period in which PSB packets will be "
"generated. A PSB packet is a synchronization packet that "
"contains a "
"TSC timestamp and the current absolute instruction pointer. "
"This parameter can only be used if "
"/sys/bus/event_source/devices/intel_pt/caps/psb_cyc is 1. "
"Otherwise, "
"the PSB period will be defined by the processor. If supported, "
"valid "
"values for this period can be found in "
"/sys/bus/event_source/devices/intel_pt/caps/psb_periods which "
"contains a hexadecimal number, whose bits represent valid values "
"e.g. if bit 2 is set, then value 2 is valid. The psb_period "
"value is "
"converted to the approximate number of raw trace bytes between "
"PSB "
"packets as: 2 ^ (value + 11), e.g. value 3 means 16KiB between "
"PSB "
"packets. Defaults to 0 if supported.">;
def process_trace_start_intel_pt_disable_cgroup_filtering
: Option<"disable-cgroup-filtering", "d">,
Desc<"Disable the automatic cgroup filtering that is applied if "
"--per-cpu "
"is provided. Cgroup filtering allows collecting intel pt data "
"exclusively of processes of the same cgroup as the target.">;
}