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
// might result in less data available for less frequent threads. See
// "perCoreTracing" below for more information.
//
-// Each actual trace buffer, either from "process tracing" or "thread tracing",
-// is stored in an in-memory circular buffer, which keeps the most recent data.
+// Each actual intel pt trace buffer, either from "process tracing" or "thread
+// tracing", is stored in an in-memory circular buffer, which keeps the most
+// recent data.
//
// Additional params in the input schema:
// {
-// "traceBufferSize": <decimal integer>,
-// Size in bytes used by each individual per-thread or per-core trace
+// "iptTraceSize": <decimal integer>,
+// 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.
//
// /* process tracing only */
// "processBufferSizeLimit": <decimal integer>,
// Maximum total buffer size per process in bytes.
-// This limit applies to the sum of the sizes of all thread or core
+// This limit applies to the sum of the sizes of all thread or cpu core
// buffers for the current process, excluding the ones started with
// "thread tracing".
//
// Size in bytes of this thread data.
// },
// ],
-// "cores"?: [
+// "cpus"?: [
// "id": <decimal integer>,
// Identifier for this CPU logical core.
// "binaryData": [
//
// INTEL PT
//
-// If per-core process tracing is enabled, "tracedThreads" will contain all
+// If per-cpu process tracing is enabled, "tracedThreads" will contain all
// the threads of the process without any trace buffers. Besides that, the
-// "cores" field will also be returned with per core trace buffers.
-// A side effect of per-core tracing is that all the threads of unrelated
+// "cpus" field will also be returned with per cpu core trace buffers.
+// A side effect of per-cpu tracing is that all the threads of unrelated
// processes will also be traced, thus polluting the tracing data.
//
// Binary data kinds:
-// - traceBuffer: trace buffer for a thread or a core.
-// - perfContextSwitchTrace: context switch trace for a core generated by
+// - iptTrace: trace buffer for a thread or a cpu.
+// - perfContextSwitchTrace: context switch trace for a cpu generated by
// perf_event_open.
// - procfsCpuInfo: contents of the /proc/cpuinfo file.
//
// Tracing technology name, e.g. intel-pt, arm-etm.
// "kind": <string>,
// Identifier for the data.
-// "coreId": <Optional decimal>,
+// "cpuId": <Optional decimal>,
// Core id in decimal if the data belongs to a CPU core.
// "tid"?: <Optional decimal>,
// Tid in decimal if the data belongs to a thread.
// }
-//
-// INTEL PT
-//
-// Binary data kinds:
-// - traceBuffer: trace buffer for a thread or a core.
-// - procfsCpuInfo: contents of the /proc/cpuinfo file.
//----------------------------------------------------------------------
send packet: jLLDBTraceGetBinaryData:{"type":<type>,"kind":<query>,"tid":<tid>,"offset":<offset>,"size":<size>}]
"threads": [
{
"tid": 815455,
- "traceBuffer": "trace.file" # raw thread-specific trace from the AUX buffer
+ "iptTrace": "trace.file" # raw thread-specific trace from the AUX buffer
}
],
"modules": [ # this are all the shared libraries + the main executable
/// - The plug-in name (this allows a specific plug-in to be selected)
/// - Architecture or target triple
/// - one or more paths to the trace data file on disk
- /// - core trace data
+ /// - cpu trace data
/// - thread events or related information
/// - shared library load information to use for this trace data that
/// allows a target to be created so the trace information can be
using OnBinaryDataReadCallback =
std::function<llvm::Error(llvm::ArrayRef<uint8_t> data)>;
- using OnCoresBinaryDataReadCallback = std::function<llvm::Error(
- const llvm::DenseMap<lldb::core_id_t, llvm::ArrayRef<uint8_t>>
- &core_to_data)>;
+ using OnCpusBinaryDataReadCallback = std::function<llvm::Error(
+ const llvm::DenseMap<lldb::cpu_id_t, llvm::ArrayRef<uint8_t>>
+ &cpu_to_data)>;
/// Fetch binary data associated with a thread, either live or postmortem, and
/// pass it to the given callback. The reason of having a callback is to free
llvm::Error OnThreadBinaryDataRead(lldb::tid_t tid, llvm::StringRef kind,
OnBinaryDataReadCallback callback);
- /// Fetch binary data associated with a core, either live or postmortem, and
+ /// Fetch binary data associated with a cpu, either live or postmortem, and
/// pass it to the given callback. The reason of having a callback is to free
/// the caller from having to manage the life cycle of the data and to hide
/// the different data fetching procedures that exist for live and post mortem
- /// cores.
+ /// cpus.
///
/// The fetched data is not persisted after the callback is invoked.
///
- /// \param[in] core_id
- /// The core who owns the data.
+ /// \param[in] cpu_id
+ /// The cpu who owns the data.
///
/// \param[in] kind
/// The kind of data to read.
/// \return
/// An \a llvm::Error if the data couldn't be fetched, or the return value
/// of the callback, otherwise.
- llvm::Error OnCoreBinaryDataRead(lldb::core_id_t core_id,
- llvm::StringRef kind,
- OnBinaryDataReadCallback callback);
+ llvm::Error OnCpuBinaryDataRead(lldb::cpu_id_t cpu_id, llvm::StringRef kind,
+ OnBinaryDataReadCallback callback);
- /// Similar to \a OnCoreBinaryDataRead but this is able to fetch the same data
- /// from all cores at once.
- llvm::Error OnAllCoresBinaryDataRead(llvm::StringRef kind,
- OnCoresBinaryDataReadCallback callback);
+ /// Similar to \a OnCpuBinaryDataRead but this is able to fetch the same data
+ /// from all cpus at once.
+ llvm::Error OnAllCpusBinaryDataRead(llvm::StringRef kind,
+ OnCpusBinaryDataReadCallback callback);
/// \return
/// All the currently traced processes.
std::vector<Process *> GetAllProcesses();
/// \return
- /// The list of cores being traced. Might be empty depending on the
+ /// The list of cpus being traced. Might be empty depending on the
/// plugin.
- llvm::ArrayRef<lldb::core_id_t> GetTracedCores();
+ llvm::ArrayRef<lldb::cpu_id_t> GetTracedCpus();
/// Helper method for reading a data file and passing its data to the given
/// callback.
llvm::Error OnLiveThreadBinaryDataRead(lldb::tid_t tid, llvm::StringRef kind,
OnBinaryDataReadCallback callback);
- /// Implementation of \a OnLiveBinaryDataRead() for live cores.
- llvm::Error OnLiveCoreBinaryDataRead(lldb::core_id_t core,
- llvm::StringRef kind,
- OnBinaryDataReadCallback callback);
+ /// Implementation of \a OnLiveBinaryDataRead() for live cpus.
+ llvm::Error OnLiveCpuBinaryDataRead(lldb::cpu_id_t cpu, llvm::StringRef kind,
+ OnBinaryDataReadCallback callback);
/// Implementation of \a OnThreadBinaryDataRead() for post mortem threads.
llvm::Error
OnPostMortemThreadBinaryDataRead(lldb::tid_t tid, llvm::StringRef kind,
OnBinaryDataReadCallback callback);
- /// Implementation of \a OnCoreBinaryDataRead() for post mortem cores.
- llvm::Error OnPostMortemCoreBinaryDataRead(lldb::core_id_t core_id,
- llvm::StringRef kind,
- OnBinaryDataReadCallback callback);
+ /// Implementation of \a OnCpuBinaryDataRead() for post mortem cpus.
+ llvm::Error OnPostMortemCpuBinaryDataRead(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind,
+ OnBinaryDataReadCallback callback);
/// Get the file path containing data of a postmortem thread given a data
/// identifier.
llvm::Expected<FileSpec> GetPostMortemThreadDataFile(lldb::tid_t tid,
llvm::StringRef kind);
- /// Get the file path containing data of a postmortem core given a data
+ /// Get the file path containing data of a postmortem cpu given a data
/// identifier.
///
- /// \param[in] core_id
- /// The core whose data is requested.
+ /// \param[in] cpu_id
+ /// The cpu whose data is requested.
///
/// \param[in] kind
/// The kind of data requested.
/// \return
/// The file spec containing the requested data, or an \a llvm::Error in
/// case of failures.
- llvm::Expected<FileSpec> GetPostMortemCoreDataFile(lldb::core_id_t core_id,
- llvm::StringRef kind);
+ llvm::Expected<FileSpec> GetPostMortemCpuDataFile(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind);
/// Associate a given thread with a data file using a data identifier.
///
void SetPostMortemThreadDataFile(lldb::tid_t tid, llvm::StringRef kind,
FileSpec file_spec);
- /// Associate a given core with a data file using a data identifier.
+ /// Associate a given cpu with a data file using a data identifier.
///
- /// \param[in] core_id
- /// The core associated with the data file.
+ /// \param[in] cpu_id
+ /// The cpu associated with the data file.
///
/// \param[in] kind
/// The kind of data being registered.
///
/// \param[in] file_spec
/// The path of the data file.
- void SetPostMortemCoreDataFile(lldb::core_id_t core_id, llvm::StringRef kind,
- FileSpec file_spec);
+ void SetPostMortemCpuDataFile(lldb::cpu_id_t cpu_id, llvm::StringRef kind,
+ FileSpec file_spec);
/// Get binary data of a live thread given a data identifier.
///
llvm::Expected<std::vector<uint8_t>>
GetLiveThreadBinaryData(lldb::tid_t tid, llvm::StringRef kind);
- /// Get binary data of a live core given a data identifier.
+ /// Get binary data of a live cpu given a data identifier.
///
- /// \param[in] core_id
- /// The core whose data is requested.
+ /// \param[in] cpu_id
+ /// The cpu whose data is requested.
///
/// \param[in] kind
/// The kind of data requested.
/// A vector of bytes with the requested data, or an \a llvm::Error in
/// case of failures.
llvm::Expected<std::vector<uint8_t>>
- GetLiveCoreBinaryData(lldb::core_id_t core_id, llvm::StringRef kind);
+ GetLiveCpuBinaryData(lldb::cpu_id_t cpu_id, llvm::StringRef kind);
/// Get binary data of the current process given a data identifier.
///
llvm::Optional<uint64_t> GetLiveThreadBinaryDataSize(lldb::tid_t tid,
llvm::StringRef kind);
- /// Get the size of the data returned by \a GetLiveCoreBinaryData
- llvm::Optional<uint64_t> GetLiveCoreBinaryDataSize(lldb::core_id_t core_id,
- llvm::StringRef kind);
+ /// Get the size of the data returned by \a GetLiveCpuBinaryData
+ llvm::Optional<uint64_t> GetLiveCpuBinaryDataSize(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind);
/// Get the size of the data returned by \a GetLiveProcessBinaryData
llvm::Optional<uint64_t> GetLiveProcessBinaryDataSize(llvm::StringRef kind);
/// Constructor for post mortem processes
Trace(llvm::ArrayRef<lldb::ProcessSP> postmortem_processes,
- llvm::Optional<std::vector<lldb::core_id_t>> postmortem_cores);
+ llvm::Optional<std::vector<lldb::cpu_id_t>> postmortem_cpus);
/// Constructor for a live process
Trace(Process &live_process) : m_live_process(&live_process) {}
llvm::DenseMap<lldb::tid_t, llvm::DenseMap<ConstString, uint64_t>>
live_thread_data;
- /// core id -> data kind -> size
- llvm::DenseMap<lldb::core_id_t, llvm::DenseMap<ConstString, uint64_t>>
- live_core_data_sizes;
- /// core id -> data kind -> bytes
- llvm::DenseMap<lldb::core_id_t,
+ /// cpu id -> data kind -> size
+ llvm::DenseMap<lldb::cpu_id_t, llvm::DenseMap<ConstString, uint64_t>>
+ live_cpu_data_sizes;
+ /// cpu id -> data kind -> bytes
+ llvm::DenseMap<lldb::cpu_id_t,
llvm::DenseMap<ConstString, std::vector<uint8_t>>>
- live_core_data;
+ live_cpu_data;
/// data kind -> size
llvm::DenseMap<ConstString, uint64_t> live_process_data;
/// \}
- /// The list of cores being traced. Might be \b None depending on the
+ /// The list of cpus being traced. Might be \b None depending on the
/// plug-in.
- llvm::Optional<std::vector<lldb::core_id_t>> cores;
+ llvm::Optional<std::vector<lldb::cpu_id_t>> cpus;
/// Postmortem traces can specific additional data files, which are
/// represented in this variable using a data kind identifier for each file.
llvm::DenseMap<lldb::tid_t, llvm::DenseMap<ConstString, FileSpec>>
postmortem_thread_data;
- /// core id -> data kind -> file
- llvm::DenseMap<lldb::core_id_t, llvm::DenseMap<ConstString, FileSpec>>
- postmortem_core_data;
+ /// cpu id -> data kind -> file
+ llvm::DenseMap<lldb::cpu_id_t, llvm::DenseMap<ConstString, FileSpec>>
+ postmortem_cpu_data;
/// \}
llvm::json::Value toJSON(const TraceThreadState &packet);
-struct TraceCoreState {
- lldb::core_id_t core_id;
+struct TraceCpuState {
+ lldb::cpu_id_t id;
/// List of binary data objects for this core.
std::vector<TraceBinaryData> binary_data;
};
-bool fromJSON(const llvm::json::Value &value, TraceCoreState &packet,
+bool fromJSON(const llvm::json::Value &value, TraceCpuState &packet,
llvm::json::Path path);
-llvm::json::Value toJSON(const TraceCoreState &packet);
+llvm::json::Value toJSON(const TraceCpuState &packet);
struct TraceGetStateResponse {
std::vector<TraceThreadState> traced_threads;
std::vector<TraceBinaryData> process_binary_data;
- llvm::Optional<std::vector<TraceCoreState>> cores;
+ llvm::Optional<std::vector<TraceCpuState>> cpus;
llvm::Optional<std::vector<std::string>> warnings;
void AddWarning(llvm::StringRef warning);
/// Optional tid if the data is related to a thread.
llvm::Optional<lldb::tid_t> tid;
/// Optional core id if the data is related to a cpu core.
- llvm::Optional<lldb::core_id_t> core_id;
+ llvm::Optional<lldb::cpu_id_t> cpu_id;
};
bool fromJSON(const llvm::json::Value &value,
// List of data kinds used by jLLDBGetState and jLLDBGetBinaryData.
struct IntelPTDataKinds {
static const char *kProcFsCpuInfo;
- static const char *kTraceBuffer;
+ static const char *kIptTrace;
static const char *kPerfContextSwitchTrace;
};
/// \{
struct TraceIntelPTStartRequest : TraceStartRequest {
/// Size in bytes to use for each thread's trace buffer.
- uint64_t trace_buffer_size;
+ uint64_t ipt_trace_size;
/// Whether to enable TSC
bool enable_tsc;
/// then a "tracing" stop event is triggered.
llvm::Optional<uint64_t> process_buffer_size_limit;
- /// Whether to have a trace buffer per thread or per cpu core.
- llvm::Optional<bool> per_core_tracing;
+ /// Whether to have a trace buffer per thread or per cpu cpu.
+ llvm::Optional<bool> per_cpu_tracing;
- bool IsPerCoreTracing() const;
+ bool IsPerCpuTracing() const;
};
bool fromJSON(const llvm::json::Value &value, TraceIntelPTStartRequest &packet,
typedef int32_t watch_id_t;
typedef void *opaque_compiler_type_t;
typedef uint64_t queue_id_t;
-typedef uint32_t core_id_t; // CPU core id
+typedef uint32_t cpu_id_t; // CPU core id
} // namespace lldb
#endif // LLDB_LLDB_TYPES_H
if 'intel-pt' not in configuration.enabled_plugins:
self.skipTest("The intel-pt test plugin is not enabled")
- def skipIfPerCoreTracingIsNotSupported(self):
+ def skipIfPerCpuTracingIsNotSupported(self):
def is_supported():
try:
with open("/proc/sys/kernel/perf_event_paranoid", "r") as permissions:
except:
return False
if not is_supported():
- self.skipTest("Per core tracing is not supported. You need "
+ self.skipTest("Per cpu tracing is not supported. You need "
"/proc/sys/kernel/perf_event_paranoid to be 0 or -1.")
def getTraceOrCreate(self):
else:
self.assertSuccess(sberror)
- def createConfiguration(self, traceBufferSize=None,
+ def createConfiguration(self, iptTraceSize=None,
processBufferSizeLimit=None, enableTsc=False,
- psbPeriod=None, perCoreTracing=False):
+ psbPeriod=None, perCpuTracing=False):
obj = {}
if processBufferSizeLimit is not None:
obj["processBufferSizeLimit"] = processBufferSizeLimit
- if traceBufferSize is not None:
- obj["traceBufferSize"] = traceBufferSize
+ if iptTraceSize is not None:
+ obj["iptTraceSize"] = iptTraceSize
if psbPeriod is not None:
obj["psbPeriod"] = psbPeriod
obj["enableTsc"] = enableTsc
- obj["perCoreTracing"] = perCoreTracing
+ obj["perCpuTracing"] = perCpuTracing
configuration = lldb.SBStructuredData()
configuration.SetFromJSON(json.dumps(obj))
return configuration
def traceStartThread(self, thread=None, error=False, substrs=None,
- traceBufferSize=None, enableTsc=False, psbPeriod=None):
+ iptTraceSize=None, enableTsc=False, psbPeriod=None):
if self.USE_SB_API:
trace = self.getTraceOrCreate()
thread = thread if thread is not None else self.thread()
configuration = self.createConfiguration(
- traceBufferSize=traceBufferSize, enableTsc=enableTsc,
+ iptTraceSize=iptTraceSize, enableTsc=enableTsc,
psbPeriod=psbPeriod)
self.assertSBError(trace.Start(thread, configuration), error)
else:
command = "thread trace start"
if thread is not None:
command += " " + str(thread.GetIndexID())
- if traceBufferSize is not None:
- command += " -s " + str(traceBufferSize)
+ if iptTraceSize is not None:
+ command += " -s " + str(iptTraceSize)
if enableTsc:
command += " --tsc"
if psbPeriod is not None:
def traceStartProcess(self, processBufferSizeLimit=None, error=False,
substrs=None, enableTsc=False, psbPeriod=None,
- perCoreTracing=False):
+ perCpuTracing=False):
if self.USE_SB_API:
trace = self.getTraceOrCreate()
configuration = self.createConfiguration(
processBufferSizeLimit=processBufferSizeLimit, enableTsc=enableTsc,
- psbPeriod=psbPeriod, perCoreTracing=perCoreTracing)
+ psbPeriod=psbPeriod, perCpuTracing=perCpuTracing)
self.assertSBError(trace.Start(configuration), error=error)
else:
command = "process trace start"
command += " --tsc"
if psbPeriod is not None:
command += " --psb-period " + str(psbPeriod)
- if perCoreTracing:
- command += " --per-core-tracing"
+ if perCpuTracing:
+ command += " --per-cpu-tracing"
self.expect(command, error=error, substrs=substrs)
def traceStopProcess(self):
inconvertibleErrorCode(),
"Process currently traced. Stop process tracing first");
}
- if (request.IsPerCoreTracing()) {
+ if (request.IsPerCpuTracing()) {
if (m_thread_traces.GetTracedThreadsCount() > 0)
return createStringError(
inconvertibleErrorCode(),
m_thread_traces.ForEachThread(
[&](lldb::tid_t tid, const IntelPTSingleBufferTrace &thread_trace) {
- state.traced_threads.push_back({tid,
- {{IntelPTDataKinds::kTraceBuffer,
- thread_trace.GetTraceBufferSize()}}});
+ state.traced_threads.push_back(
+ {tid,
+ {{IntelPTDataKinds::kIptTrace, thread_trace.GetIptTraceSize()}}});
});
if (Expected<LinuxPerfZeroTscConversion &> tsc_conversion =
return createStringError(
inconvertibleErrorCode(),
- formatv("Can't fetch data kind {0} for core_id {1}, tid {2} and "
+ formatv("Can't fetch data kind {0} for cpu_id {1}, tid {2} and "
"\"process tracing\" mode {3}",
- request.kind, request.core_id, request.tid,
+ request.kind, request.cpu_id, request.tid,
m_process_trace_up ? "enabled" : "not enabled"));
}
using namespace process_linux;
using namespace llvm;
-static bool IsTotalBufferLimitReached(ArrayRef<core_id_t> cores,
+static bool IsTotalBufferLimitReached(ArrayRef<cpu_id_t> cores,
const TraceIntelPTStartRequest &request) {
- uint64_t required = cores.size() * request.trace_buffer_size;
+ uint64_t required = cores.size() * request.ipt_trace_size;
uint64_t limit = request.process_buffer_size_limit.getValueOr(
std::numeric_limits<uint64_t>::max());
return required > limit;
Expected<std::unique_ptr<IntelPTMultiCoreTrace>>
IntelPTMultiCoreTrace::StartOnAllCores(const TraceIntelPTStartRequest &request,
NativeProcessProtocol &process) {
- Expected<ArrayRef<core_id_t>> core_ids = GetAvailableLogicalCoreIDs();
- if (!core_ids)
- return core_ids.takeError();
+ Expected<ArrayRef<cpu_id_t>> cpu_ids = GetAvailableLogicalCoreIDs();
+ if (!cpu_ids)
+ return cpu_ids.takeError();
- if (IsTotalBufferLimitReached(*core_ids, request))
+ if (IsTotalBufferLimitReached(*cpu_ids, request))
return createStringError(
inconvertibleErrorCode(),
"The process can't be traced because the process trace size limit "
"has been reached. Consider retracing with a higher limit.");
- DenseMap<core_id_t, std::pair<IntelPTSingleBufferTrace, ContextSwitchTrace>>
+ DenseMap<cpu_id_t, std::pair<IntelPTSingleBufferTrace, ContextSwitchTrace>>
traces;
- for (core_id_t core_id : *core_ids) {
+ for (cpu_id_t cpu_id : *cpu_ids) {
Expected<IntelPTSingleBufferTrace> core_trace =
- IntelPTSingleBufferTrace::Start(request, /*tid=*/None, core_id,
+ IntelPTSingleBufferTrace::Start(request, /*tid=*/None, cpu_id,
/*disabled=*/true);
if (!core_trace)
return IncludePerfEventParanoidMessageInError(core_trace.takeError());
if (Expected<PerfEvent> context_switch_trace =
- CreateContextSwitchTracePerfEvent(core_id,
+ CreateContextSwitchTracePerfEvent(cpu_id,
&core_trace->GetPerfEvent())) {
- traces.try_emplace(core_id,
+ traces.try_emplace(cpu_id,
std::make_pair(std::move(*core_trace),
std::move(*context_switch_trace)));
} else {
}
void IntelPTMultiCoreTrace::ForEachCore(
- std::function<void(core_id_t core_id, IntelPTSingleBufferTrace &core_trace)>
+ std::function<void(cpu_id_t cpu_id, IntelPTSingleBufferTrace &core_trace)>
callback) {
for (auto &it : m_traces_per_core)
callback(it.first, it.second.first);
}
void IntelPTMultiCoreTrace::ForEachCore(
- std::function<void(core_id_t core_id,
- IntelPTSingleBufferTrace &intelpt_trace,
+ std::function<void(cpu_id_t cpu_id, IntelPTSingleBufferTrace &intelpt_trace,
ContextSwitchTrace &context_switch_trace)>
callback) {
for (auto &it : m_traces_per_core)
}
void IntelPTMultiCoreTrace::ProcessDidStop() {
- ForEachCore([](core_id_t core_id, IntelPTSingleBufferTrace &core_trace) {
+ ForEachCore([](cpu_id_t cpu_id, IntelPTSingleBufferTrace &core_trace) {
if (Error err = core_trace.Pause()) {
LLDB_LOG_ERROR(GetLog(POSIXLog::Trace), std::move(err),
- "Unable to pause the core trace for core {0}", core_id);
+ "Unable to pause the core trace for core {0}", cpu_id);
}
});
}
void IntelPTMultiCoreTrace::ProcessWillResume() {
- ForEachCore([](core_id_t core_id, IntelPTSingleBufferTrace &core_trace) {
+ ForEachCore([](cpu_id_t cpu_id, IntelPTSingleBufferTrace &core_trace) {
if (Error err = core_trace.Resume()) {
LLDB_LOG_ERROR(GetLog(POSIXLog::Trace), std::move(err),
- "Unable to resume the core trace for core {0}", core_id);
+ "Unable to resume the core trace for core {0}", cpu_id);
}
});
}
state.traced_threads.push_back(
TraceThreadState{m_process.GetThreadAtIndex(i)->GetID(), {}});
- state.cores.emplace();
- ForEachCore([&](lldb::core_id_t core_id,
+ state.cpus.emplace();
+ ForEachCore([&](lldb::cpu_id_t cpu_id,
const IntelPTSingleBufferTrace &core_trace,
const ContextSwitchTrace &context_switch_trace) {
- state.cores->push_back(
- {core_id,
- {{IntelPTDataKinds::kTraceBuffer, core_trace.GetTraceBufferSize()},
+ state.cpus->push_back(
+ {cpu_id,
+ {{IntelPTDataKinds::kIptTrace, core_trace.GetIptTraceSize()},
{IntelPTDataKinds::kPerfContextSwitchTrace,
context_switch_trace.GetEffectiveDataBufferSize()}}});
});
Expected<Optional<std::vector<uint8_t>>>
IntelPTMultiCoreTrace::TryGetBinaryData(
const TraceGetBinaryDataRequest &request) {
- if (!request.core_id)
+ if (!request.cpu_id)
return None;
- auto it = m_traces_per_core.find(*request.core_id);
+ auto it = m_traces_per_core.find(*request.cpu_id);
if (it == m_traces_per_core.end())
return createStringError(
inconvertibleErrorCode(),
- formatv("Core {0} is not being traced", *request.core_id));
+ formatv("Core {0} is not being traced", *request.cpu_id));
- if (request.kind == IntelPTDataKinds::kTraceBuffer)
- return it->second.first.GetTraceBuffer();
+ if (request.kind == IntelPTDataKinds::kIptTrace)
+ return it->second.first.GetIptTrace();
if (request.kind == IntelPTDataKinds::kPerfContextSwitchTrace)
return it->second.second.GetReadOnlyDataBuffer();
return None;
/// Execute the provided callback on each core that is being traced.
///
- /// \param[in] callback.core_id
+ /// \param[in] callback.cpu_id
/// The core id that is being traced.
///
/// \param[in] callback.core_trace
/// The single-buffer trace instance for the given core.
- void ForEachCore(std::function<void(lldb::core_id_t core_id,
+ void ForEachCore(std::function<void(lldb::cpu_id_t cpu_id,
IntelPTSingleBufferTrace &core_trace)>
callback);
/// Execute the provided callback on each core that is being traced.
///
- /// \param[in] callback.core_id
+ /// \param[in] callback.cpu_id
/// The core id that is being traced.
///
/// \param[in] callback.intelpt_trace
///
/// \param[in] callback.context_switch_trace
/// The perf event collecting context switches for the given core.
- void ForEachCore(std::function<void(lldb::core_id_t core_id,
+ void ForEachCore(std::function<void(lldb::cpu_id_t cpu_id,
IntelPTSingleBufferTrace &intelpt_trace,
ContextSwitchTrace &context_switch_trace)>
callback);
/// This assumes that all underlying perf_events for each core are part of the
/// same perf event group.
IntelPTMultiCoreTrace(
- llvm::DenseMap<lldb::core_id_t,
+ llvm::DenseMap<lldb::cpu_id_t,
std::pair<IntelPTSingleBufferTrace, ContextSwitchTrace>>
&&traces_per_core,
NativeProcessProtocol &process)
: m_traces_per_core(std::move(traces_per_core)), m_process(process) {}
- llvm::DenseMap<lldb::core_id_t,
+ llvm::DenseMap<lldb::cpu_id_t,
std::pair<IntelPTSingleBufferTrace, ContextSwitchTrace>>
m_traces_per_core;
}
Error IntelPTPerThreadProcessTrace::TraceStart(lldb::tid_t tid) {
- if (m_thread_traces.GetTotalBufferSize() +
- m_tracing_params.trace_buffer_size >
+ if (m_thread_traces.GetTotalBufferSize() + m_tracing_params.ipt_trace_size >
static_cast<size_t>(*m_tracing_params.process_buffer_size_limit))
return createStringError(
inconvertibleErrorCode(),
TraceIntelPTGetStateResponse state;
m_thread_traces.ForEachThread(
[&](lldb::tid_t tid, const IntelPTSingleBufferTrace &thread_trace) {
- state.traced_threads.push_back({tid,
- {{IntelPTDataKinds::kTraceBuffer,
- thread_trace.GetTraceBufferSize()}}});
+ state.traced_threads.push_back(
+ {tid,
+ {{IntelPTDataKinds::kIptTrace, thread_trace.GetIptTraceSize()}}});
});
return state;
}
}
#endif
-size_t IntelPTSingleBufferTrace::GetTraceBufferSize() const {
+size_t IntelPTSingleBufferTrace::GetIptTraceSize() const {
return m_perf_event.GetAuxBuffer().size();
}
return m_perf_event.EnableWithIoctl();
}
-Expected<std::vector<uint8_t>> IntelPTSingleBufferTrace::GetTraceBuffer() {
+Expected<std::vector<uint8_t>> IntelPTSingleBufferTrace::GetIptTrace() {
// Disable the perf event to force a flush out of the CPU's internal buffer.
// Besides, we can guarantee that the CPU won't override any data as we are
// reading the buffer.
Expected<IntelPTSingleBufferTrace>
IntelPTSingleBufferTrace::Start(const TraceIntelPTStartRequest &request,
Optional<lldb::tid_t> tid,
- Optional<core_id_t> core_id, bool disabled) {
+ Optional<cpu_id_t> cpu_id, bool disabled) {
#ifndef PERF_ATTR_SIZE_VER5
return createStringError(inconvertibleErrorCode(),
"Intel PT Linux perf event not supported");
#else
Log *log = GetLog(POSIXLog::Trace);
- LLDB_LOG(log, "Will start tracing thread id {0} and cpu id {1}", tid,
- core_id);
+ LLDB_LOG(log, "Will start tracing thread id {0} and cpu id {1}", tid, cpu_id);
- if (__builtin_popcount(request.trace_buffer_size) != 1 ||
- request.trace_buffer_size < 4096) {
+ if (__builtin_popcount(request.ipt_trace_size) != 1 ||
+ request.ipt_trace_size < 4096) {
return createStringError(
inconvertibleErrorCode(),
- "The trace buffer size must be a power of 2 greater than or equal to "
+ "The intel pt trace size must be a power of 2 greater than or equal to "
"4096 (2^12) bytes. It was %" PRIu64 ".",
- request.trace_buffer_size);
+ request.ipt_trace_size);
}
uint64_t page_size = getpagesize();
uint64_t aux_buffer_numpages = static_cast<uint64_t>(llvm::PowerOf2Floor(
- (request.trace_buffer_size + page_size - 1) / page_size));
+ (request.ipt_trace_size + page_size - 1) / page_size));
Expected<perf_event_attr> attr = CreateIntelPTPerfEventConfiguration(
request.enable_tsc, request.psb_period.map([](int value) {
return attr.takeError();
attr->disabled = disabled;
- LLDB_LOG(log, "Will create trace buffer of size {0}",
- request.trace_buffer_size);
+ LLDB_LOG(log, "Will create intel pt trace buffer of size {0}",
+ request.ipt_trace_size);
- if (Expected<PerfEvent> perf_event = PerfEvent::Init(*attr, tid, core_id)) {
+ if (Expected<PerfEvent> perf_event = PerfEvent::Init(*attr, tid, cpu_id)) {
if (Error mmap_err = perf_event->MmapMetadataAndBuffers(
/*num_data_pages=*/0, aux_buffer_numpages,
/*data_buffer_write=*/true)) {
/// The tid of the thread to be traced. If \b None, then this traces all
/// threads of all processes.
///
- /// \param[in] core_id
+ /// \param[in] cpu_id
/// The CPU core id where to trace. If \b None, then this traces all CPUs.
///
/// \param[in] disabled
static llvm::Expected<IntelPTSingleBufferTrace>
Start(const TraceIntelPTStartRequest &request,
llvm::Optional<lldb::tid_t> tid,
- llvm::Optional<lldb::core_id_t> core_id = llvm::None,
+ llvm::Optional<lldb::cpu_id_t> cpu_id = llvm::None,
bool disabled = false);
/// \return
llvm::Expected<std::vector<uint8_t>>
GetBinaryData(const TraceGetBinaryDataRequest &request) const;
- /// Read the trace buffer managed by this trace instance. To ensure that the
- /// data is up-to-date and is not corrupted by read-write race conditions, the
- /// underlying perf_event is paused during read, and later it's returned to
- /// its initial state.
+ /// Read the intel pt trace buffer managed by this trace instance. To ensure
+ /// that the data is up-to-date and is not corrupted by read-write race
+ /// conditions, the underlying perf_event is paused during read, and later
+ /// it's returned to its initial state.
///
/// \return
/// A vector with the requested binary data.
- llvm::Expected<std::vector<uint8_t>> GetTraceBuffer();
+ llvm::Expected<std::vector<uint8_t>> GetIptTrace();
/// \return
- /// The total the size in bytes used by the trace buffer managed by this
- /// trace instance.
- size_t GetTraceBufferSize() const;
+ /// The total the size in bytes used by the intel pt trace buffer managed
+ /// by this trace instance.
+ size_t GetIptTraceSize() const;
/// Resume the collection of this trace.
///
if (it == m_thread_traces.end())
return createStringError(inconvertibleErrorCode(),
"Thread %" PRIu64 " not currently traced", tid);
- m_total_buffer_size -= it->second.GetTraceBufferSize();
+ m_total_buffer_size -= it->second.GetIptTraceSize();
m_thread_traces.erase(tid);
return Error::success();
}
if (!trace)
return trace.takeError();
- m_total_buffer_size += trace->GetTraceBufferSize();
+ m_total_buffer_size += trace->GetIptTraceSize();
m_thread_traces.try_emplace(tid, std::move(*trace));
return Error::success();
}
const TraceGetBinaryDataRequest &request) {
if (!request.tid)
return None;
- if (request.kind != IntelPTDataKinds::kTraceBuffer)
+ if (request.kind != IntelPTDataKinds::kIptTrace)
return None;
if (!TracesThread(*request.tid))
if (Expected<IntelPTSingleBufferTrace &> trace =
GetTracedThread(*request.tid))
- return trace->GetTraceBuffer();
+ return trace->GetIptTrace();
else
return trace.takeError();
}
bool TracesThread(lldb::tid_t tid) const;
/// \return
- /// The total sum of the trace buffer sizes used by this collection.
+ /// The total sum of the intel pt trace buffer sizes used by this
+ /// collection.
size_t GetTotalBufferSize() const;
/// Execute the provided callback on each thread that is being traced.
llvm::Expected<PerfEvent> PerfEvent::Init(perf_event_attr &attr,
Optional<lldb::pid_t> pid,
- Optional<lldb::core_id_t> cpu,
+ Optional<lldb::cpu_id_t> cpu,
Optional<long> group_fd,
unsigned long flags) {
errno = 0;
llvm::Expected<PerfEvent> PerfEvent::Init(perf_event_attr &attr,
Optional<lldb::pid_t> pid,
- Optional<lldb::core_id_t> cpu) {
+ Optional<lldb::cpu_id_t> cpu) {
return Init(attr, pid, cpu, -1, 0);
}
Expected<PerfEvent>
lldb_private::process_linux::CreateContextSwitchTracePerfEvent(
- lldb::core_id_t core_id, const PerfEvent *parent_perf_event) {
+ lldb::cpu_id_t cpu_id, const PerfEvent *parent_perf_event) {
Log *log = GetLog(POSIXLog::Trace);
#ifndef PERF_ATTR_SIZE_VER5
return createStringError(inconvertibleErrorCode(),
group_fd = parent_perf_event->GetFd();
if (Expected<PerfEvent> perf_event =
- PerfEvent::Init(attr, /*pid=*/None, core_id, group_fd, /*flags=*/0)) {
+ PerfEvent::Init(attr, /*pid=*/None, cpu_id, group_fd, /*flags=*/0)) {
if (Error mmap_err = perf_event->MmapMetadataAndBuffers(
data_buffer_numpages, 0, /*data_buffer_write=*/false)) {
return std::move(mmap_err);
/// instance, or an \a llvm::Error otherwise.
static llvm::Expected<PerfEvent> Init(perf_event_attr &attr,
llvm::Optional<lldb::pid_t> pid,
- llvm::Optional<lldb::core_id_t> cpu,
+ llvm::Optional<lldb::cpu_id_t> cpu,
llvm::Optional<long> group_fd,
unsigned long flags);
/// all threads and processes are monitored.
static llvm::Expected<PerfEvent>
Init(perf_event_attr &attr, llvm::Optional<lldb::pid_t> pid,
- llvm::Optional<lldb::core_id_t> core = llvm::None);
+ llvm::Optional<lldb::cpu_id_t> core = llvm::None);
/// Mmap the metadata page and the data and aux buffers of the perf event and
/// expose them through \a PerfEvent::GetMetadataPage() , \a
/// Create a perf event that tracks context switches on a cpu.
///
-/// \param[in] core_id
+/// \param[in] cpu_id
/// The core to trace.
///
/// \param[in] parent_perf_event
/// An optional perf event that will be grouped with the
/// new perf event.
llvm::Expected<PerfEvent>
-CreateContextSwitchTracePerfEvent(lldb::core_id_t core_id,
+CreateContextSwitchTracePerfEvent(lldb::cpu_id_t cpu_id,
const PerfEvent *parent_perf_event = nullptr);
/// Load \a PerfTscConversionParameters from \a perf_event_mmap_page, if
return *cpu_info;
}
-Expected<std::vector<core_id_t>>
+Expected<std::vector<cpu_id_t>>
lldb_private::process_linux::GetAvailableLogicalCoreIDs(StringRef cpuinfo) {
SmallVector<StringRef, 8> lines;
cpuinfo.split(lines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
- std::vector<core_id_t> logical_cores;
+ std::vector<cpu_id_t> logical_cores;
for (StringRef line : lines) {
std::pair<StringRef, StringRef> key_value = line.split(':');
auto key = key_value.first.trim();
auto val = key_value.second.trim();
if (key == "processor") {
- core_id_t processor;
+ cpu_id_t processor;
if (val.getAsInteger(10, processor))
return createStringError(
inconvertibleErrorCode(),
return logical_cores;
}
-llvm::Expected<llvm::ArrayRef<core_id_t>>
+llvm::Expected<llvm::ArrayRef<cpu_id_t>>
lldb_private::process_linux::GetAvailableLogicalCoreIDs() {
- static Optional<std::vector<core_id_t>> logical_cores_ids;
+ static Optional<std::vector<cpu_id_t>> logical_cores_ids;
if (!logical_cores_ids) {
// We find the actual list of core ids by parsing /proc/cpuinfo
Expected<ArrayRef<uint8_t>> cpuinfo = GetProcfsCpuInfo();
if (!cpuinfo)
return cpuinfo.takeError();
- Expected<std::vector<core_id_t>> core_ids = GetAvailableLogicalCoreIDs(
+ Expected<std::vector<cpu_id_t>> cpu_ids = GetAvailableLogicalCoreIDs(
StringRef(reinterpret_cast<const char *>(cpuinfo->data())));
- if (!core_ids)
- return core_ids.takeError();
+ if (!cpu_ids)
+ return cpu_ids.takeError();
- logical_cores_ids.emplace(std::move(*core_ids));
+ logical_cores_ids.emplace(std::move(*cpu_ids));
}
return *logical_cores_ids;
}
/// \return
/// A list of available logical core ids given the contents of
/// /proc/cpuinfo.
-llvm::Expected<std::vector<lldb::core_id_t>>
+llvm::Expected<std::vector<lldb::cpu_id_t>>
GetAvailableLogicalCoreIDs(llvm::StringRef cpuinfo);
/// \return
/// A list with all the logical cores available in the system and cache it
/// if errors didn't happen.
-llvm::Expected<llvm::ArrayRef<lldb::core_id_t>> GetAvailableLogicalCoreIDs();
+llvm::Expected<llvm::ArrayRef<lldb::cpu_id_t>> GetAvailableLogicalCoreIDs();
} // namespace process_linux
} // namespace lldb_private
TraceCursorIntelPT.cpp
TraceIntelPT.cpp
TraceIntelPTJSONStructs.cpp
- TraceIntelPTMultiCoreDecoder.cpp
+ TraceIntelPTMultiCpuDecoder.cpp
TraceIntelPTSessionFileParser.cpp
TraceIntelPTSessionSaver.cpp
switch (short_option) {
case 's': {
- int64_t trace_buffer_size;
- if (option_arg.empty() || option_arg.getAsInteger(0, trace_buffer_size) ||
- trace_buffer_size < 0)
+ int64_t ipt_trace_size;
+ if (option_arg.empty() || option_arg.getAsInteger(0, ipt_trace_size) ||
+ ipt_trace_size < 0)
error.SetErrorStringWithFormat("invalid integer value for option '%s'",
option_arg.str().c_str());
else
- m_trace_buffer_size = trace_buffer_size;
+ m_ipt_trace_size = ipt_trace_size;
break;
}
case 't': {
void CommandObjectThreadTraceStartIntelPT::CommandOptions::
OptionParsingStarting(ExecutionContext *execution_context) {
- m_trace_buffer_size = kDefaultTraceBufferSize;
+ m_ipt_trace_size = kDefaultIptTraceSize;
m_enable_tsc = kDefaultEnableTscValue;
m_psb_period = kDefaultPsbPeriod;
}
bool CommandObjectThreadTraceStartIntelPT::DoExecuteOnThreads(
Args &command, CommandReturnObject &result,
llvm::ArrayRef<lldb::tid_t> tids) {
- if (Error err = m_trace.Start(tids, m_options.m_trace_buffer_size,
+ if (Error err = m_trace.Start(tids, m_options.m_ipt_trace_size,
m_options.m_enable_tsc, m_options.m_psb_period))
result.SetError(Status(std::move(err)));
else
switch (short_option) {
case 's': {
- int64_t trace_buffer_size;
- if (option_arg.empty() || option_arg.getAsInteger(0, trace_buffer_size) ||
- trace_buffer_size < 0)
+ int64_t ipt_trace_size;
+ if (option_arg.empty() || option_arg.getAsInteger(0, ipt_trace_size) ||
+ ipt_trace_size < 0)
error.SetErrorStringWithFormat("invalid integer value for option '%s'",
option_arg.str().c_str());
else
- m_trace_buffer_size = trace_buffer_size;
+ m_ipt_trace_size = ipt_trace_size;
break;
}
case 'l': {
break;
}
case 'c': {
- m_per_core_tracing = true;
+ m_per_cpu_tracing = true;
break;
}
case 'p': {
void CommandObjectProcessTraceStartIntelPT::CommandOptions::
OptionParsingStarting(ExecutionContext *execution_context) {
- m_trace_buffer_size = kDefaultTraceBufferSize;
+ m_ipt_trace_size = kDefaultIptTraceSize;
m_process_buffer_size_limit = kDefaultProcessBufferSizeLimit;
m_enable_tsc = kDefaultEnableTscValue;
m_psb_period = kDefaultPsbPeriod;
- m_per_core_tracing = kDefaultPerCoreTracing;
+ m_per_cpu_tracing = kDefaultPerCpuTracing;
}
llvm::ArrayRef<OptionDefinition>
bool CommandObjectProcessTraceStartIntelPT::DoExecute(
Args &command, CommandReturnObject &result) {
- if (Error err = m_trace.Start(m_options.m_trace_buffer_size,
+ if (Error err = m_trace.Start(m_options.m_ipt_trace_size,
m_options.m_process_buffer_size_limit,
m_options.m_enable_tsc, m_options.m_psb_period,
- m_options.m_per_core_tracing))
+ m_options.m_per_cpu_tracing))
result.SetError(Status(std::move(err)));
else
result.SetStatus(eReturnStatusSuccessFinishResult);
llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
- uint64_t m_trace_buffer_size;
+ uint64_t m_ipt_trace_size;
bool m_enable_tsc;
llvm::Optional<uint64_t> m_psb_period;
};
llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
- uint64_t m_trace_buffer_size;
+ uint64_t m_ipt_trace_size;
uint64_t m_process_buffer_size_limit;
bool m_enable_tsc;
llvm::Optional<uint64_t> m_psb_period;
- bool m_per_core_tracing;
+ bool m_per_cpu_tracing;
};
CommandObjectProcessTraceStartIntelPT(TraceIntelPT &trace,
: CommandObjectParsed(
interpreter, "process trace start",
"Start tracing this process with intel-pt, including future "
- "threads. If --per-core-tracing is not provided, this traces each "
+ "threads. If --per-cpu-tracing is not provided, this traces each "
"thread independently, thus using a trace buffer per thread. "
"Threads traced with the \"thread trace start\" command are left "
"unaffected ant not retraced. This is the recommended option "
- "unless the number of threads is huge. If --per-core-tracing is "
+ "unless the number of threads is huge. If --per-cpu-tracing is "
"passed, each cpu core is traced instead of each thread, which "
"uses a fixed number of trace buffers, but might result in less "
"data available for less frequent threads.",
void lldb_private::trace_intel_pt::DecodeSystemWideTraceForThread(
DecodedThread &decoded_thread, TraceIntelPT &trace_intel_pt,
- const DenseMap<lldb::core_id_t, llvm::ArrayRef<uint8_t>> &buffers,
+ const DenseMap<lldb::cpu_id_t, llvm::ArrayRef<uint8_t>> &buffers,
const std::vector<IntelPTThreadContinousExecution> &executions) {
- DenseMap<lldb::core_id_t, LibiptDecoder> decoders;
- for (auto &core_id_buffer : buffers) {
+ DenseMap<lldb::cpu_id_t, LibiptDecoder> decoders;
+ for (auto &cpu_id_buffer : buffers) {
Expected<PtInsnDecoderUP> decoder_up =
- CreateInstructionDecoder(trace_intel_pt, core_id_buffer.second);
+ CreateInstructionDecoder(trace_intel_pt, cpu_id_buffer.second);
if (!decoder_up)
return decoded_thread.SetAsFailed(decoder_up.takeError());
*decoded_thread.GetThread()->GetProcess()))
return decoded_thread.SetAsFailed(std::move(err));
- decoders.try_emplace(core_id_buffer.first,
+ decoders.try_emplace(cpu_id_buffer.first,
LibiptDecoder(*decoder_up->release(), decoded_thread));
}
decoded_thread.AppendError(createStringError(
inconvertibleErrorCode(),
formatv("Unable to find intel pt data for thread execution with "
- "tsc = {0} on core id = {1}",
+ "tsc = {0} on cpu id = {1}",
execution.thread_execution.GetLowestKnownTSC(),
- execution.thread_execution.core_id)));
+ execution.thread_execution.cpu_id)));
}
// If the first execution is incomplete because it doesn't have a previous
variant == ThreadContinuousExecution::Variant::HintedStart) {
decoded_thread.AppendError(createStringError(
inconvertibleErrorCode(),
- formatv("Thread execution starting at tsc = {0} on core id = {1} "
+ formatv("Thread execution starting at tsc = {0} on cpu id = {1} "
"doesn't have a matching context switch in.",
execution.thread_execution.GetLowestKnownTSC(),
- execution.thread_execution.core_id)));
+ execution.thread_execution.cpu_id)));
}
}
LibiptDecoder &decoder =
- decoders.find(execution.thread_execution.core_id)->second;
+ decoders.find(execution.thread_execution.cpu_id)->second;
for (const IntelPTThreadSubtrace &intel_pt_execution :
execution.intelpt_subtraces) {
has_seen_psbs = true;
variant == ThreadContinuousExecution::Variant::HintedEnd) {
decoded_thread.AppendError(createStringError(
inconvertibleErrorCode(),
- formatv("Thread execution starting at tsc = {0} on core id = {1} "
+ formatv("Thread execution starting at tsc = {0} on cpu id = {1} "
"doesn't have a matching context switch out",
execution.thread_execution.GetLowestKnownTSC(),
- execution.thread_execution.core_id)));
+ execution.thread_execution.cpu_id)));
}
}
}
uint64_t tsc;
};
-/// This struct represents a continuous execution of a thread in a core,
+/// This struct represents a continuous execution of a thread in a cpu,
/// delimited by a context switch in and out, and a list of Intel PT subtraces
/// that belong to this execution.
struct IntelPTThreadContinousExecution {
/// part of the execution ocurred.
void DecodeSystemWideTraceForThread(
DecodedThread &decoded_thread, TraceIntelPT &trace_intel_pt,
- const llvm::DenseMap<lldb::core_id_t, llvm::ArrayRef<uint8_t>> &buffers,
+ const llvm::DenseMap<lldb::cpu_id_t, llvm::ArrayRef<uint8_t>> &buffers,
const std::vector<IntelPTThreadContinousExecution> &executions);
/// Given an intel pt trace, split it in chunks delimited by PSB packets. Each of these chunks
}
ThreadContinuousExecution ThreadContinuousExecution::CreateCompleteExecution(
- lldb::core_id_t core_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t start,
+ lldb::cpu_id_t cpu_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t start,
uint64_t end) {
- ThreadContinuousExecution o(core_id, tid, pid);
+ ThreadContinuousExecution o(cpu_id, tid, pid);
o.variant = Variant::Complete;
o.tscs.complete.start = start;
o.tscs.complete.end = end;
}
ThreadContinuousExecution ThreadContinuousExecution::CreateHintedStartExecution(
- lldb::core_id_t core_id, lldb::tid_t tid, lldb::pid_t pid,
+ lldb::cpu_id_t cpu_id, lldb::tid_t tid, lldb::pid_t pid,
uint64_t hinted_start, uint64_t end) {
- ThreadContinuousExecution o(core_id, tid, pid);
+ ThreadContinuousExecution o(cpu_id, tid, pid);
o.variant = Variant::HintedStart;
o.tscs.hinted_start.hinted_start = hinted_start;
o.tscs.hinted_start.end = end;
}
ThreadContinuousExecution ThreadContinuousExecution::CreateHintedEndExecution(
- lldb::core_id_t core_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t start,
+ lldb::cpu_id_t cpu_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t start,
uint64_t hinted_end) {
- ThreadContinuousExecution o(core_id, tid, pid);
+ ThreadContinuousExecution o(cpu_id, tid, pid);
o.variant = Variant::HintedEnd;
o.tscs.hinted_end.start = start;
o.tscs.hinted_end.hinted_end = hinted_end;
}
ThreadContinuousExecution ThreadContinuousExecution::CreateOnlyEndExecution(
- lldb::core_id_t core_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t end) {
- ThreadContinuousExecution o(core_id, tid, pid);
+ lldb::cpu_id_t cpu_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t end) {
+ ThreadContinuousExecution o(cpu_id, tid, pid);
o.variant = Variant::OnlyEnd;
o.tscs.only_end.end = end;
return o;
}
ThreadContinuousExecution ThreadContinuousExecution::CreateOnlyStartExecution(
- lldb::core_id_t core_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t start) {
- ThreadContinuousExecution o(core_id, tid, pid);
+ lldb::cpu_id_t cpu_id, lldb::tid_t tid, lldb::pid_t pid, uint64_t start) {
+ ThreadContinuousExecution o(cpu_id, tid, pid);
o.variant = Variant::OnlyStart;
o.tscs.only_start.start = start;
return o;
}
static Error RecoverExecutionsFromConsecutiveRecords(
- core_id_t core_id, const LinuxPerfZeroTscConversion &tsc_conversion,
+ cpu_id_t cpu_id, const LinuxPerfZeroTscConversion &tsc_conversion,
const ContextSwitchRecord ¤t_record,
const Optional<ContextSwitchRecord> &prev_record,
std::function<void(const ThreadContinuousExecution &execution)>
if (!prev_record) {
if (current_record.IsOut()) {
on_new_execution(ThreadContinuousExecution::CreateOnlyEndExecution(
- core_id, current_record.tid, current_record.pid, current_record.tsc));
+ cpu_id, current_record.tid, current_record.pid, current_record.tsc));
}
// The 'in' case will be handled later when we try to look for its end
return Error::success();
// We found two consecutive ins, which means that we didn't capture
// the end of the previous execution.
on_new_execution(ThreadContinuousExecution::CreateHintedEndExecution(
- core_id, prev.tid, prev.pid, prev.tsc, current_record.tsc - 1));
+ cpu_id, prev.tid, prev.pid, prev.tsc, current_record.tsc - 1));
} else if (current_record.IsOut() && prev.IsOut()) {
// We found two consecutive outs, that means that we didn't capture
// the beginning of the current execution.
on_new_execution(ThreadContinuousExecution::CreateHintedStartExecution(
- core_id, current_record.tid, current_record.pid, prev.tsc + 1,
+ cpu_id, current_record.tid, current_record.pid, prev.tsc + 1,
current_record.tsc));
} else if (current_record.IsOut() && prev.IsIn()) {
if (current_record.pid == prev.pid && current_record.tid == prev.tid) {
/// A complete execution
on_new_execution(ThreadContinuousExecution::CreateCompleteExecution(
- core_id, current_record.tid, current_record.pid, prev.tsc,
+ cpu_id, current_record.tid, current_record.pid, prev.tsc,
current_record.tsc));
} else {
// An out after the in of a different thread. The first one doesn't
// have an end, and the second one doesn't have a start.
on_new_execution(ThreadContinuousExecution::CreateHintedEndExecution(
- core_id, prev.tid, prev.pid, prev.tsc, current_record.tsc - 1));
+ cpu_id, prev.tid, prev.pid, prev.tsc, current_record.tsc - 1));
on_new_execution(ThreadContinuousExecution::CreateHintedStartExecution(
- core_id, current_record.tid, current_record.pid, prev.tsc + 1,
+ cpu_id, current_record.tid, current_record.pid, prev.tsc + 1,
current_record.tsc));
}
}
Expected<std::vector<ThreadContinuousExecution>>
lldb_private::trace_intel_pt::DecodePerfContextSwitchTrace(
- ArrayRef<uint8_t> data, core_id_t core_id,
+ ArrayRef<uint8_t> data, cpu_id_t cpu_id,
const LinuxPerfZeroTscConversion &tsc_conversion) {
std::vector<ThreadContinuousExecution> executions;
static_cast<lldb::tid_t>(context_switch_record.tid)};
if (Error err = RecoverExecutionsFromConsecutiveRecords(
- core_id, tsc_conversion, record, prev_record,
+ cpu_id, tsc_conversion, record, prev_record,
[&](const ThreadContinuousExecution &execution) {
executions.push_back(execution);
}))
// We might have an incomplete last record
if (prev_record && prev_record->IsIn())
executions.push_back(ThreadContinuousExecution::CreateOnlyStartExecution(
- core_id, prev_record->tid, prev_record->pid, prev_record->tsc));
+ cpu_id, prev_record->tid, prev_record->pid, prev_record->tsc));
return Error::success();
};
return createStringError(inconvertibleErrorCode(),
formatv("Malformed perf context switch trace for "
"cpu {0} at offset {1}. {2}",
- core_id, offset,
- toString(std::move(err))));
+ cpu_id, offset, toString(std::move(err))));
return executions;
}
/// This class indicates the time interval in which a thread was running
/// continuously on a cpu core.
-///
-/// Note: we use the terms CPU and cores interchangeably.
struct ThreadContinuousExecution {
/// In most cases both the start and end of a continuous execution can be
/// Both endpoints are known.
Complete,
/// The end is known and we have a lower bound for the start, i.e. the
- /// previous execution in the same core happens strictly before the hinted
+ /// previous execution in the same cpu happens strictly before the hinted
/// start.
HintedStart,
/// The start is known and we have an upper bound for the end, i.e. the next
- /// execution in the same core happens strictly after the hinted end.
+ /// execution in the same cpu happens strictly after the hinted end.
HintedEnd,
- /// We only know the start. This might be the last entry of a core trace.
+ /// We only know the start. This might be the last entry of a cpu trace.
OnlyStart,
- /// We only know the end. This might be the first entry or a core trace.
+ /// We only know the end. This might be the first entry or a cpu trace.
OnlyEnd,
} variant;
///
/// \{
static ThreadContinuousExecution
- CreateCompleteExecution(lldb::core_id_t core_id, lldb::tid_t tid,
+ CreateCompleteExecution(lldb::cpu_id_t cpu_id, lldb::tid_t tid,
lldb::pid_t pid, uint64_t start, uint64_t end);
static ThreadContinuousExecution
- CreateHintedStartExecution(lldb::core_id_t core_id, lldb::tid_t tid,
+ CreateHintedStartExecution(lldb::cpu_id_t cpu_id, lldb::tid_t tid,
lldb::pid_t pid, uint64_t hinted_start,
uint64_t end);
static ThreadContinuousExecution
- CreateHintedEndExecution(lldb::core_id_t core_id, lldb::tid_t tid,
+ CreateHintedEndExecution(lldb::cpu_id_t cpu_id, lldb::tid_t tid,
lldb::pid_t pid, uint64_t start,
uint64_t hinted_end);
- static ThreadContinuousExecution
- CreateOnlyEndExecution(lldb::core_id_t core_id, lldb::tid_t tid,
- lldb::pid_t pid, uint64_t end);
+ static ThreadContinuousExecution CreateOnlyEndExecution(lldb::cpu_id_t cpu_id,
+ lldb::tid_t tid,
+ lldb::pid_t pid,
+ uint64_t end);
static ThreadContinuousExecution
- CreateOnlyStartExecution(lldb::core_id_t core_id, lldb::tid_t tid,
+ CreateOnlyStartExecution(lldb::cpu_id_t cpu_id, lldb::tid_t tid,
lldb::pid_t pid, uint64_t start);
/// \}
} hinted_end;
} tscs;
- lldb::core_id_t core_id;
+ lldb::cpu_id_t cpu_id;
lldb::tid_t tid;
lldb::pid_t pid;
private:
/// We keep this constructor private to force the usage of the static named
/// constructors.
- ThreadContinuousExecution(lldb::core_id_t core_id, lldb::tid_t tid,
+ ThreadContinuousExecution(lldb::cpu_id_t cpu_id, lldb::tid_t tid,
lldb::pid_t pid)
- : core_id(core_id), tid(tid), pid(pid) {}
+ : cpu_id(cpu_id), tid(tid), pid(pid) {}
};
/// Decodes a context switch trace collected with perf_event_open.
/// \param[in] data
/// The context switch trace in binary format.
///
-/// \param[i] core_id
-/// The core_id where the trace were gotten from.
+/// \param[i] cpu_id
+/// The cpu_id where the trace were gotten from.
///
/// \param[in] tsc_conversion
/// The conversion values used to confert nanoseconds to TSC.
/// time, or an \a llvm::Error if the data is malformed.
llvm::Expected<std::vector<ThreadContinuousExecution>>
DecodePerfContextSwitchTrace(llvm::ArrayRef<uint8_t> data,
- lldb::core_id_t core_id,
+ lldb::cpu_id_t cpu_id,
const LinuxPerfZeroTscConversion &tsc_conversion);
} // namespace trace_intel_pt
class ThreadDecoder {
public:
/// \param[in] thread_sp
- /// The thread whose trace buffer will be decoded.
+ /// The thread whose intel pt trace buffer will be decoded.
///
/// \param[in] trace
/// The main Trace object who owns this decoder and its data.
TraceIntelPT::TraceIntelPT(JSONTraceSession &session,
ArrayRef<ProcessSP> traced_processes,
ArrayRef<ThreadPostMortemTraceSP> traced_threads)
- : Trace(traced_processes, session.GetCoreIds()),
+ : Trace(traced_processes, session.GetCpuIds()),
m_cpu_info(session.cpu_info) {
m_storage.tsc_conversion = session.tsc_perf_zero_conversion;
- if (session.cores) {
- std::vector<core_id_t> cores;
+ if (session.cpus) {
+ std::vector<cpu_id_t> cpus;
- for (const JSONCore &core : *session.cores) {
- SetPostMortemCoreDataFile(core.core_id, IntelPTDataKinds::kTraceBuffer,
- FileSpec(core.trace_buffer));
+ for (const JSONCpu &cpu : *session.cpus) {
+ SetPostMortemCpuDataFile(cpu.id, IntelPTDataKinds::kIptTrace,
+ FileSpec(cpu.ipt_trace));
- SetPostMortemCoreDataFile(core.core_id,
- IntelPTDataKinds::kPerfContextSwitchTrace,
- FileSpec(core.context_switch_trace));
- cores.push_back(core.core_id);
+ SetPostMortemCpuDataFile(cpu.id,
+ IntelPTDataKinds::kPerfContextSwitchTrace,
+ FileSpec(cpu.context_switch_trace));
+ cpus.push_back(cpu.id);
}
std::vector<tid_t> tids;
for (const JSONThread &thread : process.threads)
tids.push_back(thread.tid);
- m_storage.multicore_decoder.emplace(*this);
+ m_storage.multicpu_decoder.emplace(*this);
} else {
for (const ThreadPostMortemTraceSP &thread : traced_threads) {
m_storage.thread_decoders.try_emplace(
thread->GetID(), std::make_unique<ThreadDecoder>(thread, *this));
if (const Optional<FileSpec> &trace_file = thread->GetTraceFile()) {
- SetPostMortemThreadDataFile(
- thread->GetID(), IntelPTDataKinds::kTraceBuffer, *trace_file);
+ SetPostMortemThreadDataFile(thread->GetID(),
+ IntelPTDataKinds::kIptTrace, *trace_file);
}
}
}
createStringError(inconvertibleErrorCode(), error));
Storage &storage = GetUpdatedStorage();
- if (storage.multicore_decoder)
- return storage.multicore_decoder->Decode(thread);
+ if (storage.multicpu_decoder)
+ return storage.multicpu_decoder->Decode(thread);
auto it = storage.thread_decoders.find(thread.GetID());
if (it == storage.thread_decoders.end())
}
}
- // Multicode decoding stats
- if (storage.multicore_decoder) {
- s << "\n Multi-core decoding:\n";
+ if (storage.multicpu_decoder) {
+ s << "\n Multi-cpu decoding:\n";
s.Format(" Total number of continuous executions found: {0}\n",
- storage.multicore_decoder->GetTotalContinuousExecutionsCount());
+ storage.multicpu_decoder->GetTotalContinuousExecutionsCount());
s.Format(
" Number of continuous executions for this thread: {0}\n",
- storage.multicore_decoder->GetNumContinuousExecutionsForThread(tid));
+ storage.multicpu_decoder->GetNumContinuousExecutionsForThread(tid));
}
// Errors
llvm::Expected<Optional<uint64_t>>
TraceIntelPT::GetRawTraceSize(Thread &thread) {
- if (GetUpdatedStorage().multicore_decoder)
+ if (GetUpdatedStorage().multicpu_decoder)
return None; // TODO: calculate the amount of intel pt raw trace associated
// with the given thread.
if (GetLiveProcess())
return GetLiveThreadBinaryDataSize(thread.GetID(),
- IntelPTDataKinds::kTraceBuffer);
+ IntelPTDataKinds::kIptTrace);
uint64_t size;
auto callback = [&](llvm::ArrayRef<uint8_t> data) {
size = data.size();
m_storage.tsc_conversion = intelpt_state->tsc_perf_zero_conversion;
- if (!intelpt_state->cores) {
+ if (!intelpt_state->cpus) {
for (const TraceThreadState &thread_state : state.traced_threads) {
ThreadSP thread_sp =
GetLiveProcess()->GetThreadList().FindThreadByID(thread_state.tid);
thread_state.tid, std::make_unique<ThreadDecoder>(thread_sp, *this));
}
} else {
- std::vector<core_id_t> cores;
- for (const TraceCoreState &core : *intelpt_state->cores)
- cores.push_back(core.core_id);
+ std::vector<cpu_id_t> cpus;
+ for (const TraceCpuState &cpu : *intelpt_state->cpus)
+ cpus.push_back(cpu.id);
std::vector<tid_t> tids;
for (const TraceThreadState &thread : intelpt_state->traced_threads)
if (!intelpt_state->tsc_perf_zero_conversion)
return createStringError(inconvertibleErrorCode(),
"Missing perf time_zero conversion values");
- m_storage.multicore_decoder.emplace(*this);
+ m_storage.multicpu_decoder.emplace(*this);
}
if (m_storage.tsc_conversion) {
bool TraceIntelPT::IsTraced(lldb::tid_t tid) {
Storage &storage = GetUpdatedStorage();
- if (storage.multicore_decoder)
- return storage.multicore_decoder->TracesThread(tid);
+ if (storage.multicpu_decoder)
+ return storage.multicpu_decoder->TracesThread(tid);
return storage.thread_decoders.count(tid);
}
See the jLLDBTraceStart section in lldb/docs/lldb-gdb-remote.txt for a
description of each parameter below.
- - int traceBufferSize (defaults to {0} bytes):
+ - int iptTraceSize (defaults to {0} bytes):
[process and thread tracing]
- boolean enableTsc (default to {1}):
- int psbPeriod (defaults to {2}):
[process and thread tracing]
- - boolean perCoreTracing (default to {3}):
+ - boolean perCpuTracing (default to {3}):
[process tracing only]
- int processBufferSizeLimit (defaults to {4} MiB):
[process tracing only])",
- kDefaultTraceBufferSize, kDefaultEnableTscValue,
- kDefaultPsbPeriod, kDefaultPerCoreTracing,
+ kDefaultIptTraceSize, kDefaultEnableTscValue,
+ kDefaultPsbPeriod, kDefaultPerCpuTracing,
kDefaultProcessBufferSizeLimit / 1024 / 1024));
}
return message->c_str();
}
-Error TraceIntelPT::Start(uint64_t trace_buffer_size,
+Error TraceIntelPT::Start(uint64_t ipt_trace_size,
uint64_t total_buffer_size_limit, bool enable_tsc,
- Optional<uint64_t> psb_period,
- bool per_core_tracing) {
+ Optional<uint64_t> psb_period, bool per_cpu_tracing) {
TraceIntelPTStartRequest request;
- request.trace_buffer_size = trace_buffer_size;
+ request.ipt_trace_size = ipt_trace_size;
request.process_buffer_size_limit = total_buffer_size_limit;
request.enable_tsc = enable_tsc;
request.psb_period = psb_period;
request.type = GetPluginName().str();
- request.per_core_tracing = per_core_tracing;
+ request.per_cpu_tracing = per_cpu_tracing;
return Trace::Start(toJSON(request));
}
Error TraceIntelPT::Start(StructuredData::ObjectSP configuration) {
- uint64_t trace_buffer_size = kDefaultTraceBufferSize;
+ uint64_t ipt_trace_size = kDefaultIptTraceSize;
uint64_t process_buffer_size_limit = kDefaultProcessBufferSizeLimit;
bool enable_tsc = kDefaultEnableTscValue;
Optional<uint64_t> psb_period = kDefaultPsbPeriod;
- bool per_core_tracing = kDefaultPerCoreTracing;
+ bool per_cpu_tracing = kDefaultPerCpuTracing;
if (configuration) {
if (StructuredData::Dictionary *dict = configuration->GetAsDictionary()) {
- dict->GetValueForKeyAsInteger("traceBufferSize", trace_buffer_size);
+ dict->GetValueForKeyAsInteger("iptTraceSize", ipt_trace_size);
dict->GetValueForKeyAsInteger("processBufferSizeLimit",
process_buffer_size_limit);
dict->GetValueForKeyAsBoolean("enableTsc", enable_tsc);
dict->GetValueForKeyAsInteger("psbPeriod", psb_period);
- dict->GetValueForKeyAsBoolean("perCoreTracing", per_core_tracing);
+ dict->GetValueForKeyAsBoolean("perCpuTracing", per_cpu_tracing);
} else {
return createStringError(inconvertibleErrorCode(),
"configuration object is not a dictionary");
}
}
- return Start(trace_buffer_size, process_buffer_size_limit, enable_tsc,
- psb_period, per_core_tracing);
+ return Start(ipt_trace_size, process_buffer_size_limit, enable_tsc,
+ psb_period, per_cpu_tracing);
}
llvm::Error TraceIntelPT::Start(llvm::ArrayRef<lldb::tid_t> tids,
- uint64_t trace_buffer_size, bool enable_tsc,
+ uint64_t ipt_trace_size, bool enable_tsc,
Optional<uint64_t> psb_period) {
TraceIntelPTStartRequest request;
- request.trace_buffer_size = trace_buffer_size;
+ request.ipt_trace_size = ipt_trace_size;
request.enable_tsc = enable_tsc;
request.psb_period = psb_period;
request.type = GetPluginName().str();
Error TraceIntelPT::Start(llvm::ArrayRef<lldb::tid_t> tids,
StructuredData::ObjectSP configuration) {
- uint64_t trace_buffer_size = kDefaultTraceBufferSize;
+ uint64_t ipt_trace_size = kDefaultIptTraceSize;
bool enable_tsc = kDefaultEnableTscValue;
Optional<uint64_t> psb_period = kDefaultPsbPeriod;
if (configuration) {
if (StructuredData::Dictionary *dict = configuration->GetAsDictionary()) {
- dict->GetValueForKeyAsInteger("traceBufferSize", trace_buffer_size);
+ dict->GetValueForKeyAsInteger("iptTraceSize", ipt_trace_size);
dict->GetValueForKeyAsBoolean("enableTsc", enable_tsc);
dict->GetValueForKeyAsInteger("psbPeriod", psb_period);
} else {
}
}
- return Start(tids, trace_buffer_size, enable_tsc, psb_period);
+ return Start(tids, ipt_trace_size, enable_tsc, psb_period);
}
Error TraceIntelPT::OnThreadBufferRead(lldb::tid_t tid,
OnBinaryDataReadCallback callback) {
- return OnThreadBinaryDataRead(tid, IntelPTDataKinds::kTraceBuffer, callback);
+ return OnThreadBinaryDataRead(tid, IntelPTDataKinds::kIptTrace, callback);
}
TaskTimer &TraceIntelPT::GetTimer() { return GetUpdatedStorage().task_timer; }
#include "TaskTimer.h"
#include "ThreadDecoder.h"
-#include "TraceIntelPTMultiCoreDecoder.h"
+#include "TraceIntelPTMultiCpuDecoder.h"
#include "TraceIntelPTSessionFileParser.h"
#include "lldb/Utility/FileSpec.h"
/// More information on the parameters below can be found in the
/// jLLDBTraceStart section in lldb/docs/lldb-gdb-remote.txt.
///
- /// \param[in] trace_buffer_size
+ /// \param[in] ipt_trace_size
/// Trace size per thread in bytes.
///
/// \param[in] total_buffer_size_limit
/// \param[in] psb_period
/// This value defines the period in which PSB packets will be generated.
///
- /// \param[in] per_core_tracing
- /// This value defines whether to have a trace buffer per thread or per
- /// cpu core.
+ /// \param[in] per_cpu_tracing
+ /// This value defines whether to have an intel pt trace buffer per thread
+ /// or per cpu core.
///
/// \return
/// \a llvm::Error::success if the operation was successful, or
/// \a llvm::Error otherwise.
- llvm::Error Start(uint64_t trace_buffer_size,
- uint64_t total_buffer_size_limit, bool enable_tsc,
- llvm::Optional<uint64_t> psb_period,
- bool m_per_core_tracing);
+ llvm::Error Start(uint64_t ipt_trace_size, uint64_t total_buffer_size_limit,
+ bool enable_tsc, llvm::Optional<uint64_t> psb_period,
+ bool m_per_cpu_tracing);
/// \copydoc Trace::Start
llvm::Error Start(StructuredData::ObjectSP configuration =
/// \param[in] tids
/// Threads to trace.
///
- /// \param[in] trace_buffer_size
- /// Trace size per thread or per core in bytes.
+ /// \param[in] ipt_trace_size
+ /// Trace size per thread or per cpu core in bytes.
///
/// \param[in] enable_tsc
/// Whether to use enable TSC timestamps or not.
/// \return
/// \a llvm::Error::success if the operation was successful, or
/// \a llvm::Error otherwise.
- llvm::Error Start(llvm::ArrayRef<lldb::tid_t> tids,
- uint64_t trace_buffer_size, bool enable_tsc,
- llvm::Optional<uint64_t> psb_period);
+ llvm::Error Start(llvm::ArrayRef<lldb::tid_t> tids, uint64_t ipt_trace_size,
+ bool enable_tsc, llvm::Optional<uint64_t> psb_period);
/// \copydoc Trace::Start
llvm::Error Start(llvm::ArrayRef<lldb::tid_t> tids,
/// This variable should only be accessed directly by constructores or live
/// process data refreshers.
struct Storage {
- llvm::Optional<TraceIntelPTMultiCoreDecoder> multicore_decoder;
- /// These decoders are used for the non-per-core case
+ llvm::Optional<TraceIntelPTMultiCpuDecoder> multicpu_decoder;
+ /// These decoders are used for the non-per-cpu case
llvm::DenseMap<lldb::tid_t, std::unique_ptr<ThreadDecoder>> thread_decoders;
/// Helper variable used to track long running operations for telemetry.
TaskTimer task_timer;
namespace lldb_private {
namespace trace_intel_pt {
-const size_t kDefaultTraceBufferSize = 4 * 1024; // 4KB
+const size_t kDefaultIptTraceSize = 4 * 1024; // 4KB
const size_t kDefaultProcessBufferSizeLimit = 5 * 1024 * 1024; // 500MB
const bool kDefaultEnableTscValue = false;
const llvm::Optional<size_t> kDefaultPsbPeriod = llvm::None;
-const bool kDefaultPerCoreTracing = false;
+const bool kDefaultPerCpuTracing = false;
} // namespace trace_intel_pt
} // namespace lldb_private
namespace lldb_private {
namespace trace_intel_pt {
-Optional<std::vector<lldb::core_id_t>> JSONTraceSession::GetCoreIds() {
- if (!cores)
+Optional<std::vector<lldb::cpu_id_t>> JSONTraceSession::GetCpuIds() {
+ if (!cpus)
return None;
- std::vector<lldb::core_id_t> core_ids;
- for (const JSONCore &core : *cores)
- core_ids.push_back(core.core_id);
- return core_ids;
+ std::vector<lldb::cpu_id_t> cpu_ids;
+ for (const JSONCpu &cpu : *cpus)
+ cpu_ids.push_back(cpu.id);
+ return cpu_ids;
}
json::Value toJSON(const JSONModule &module) {
json::Value toJSON(const JSONThread &thread) {
json::Object obj{{"tid", thread.tid}};
- if (thread.trace_buffer)
- obj["traceBuffer"] = *thread.trace_buffer;
+ if (thread.ipt_trace)
+ obj["iptTrace"] = *thread.ipt_trace;
return obj;
}
bool fromJSON(const json::Value &value, JSONThread &thread, Path path) {
ObjectMapper o(value, path);
- return o && o.map("tid", thread.tid) &&
- o.map("traceBuffer", thread.trace_buffer);
+ return o && o.map("tid", thread.tid) && o.map("iptTrace", thread.ipt_trace);
}
json::Value toJSON(const JSONProcess &process) {
o.map("threads", process.threads) && o.map("modules", process.modules);
}
-json::Value toJSON(const JSONCore &core) {
+json::Value toJSON(const JSONCpu &cpu) {
return Object{
- {"coreId", core.core_id},
- {"traceBuffer", core.trace_buffer},
- {"contextSwitchTrace", core.context_switch_trace},
+ {"id", cpu.id},
+ {"iptTrace", cpu.ipt_trace},
+ {"contextSwitchTrace", cpu.context_switch_trace},
};
}
-bool fromJSON(const json::Value &value, JSONCore &core, Path path) {
+bool fromJSON(const json::Value &value, JSONCpu &cpu, Path path) {
ObjectMapper o(value, path);
- uint64_t core_id;
- if (!(o && o.map("coreId", core_id) &&
- o.map("traceBuffer", core.trace_buffer) &&
- o.map("contextSwitchTrace", core.context_switch_trace)))
+ uint64_t cpu_id;
+ if (!(o && o.map("id", cpu_id) && o.map("iptTrace", cpu.ipt_trace) &&
+ o.map("contextSwitchTrace", cpu.context_switch_trace)))
return false;
- core.core_id = core_id;
+ cpu.id = cpu_id;
return true;
}
// We have to do this because the compiler fails at doing it
// automatically because pt_cpu is not in a namespace
{"cpuInfo", toJSON(session.cpu_info)},
- {"cores", session.cores},
+ {"cpus", session.cpus},
{"tscPerfZeroConversion", session.tsc_perf_zero_conversion}};
}
bool fromJSON(const json::Value &value, JSONTraceSession &session, Path path) {
ObjectMapper o(value, path);
if (!(o && o.map("processes", session.processes) &&
- o.map("type", session.type) && o.map("cores", session.cores) &&
+ o.map("type", session.type) && o.map("cpus", session.cpus) &&
o.map("tscPerfZeroConversion", session.tsc_perf_zero_conversion)))
return false;
- if (session.cores && !session.tsc_perf_zero_conversion) {
+ if (session.cpus && !session.tsc_perf_zero_conversion) {
path.report(
- "\"tscPerfZeroConversion\" is required when \"cores\" is provided");
+ "\"tscPerfZeroConversion\" is required when \"cpus\" is provided");
return false;
}
// We have to do this because the compiler fails at doing it automatically
struct JSONThread {
uint64_t tid;
- llvm::Optional<std::string> trace_buffer;
+ llvm::Optional<std::string> ipt_trace;
};
struct JSONProcess {
std::vector<JSONModule> modules;
};
-struct JSONCore {
- lldb::core_id_t core_id;
- std::string trace_buffer;
+struct JSONCpu {
+ lldb::cpu_id_t id;
+ std::string ipt_trace;
std::string context_switch_trace;
};
std::string type;
pt_cpu cpu_info;
std::vector<JSONProcess> processes;
- llvm::Optional<std::vector<JSONCore>> cores;
+ llvm::Optional<std::vector<JSONCpu>> cpus;
llvm::Optional<LinuxPerfZeroTscConversion> tsc_perf_zero_conversion;
- llvm::Optional<std::vector<lldb::core_id_t>> GetCoreIds();
+ llvm::Optional<std::vector<lldb::cpu_id_t>> GetCpuIds();
};
llvm::json::Value toJSON(const JSONModule &module);
llvm::json::Value toJSON(const JSONProcess &process);
-llvm::json::Value toJSON(const JSONCore &core);
+llvm::json::Value toJSON(const JSONCpu &cpu);
llvm::json::Value toJSON(const pt_cpu &cpu_info);
bool fromJSON(const llvm::json::Value &value, JSONProcess &process,
llvm::json::Path path);
-bool fromJSON(const llvm::json::Value &value, JSONCore &core,
+bool fromJSON(const llvm::json::Value &value, JSONCpu &cpu,
llvm::json::Path path);
bool fromJSON(const llvm::json::Value &value, pt_cpu &cpu_info,
-//===-- TraceIntelPTMultiCoreDecoder.cpp ----------------------------------===//
+//===-- TraceIntelPTMultiCpuDecoder.cpp ----0------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//
-#include "TraceIntelPTMultiCoreDecoder.h"
+#include "TraceIntelPTMultiCpuDecoder.h"
#include "TraceIntelPT.h"
using namespace lldb_private::trace_intel_pt;
using namespace llvm;
-TraceIntelPTMultiCoreDecoder::TraceIntelPTMultiCoreDecoder(TraceIntelPT &trace)
+TraceIntelPTMultiCpuDecoder::TraceIntelPTMultiCpuDecoder(TraceIntelPT &trace)
: m_trace(&trace) {
for (Process *proc : trace.GetAllProcesses()) {
for (ThreadSP thread_sp : proc->GetThreadList().Threads()) {
}
}
-bool TraceIntelPTMultiCoreDecoder::TracesThread(lldb::tid_t tid) const {
+bool TraceIntelPTMultiCpuDecoder::TracesThread(lldb::tid_t tid) const {
return m_tids.count(tid);
}
-DecodedThreadSP TraceIntelPTMultiCoreDecoder::Decode(Thread &thread) {
+DecodedThreadSP TraceIntelPTMultiCpuDecoder::Decode(Thread &thread) {
if (Error err = CorrelateContextSwitchesAndIntelPtTraces())
return std::make_shared<DecodedThread>(thread.shared_from_this(),
std::move(err));
DecodedThreadSP decoded_thread_sp =
std::make_shared<DecodedThread>(thread.shared_from_this());
- Error err = m_trace->OnAllCoresBinaryDataRead(
- IntelPTDataKinds::kTraceBuffer,
- [&](const DenseMap<core_id_t, ArrayRef<uint8_t>>& buffers) -> Error {
+ Error err = m_trace->OnAllCpusBinaryDataRead(
+ IntelPTDataKinds::kIptTrace,
+ [&](const DenseMap<cpu_id_t, ArrayRef<uint8_t>> &buffers) -> Error {
auto it = m_continuous_executions_per_thread->find(thread.GetID());
if (it != m_continuous_executions_per_thread->end())
- DecodeSystemWideTraceForThread(*decoded_thread_sp, *m_trace, buffers, it->second);
+ DecodeSystemWideTraceForThread(*decoded_thread_sp, *m_trace, buffers,
+ it->second);
return Error::success();
});
}
static Expected<std::vector<IntelPTThreadSubtrace>>
-GetIntelPTSubtracesForCore(TraceIntelPT &trace, core_id_t core_id) {
+GetIntelPTSubtracesForCpu(TraceIntelPT &trace, cpu_id_t cpu_id) {
std::vector<IntelPTThreadSubtrace> intel_pt_subtraces;
- Error err = trace.OnCoreBinaryDataRead(
- core_id, IntelPTDataKinds::kTraceBuffer,
+ Error err = trace.OnCpuBinaryDataRead(
+ cpu_id, IntelPTDataKinds::kIptTrace,
[&](ArrayRef<uint8_t> data) -> Error {
Expected<std::vector<IntelPTThreadSubtrace>> split_trace =
SplitTraceInContinuousExecutions(trace, data);
return intel_pt_subtraces;
}
-Expected<
- DenseMap<lldb::tid_t, std::vector<IntelPTThreadContinousExecution>>>
-TraceIntelPTMultiCoreDecoder::DoCorrelateContextSwitchesAndIntelPtTraces() {
+Expected<DenseMap<lldb::tid_t, std::vector<IntelPTThreadContinousExecution>>>
+TraceIntelPTMultiCpuDecoder::DoCorrelateContextSwitchesAndIntelPtTraces() {
DenseMap<lldb::tid_t, std::vector<IntelPTThreadContinousExecution>>
continuous_executions_per_thread;
LinuxPerfZeroTscConversion tsc_conversion = *conv_opt;
- for (core_id_t core_id : m_trace->GetTracedCores()) {
+ for (cpu_id_t cpu_id : m_trace->GetTracedCpus()) {
Expected<std::vector<IntelPTThreadSubtrace>> intel_pt_subtraces =
- GetIntelPTSubtracesForCore(*m_trace, core_id);
+ GetIntelPTSubtracesForCpu(*m_trace, cpu_id);
if (!intel_pt_subtraces)
return intel_pt_subtraces.takeError();
// pt subtraces sorted by time.
auto it = intel_pt_subtraces->begin();
auto on_new_thread_execution =
- [&](const ThreadContinuousExecution& thread_execution) {
+ [&](const ThreadContinuousExecution &thread_execution) {
IntelPTThreadContinousExecution execution(thread_execution);
for (; it != intel_pt_subtraces->end() &&
continuous_executions_per_thread[thread_execution.tid].push_back(
execution);
};
- Error err = m_trace->OnCoreBinaryDataRead(
- core_id, IntelPTDataKinds::kPerfContextSwitchTrace,
+ Error err = m_trace->OnCpuBinaryDataRead(
+ cpu_id, IntelPTDataKinds::kPerfContextSwitchTrace,
[&](ArrayRef<uint8_t> data) -> Error {
Expected<std::vector<ThreadContinuousExecution>> executions =
- DecodePerfContextSwitchTrace(data, core_id, tsc_conversion);
+ DecodePerfContextSwitchTrace(data, cpu_id, tsc_conversion);
if (!executions)
return executions.takeError();
for (const ThreadContinuousExecution &exec : *executions)
return continuous_executions_per_thread;
}
-Error TraceIntelPTMultiCoreDecoder::CorrelateContextSwitchesAndIntelPtTraces() {
+Error TraceIntelPTMultiCpuDecoder::CorrelateContextSwitchesAndIntelPtTraces() {
if (m_setup_error)
return createStringError(inconvertibleErrorCode(), m_setup_error->c_str());
return Error::success();
}
-size_t TraceIntelPTMultiCoreDecoder::GetNumContinuousExecutionsForThread(
+size_t TraceIntelPTMultiCpuDecoder::GetNumContinuousExecutionsForThread(
lldb::tid_t tid) const {
if (!m_continuous_executions_per_thread)
return 0;
return it->second.size();
}
-size_t TraceIntelPTMultiCoreDecoder::GetTotalContinuousExecutionsCount() const {
+size_t TraceIntelPTMultiCpuDecoder::GetTotalContinuousExecutionsCount() const {
if (!m_continuous_executions_per_thread)
return 0;
size_t count = 0;
-//===-- TraceIntelPTMultiCoreDecoder.h --------------------------*- C++ -*-===//
+//===-- TraceIntelPTMultiCpuDecoder.h ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTMULTICOREDECODER_H
-#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTMULTICOREDECODER_H
+#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTMULTICPUDECODER_H
+#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTMULTICPUDECODER_H
#include "LibiptDecoder.h"
#include "PerfContextSwitchDecoder.h"
namespace lldb_private {
namespace trace_intel_pt {
-/// Class used to decode a multi-core Intel PT trace. It assumes that each
-/// thread could have potentially been executed on different cores. It uses a
-/// context switch trace per CPU with timestamps to identify which thread owns
+/// Class used to decode a multi-cpu Intel PT trace. It assumes that each
+/// thread could have potentially been executed on different cpu cores. It uses
+/// a context switch trace per CPU with timestamps to identify which thread owns
/// each Intel PT decoded instruction and in which order. It also assumes that
/// the Intel PT data and context switches might have gaps in their traces due
/// to contention or race conditions. Finally, it assumes that a tid is not
///
/// This object should be recreated after every stop in the case of live
/// processes.
-class TraceIntelPTMultiCoreDecoder {
+class TraceIntelPTMultiCpuDecoder {
public:
/// \param[in] TraceIntelPT
/// The trace object to be decoded
- TraceIntelPTMultiCoreDecoder(TraceIntelPT &trace);
+ TraceIntelPTMultiCpuDecoder(TraceIntelPT &trace);
/// \return
/// A \a DecodedThread for the \p thread by decoding its instructions on all
size_t GetTotalContinuousExecutionsCount() const;
private:
- /// Traverse the context switch traces and the basic intel pt continuous subtraces
- /// and produce a list of continuous executions for each process and thread.
+ /// Traverse the context switch traces and the basic intel pt continuous
+ /// subtraces and produce a list of continuous executions for each process and
+ /// thread.
///
/// See \a DoCorrelateContextSwitchesAndIntelPtTraces.
///
} // namespace trace_intel_pt
} // namespace lldb_private
-#endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTMULTICOREDECODER_H
+#endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTMULTICPUDECODER_H
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-core trace "
+ 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.">;
- def process_trace_start_intel_pt_per_core_tracing:
- Option<"per-core-tracing", "c">,
+ 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 cores "
+ "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 "
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 core traces of this process, "
+ "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 "
lldb::tid_t tid = static_cast<lldb::tid_t>(thread.tid);
Optional<FileSpec> trace_file;
- if (thread.trace_buffer)
- trace_file = FileSpec(*thread.trace_buffer);
+ if (thread.ipt_trace)
+ trace_file = FileSpec(*thread.ipt_trace);
ThreadPostMortemTraceSP thread_sp =
std::make_shared<ThreadPostMortemTrace>(process, tid, trace_file);
// optional.
{
"tid": integer,
- "traceBuffer"?: string
+ "iptTrace"?: string
// Path to the raw Intel PT buffer file for this thread.
}
],
]
}
],
- "cores"?: [
+ "cpus"?: [
{
- "coreId": integer,
+ "id": integer,
// Id of this CPU core.
- "traceBuffer": string,
- // Path to the raw Intel PT buffer for this core.
+ "iptTrace": string,
+ // Path to the raw Intel PT buffer for this cpu core.
"contextSwitchTrace": string,
- // Path to the raw perf_event_open context switch trace file for this core.
+ // Path to the raw perf_event_open context switch trace file for this cpu core.
// The perf_event must have been configured with PERF_SAMPLE_TID and
// PERF_SAMPLE_TIME, as well as sample_id_all = 1.
}
Notes:
- All paths are either absolute or relative to folder containing the session file.
-- "cores" is provided if and only if processes[].threads[].traceBuffer is not provided.
-- "tscPerfZeroConversion" must be provided if "cores" is provided.
+- "cpus" is provided if and only if processes[].threads[].iptTrace is not provided.
+- "tscPerfZeroConversion" must be provided if "cpus" is provided.
})";
}
return schema;
Error TraceIntelPTSessionFileParser::AugmentThreadsFromContextSwitches(
JSONTraceSession &session) {
- if (!session.cores)
+ if (!session.cpus)
return Error::success();
if (!session.tsc_perf_zero_conversion)
if (indexed_threads[proc->second].count(tid))
return;
indexed_threads[proc->second].insert(tid);
- proc->second->threads.push_back({tid, /*trace_buffer=*/None});
+ proc->second->threads.push_back({tid, /*ipt_trace=*/None});
};
- for (const JSONCore &core : *session.cores) {
+ for (const JSONCpu &cpu : *session.cpus) {
Error err = Trace::OnDataFileRead(
- FileSpec(core.context_switch_trace),
+ FileSpec(cpu.context_switch_trace),
[&](ArrayRef<uint8_t> data) -> Error {
Expected<std::vector<ThreadContinuousExecution>> executions =
- DecodePerfContextSwitchTrace(data, core.core_id,
+ DecodePerfContextSwitchTrace(data, cpu.id,
*session.tsc_perf_zero_conversion);
if (!executions)
return executions.takeError();
module.file = NormalizePath(*module.file).GetPath();
}
for (JSONThread &thread : process.threads) {
- if (thread.trace_buffer)
- thread.trace_buffer = NormalizePath(*thread.trace_buffer).GetPath();
+ if (thread.ipt_trace)
+ thread.ipt_trace = NormalizePath(*thread.ipt_trace).GetPath();
}
}
- if (session.cores) {
- for (JSONCore &core : *session.cores) {
- core.context_switch_trace =
- NormalizePath(core.context_switch_trace).GetPath();
- core.trace_buffer = NormalizePath(core.trace_buffer).GetPath();
+ if (session.cpus) {
+ for (JSONCpu &cpu : *session.cpus) {
+ cpu.context_switch_trace =
+ NormalizePath(cpu.context_switch_trace).GetPath();
+ cpu.ipt_trace = NormalizePath(cpu.ipt_trace).GetPath();
}
}
}
JSONThread json_thread;
json_thread.tid = tid;
- if (trace_sp->GetTracedCores().empty()) {
+ if (trace_sp->GetTracedCpus().empty()) {
FileSpec output_file = threads_dir;
output_file.AppendPathComponent(std::to_string(tid) + ".intelpt_trace");
- json_thread.trace_buffer = output_file.GetPath();
+ json_thread.ipt_trace = output_file.GetPath();
llvm::Error err = process.GetTarget().GetTrace()->OnThreadBinaryDataRead(
- tid, IntelPTDataKinds::kTraceBuffer,
+ tid, IntelPTDataKinds::kIptTrace,
[&](llvm::ArrayRef<uint8_t> data) -> llvm::Error {
return WriteBytesToDisk(output_file, data);
});
return json_threads;
}
-static llvm::Expected<llvm::Optional<std::vector<JSONCore>>>
-BuildCoresSection(TraceIntelPT &trace_ipt, FileSpec directory) {
- if (trace_ipt.GetTracedCores().empty())
+static llvm::Expected<llvm::Optional<std::vector<JSONCpu>>>
+BuildCpusSection(TraceIntelPT &trace_ipt, FileSpec directory) {
+ if (trace_ipt.GetTracedCpus().empty())
return None;
- std::vector<JSONCore> json_cores;
- FileSpec cores_dir = directory;
- cores_dir.AppendPathComponent("cores");
- sys::fs::create_directories(cores_dir.GetCString());
+ std::vector<JSONCpu> json_cpus;
+ FileSpec cpus_dir = directory;
+ cpus_dir.AppendPathComponent("cpus");
+ sys::fs::create_directories(cpus_dir.GetCString());
- for (lldb::core_id_t core_id : trace_ipt.GetTracedCores()) {
- JSONCore json_core;
- json_core.core_id = core_id;
+ for (lldb::cpu_id_t cpu_id : trace_ipt.GetTracedCpus()) {
+ JSONCpu json_cpu;
+ json_cpu.id = cpu_id;
{
- FileSpec output_trace = cores_dir;
- output_trace.AppendPathComponent(std::to_string(core_id) +
+ FileSpec output_trace = cpus_dir;
+ output_trace.AppendPathComponent(std::to_string(cpu_id) +
".intelpt_trace");
- json_core.trace_buffer = output_trace.GetPath();
+ json_cpu.ipt_trace = output_trace.GetPath();
- llvm::Error err = trace_ipt.OnCoreBinaryDataRead(
- core_id, IntelPTDataKinds::kTraceBuffer,
+ llvm::Error err = trace_ipt.OnCpuBinaryDataRead(
+ cpu_id, IntelPTDataKinds::kIptTrace,
[&](llvm::ArrayRef<uint8_t> data) -> llvm::Error {
return WriteBytesToDisk(output_trace, data);
});
}
{
- FileSpec output_context_switch_trace = cores_dir;
+ FileSpec output_context_switch_trace = cpus_dir;
output_context_switch_trace.AppendPathComponent(
- std::to_string(core_id) + ".perf_context_switch_trace");
- json_core.context_switch_trace = output_context_switch_trace.GetPath();
+ std::to_string(cpu_id) + ".perf_context_switch_trace");
+ json_cpu.context_switch_trace = output_context_switch_trace.GetPath();
- llvm::Error err = trace_ipt.OnCoreBinaryDataRead(
- core_id, IntelPTDataKinds::kPerfContextSwitchTrace,
+ llvm::Error err = trace_ipt.OnCpuBinaryDataRead(
+ cpu_id, IntelPTDataKinds::kPerfContextSwitchTrace,
[&](llvm::ArrayRef<uint8_t> data) -> llvm::Error {
return WriteBytesToDisk(output_context_switch_trace, data);
});
if (err)
return std::move(err);
}
- json_cores.push_back(std::move(json_core));
+ json_cpus.push_back(std::move(json_cpu));
}
- return json_cores;
+ return json_cpus;
}
/// Build modules sub-section of the trace's session. The original modules
if (!json_processes)
return json_processes.takeError();
- Expected<Optional<std::vector<JSONCore>>> json_cores =
- BuildCoresSection(trace_ipt, directory);
- if (!json_cores)
- return json_cores.takeError();
+ Expected<Optional<std::vector<JSONCpu>>> json_cpus =
+ BuildCpusSection(trace_ipt, directory);
+ if (!json_cpus)
+ return json_cpus.takeError();
JSONTraceSession json_intel_pt_session{"intel-pt", *cpu_info, *json_processes,
- *json_cores,
+ *json_cpus,
trace_ipt.GetPerfZeroTscConversion()};
return WriteSessionToFile(toJSON(json_intel_pt_session), directory);
return Lookup2(storage.live_thread_data, tid, ConstString(kind));
}
-Optional<uint64_t> Trace::GetLiveCoreBinaryDataSize(lldb::core_id_t core_id,
- llvm::StringRef kind) {
+Optional<uint64_t> Trace::GetLiveCpuBinaryDataSize(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind) {
Storage &storage = GetUpdatedStorage();
- return Lookup2(storage.live_core_data_sizes, core_id, ConstString(kind));
+ return Lookup2(storage.live_cpu_data_sizes, cpu_id, ConstString(kind));
}
Optional<uint64_t> Trace::GetLiveProcessBinaryDataSize(llvm::StringRef kind) {
return createStringError(
inconvertibleErrorCode(),
formatv("Attempted to fetch live trace data without a live process. "
- "Data kind = {0}, tid = {1}, core id = {2}.",
- request.kind, request.tid, request.core_id));
+ "Data kind = {0}, tid = {1}, cpu id = {2}.",
+ request.kind, request.tid, request.cpu_id));
Expected<std::vector<uint8_t>> data =
m_live_process->TraceGetBinaryData(request);
return createStringError(
inconvertibleErrorCode(),
formatv("Got incomplete live trace data. Data kind = {0}, expected "
- "size = {1}, actual size = {2}, tid = {3}, core id = {4}",
+ "size = {1}, actual size = {2}, tid = {3}, cpu id = {4}",
request.kind, expected_size, data->size(), request.tid,
- request.core_id));
+ request.cpu_id));
return data;
}
kind.data(), tid);
TraceGetBinaryDataRequest request{GetPluginName().str(), kind.str(), tid,
- /*core_id=*/None};
+ /*cpu_id=*/None};
return GetLiveTraceBinaryData(request, *size);
}
Expected<std::vector<uint8_t>>
-Trace::GetLiveCoreBinaryData(lldb::core_id_t core_id, llvm::StringRef kind) {
+Trace::GetLiveCpuBinaryData(lldb::cpu_id_t cpu_id, llvm::StringRef kind) {
if (!m_live_process)
return createStringError(
inconvertibleErrorCode(),
"Attempted to fetch live cpu data without a live process.");
- llvm::Optional<uint64_t> size = GetLiveCoreBinaryDataSize(core_id, kind);
+ llvm::Optional<uint64_t> size = GetLiveCpuBinaryDataSize(cpu_id, kind);
if (!size)
return createStringError(
inconvertibleErrorCode(),
- "Tracing data \"%s\" is not available for core_id %" PRIu64 ".",
- kind.data(), core_id);
+ "Tracing data \"%s\" is not available for cpu_id %" PRIu64 ".",
+ kind.data(), cpu_id);
TraceGetBinaryDataRequest request{GetPluginName().str(), kind.str(),
- /*tid=*/None, core_id};
+ /*tid=*/None, cpu_id};
return m_live_process->TraceGetBinaryData(request);
}
"Tracing data \"%s\" is not available for the process.", kind.data());
TraceGetBinaryDataRequest request{GetPluginName().str(), kind.str(),
- /*tid=*/None, /*core_id*/ None};
+ /*tid=*/None, /*cpu_id*/ None};
return GetLiveTraceBinaryData(request, *size);
}
LLDB_LOG(log, "== Found {0} threads being traced",
live_process_state->traced_threads.size());
- if (live_process_state->cores) {
- m_storage.cores.emplace();
- for (const TraceCoreState &core_state : *live_process_state->cores) {
- m_storage.cores->push_back(core_state.core_id);
- for (const TraceBinaryData &item : core_state.binary_data)
- m_storage.live_core_data_sizes[core_state.core_id].insert(
+ if (live_process_state->cpus) {
+ m_storage.cpus.emplace();
+ for (const TraceCpuState &cpu_state : *live_process_state->cpus) {
+ m_storage.cpus->push_back(cpu_state.id);
+ for (const TraceBinaryData &item : cpu_state.binary_data)
+ m_storage.live_cpu_data_sizes[cpu_state.id].insert(
{ConstString(item.kind), item.size});
}
- LLDB_LOG(log, "== Found {0} cpu cores being traced",
- live_process_state->cores->size());
+ LLDB_LOG(log, "== Found {0} cpu cpus being traced",
+ live_process_state->cpus->size());
}
for (const TraceBinaryData &item : live_process_state->process_binary_data)
}
Trace::Trace(ArrayRef<ProcessSP> postmortem_processes,
- Optional<std::vector<lldb::core_id_t>> postmortem_cores) {
+ Optional<std::vector<lldb::cpu_id_t>> postmortem_cpus) {
for (ProcessSP process_sp : postmortem_processes)
m_storage.postmortem_processes.push_back(process_sp.get());
- m_storage.cores = postmortem_cores;
+ m_storage.cpus = postmortem_cpus;
}
Process *Trace::GetLiveProcess() { return m_live_process; }
tid, kind));
}
-llvm::Expected<FileSpec>
-Trace::GetPostMortemCoreDataFile(lldb::core_id_t core_id,
- llvm::StringRef kind) {
+llvm::Expected<FileSpec> Trace::GetPostMortemCpuDataFile(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind) {
Storage &storage = GetUpdatedStorage();
if (Optional<FileSpec> file =
- Lookup2(storage.postmortem_core_data, core_id, ConstString(kind)))
+ Lookup2(storage.postmortem_cpu_data, cpu_id, ConstString(kind)))
return *file;
else
return createStringError(
inconvertibleErrorCode(),
- formatv("The core with id={0} doesn't have the tracing data {1}",
- core_id, kind));
+ formatv("The cpu with id={0} doesn't have the tracing data {1}", cpu_id,
+ kind));
}
void Trace::SetPostMortemThreadDataFile(lldb::tid_t tid, llvm::StringRef kind,
storage.postmortem_thread_data[tid].insert({ConstString(kind), file_spec});
}
-void Trace::SetPostMortemCoreDataFile(lldb::core_id_t core_id,
- llvm::StringRef kind,
- FileSpec file_spec) {
+void Trace::SetPostMortemCpuDataFile(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind, FileSpec file_spec) {
Storage &storage = GetUpdatedStorage();
- storage.postmortem_core_data[core_id].insert({ConstString(kind), file_spec});
+ storage.postmortem_cpu_data[cpu_id].insert({ConstString(kind), file_spec});
}
llvm::Error
return callback(*data);
}
-llvm::Error Trace::OnLiveCoreBinaryDataRead(lldb::core_id_t core_id,
- llvm::StringRef kind,
- OnBinaryDataReadCallback callback) {
+llvm::Error Trace::OnLiveCpuBinaryDataRead(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind,
+ OnBinaryDataReadCallback callback) {
Storage &storage = GetUpdatedStorage();
- if (std::vector<uint8_t> *core_data =
- Lookup2AsPtr(storage.live_core_data, core_id, ConstString(kind)))
- return callback(*core_data);
+ if (std::vector<uint8_t> *cpu_data =
+ Lookup2AsPtr(storage.live_cpu_data, cpu_id, ConstString(kind)))
+ return callback(*cpu_data);
- Expected<std::vector<uint8_t>> data = GetLiveCoreBinaryData(core_id, kind);
+ Expected<std::vector<uint8_t>> data = GetLiveCpuBinaryData(cpu_id, kind);
if (!data)
return data.takeError();
- auto it = storage.live_core_data[core_id].insert(
+ auto it = storage.live_cpu_data[cpu_id].insert(
{ConstString(kind), std::move(*data)});
return callback(it.first->second);
}
}
llvm::Error
-Trace::OnPostMortemCoreBinaryDataRead(lldb::core_id_t core_id,
- llvm::StringRef kind,
- OnBinaryDataReadCallback callback) {
- if (Expected<FileSpec> file = GetPostMortemCoreDataFile(core_id, kind))
+Trace::OnPostMortemCpuBinaryDataRead(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind,
+ OnBinaryDataReadCallback callback) {
+ if (Expected<FileSpec> file = GetPostMortemCpuDataFile(cpu_id, kind))
return OnDataFileRead(*file, callback);
else
return file.takeError();
}
llvm::Error
-Trace::OnAllCoresBinaryDataRead(llvm::StringRef kind,
- OnCoresBinaryDataReadCallback callback) {
- DenseMap<core_id_t, ArrayRef<uint8_t>> buffers;
+Trace::OnAllCpusBinaryDataRead(llvm::StringRef kind,
+ OnCpusBinaryDataReadCallback callback) {
+ DenseMap<cpu_id_t, ArrayRef<uint8_t>> buffers;
Storage &storage = GetUpdatedStorage();
- if (!storage.cores)
+ if (!storage.cpus)
return Error::success();
- std::function<Error(std::vector<core_id_t>::iterator)> process_core =
- [&](std::vector<core_id_t>::iterator core_id) -> Error {
- if (core_id == storage.cores->end())
+ std::function<Error(std::vector<cpu_id_t>::iterator)> process_cpu =
+ [&](std::vector<cpu_id_t>::iterator cpu_id) -> Error {
+ if (cpu_id == storage.cpus->end())
return callback(buffers);
- return OnCoreBinaryDataRead(*core_id, kind,
- [&](ArrayRef<uint8_t> data) -> Error {
- buffers.try_emplace(*core_id, data);
- auto next_id = core_id;
- next_id++;
- return process_core(next_id);
- });
+ return OnCpuBinaryDataRead(*cpu_id, kind,
+ [&](ArrayRef<uint8_t> data) -> Error {
+ buffers.try_emplace(*cpu_id, data);
+ auto next_id = cpu_id;
+ next_id++;
+ return process_cpu(next_id);
+ });
};
- return process_core(storage.cores->begin());
+ return process_cpu(storage.cpus->begin());
}
-llvm::Error Trace::OnCoreBinaryDataRead(lldb::core_id_t core_id,
- llvm::StringRef kind,
- OnBinaryDataReadCallback callback) {
+llvm::Error Trace::OnCpuBinaryDataRead(lldb::cpu_id_t cpu_id,
+ llvm::StringRef kind,
+ OnBinaryDataReadCallback callback) {
if (m_live_process)
- return OnLiveCoreBinaryDataRead(core_id, kind, callback);
+ return OnLiveCpuBinaryDataRead(cpu_id, kind, callback);
else
- return OnPostMortemCoreBinaryDataRead(core_id, kind, callback);
+ return OnPostMortemCpuBinaryDataRead(cpu_id, kind, callback);
}
-ArrayRef<lldb::core_id_t> Trace::GetTracedCores() {
+ArrayRef<lldb::cpu_id_t> Trace::GetTracedCpus() {
Storage &storage = GetUpdatedStorage();
- if (storage.cores)
- return *storage.cores;
+ if (storage.cpus)
+ return *storage.cpus;
return {};
}
ObjectMapper o(value, path);
return o && o.map("tracedThreads", packet.traced_threads) &&
o.map("processBinaryData", packet.process_binary_data) &&
- o.map("cores", packet.cores) &&
- o.map("warnings", packet.warnings);
+ o.map("cpus", packet.cpus) && o.map("warnings", packet.warnings);
}
json::Value toJSON(const TraceGetStateResponse &packet) {
return json::Value(Object{{"tracedThreads", packet.traced_threads},
{"processBinaryData", packet.process_binary_data},
- {"cores", packet.cores},
+ {"cpus", packet.cpus},
{"warnings", packet.warnings}});
}
warnings->push_back(warning.data());
}
-bool fromJSON(const json::Value &value, TraceCoreState &packet,
+bool fromJSON(const json::Value &value, TraceCpuState &packet,
json::Path path) {
ObjectMapper o(value, path);
- uint64_t core_id;
- if (!(o && o.map("coreId", core_id) &&
- o.map("binaryData", packet.binary_data)))
+ uint64_t cpu_id;
+ if (!(o && o.map("id", cpu_id) && o.map("binaryData", packet.binary_data)))
return false;
- packet.core_id = static_cast<lldb::core_id_t>(core_id);
+ packet.id = static_cast<lldb::cpu_id_t>(cpu_id);
return true;
}
-json::Value toJSON(const TraceCoreState &packet) {
+json::Value toJSON(const TraceCpuState &packet) {
return json::Value(
- Object{{"coreId", packet.core_id}, {"binaryData", packet.binary_data}});
+ Object{{"id", packet.id}, {"binaryData", packet.binary_data}});
}
/// \}
return json::Value(Object{{"type", packet.type},
{"kind", packet.kind},
{"tid", packet.tid},
- {"coreId", packet.core_id}});
+ {"cpuId", packet.cpu_id}});
}
bool fromJSON(const json::Value &value, TraceGetBinaryDataRequest &packet,
Path path) {
ObjectMapper o(value, path);
- Optional<uint64_t> core_id;
+ Optional<uint64_t> cpu_id;
if (!(o && o.map("type", packet.type) && o.map("kind", packet.kind) &&
- o.map("tid", packet.tid) && o.map("coreId", core_id)))
+ o.map("tid", packet.tid) && o.map("cpuId", cpu_id)))
return false;
- if (core_id)
- packet.core_id = static_cast<lldb::core_id_t>(*core_id);
+ if (cpu_id)
+ packet.cpu_id = static_cast<lldb::cpu_id_t>(*cpu_id);
return true;
}
/// \}
namespace lldb_private {
const char *IntelPTDataKinds::kProcFsCpuInfo = "procfsCpuInfo";
-const char *IntelPTDataKinds::kTraceBuffer = "traceBuffer";
+const char *IntelPTDataKinds::kIptTrace = "iptTrace";
const char *IntelPTDataKinds::kPerfContextSwitchTrace =
"perfContextSwitchTrace";
-bool TraceIntelPTStartRequest::IsPerCoreTracing() const {
- return per_core_tracing.getValueOr(false);
+bool TraceIntelPTStartRequest::IsPerCpuTracing() const {
+ return per_cpu_tracing.getValueOr(false);
}
bool fromJSON(const json::Value &value, TraceIntelPTStartRequest &packet,
if (!o || !fromJSON(value, (TraceStartRequest &)packet, path) ||
!o.map("enableTsc", packet.enable_tsc) ||
!o.map("psbPeriod", packet.psb_period) ||
- !o.map("traceBufferSize", packet.trace_buffer_size))
+ !o.map("iptTraceSize", packet.ipt_trace_size))
return false;
if (packet.IsProcessTracing()) {
if (!o.map("processBufferSizeLimit", packet.process_buffer_size_limit) ||
- !o.map("perCoreTracing", packet.per_core_tracing))
+ !o.map("perCpuTracing", packet.per_cpu_tracing))
return false;
}
return true;
json::Value toJSON(const TraceIntelPTStartRequest &packet) {
json::Value base = toJSON((const TraceStartRequest &)packet);
json::Object &obj = *base.getAsObject();
- obj.try_emplace("traceBufferSize", packet.trace_buffer_size);
+ obj.try_emplace("iptTraceSize", packet.ipt_trace_size);
obj.try_emplace("processBufferSizeLimit", packet.process_buffer_size_limit);
obj.try_emplace("psbPeriod", packet.psb_period);
obj.try_emplace("enableTsc", packet.enable_tsc);
- obj.try_emplace("perCoreTracing", packet.per_core_tracing);
+ obj.try_emplace("perCpuTracing", packet.per_cpu_tracing);
return base;
}
self.expect("process trace save -d " +
os.path.join(self.getBuildDir(), "intelpt-trace", "trace_not_live_dir"))
- def testSaveMultiCoreTrace(self):
+ def testSaveMultiCpuTrace(self):
'''
- This test starts a per-core tracing session, then saves the session to disk, and
+ This test starts a per-cpu tracing session, then saves the session to disk, and
finally it loads it again.
'''
- self.skipIfPerCoreTracingIsNotSupported()
+ self.skipIfPerCpuTracingIsNotSupported()
self.expect("target create " +
os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
self.expect("b main")
self.expect("r")
- self.expect("process trace start --per-core-tracing")
+ self.expect("process trace start --per-cpu-tracing")
self.expect("b 7")
output_dir = os.path.join(self.getBuildDir(), "intelpt-trace", "trace_save")
session = json.load(session_file)
# We expect tsc conversion info
self.assertTrue("tscPerfZeroConversion" in session)
- # We expect at least one core
- self.assertGreater(len(session["cores"]), 0)
+ # We expect at least one cpu
+ self.assertGreater(len(session["cpus"]), 0)
# We expect the required trace files to be created
- for core in session["cores"]:
- core_files_prefix = os.path.join(output_dir, "cores", str(core["coreId"]))
- self.assertTrue(os.path.exists(core_files_prefix + ".intelpt_trace"))
- self.assertTrue(os.path.exists(core_files_prefix + ".perf_context_switch_trace"))
+ for cpu in session["cpus"]:
+ cpu_files_prefix = os.path.join(output_dir, "cpus", str(cpu["id"]))
+ self.assertTrue(os.path.exists(cpu_files_prefix + ".intelpt_trace"))
+ self.assertTrue(os.path.exists(cpu_files_prefix + ".perf_context_switch_trace"))
# We expect at least one one process
self.assertGreater(len(session["processes"]), 0)
self.assertGreater(len(process["threads"]), 0)
# We don't expect thread traces
for thread in process["threads"]:
- self.assertTrue(("traceBuffer" not in thread) or (thread["traceBuffer"] is None))
+ self.assertTrue(("iptTrace" not in thread) or (thread["iptTrace"] is None))
original_trace_session_file = os.path.join(output_dir, "trace.json")
checkSessionBundle(original_trace_session_file)
copied_thread = find(lambda thr : thr["tid"] == thread["tid"], copied_process["threads"])
self.assertTrue(copied_thread is not None)
- for core in original["cores"]:
- copied_core = find(lambda cor : cor["coreId"] == core["coreId"], copy["cores"])
- self.assertTrue(copied_core is not None)
+ for cpu in original["cpus"]:
+ copied_cpu = find(lambda cor : cor["id"] == cpu["id"], copy["cpus"])
+ self.assertTrue(copied_cpu is not None)
def testSaveTrace(self):
self.expect("target create " +
mydir = TestBase.compute_mydir(__file__)
def testSchema(self):
- self.expect("trace schema intel-pt", substrs=["triple", "threads", "traceBuffer"])
+ self.expect("trace schema intel-pt", substrs=["triple", "threads", "iptTrace"])
def testInvalidPluginSchema(self):
self.expect("trace schema invalid-plugin", error=True,
self.expect("r")
self.traceStartThread(
- error=True, traceBufferSize=2000,
- substrs=["The trace buffer size must be a power of 2", "It was 2000"])
+ error=True, iptTraceSize=2000,
+ substrs=["The intel pt trace size must be a power of 2", "It was 2000"])
self.traceStartThread(
- error=True, traceBufferSize=5000,
- substrs=["The trace buffer size must be a power of 2", "It was 5000"])
+ error=True, iptTraceSize=5000,
+ substrs=["The intel pt trace size must be a power of 2", "It was 5000"])
self.traceStartThread(
- error=True, traceBufferSize=0,
- substrs=["The trace buffer size must be a power of 2", "It was 0"])
+ error=True, iptTraceSize=0,
+ substrs=["The intel pt trace size must be a power of 2", "It was 0"])
- self.traceStartThread(traceBufferSize=1048576)
+ self.traceStartThread(iptTraceSize=1048576)
@skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))
def testSBAPIHelp(self):
self.expect("r")
help = self.getTraceOrCreate().GetStartConfigurationHelp()
- self.assertIn("traceBufferSize", help)
+ self.assertIn("iptTraceSize", help)
self.assertIn("processBufferSizeLimit", help)
@skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))
{
- "cores": [
+ "cpus": [
{
"contextSwitchTrace": "cores/45.perf_context_switch_trace",
- "coreId": 45,
- "traceBuffer": "cores/45.intelpt_trace"
+ "id": 45,
+ "iptTrace": "cores/45.intelpt_trace"
},
{
"contextSwitchTrace": "cores/51.perf_context_switch_trace",
- "coreId": 51,
- "traceBuffer": "cores/51.intelpt_trace"
+ "id": 51,
+ "iptTrace": "cores/51.intelpt_trace"
}
],
"cpuInfo": {
{
- "cores": [
+ "cpus": [
{
"contextSwitchTrace": "cores/45.perf_context_switch_trace",
- "coreId": 45,
- "traceBuffer": "cores/45.intelpt_trace"
+ "id": 45,
+ "iptTrace": "cores/45.intelpt_trace"
},
{
"contextSwitchTrace": "cores/51.perf_context_switch_trace",
- "coreId": 51,
- "traceBuffer": "cores/51.intelpt_trace"
+ "id": 51,
+ "iptTrace": "cores/51.intelpt_trace"
}
],
"cpuInfo": {
"threads": [
{
"tid": 815455,
- "traceBuffer": "multi-file.trace"
+ "iptTrace": "multi-file.trace"
}
],
"modules": [
"threads": [
{
"tid": 3842849,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": [
"threads": [
{
"tid": 3842849,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
},
{
"tid": 3842850,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": [
"threads": [
{
"tid": 5678,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": [
"threads": [
{
"tid": 56789,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": []
"threads": [
{
"tid": 5678,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": [
"threads": [
{
"tid": 5678,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": [
"threads": [
{
"tid": 3842849,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": [
"threads": [
{
"tid": 3842849,
- "traceBuffer": "3842849.trace"
+ "iptTrace": "3842849.trace"
}
],
"modules": [
@skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))
@testSBAPIAndCommands
- def testStartPerCoreSession(self):
- self.skipIfPerCoreTracingIsNotSupported()
+ def testStartPerCpuSession(self):
+ self.skipIfPerCpuTracingIsNotSupported()
self.build()
exe = self.getBuildArtifact("a.out")
self.expect("r")
# We should fail if we hit the total buffer limit. Useful if the number
- # of cores is huge.
+ # of cpus is huge.
self.traceStartProcess(error="True", processBufferSizeLimit=100,
- perCoreTracing=True,
+ perCpuTracing=True,
substrs=["The process can't be traced because the process trace size "
"limit has been reached. Consider retracing with a higher limit."])
- self.traceStartProcess(perCoreTracing=True)
+ self.traceStartProcess(perCpuTracing=True)
self.traceStopProcess()
- self.traceStartProcess(perCoreTracing=True)
- # We can't support multiple per-core tracing sessions.
- self.traceStartProcess(error=True, perCoreTracing=True,
+ self.traceStartProcess(perCpuTracing=True)
+ # We can't support multiple per-cpu tracing sessions.
+ self.traceStartProcess(error=True, perCpuTracing=True,
substrs=["Process currently traced. Stop process tracing first"])
- # We can't support tracing per thread is per core is enabled.
+ # We can't support tracing per thread is per cpu is enabled.
self.traceStartThread(
error="True",
substrs=["Thread with tid ", "is currently traced"])
- # We can't stop individual thread when per core is enabled.
+ # We can't stop individual thread when per cpu is enabled.
self.traceStopThread(error="True",
- substrs=["Can't stop tracing an individual thread when per-core process tracing is enabled"])
+ substrs=["Can't stop tracing an individual thread when per-cpu process tracing is enabled"])
# We move forward a little bit to collect some data
self.expect("b 19")
self.expect("c")
- # We will assert that the trace state will contain valid context switch and trace buffer entries.
+ # We will assert that the trace state will contain valid context switch and intel pt trace buffer entries.
# Besides that, we need to get tsc-to-nanos conversion information.
# We first parse the json response from the custom packet
output = json.loads(response)
self.assertTrue(output is not None)
- self.assertIn("cores", output)
+ self.assertIn("cpus", output)
self.assertIn("tscPerfZeroConversion", output)
found_non_empty_context_switch = False
- for core in output["cores"]:
+ for cpu in output["cpus"]:
context_switch_size = None
- trace_buffer_size = None
- for binary_data in core["binaryData"]:
- if binary_data["kind"] == "traceBuffer":
- trace_buffer_size = binary_data["size"]
+ ipt_trace_size = None
+ for binary_data in cpu["binaryData"]:
+ if binary_data["kind"] == "iptTrace":
+ ipt_trace_size = binary_data["size"]
elif binary_data["kind"] == "perfContextSwitchTrace":
context_switch_size = binary_data["size"]
self.assertTrue(context_switch_size is not None)
- self.assertTrue(trace_buffer_size is not None)
+ self.assertTrue(ipt_trace_size is not None)
if context_switch_size > 0:
found_non_empty_context_switch = True
using namespace llvm;
TEST(Perf, HardcodedLogicalCoreIDs) {
- Expected<std::vector<lldb::core_id_t>> core_ids =
+ Expected<std::vector<lldb::cpu_id_t>> cpu_ids =
GetAvailableLogicalCoreIDs(R"(processor : 13
vendor_id : GenuineIntel
cpu family : 6
power management:
)");
- ASSERT_TRUE((bool)core_ids);
- ASSERT_THAT(*core_ids, ::testing::ElementsAre(13, 24, 35, 79));
+ ASSERT_TRUE((bool)cpu_ids);
+ ASSERT_THAT(*cpu_ids, ::testing::ElementsAre(13, 24, 35, 79));
}
TEST(Perf, RealLogicalCoreIDs) {
GTEST_SKIP() << toString(buffer_or_error.takeError());
// At this point we shouldn't fail parsing the core ids
- Expected<ArrayRef<lldb::core_id_t>> core_ids = GetAvailableLogicalCoreIDs();
- ASSERT_TRUE((bool)core_ids);
- ASSERT_GT((int)core_ids->size(), 0) << "We must see at least one core";
+ Expected<ArrayRef<lldb::cpu_id_t>> cpu_ids = GetAvailableLogicalCoreIDs();
+ ASSERT_TRUE((bool)cpu_ids);
+ ASSERT_GT((int)cpu_ids->size(), 0) << "We must see at least one core";
}