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 @@ -467,7 +467,7 @@ // // Binary data kinds: // - threadTraceBuffer: trace buffer for a thread. -// - cpuInfo: contents of the /proc/cpuinfo file. +// - procFsCpuInfo: contents of the /proc/cpuinfo file. // // Counter info kinds: // tsc-perf-zero-conversion: @@ -522,7 +522,7 @@ // // Binary data kinds: // - threadTraceBuffer: trace buffer for a thread. -// - cpuInfo: contents of the /proc/cpuinfo file. +// - procFsCpuInfo: contents of the /proc/cpuinfo file. //---------------------------------------------------------------------- send packet: jLLDBTraceGetBinaryData:{"type":,"kind":,"tid":,"offset":,"size":}] 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 @@ -18,6 +18,12 @@ /// See docs/lldb-gdb-remote.txt for more information. namespace lldb_private { +// List of data kinds used by jLLDBGetState and jLLDBGetBinaryData. +struct IntelPTDataKinds { + static const char *kProcFsCpuInfo; + static const char *kThreadTraceBuffer; +}; + /// jLLDBTraceStart gdb-remote packet /// \{ struct TraceIntelPTStartRequest : TraceStartRequest { 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 @@ -415,7 +415,7 @@ TraceThreadState IntelPTThreadTrace::GetState() const { return {static_cast(m_tid), - {TraceBinaryData{"threadTraceBuffer", + {TraceBinaryData{IntelPTDataKinds::kThreadTraceBuffer, static_cast(GetTraceBufferSize())}}}; } @@ -577,13 +577,13 @@ } Expected IntelPTCollector::GetState() const { - Expected> cpu_info = GetCPUInfo(); + Expected> cpu_info = GetProcFsCpuInfo(); if (!cpu_info) return cpu_info.takeError(); TraceGetStateResponse state; - state.processBinaryData.push_back( - {"cpuInfo", static_cast(cpu_info->size())}); + state.processBinaryData.push_back({IntelPTDataKinds::kProcFsCpuInfo, + static_cast(cpu_info->size())}); std::vector thread_states = m_thread_traces.GetThreadStates(); @@ -607,14 +607,14 @@ Expected> IntelPTCollector::GetBinaryData(const TraceGetBinaryDataRequest &request) const { - if (request.kind == "threadTraceBuffer") { + if (request.kind == IntelPTDataKinds::kThreadTraceBuffer) { if (Expected trace = GetTracedThread(*request.tid)) return trace->GetIntelPTBuffer(request.offset, request.size); else return trace.takeError(); - } else if (request.kind == "cpuInfo") { - return GetCPUInfo(); + } else if (request.kind == IntelPTDataKinds::kProcFsCpuInfo) { + return GetProcFsCpuInfo(); } return createStringError(inconvertibleErrorCode(), "Unsuported trace binary data kind: %s", 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 @@ -76,7 +76,7 @@ /// \return /// The content of /proc/cpuinfo and cache it if errors didn't happen. -llvm::Expected> GetCPUInfo(); +llvm::Expected> GetProcFsCpuInfo(); /// \return /// A list of available logical core ids given the contents of 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 @@ -22,7 +22,7 @@ using namespace process_linux; using namespace llvm; -Expected> lldb_private::process_linux::GetCPUInfo() { +Expected> lldb_private::process_linux::GetProcFsCpuInfo() { static Optional> cpu_info; if (!cpu_info) { auto buffer_or_error = errorOrToExpected(getProcFile("cpuinfo")); @@ -63,7 +63,7 @@ static Optional> logical_cores_ids; if (!logical_cores_ids) { // We find the actual list of core ids by parsing /proc/cpuinfo - Expected> cpuinfo = GetCPUInfo(); + Expected> cpuinfo = GetProcFsCpuInfo(); if (!cpuinfo) return cpuinfo.takeError(); 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 @@ -81,7 +81,8 @@ for (const ThreadPostMortemTraceSP &thread : traced_threads) { m_thread_decoders.emplace(thread->GetID(), std::make_unique(thread, *this)); - SetPostMortemThreadDataFile(thread->GetID(), "threadTraceBuffer", + SetPostMortemThreadDataFile(thread->GetID(), + IntelPTDataKinds::kThreadTraceBuffer, thread->GetTraceFile()); } } @@ -179,7 +180,8 @@ } Expected TraceIntelPT::GetCPUInfoForLiveProcess() { - Expected> cpu_info = GetLiveProcessBinaryData("cpuInfo"); + Expected> cpu_info = + GetLiveProcessBinaryData(IntelPTDataKinds::kProcFsCpuInfo); if (!cpu_info) return cpu_info.takeError(); @@ -393,7 +395,8 @@ Error TraceIntelPT::OnThreadBufferRead(lldb::tid_t tid, OnBinaryDataReadCallback callback) { - return OnThreadBinaryDataRead(tid, "threadTraceBuffer", callback); + return OnThreadBinaryDataRead(tid, IntelPTDataKinds::kThreadTraceBuffer, + callback); } TaskTimer &TraceIntelPT::GetTimer() { return m_task_timer; } 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 @@ -48,8 +48,8 @@ return json_intel_pt_trace.takeError(); llvm::Expected json_session_description = - TraceSessionSaver::BuildProcessesSection(*live_process, - "threadTraceBuffer", directory); + TraceSessionSaver::BuildProcessesSection( + *live_process, IntelPTDataKinds::kThreadTraceBuffer, directory); if (!json_session_description) return json_session_description.takeError(); 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 @@ -13,6 +13,9 @@ namespace lldb_private { +const char *IntelPTDataKinds::kProcFsCpuInfo = "procFsCpuInfo"; +const char *IntelPTDataKinds::kThreadTraceBuffer = "threadTraceBuffer"; + bool fromJSON(const json::Value &value, TraceIntelPTStartRequest &packet, Path path) { ObjectMapper o(value, path);