diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt --- a/lldb/docs/lldb-gdb-remote.txt +++ b/lldb/docs/lldb-gdb-remote.txt @@ -308,13 +308,14 @@ // 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": , -// Size in bytes used by each individual per-thread or per-core trace +// "iptTraceSize": , +// 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. // @@ -369,7 +370,7 @@ // /* process tracing only */ // "processBufferSizeLimit": , // 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". // @@ -482,7 +483,7 @@ // Size in bytes of this thread data. // }, // ], -// "cores"?: [ +// "cpus"?: [ // "id": , // Identifier for this CPU logical core. // "binaryData": [ @@ -507,15 +508,15 @@ // // 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. // @@ -558,17 +559,11 @@ // Tracing technology name, e.g. intel-pt, arm-etm. // "kind": , // Identifier for the data. -// "coreId": , +// "cpuId": , // Core id in decimal if the data belongs to a CPU core. // "tid"?: , // 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":,"kind":,"tid":,"offset":,"size":}] diff --git a/lldb/docs/use/intel_pt.rst b/lldb/docs/use/intel_pt.rst --- a/lldb/docs/use/intel_pt.rst +++ b/lldb/docs/use/intel_pt.rst @@ -196,7 +196,7 @@ "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 diff --git a/lldb/include/lldb/Target/Trace.h b/lldb/include/lldb/Target/Trace.h --- a/lldb/include/lldb/Target/Trace.h +++ b/lldb/include/lldb/Target/Trace.h @@ -82,7 +82,7 @@ /// - 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 @@ -240,9 +240,9 @@ using OnBinaryDataReadCallback = std::function data)>; - using OnCoresBinaryDataReadCallback = std::function> - &core_to_data)>; + using OnCpusBinaryDataReadCallback = std::function> + &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 @@ -269,16 +269,16 @@ 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. @@ -291,23 +291,22 @@ /// \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 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 GetTracedCores(); + llvm::ArrayRef GetTracedCpus(); /// Helper method for reading a data file and passing its data to the given /// callback. @@ -337,20 +336,19 @@ 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. @@ -367,11 +365,11 @@ llvm::Expected 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. @@ -379,8 +377,8 @@ /// \return /// The file spec containing the requested data, or an \a llvm::Error in /// case of failures. - llvm::Expected GetPostMortemCoreDataFile(lldb::core_id_t core_id, - llvm::StringRef kind); + llvm::Expected GetPostMortemCpuDataFile(lldb::cpu_id_t cpu_id, + llvm::StringRef kind); /// Associate a given thread with a data file using a data identifier. /// @@ -395,18 +393,18 @@ 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. /// @@ -422,10 +420,10 @@ llvm::Expected> 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. @@ -434,7 +432,7 @@ /// A vector of bytes with the requested data, or an \a llvm::Error in /// case of failures. llvm::Expected> - 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. /// @@ -451,16 +449,16 @@ llvm::Optional GetLiveThreadBinaryDataSize(lldb::tid_t tid, llvm::StringRef kind); - /// Get the size of the data returned by \a GetLiveCoreBinaryData - llvm::Optional GetLiveCoreBinaryDataSize(lldb::core_id_t core_id, - llvm::StringRef kind); + /// Get the size of the data returned by \a GetLiveCpuBinaryData + llvm::Optional GetLiveCpuBinaryDataSize(lldb::cpu_id_t cpu_id, + llvm::StringRef kind); /// Get the size of the data returned by \a GetLiveProcessBinaryData llvm::Optional GetLiveProcessBinaryDataSize(llvm::StringRef kind); /// Constructor for post mortem processes Trace(llvm::ArrayRef postmortem_processes, - llvm::Optional> postmortem_cores); + llvm::Optional> postmortem_cpus); /// Constructor for a live process Trace(Process &live_process) : m_live_process(&live_process) {} @@ -541,21 +539,21 @@ llvm::DenseMap> live_thread_data; - /// core id -> data kind -> size - llvm::DenseMap> - live_core_data_sizes; - /// core id -> data kind -> bytes - llvm::DenseMap data kind -> size + llvm::DenseMap> + live_cpu_data_sizes; + /// cpu id -> data kind -> bytes + llvm::DenseMap>> - live_core_data; + live_cpu_data; /// data kind -> size llvm::DenseMap 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> cores; + llvm::Optional> cpus; /// Postmortem traces can specific additional data files, which are /// represented in this variable using a data kind identifier for each file. @@ -565,9 +563,9 @@ llvm::DenseMap> postmortem_thread_data; - /// core id -> data kind -> file - llvm::DenseMap> - postmortem_core_data; + /// cpu id -> data kind -> file + llvm::DenseMap> + postmortem_cpu_data; /// \} diff --git a/lldb/include/lldb/Utility/TraceGDBRemotePackets.h b/lldb/include/lldb/Utility/TraceGDBRemotePackets.h --- a/lldb/include/lldb/Utility/TraceGDBRemotePackets.h +++ b/lldb/include/lldb/Utility/TraceGDBRemotePackets.h @@ -118,21 +118,21 @@ 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 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 traced_threads; std::vector process_binary_data; - llvm::Optional> cores; + llvm::Optional> cpus; llvm::Optional> warnings; void AddWarning(llvm::StringRef warning); @@ -154,7 +154,7 @@ /// Optional tid if the data is related to a thread. llvm::Optional tid; /// Optional core id if the data is related to a cpu core. - llvm::Optional core_id; + llvm::Optional cpu_id; }; bool fromJSON(const llvm::json::Value &value, diff --git a/lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h b/lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h --- a/lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h +++ b/lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h @@ -24,7 +24,7 @@ // 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; }; @@ -32,7 +32,7 @@ /// \{ 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; @@ -47,10 +47,10 @@ /// then a "tracing" stop event is triggered. llvm::Optional process_buffer_size_limit; - /// Whether to have a trace buffer per thread or per cpu core. - llvm::Optional per_core_tracing; + /// Whether to have a trace buffer per thread or per cpu cpu. + llvm::Optional per_cpu_tracing; - bool IsPerCoreTracing() const; + bool IsPerCpuTracing() const; }; bool fromJSON(const llvm::json::Value &value, TraceIntelPTStartRequest &packet, diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -89,7 +89,7 @@ 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 diff --git a/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py --- a/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py @@ -33,7 +33,7 @@ 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: @@ -43,7 +43,7 @@ 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): @@ -58,38 +58,38 @@ 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: @@ -98,12 +98,12 @@ 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" @@ -113,8 +113,8 @@ 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): diff --git a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp --- a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp @@ -72,7 +72,7 @@ inconvertibleErrorCode(), "Process currently traced. Stop process tracing first"); } - if (request.IsPerCoreTracing()) { + if (request.IsPerCpuTracing()) { if (m_thread_traces.GetTracedThreadsCount() > 0) return createStringError( inconvertibleErrorCode(), @@ -170,9 +170,9 @@ 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 tsc_conversion = @@ -208,9 +208,9 @@ 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")); } diff --git a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h --- a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h +++ b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h @@ -44,18 +44,18 @@ /// 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 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 @@ -63,7 +63,7 @@ /// /// \param[in] callback.context_switch_trace /// The perf event collecting context switches for the given core. - void ForEachCore(std::function callback); @@ -87,13 +87,13 @@ /// This assumes that all underlying perf_events for each core are part of the /// same perf event group. IntelPTMultiCoreTrace( - llvm::DenseMap> &&traces_per_core, NativeProcessProtocol &process) : m_traces_per_core(std::move(traces_per_core)), m_process(process) {} - llvm::DenseMap> m_traces_per_core; diff --git a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp --- a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp @@ -17,9 +17,9 @@ using namespace process_linux; using namespace llvm; -static bool IsTotalBufferLimitReached(ArrayRef cores, +static bool IsTotalBufferLimitReached(ArrayRef 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::max()); return required > limit; @@ -36,30 +36,30 @@ Expected> IntelPTMultiCoreTrace::StartOnAllCores(const TraceIntelPTStartRequest &request, NativeProcessProtocol &process) { - Expected> core_ids = GetAvailableLogicalCoreIDs(); - if (!core_ids) - return core_ids.takeError(); + Expected> 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> + DenseMap> traces; - for (core_id_t core_id : *core_ids) { + for (cpu_id_t cpu_id : *cpu_ids) { Expected 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 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 { @@ -72,15 +72,14 @@ } void IntelPTMultiCoreTrace::ForEachCore( - std::function + std::function callback) { for (auto &it : m_traces_per_core) callback(it.first, it.second.first); } void IntelPTMultiCoreTrace::ForEachCore( - std::function callback) { for (auto &it : m_traces_per_core) @@ -88,19 +87,19 @@ } 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); } }); } @@ -112,13 +111,13 @@ 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()}}}); }); @@ -149,16 +148,16 @@ Expected>> 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; diff --git a/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp b/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp --- a/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp @@ -22,8 +22,7 @@ } 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(*m_tracing_params.process_buffer_size_limit)) return createStringError( inconvertibleErrorCode(), @@ -39,9 +38,9 @@ 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; } diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h --- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h +++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h @@ -36,7 +36,7 @@ /// 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 @@ -50,7 +50,7 @@ static llvm::Expected Start(const TraceIntelPTStartRequest &request, llvm::Optional tid, - llvm::Optional core_id = llvm::None, + llvm::Optional cpu_id = llvm::None, bool disabled = false); /// \return @@ -59,19 +59,19 @@ llvm::Expected> 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> GetTraceBuffer(); + llvm::Expected> 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. /// diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp --- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp @@ -201,7 +201,7 @@ } #endif -size_t IntelPTSingleBufferTrace::GetTraceBufferSize() const { +size_t IntelPTSingleBufferTrace::GetIptTraceSize() const { return m_perf_event.GetAuxBuffer().size(); } @@ -213,7 +213,7 @@ return m_perf_event.EnableWithIoctl(); } -Expected> IntelPTSingleBufferTrace::GetTraceBuffer() { +Expected> 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. @@ -234,27 +234,26 @@ Expected IntelPTSingleBufferTrace::Start(const TraceIntelPTStartRequest &request, Optional tid, - Optional core_id, bool disabled) { + Optional 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(llvm::PowerOf2Floor( - (request.trace_buffer_size + page_size - 1) / page_size)); + (request.ipt_trace_size + page_size - 1) / page_size)); Expected attr = CreateIntelPTPerfEventConfiguration( request.enable_tsc, request.psb_period.map([](int value) { @@ -264,10 +263,10 @@ 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 perf_event = PerfEvent::Init(*attr, tid, core_id)) { + if (Expected 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)) { diff --git a/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.h b/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.h --- a/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.h +++ b/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.h @@ -27,7 +27,8 @@ 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. diff --git a/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp b/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp --- a/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTThreadTraceCollection.cpp @@ -22,7 +22,7 @@ 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(); } @@ -38,7 +38,7 @@ 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(); } @@ -77,7 +77,7 @@ const TraceGetBinaryDataRequest &request) { if (!request.tid) return None; - if (request.kind != IntelPTDataKinds::kTraceBuffer) + if (request.kind != IntelPTDataKinds::kIptTrace) return None; if (!TracesThread(*request.tid)) @@ -85,7 +85,7 @@ if (Expected trace = GetTracedThread(*request.tid)) - return trace->GetTraceBuffer(); + return trace->GetIptTrace(); else return trace.takeError(); } diff --git a/lldb/source/Plugins/Process/Linux/Perf.h b/lldb/source/Plugins/Process/Linux/Perf.h --- a/lldb/source/Plugins/Process/Linux/Perf.h +++ b/lldb/source/Plugins/Process/Linux/Perf.h @@ -110,7 +110,7 @@ /// instance, or an \a llvm::Error otherwise. static llvm::Expected Init(perf_event_attr &attr, llvm::Optional pid, - llvm::Optional cpu, + llvm::Optional cpu, llvm::Optional group_fd, unsigned long flags); @@ -128,7 +128,7 @@ /// all threads and processes are monitored. static llvm::Expected Init(perf_event_attr &attr, llvm::Optional pid, - llvm::Optional core = llvm::None); + llvm::Optional 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 @@ -309,14 +309,14 @@ /// 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 -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 diff --git a/lldb/source/Plugins/Process/Linux/Perf.cpp b/lldb/source/Plugins/Process/Linux/Perf.cpp --- a/lldb/source/Plugins/Process/Linux/Perf.cpp +++ b/lldb/source/Plugins/Process/Linux/Perf.cpp @@ -73,7 +73,7 @@ llvm::Expected PerfEvent::Init(perf_event_attr &attr, Optional pid, - Optional cpu, + Optional cpu, Optional group_fd, unsigned long flags) { errno = 0; @@ -89,7 +89,7 @@ llvm::Expected PerfEvent::Init(perf_event_attr &attr, Optional pid, - Optional cpu) { + Optional cpu) { return Init(attr, pid, cpu, -1, 0); } @@ -306,7 +306,7 @@ Expected 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(), @@ -342,7 +342,7 @@ group_fd = parent_perf_event->GetFd(); if (Expected 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); diff --git a/lldb/source/Plugins/Process/Linux/Procfs.h b/lldb/source/Plugins/Process/Linux/Procfs.h --- a/lldb/source/Plugins/Process/Linux/Procfs.h +++ b/lldb/source/Plugins/Process/Linux/Procfs.h @@ -45,13 +45,13 @@ /// \return /// A list of available logical core ids given the contents of /// /proc/cpuinfo. -llvm::Expected> +llvm::Expected> 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> GetAvailableLogicalCoreIDs(); +llvm::Expected> GetAvailableLogicalCoreIDs(); } // namespace process_linux } // namespace lldb_private diff --git a/lldb/source/Plugins/Process/Linux/Procfs.cpp b/lldb/source/Plugins/Process/Linux/Procfs.cpp --- a/lldb/source/Plugins/Process/Linux/Procfs.cpp +++ b/lldb/source/Plugins/Process/Linux/Procfs.cpp @@ -30,18 +30,18 @@ return *cpu_info; } -Expected> +Expected> lldb_private::process_linux::GetAvailableLogicalCoreIDs(StringRef cpuinfo) { SmallVector lines; cpuinfo.split(lines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false); - std::vector logical_cores; + std::vector logical_cores; for (StringRef line : lines) { std::pair 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(), @@ -52,21 +52,21 @@ return logical_cores; } -llvm::Expected> +llvm::Expected> lldb_private::process_linux::GetAvailableLogicalCoreIDs() { - static Optional> logical_cores_ids; + static Optional> logical_cores_ids; if (!logical_cores_ids) { // We find the actual list of core ids by parsing /proc/cpuinfo Expected> cpuinfo = GetProcfsCpuInfo(); if (!cpuinfo) return cpuinfo.takeError(); - Expected> core_ids = GetAvailableLogicalCoreIDs( + Expected> cpu_ids = GetAvailableLogicalCoreIDs( StringRef(reinterpret_cast(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; } diff --git a/lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt b/lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt --- a/lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt +++ b/lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt @@ -23,7 +23,7 @@ TraceCursorIntelPT.cpp TraceIntelPT.cpp TraceIntelPTJSONStructs.cpp - TraceIntelPTMultiCoreDecoder.cpp + TraceIntelPTMultiCpuDecoder.cpp TraceIntelPTSessionFileParser.cpp TraceIntelPTSessionSaver.cpp diff --git a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h --- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h +++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h @@ -31,7 +31,7 @@ llvm::ArrayRef GetDefinitions() override; - uint64_t m_trace_buffer_size; + uint64_t m_ipt_trace_size; bool m_enable_tsc; llvm::Optional m_psb_period; }; @@ -74,11 +74,11 @@ llvm::ArrayRef 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 m_psb_period; - bool m_per_core_tracing; + bool m_per_cpu_tracing; }; CommandObjectProcessTraceStartIntelPT(TraceIntelPT &trace, @@ -86,11 +86,11 @@ : 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.", diff --git a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp --- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp @@ -32,13 +32,13 @@ 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': { @@ -63,7 +63,7 @@ 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; } @@ -76,7 +76,7 @@ bool CommandObjectThreadTraceStartIntelPT::DoExecuteOnThreads( Args &command, CommandReturnObject &result, llvm::ArrayRef 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 @@ -98,13 +98,13 @@ 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': { @@ -123,7 +123,7 @@ break; } case 'c': { - m_per_core_tracing = true; + m_per_cpu_tracing = true; break; } case 'p': { @@ -144,11 +144,11 @@ 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 @@ -158,10 +158,10 @@ 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); diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h --- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h @@ -27,7 +27,7 @@ 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 { @@ -65,7 +65,7 @@ /// part of the execution ocurred. void DecodeSystemWideTraceForThread( DecodedThread &decoded_thread, TraceIntelPT &trace_intel_pt, - const llvm::DenseMap> &buffers, + const llvm::DenseMap> &buffers, const std::vector &executions); /// Given an intel pt trace, split it in chunks delimited by PSB packets. Each of these chunks diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp --- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp @@ -326,12 +326,12 @@ void lldb_private::trace_intel_pt::DecodeSystemWideTraceForThread( DecodedThread &decoded_thread, TraceIntelPT &trace_intel_pt, - const DenseMap> &buffers, + const DenseMap> &buffers, const std::vector &executions) { - DenseMap decoders; - for (auto &core_id_buffer : buffers) { + DenseMap decoders; + for (auto &cpu_id_buffer : buffers) { Expected 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()); @@ -339,7 +339,7 @@ *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)); } @@ -354,9 +354,9 @@ 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 @@ -365,15 +365,15 @@ 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; @@ -389,10 +389,10 @@ 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))); } } } diff --git a/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.h b/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.h --- a/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.h @@ -21,8 +21,6 @@ /// 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 @@ -35,15 +33,15 @@ /// 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; @@ -64,25 +62,26 @@ /// /// \{ 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); /// \} @@ -109,16 +108,16 @@ } 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. @@ -126,8 +125,8 @@ /// \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. @@ -137,7 +136,7 @@ /// time, or an \a llvm::Error if the data is malformed. llvm::Expected> DecodePerfContextSwitchTrace(llvm::ArrayRef data, - lldb::core_id_t core_id, + lldb::cpu_id_t cpu_id, const LinuxPerfZeroTscConversion &tsc_conversion); } // namespace trace_intel_pt diff --git a/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.cpp --- a/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.cpp @@ -133,9 +133,9 @@ } 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; @@ -143,9 +143,9 @@ } 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; @@ -153,9 +153,9 @@ } 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; @@ -163,23 +163,23 @@ } 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 &prev_record, std::function @@ -187,7 +187,7 @@ 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(); @@ -205,26 +205,26 @@ // 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)); } } @@ -233,7 +233,7 @@ Expected> lldb_private::trace_intel_pt::DecodePerfContextSwitchTrace( - ArrayRef data, core_id_t core_id, + ArrayRef data, cpu_id_t cpu_id, const LinuxPerfZeroTscConversion &tsc_conversion) { std::vector executions; @@ -260,7 +260,7 @@ static_cast(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); })) @@ -274,7 +274,7 @@ // 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(); }; @@ -282,8 +282,7 @@ 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; } diff --git a/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h b/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h --- a/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h @@ -23,7 +23,7 @@ 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. diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h @@ -11,7 +11,7 @@ #include "TaskTimer.h" #include "ThreadDecoder.h" -#include "TraceIntelPTMultiCoreDecoder.h" +#include "TraceIntelPTMultiCpuDecoder.h" #include "TraceIntelPTSessionFileParser.h" #include "lldb/Utility/FileSpec.h" @@ -89,7 +89,7 @@ /// 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 @@ -101,17 +101,16 @@ /// \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 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 psb_period, + bool m_per_cpu_tracing); /// \copydoc Trace::Start llvm::Error Start(StructuredData::ObjectSP configuration = @@ -125,8 +124,8 @@ /// \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. @@ -137,9 +136,8 @@ /// \return /// \a llvm::Error::success if the operation was successful, or /// \a llvm::Error otherwise. - llvm::Error Start(llvm::ArrayRef tids, - uint64_t trace_buffer_size, bool enable_tsc, - llvm::Optional psb_period); + llvm::Error Start(llvm::ArrayRef tids, uint64_t ipt_trace_size, + bool enable_tsc, llvm::Optional psb_period); /// \copydoc Trace::Start llvm::Error Start(llvm::ArrayRef tids, @@ -200,8 +198,8 @@ /// This variable should only be accessed directly by constructores or live /// process data refreshers. struct Storage { - llvm::Optional multicore_decoder; - /// These decoders are used for the non-per-core case + llvm::Optional multicpu_decoder; + /// These decoders are used for the non-per-cpu case llvm::DenseMap> thread_decoders; /// Helper variable used to track long running operations for telemetry. TaskTimer task_timer; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp @@ -77,21 +77,21 @@ TraceIntelPT::TraceIntelPT(JSONTraceSession &session, ArrayRef traced_processes, ArrayRef 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 cores; + if (session.cpus) { + std::vector 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 tids; @@ -99,14 +99,14 @@ 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(thread, *this)); if (const Optional &trace_file = thread->GetTraceFile()) { - SetPostMortemThreadDataFile( - thread->GetID(), IntelPTDataKinds::kTraceBuffer, *trace_file); + SetPostMortemThreadDataFile(thread->GetID(), + IntelPTDataKinds::kIptTrace, *trace_file); } } } @@ -119,8 +119,8 @@ 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()) @@ -204,14 +204,13 @@ } } - // 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 @@ -231,12 +230,12 @@ llvm::Expected> 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 data) { size = data.size(); @@ -333,7 +332,7 @@ 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); @@ -341,9 +340,9 @@ thread_state.tid, std::make_unique(thread_sp, *this)); } } else { - std::vector cores; - for (const TraceCoreState &core : *intelpt_state->cores) - cores.push_back(core.core_id); + std::vector cpus; + for (const TraceCpuState &cpu : *intelpt_state->cpus) + cpus.push_back(cpu.id); std::vector tids; for (const TraceThreadState &thread : intelpt_state->traced_threads) @@ -352,7 +351,7 @@ 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) { @@ -364,8 +363,8 @@ 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); } @@ -381,7 +380,7 @@ 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}): @@ -390,62 +389,61 @@ - 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 psb_period, - bool per_core_tracing) { + Optional 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 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 tids, - uint64_t trace_buffer_size, bool enable_tsc, + uint64_t ipt_trace_size, bool enable_tsc, Optional 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(); @@ -457,13 +455,13 @@ Error TraceIntelPT::Start(llvm::ArrayRef tids, StructuredData::ObjectSP configuration) { - uint64_t trace_buffer_size = kDefaultTraceBufferSize; + uint64_t ipt_trace_size = kDefaultIptTraceSize; bool enable_tsc = kDefaultEnableTscValue; Optional 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 { @@ -472,12 +470,12 @@ } } - 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; } diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h @@ -16,11 +16,11 @@ 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 kDefaultPsbPeriod = llvm::None; -const bool kDefaultPerCoreTracing = false; +const bool kDefaultPerCpuTracing = false; } // namespace trace_intel_pt } // namespace lldb_private diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h @@ -31,7 +31,7 @@ struct JSONThread { uint64_t tid; - llvm::Optional trace_buffer; + llvm::Optional ipt_trace; }; struct JSONProcess { @@ -41,9 +41,9 @@ std::vector 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; }; @@ -51,10 +51,10 @@ std::string type; pt_cpu cpu_info; std::vector processes; - llvm::Optional> cores; + llvm::Optional> cpus; llvm::Optional tsc_perf_zero_conversion; - llvm::Optional> GetCoreIds(); + llvm::Optional> GetCpuIds(); }; llvm::json::Value toJSON(const JSONModule &module); @@ -63,7 +63,7 @@ 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); @@ -78,7 +78,7 @@ 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, diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp @@ -20,13 +20,13 @@ namespace lldb_private { namespace trace_intel_pt { -Optional> JSONTraceSession::GetCoreIds() { - if (!cores) +Optional> JSONTraceSession::GetCpuIds() { + if (!cpus) return None; - std::vector core_ids; - for (const JSONCore &core : *cores) - core_ids.push_back(core.core_id); - return core_ids; + std::vector cpu_ids; + for (const JSONCpu &cpu : *cpus) + cpu_ids.push_back(cpu.id); + return cpu_ids; } json::Value toJSON(const JSONModule &module) { @@ -50,15 +50,14 @@ 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) { @@ -76,22 +75,21 @@ 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; } @@ -124,19 +122,19 @@ // 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 diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCoreDecoder.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h rename from lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCoreDecoder.h rename to lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCoreDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.h @@ -1,4 +1,4 @@ -//===-- 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. @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#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" @@ -16,9 +16,9 @@ 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 @@ -27,11 +27,11 @@ /// /// 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 @@ -52,8 +52,9 @@ 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. /// @@ -81,4 +82,4 @@ } // 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 diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCoreDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp rename from lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCoreDecoder.cpp rename to lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCoreDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp @@ -1,4 +1,4 @@ -//===-- 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. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "TraceIntelPTMultiCoreDecoder.h" +#include "TraceIntelPTMultiCpuDecoder.h" #include "TraceIntelPT.h" @@ -17,7 +17,7 @@ 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()) { @@ -26,11 +26,11 @@ } } -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(thread.shared_from_this(), std::move(err)); @@ -41,12 +41,13 @@ DecodedThreadSP decoded_thread_sp = std::make_shared(thread.shared_from_this()); - Error err = m_trace->OnAllCoresBinaryDataRead( - IntelPTDataKinds::kTraceBuffer, - [&](const DenseMap>& buffers) -> Error { + Error err = m_trace->OnAllCpusBinaryDataRead( + IntelPTDataKinds::kIptTrace, + [&](const DenseMap> &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(); }); @@ -58,10 +59,10 @@ } static Expected> -GetIntelPTSubtracesForCore(TraceIntelPT &trace, core_id_t core_id) { +GetIntelPTSubtracesForCpu(TraceIntelPT &trace, cpu_id_t cpu_id) { std::vector intel_pt_subtraces; - Error err = trace.OnCoreBinaryDataRead( - core_id, IntelPTDataKinds::kTraceBuffer, + Error err = trace.OnCpuBinaryDataRead( + cpu_id, IntelPTDataKinds::kIptTrace, [&](ArrayRef data) -> Error { Expected> split_trace = SplitTraceInContinuousExecutions(trace, data); @@ -76,9 +77,8 @@ return intel_pt_subtraces; } -Expected< - DenseMap>> -TraceIntelPTMultiCoreDecoder::DoCorrelateContextSwitchesAndIntelPtTraces() { +Expected>> +TraceIntelPTMultiCpuDecoder::DoCorrelateContextSwitchesAndIntelPtTraces() { DenseMap> continuous_executions_per_thread; @@ -91,9 +91,9 @@ LinuxPerfZeroTscConversion tsc_conversion = *conv_opt; - for (core_id_t core_id : m_trace->GetTracedCores()) { + for (cpu_id_t cpu_id : m_trace->GetTracedCpus()) { Expected> intel_pt_subtraces = - GetIntelPTSubtracesForCore(*m_trace, core_id); + GetIntelPTSubtracesForCpu(*m_trace, cpu_id); if (!intel_pt_subtraces) return intel_pt_subtraces.takeError(); @@ -101,7 +101,7 @@ // 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() && @@ -116,11 +116,11 @@ 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 data) -> Error { Expected> executions = - DecodePerfContextSwitchTrace(data, core_id, tsc_conversion); + DecodePerfContextSwitchTrace(data, cpu_id, tsc_conversion); if (!executions) return executions.takeError(); for (const ThreadContinuousExecution &exec : *executions) @@ -138,7 +138,7 @@ return continuous_executions_per_thread; } -Error TraceIntelPTMultiCoreDecoder::CorrelateContextSwitchesAndIntelPtTraces() { +Error TraceIntelPTMultiCpuDecoder::CorrelateContextSwitchesAndIntelPtTraces() { if (m_setup_error) return createStringError(inconvertibleErrorCode(), m_setup_error->c_str()); @@ -161,7 +161,7 @@ return Error::success(); } -size_t TraceIntelPTMultiCoreDecoder::GetNumContinuousExecutionsForThread( +size_t TraceIntelPTMultiCpuDecoder::GetNumContinuousExecutionsForThread( lldb::tid_t tid) const { if (!m_continuous_executions_per_thread) return 0; @@ -171,7 +171,7 @@ 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; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td @@ -38,16 +38,16 @@ 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 " @@ -57,7 +57,7 @@ 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 " diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.cpp --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.cpp @@ -79,8 +79,8 @@ lldb::tid_t tid = static_cast(thread.tid); Optional 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(process, tid, trace_file); @@ -175,7 +175,7 @@ // optional. { "tid": integer, - "traceBuffer"?: string + "iptTrace"?: string // Path to the raw Intel PT buffer file for this thread. } ], @@ -193,14 +193,14 @@ ] } ], - "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. } @@ -219,8 +219,8 @@ 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; @@ -228,7 +228,7 @@ Error TraceIntelPTSessionFileParser::AugmentThreadsFromContextSwitches( JSONTraceSession &session) { - if (!session.cores) + if (!session.cpus) return Error::success(); if (!session.tsc_perf_zero_conversion) @@ -252,15 +252,15 @@ 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 data) -> Error { Expected> executions = - DecodePerfContextSwitchTrace(data, core.core_id, + DecodePerfContextSwitchTrace(data, cpu.id, *session.tsc_perf_zero_conversion); if (!executions) return executions.takeError(); @@ -300,15 +300,15 @@ 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(); } } } diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionSaver.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionSaver.cpp --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionSaver.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionSaver.cpp @@ -103,13 +103,13 @@ 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 data) -> llvm::Error { return WriteBytesToDisk(output_file, data); }); @@ -122,28 +122,28 @@ return json_threads; } -static llvm::Expected>> -BuildCoresSection(TraceIntelPT &trace_ipt, FileSpec directory) { - if (trace_ipt.GetTracedCores().empty()) +static llvm::Expected>> +BuildCpusSection(TraceIntelPT &trace_ipt, FileSpec directory) { + if (trace_ipt.GetTracedCpus().empty()) return None; - std::vector json_cores; - FileSpec cores_dir = directory; - cores_dir.AppendPathComponent("cores"); - sys::fs::create_directories(cores_dir.GetCString()); + std::vector 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 data) -> llvm::Error { return WriteBytesToDisk(output_trace, data); }); @@ -152,22 +152,22 @@ } { - 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 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 @@ -298,13 +298,13 @@ if (!json_processes) return json_processes.takeError(); - Expected>> json_cores = - BuildCoresSection(trace_ipt, directory); - if (!json_cores) - return json_cores.takeError(); + Expected>> 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); diff --git a/lldb/source/Target/Trace.cpp b/lldb/source/Target/Trace.cpp --- a/lldb/source/Target/Trace.cpp +++ b/lldb/source/Target/Trace.cpp @@ -162,10 +162,10 @@ return Lookup2(storage.live_thread_data, tid, ConstString(kind)); } -Optional Trace::GetLiveCoreBinaryDataSize(lldb::core_id_t core_id, - llvm::StringRef kind) { +Optional 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 Trace::GetLiveProcessBinaryDataSize(llvm::StringRef kind) { @@ -180,8 +180,8 @@ 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> data = m_live_process->TraceGetBinaryData(request); @@ -193,9 +193,9 @@ 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; } @@ -210,25 +210,25 @@ kind.data(), tid); TraceGetBinaryDataRequest request{GetPluginName().str(), kind.str(), tid, - /*core_id=*/None}; + /*cpu_id=*/None}; return GetLiveTraceBinaryData(request, *size); } Expected> -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 size = GetLiveCoreBinaryDataSize(core_id, kind); + llvm::Optional 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); } @@ -241,7 +241,7 @@ "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); } @@ -290,16 +290,16 @@ 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) @@ -318,10 +318,10 @@ } Trace::Trace(ArrayRef postmortem_processes, - Optional> postmortem_cores) { + Optional> 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; } @@ -354,18 +354,17 @@ tid, kind)); } -llvm::Expected -Trace::GetPostMortemCoreDataFile(lldb::core_id_t core_id, - llvm::StringRef kind) { +llvm::Expected Trace::GetPostMortemCpuDataFile(lldb::cpu_id_t cpu_id, + llvm::StringRef kind) { Storage &storage = GetUpdatedStorage(); if (Optional 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, @@ -374,11 +373,10 @@ 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 @@ -390,18 +388,18 @@ 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 *core_data = - Lookup2AsPtr(storage.live_core_data, core_id, ConstString(kind))) - return callback(*core_data); + if (std::vector *cpu_data = + Lookup2AsPtr(storage.live_cpu_data, cpu_id, ConstString(kind))) + return callback(*cpu_data); - Expected> data = GetLiveCoreBinaryData(core_id, kind); + Expected> 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); } @@ -432,10 +430,10 @@ } llvm::Error -Trace::OnPostMortemCoreBinaryDataRead(lldb::core_id_t core_id, - llvm::StringRef kind, - OnBinaryDataReadCallback callback) { - if (Expected file = GetPostMortemCoreDataFile(core_id, kind)) +Trace::OnPostMortemCpuBinaryDataRead(lldb::cpu_id_t cpu_id, + llvm::StringRef kind, + OnBinaryDataReadCallback callback) { + if (Expected file = GetPostMortemCpuDataFile(cpu_id, kind)) return OnDataFileRead(*file, callback); else return file.takeError(); @@ -450,42 +448,42 @@ } llvm::Error -Trace::OnAllCoresBinaryDataRead(llvm::StringRef kind, - OnCoresBinaryDataReadCallback callback) { - DenseMap> buffers; +Trace::OnAllCpusBinaryDataRead(llvm::StringRef kind, + OnCpusBinaryDataReadCallback callback) { + DenseMap> buffers; Storage &storage = GetUpdatedStorage(); - if (!storage.cores) + if (!storage.cpus) return Error::success(); - std::function::iterator)> process_core = - [&](std::vector::iterator core_id) -> Error { - if (core_id == storage.cores->end()) + std::function::iterator)> process_cpu = + [&](std::vector::iterator cpu_id) -> Error { + if (cpu_id == storage.cpus->end()) return callback(buffers); - return OnCoreBinaryDataRead(*core_id, kind, - [&](ArrayRef 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 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 Trace::GetTracedCores() { +ArrayRef Trace::GetTracedCpus() { Storage &storage = GetUpdatedStorage(); - if (storage.cores) - return *storage.cores; + if (storage.cpus) + return *storage.cpus; return {}; } diff --git a/lldb/source/Utility/TraceGDBRemotePackets.cpp b/lldb/source/Utility/TraceGDBRemotePackets.cpp --- a/lldb/source/Utility/TraceGDBRemotePackets.cpp +++ b/lldb/source/Utility/TraceGDBRemotePackets.cpp @@ -100,14 +100,13 @@ 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}}); } @@ -117,20 +116,19 @@ 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(core_id); + packet.id = static_cast(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}}); } /// \} @@ -140,19 +138,19 @@ 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 core_id; + Optional 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(*core_id); + if (cpu_id) + packet.cpu_id = static_cast(*cpu_id); return true; } /// \} diff --git a/lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp b/lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp --- a/lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp +++ b/lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp @@ -14,12 +14,12 @@ 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, @@ -28,12 +28,12 @@ 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; @@ -42,11 +42,11 @@ 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; } diff --git a/lldb/test/API/commands/trace/TestTraceSave.py b/lldb/test/API/commands/trace/TestTraceSave.py --- a/lldb/test/API/commands/trace/TestTraceSave.py +++ b/lldb/test/API/commands/trace/TestTraceSave.py @@ -62,18 +62,18 @@ 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") @@ -84,14 +84,14 @@ 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) @@ -100,7 +100,7 @@ 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) @@ -130,9 +130,9 @@ 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 " + diff --git a/lldb/test/API/commands/trace/TestTraceSchema.py b/lldb/test/API/commands/trace/TestTraceSchema.py --- a/lldb/test/API/commands/trace/TestTraceSchema.py +++ b/lldb/test/API/commands/trace/TestTraceSchema.py @@ -9,7 +9,7 @@ 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, diff --git a/lldb/test/API/commands/trace/TestTraceStartStop.py b/lldb/test/API/commands/trace/TestTraceStartStop.py --- a/lldb/test/API/commands/trace/TestTraceStartStop.py +++ b/lldb/test/API/commands/trace/TestTraceStartStop.py @@ -35,18 +35,18 @@ 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): @@ -55,7 +55,7 @@ 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'])) diff --git a/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace.json b/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace.json --- a/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace.json +++ b/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace.json @@ -1,14 +1,14 @@ { - "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": { diff --git a/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace_missing_threads.json b/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace_missing_threads.json --- a/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace_missing_threads.json +++ b/lldb/test/API/commands/trace/intelpt-multi-core-trace/trace_missing_threads.json @@ -1,14 +1,14 @@ { - "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": { diff --git a/lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json b/lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json --- a/lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json +++ b/lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json @@ -13,7 +13,7 @@ "threads": [ { "tid": 815455, - "traceBuffer": "multi-file.trace" + "iptTrace": "multi-file.trace" } ], "modules": [ diff --git a/lldb/test/API/commands/trace/intelpt-trace/trace.json b/lldb/test/API/commands/trace/intelpt-trace/trace.json --- a/lldb/test/API/commands/trace/intelpt-trace/trace.json +++ b/lldb/test/API/commands/trace/intelpt-trace/trace.json @@ -13,7 +13,7 @@ "threads": [ { "tid": 3842849, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [ diff --git a/lldb/test/API/commands/trace/intelpt-trace/trace_2threads.json b/lldb/test/API/commands/trace/intelpt-trace/trace_2threads.json --- a/lldb/test/API/commands/trace/intelpt-trace/trace_2threads.json +++ b/lldb/test/API/commands/trace/intelpt-trace/trace_2threads.json @@ -13,11 +13,11 @@ "threads": [ { "tid": 3842849, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" }, { "tid": 3842850, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [ diff --git a/lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json b/lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json --- a/lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json +++ b/lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json @@ -12,7 +12,7 @@ "threads": [ { "tid": 5678, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [ @@ -29,7 +29,7 @@ "threads": [ { "tid": 56789, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [] diff --git a/lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json b/lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json --- a/lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json +++ b/lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json @@ -13,7 +13,7 @@ "threads": [ { "tid": 5678, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [ diff --git a/lldb/test/API/commands/trace/intelpt-trace/trace_bad5.json b/lldb/test/API/commands/trace/intelpt-trace/trace_bad5.json --- a/lldb/test/API/commands/trace/intelpt-trace/trace_bad5.json +++ b/lldb/test/API/commands/trace/intelpt-trace/trace_bad5.json @@ -13,7 +13,7 @@ "threads": [ { "tid": 5678, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [ diff --git a/lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json b/lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json --- a/lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json +++ b/lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json @@ -13,7 +13,7 @@ "threads": [ { "tid": 3842849, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [ diff --git a/lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json b/lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json --- a/lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json +++ b/lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json @@ -13,7 +13,7 @@ "threads": [ { "tid": 3842849, - "traceBuffer": "3842849.trace" + "iptTrace": "3842849.trace" } ], "modules": [ diff --git a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py --- a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py +++ b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py @@ -162,8 +162,8 @@ @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") @@ -173,34 +173,34 @@ 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 @@ -213,20 +213,20 @@ 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 diff --git a/lldb/unittests/Process/Linux/ProcfsTests.cpp b/lldb/unittests/Process/Linux/ProcfsTests.cpp --- a/lldb/unittests/Process/Linux/ProcfsTests.cpp +++ b/lldb/unittests/Process/Linux/ProcfsTests.cpp @@ -18,7 +18,7 @@ using namespace llvm; TEST(Perf, HardcodedLogicalCoreIDs) { - Expected> core_ids = + Expected> cpu_ids = GetAvailableLogicalCoreIDs(R"(processor : 13 vendor_id : GenuineIntel cpu family : 6 @@ -87,8 +87,8 @@ 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) { @@ -98,7 +98,7 @@ GTEST_SKIP() << toString(buffer_or_error.takeError()); // At this point we shouldn't fail parsing the core ids - Expected> core_ids = GetAvailableLogicalCoreIDs(); - ASSERT_TRUE((bool)core_ids); - ASSERT_GT((int)core_ids->size(), 0) << "We must see at least one core"; + Expected> cpu_ids = GetAvailableLogicalCoreIDs(); + ASSERT_TRUE((bool)cpu_ids); + ASSERT_GT((int)cpu_ids->size(), 0) << "We must see at least one core"; }