wallace updated this revision to Diff 302402.
wallace edited the summary of this revision.
wallace added a comment.
Thanks for the feedback! Some changes:
- I'm no longer showing the AAAAA in the documentation, as @labath pointed out
that I was not using it, and, in fact, there's no need to use it.
- I'm now using a json array to represent the return value of the packet. It's
going to be a 0 or 1 element array for, probably, many years, but it makes the
packet more robust and can use the j prefix sensically.
- I improved the documentation, addressing @DavidSpickett questions. In short,
a TraceType corresponds to a high-level Trace plugin that can provide LLDB with
a list of instructions executed by a given program.
- I renamed eTraceTypeProcessorTrace to eTraceTypeIntelProcessorTrace (notice
the Intel word) to disambiguate.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90490/new/
https://reviews.llvm.org/D90490
Files:
lldb/docs/lldb-gdb-remote.txt
lldb/include/lldb/Host/common/NativeProcessProtocol.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Utility/StringExtractorGDBRemote.h
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
lldb/source/Plugins/Process/Linux/ProcessorTrace.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Utility/StringExtractorGDBRemote.cpp
lldb/tools/intel-features/intel-pt/Decoder.cpp
lldb/tools/intel-features/intel-pt/PTDecoder.h
lldb/tools/intel-features/intel-pt/README_TOOL.txt
lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===================================================================
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -362,11 +362,35 @@
EXPECT_FALSE(result.get().Success());
}
+TEST_F(GDBRemoteCommunicationClientTest, SendTraceSupportedTypePacket) {
+ // Success response
+ {
+ std::future<llvm::Expected<lldb::TraceType>> result = std::async(
+ std::launch::async, [&] { return client.SendGetSupportedTraceType(); });
+
+ HandlePacket(server, "jTraceSupportedTypes", "[1]");
+ llvm::Expected<lldb::TraceType> trace_type_or_err = result.get();
+ EXPECT_THAT_EXPECTED(
+ trace_type_or_err,
+ llvm::HasValue(lldb::TraceType::eTraceTypeIntelProcessorTrace));
+ }
+
+ // Error response
+ {
+ std::future<llvm::Expected<lldb::TraceType>> result = std::async(
+ std::launch::async, [&] { return client.SendGetSupportedTraceType(); });
+
+ HandlePacket(server, "jTraceSupportedTypes", "E23");
+ llvm::Expected<lldb::TraceType> trace_type_or_err = result.get();
+ ASSERT_THAT_EXPECTED(trace_type_or_err, llvm::Failed());
+ }
+}
+
TEST_F(GDBRemoteCommunicationClientTest, SendStartTracePacket) {
TraceOptions options;
Status error;
- options.setType(lldb::TraceType::eTraceTypeProcessorTrace);
+ options.setType(lldb::TraceType::eTraceTypeIntelProcessorTrace);
options.setMetaDataBufferSize(8192);
options.setTraceBufferSize(8192);
options.setThreadID(0x23);
Index: lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
===================================================================
--- lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
+++ lldb/tools/intel-features/intel-pt/cli-wrapper-pt.cpp
@@ -169,7 +169,7 @@
trace_buffer_size = m_max_trace_buff_size;
// Set API's arguments with parsed values
- lldb_SBTraceOptions.setType(lldb::TraceType::eTraceTypeProcessorTrace);
+ lldb_SBTraceOptions.setType(lldb::TraceType::eTraceTypeIntelProcessorTrace);
lldb_SBTraceOptions.setTraceBufferSize(trace_buffer_size);
lldb_SBTraceOptions.setMetaDataBufferSize(0);
lldb_SBTraceOptions.setThreadID(thread_id);
Index: lldb/tools/intel-features/intel-pt/README_TOOL.txt
===================================================================
--- lldb/tools/intel-features/intel-pt/README_TOOL.txt
+++ lldb/tools/intel-features/intel-pt/README_TOOL.txt
@@ -190,7 +190,7 @@
- PSBFreq Frequency of PSB Packets
TraceType should be set to
- lldb::TraceType::eTraceTypeProcessorTrace, else error is
+ lldb::TraceType::eTraceTypeIntelProcessorTrace, else error is
returned. To find out any other requirement to start tracing
successfully, refer to SBProcess::StartTrace() API description.
LLDB's current implementation of Intel(R) Processor Trace
Index: lldb/tools/intel-features/intel-pt/PTDecoder.h
===================================================================
--- lldb/tools/intel-features/intel-pt/PTDecoder.h
+++ lldb/tools/intel-features/intel-pt/PTDecoder.h
@@ -168,15 +168,16 @@
/// Intel(R) Processor Trace, please refer to Intel(R) 64 and IA-32
/// Architectures Software Developer's Manual.
///
- /// TraceType should be set to lldb::TraceType::eTraceTypeProcessorTrace,
- /// else error is returned. To find out any other requirement to start
- /// tracing successfully, please refer to SBProcess::StartTrace() API
- /// description. LLDB's current implementation of Intel(R) Processor Trace
- /// feature may round off invalid values for configuration options.
- /// Therefore, the configuration options with which the trace was actually
- /// started, might be different to the ones with which trace was asked to
- /// be started by user. The actual used configuration options can be
- /// obtained from GetProcessorTraceInfo() API.
+ /// TraceType should be set to
+ /// lldb::TraceType::eTraceTypeIntelProcessorTrace, else error is
+ /// returned. To find out any other requirement to start tracing
+ /// successfully, please refer to SBProcess::StartTrace() API description.
+ /// LLDB's current implementation of Intel(R) Processor Trace feature may
+ /// round off invalid values for configuration options. Therefore, the
+ /// configuration options with which the trace was actually started, might
+ /// be different to the ones with which trace was asked to be started by
+ /// user. The actual used configuration options can be obtained from
+ /// GetProcessorTraceInfo() API.
///
/// \param[out] sberror
/// An error with the failure reason if API fails. Else success.
Index: lldb/tools/intel-features/intel-pt/Decoder.cpp
===================================================================
--- lldb/tools/intel-features/intel-pt/Decoder.cpp
+++ lldb/tools/intel-features/intel-pt/Decoder.cpp
@@ -84,11 +84,13 @@
m_mapProcessUID_mapThreadID_TraceInfo_mutex);
RemoveDeadProcessesAndThreads(sbprocess);
- if (sbtraceoptions.getType() != lldb::TraceType::eTraceTypeProcessorTrace) {
- sberror.SetErrorStringWithFormat("SBTraceOptions::TraceType not set to "
- "eTraceTypeProcessorTrace; ProcessID = "
- "%" PRIu64,
- sbprocess.GetProcessID());
+ if (sbtraceoptions.getType() !=
+ lldb::TraceType::eTraceTypeIntelProcessorTrace) {
+ sberror.SetErrorStringWithFormat(
+ "SBTraceOptions::TraceType not set to "
+ "eTraceTypeIntelProcessorTrace; ProcessID = "
+ "%" PRIu64,
+ sbprocess.GetProcessID());
return;
}
lldb::SBStructuredData sbstructdata = sbtraceoptions.getTraceParams(sberror);
@@ -266,7 +268,8 @@
sbprocess.GetProcessID());
return;
}
- if (traceoptions.getType() != lldb::TraceType::eTraceTypeProcessorTrace) {
+ if (traceoptions.getType() !=
+ lldb::TraceType::eTraceTypeIntelProcessorTrace) {
sberror.SetErrorStringWithFormat("invalid TraceType received from LLDB "
"for this thread; thread id=%" PRIu64
", ProcessID = %" PRIu64,
@@ -834,7 +837,8 @@
sbprocess.GetProcessID());
return;
}
- if (traceoptions.getType() != lldb::TraceType::eTraceTypeProcessorTrace) {
+ if (traceoptions.getType() !=
+ lldb::TraceType::eTraceTypeIntelProcessorTrace) {
sberror.SetErrorStringWithFormat("invalid TraceType received from LLDB "
"for this thread; thread id=%" PRIu64
", ProcessID = %" PRIu64,
Index: lldb/source/Utility/StringExtractorGDBRemote.cpp
===================================================================
--- lldb/source/Utility/StringExtractorGDBRemote.cpp
+++ lldb/source/Utility/StringExtractorGDBRemote.cpp
@@ -310,6 +310,8 @@
return eServerPacketType_jTraceStart;
if (PACKET_STARTS_WITH("jTraceStop:"))
return eServerPacketType_jTraceStop;
+ if (PACKET_MATCHES("jTraceSupportedTypes"))
+ return eServerPacketType_jTraceSupportedTypes;
break;
case 'v':
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -175,6 +175,8 @@
llvm::MutableArrayRef<uint8_t> &buffer,
size_t offset = 0) override;
+ llvm::Expected<lldb::TraceType> GetSupportedTraceType() override;
+
Status GetTraceConfig(lldb::user_id_t uid, TraceOptions &options) override;
Status GetWatchpointSupportInfo(uint32_t &num, bool &after) override;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1224,6 +1224,10 @@
return m_gdb_comm.SendGetTraceConfigPacket(uid, options);
}
+llvm::Expected<lldb::TraceType> ProcessGDBRemote::GetSupportedTraceType() {
+ return m_gdb_comm.SendGetSupportedTraceType();
+}
+
void ProcessGDBRemote::DidExit() {
// When we exit, disconnect from the GDB server communications
m_gdb_comm.Disconnect();
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -164,6 +164,8 @@
PacketResult Handle_jTraceConfigRead(StringExtractorGDBRemote &packet);
+ PacketResult Handle_jTraceSupportedTypes(StringExtractorGDBRemote &packet);
+
PacketResult Handle_QRestoreRegisterState(StringExtractorGDBRemote &packet);
PacketResult Handle_vAttach(StringExtractorGDBRemote &packet);
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -191,6 +191,9 @@
RegisterMemberFunctionHandler(
StringExtractorGDBRemote::eServerPacketType_jTraceConfigRead,
&GDBRemoteCommunicationServerLLGS::Handle_jTraceConfigRead);
+ RegisterMemberFunctionHandler(
+ StringExtractorGDBRemote::eServerPacketType_jTraceSupportedTypes,
+ &GDBRemoteCommunicationServerLLGS::Handle_jTraceSupportedTypes);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_g,
&GDBRemoteCommunicationServerLLGS::Handle_g);
@@ -1173,7 +1176,7 @@
std::static_pointer_cast<StructuredData::Dictionary>(custom_params_sp));
if (buffersize == std::numeric_limits<uint64_t>::max() ||
- type != lldb::TraceType::eTraceTypeProcessorTrace) {
+ type != lldb::TraceType::eTraceTypeIntelProcessorTrace) {
LLDB_LOG(log, "Ill formed packet buffersize = {0} type = {1}", buffersize,
type);
return SendIllFormedResponse(packet, "JTrace:start: Ill formed packet ");
@@ -1226,6 +1229,31 @@
return SendOKResponse();
}
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_jTraceSupportedTypes(
+ StringExtractorGDBRemote &packet) {
+
+ // Fail if we don't have a current process.
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID))
+ return SendErrorResponse(68);
+
+ StreamString json_string;
+ json_string << "[";
+
+ lldb::TraceType supported_trace_type =
+ m_debugged_process_up->GetSupportedTraceType();
+ if (supported_trace_type != lldb::eTraceTypeNone)
+ json_string.Printf("%" PRIu32, static_cast<uint32_t>(supported_trace_type));
+
+ json_string << "]";
+
+ StreamGDBRemote escaped_response;
+ escaped_response.PutEscapedBytes(json_string.GetData(),
+ json_string.GetSize());
+ return SendPacketNoLock(escaped_response.GetString());
+}
+
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_jTraceConfigRead(
StringExtractorGDBRemote &packet) {
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -519,6 +519,8 @@
Status SendGetTraceConfigPacket(lldb::user_id_t uid, TraceOptions &options);
+ llvm::Expected<lldb::TraceType> SendGetSupportedTraceType();
+
protected:
LazyBool m_supports_not_sending_acks;
LazyBool m_supports_thread_suffix;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -43,6 +43,7 @@
using namespace lldb;
using namespace lldb_private::process_gdb_remote;
using namespace lldb_private;
+using namespace llvm;
using namespace std::chrono;
llvm::raw_ostream &process_gdb_remote::operator<<(llvm::raw_ostream &os,
@@ -3454,6 +3455,40 @@
return SendGetTraceDataPacket(escaped_packet, uid, thread_id, buffer, offset);
}
+llvm::Expected<lldb::TraceType>
+GDBRemoteCommunicationClient::SendGetSupportedTraceType() {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+
+ StreamGDBRemote escaped_packet;
+ escaped_packet.PutCString("jTraceSupportedTypes");
+
+ StringExtractorGDBRemote response;
+ if (SendPacketAndWaitForResponse(escaped_packet.GetString(), response,
+ true) ==
+ GDBRemoteCommunication::PacketResult::Success) {
+ if (response.IsNormalResponse()) {
+ if (Expected<std::vector<int>> types =
+ llvm::json::parse<std::vector<int>>(response.Peek())) {
+ if (types->empty())
+ return lldb::eTraceTypeNone;
+ else {
+ // Even though jTraceSupportedTypes returns a list, at the time of
+ // writing, there's no OS-architecture pair that supports two or more
+ // kinds of fully featured user-level processor tracing (like Intel PT
+ // or ARM CoreSight), so we assume this is a 1-element array for
+ // simplicity of the rest of the tracing implementation.
+ return static_cast<lldb::TraceType>(types->at(0));
+ }
+ } else
+ return types.takeError();
+ } else
+ return response.GetStatus().ToError();
+ }
+ LLDB_LOG(log, "failed to send packet: jTraceSupportedTypes");
+ return createStringError(inconvertibleErrorCode(),
+ "failed to send packet: jTraceSupportedTypes");
+}
+
Status
GDBRemoteCommunicationClient::SendGetTraceConfigPacket(lldb::user_id_t uid,
TraceOptions &options) {
Index: lldb/source/Plugins/Process/Linux/ProcessorTrace.h
===================================================================
--- lldb/source/Plugins/Process/Linux/ProcessorTrace.h
+++ lldb/source/Plugins/Process/Linux/ProcessorTrace.h
@@ -93,6 +93,10 @@
void SetThreadID(lldb::tid_t tid) { m_thread_id = tid; }
public:
+ static llvm::Expected<uint32_t> GetOSEventType();
+
+ static bool IsSupported();
+
static Status GetCPUType(TraceOptions &config);
static llvm::Expected<ProcessorTraceMonitorUP>
Index: lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
===================================================================
--- lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
+++ lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp
@@ -26,6 +26,8 @@
using namespace llvm;
lldb::user_id_t ProcessorTraceMonitor::m_trace_num = 1;
+const char *kOSEventIntelPTTypeFile =
+ "/sys/bus/event_source/devices/intel_pt/type";
Status ProcessorTraceMonitor::GetTraceConfig(TraceOptions &config) const {
#ifndef PERF_ATTR_SIZE_VER5
@@ -33,7 +35,7 @@
#else
Status error;
- config.setType(lldb::TraceType::eTraceTypeProcessorTrace);
+ config.setType(lldb::TraceType::eTraceTypeIntelProcessorTrace);
config.setMetaDataBufferSize(m_mmap_meta->data_size);
config.setTraceBufferSize(m_mmap_meta->aux_size);
@@ -44,6 +46,27 @@
#endif
}
+Expected<uint32_t> ProcessorTraceMonitor::GetOSEventType() {
+ auto intel_pt_type_text =
+ llvm::MemoryBuffer::getFileAsStream(kOSEventIntelPTTypeFile);
+
+ if (!intel_pt_type_text)
+ return createStringError(inconvertibleErrorCode(),
+ "Can't open the file '%s'",
+ kOSEventIntelPTTypeFile);
+
+ uint32_t intel_pt_type = 0;
+ StringRef buffer = intel_pt_type_text.get()->getBuffer();
+ if (buffer.empty() || buffer.trim().getAsInteger(10, intel_pt_type))
+ return createStringError(
+ inconvertibleErrorCode(),
+ "The file '%s' has a invalid value. It should be an unsigned int.",
+ kOSEventIntelPTTypeFile);
+ return intel_pt_type;
+}
+
+bool ProcessorTraceMonitor::IsSupported() { return (bool)GetOSEventType(); }
+
Status ProcessorTraceMonitor::StartTrace(lldb::pid_t pid, lldb::tid_t tid,
const TraceOptions &config) {
#ifndef PERF_ATTR_SIZE_VER5
@@ -76,25 +99,15 @@
attr.exclude_idle = 1;
attr.mmap = 1;
- int intel_pt_type = 0;
-
- auto ret = llvm::MemoryBuffer::getFileAsStream(
- "/sys/bus/event_source/devices/intel_pt/type");
- if (!ret) {
- LLDB_LOG(log, "failed to open Config file");
- return ret.getError();
- }
+ Expected<uint32_t> intel_pt_type = GetOSEventType();
- StringRef rest = ret.get()->getBuffer();
- if (rest.empty() || rest.trim().getAsInteger(10, intel_pt_type)) {
- LLDB_LOG(log, "failed to read Config file");
- error.SetErrorString("invalid file");
+ if (!intel_pt_type) {
+ error = intel_pt_type.takeError();
return error;
}
- rest.trim().getAsInteger(10, intel_pt_type);
- LLDB_LOG(log, "intel pt type {0}", intel_pt_type);
- attr.type = intel_pt_type;
+ LLDB_LOG(log, "intel pt type {0}", *intel_pt_type);
+ attr.type = *intel_pt_type;
LLDB_LOG(log, "meta buffer size {0}", metabufsize);
LLDB_LOG(log, "buffer size {0} ", bufsize);
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
===================================================================
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -117,6 +117,8 @@
Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) override;
+ virtual lldb::TraceType GetSupportedTraceType() override;
+
// Interface used by NativeRegisterContext-derived classes.
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
void *data = nullptr, size_t data_size = 0,
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1995,12 +1995,18 @@
return error;
}
+lldb::TraceType NativeProcessLinux::GetSupportedTraceType() {
+ if (ProcessorTraceMonitor::IsSupported())
+ return eTraceTypeIntelProcessorTrace;
+ return eTraceTypeNone;
+}
+
lldb::user_id_t
NativeProcessLinux::StartTraceGroup(const TraceOptions &config,
Status &error) {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
- if (config.getType() != TraceType::eTraceTypeProcessorTrace)
+ if (config.getType() != TraceType::eTraceTypeIntelProcessorTrace)
return LLDB_INVALID_UID;
if (m_pt_proces_trace_id != LLDB_INVALID_UID) {
@@ -2029,7 +2035,7 @@
lldb::user_id_t NativeProcessLinux::StartTrace(const TraceOptions &config,
Status &error) {
- if (config.getType() != TraceType::eTraceTypeProcessorTrace)
+ if (config.getType() != TraceType::eTraceTypeIntelProcessorTrace)
return NativeProcessProtocol::StartTrace(config, error);
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
@@ -2100,7 +2106,7 @@
return error;
switch (trace_options.getType()) {
- case lldb::TraceType::eTraceTypeProcessorTrace:
+ case lldb::TraceType::eTraceTypeIntelProcessorTrace:
if (traceid == m_pt_proces_trace_id &&
thread == LLDB_INVALID_THREAD_ID)
StopProcessorTracingOnProcess();
Index: lldb/include/lldb/lldb-enumerations.h
===================================================================
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -769,11 +769,16 @@
eBasicTypeOther
};
+/// Low-level processor trace types for the gdb-remote protocol.
+///
+/// See \a lldb_private::Trace.h for the actual Trace API.
+///
+/// Each Trace plug-in is an implementation for one of these
+/// TraceTypes.
enum TraceType {
eTraceTypeNone = 0,
- // Hardware Trace generated by the processor.
- eTraceTypeProcessorTrace
+ eTraceTypeIntelProcessorTrace
};
enum StructuredDataType {
Index: lldb/include/lldb/Utility/StringExtractorGDBRemote.h
===================================================================
--- lldb/include/lldb/Utility/StringExtractorGDBRemote.h
+++ lldb/include/lldb/Utility/StringExtractorGDBRemote.h
@@ -167,6 +167,7 @@
eServerPacketType_jTraceMetaRead,
eServerPacketType_jTraceStop,
eServerPacketType_jTraceConfigRead,
+ eServerPacketType_jTraceSupportedTypes,
};
ServerPacketType GetServerPacketType() const;
Index: lldb/include/lldb/Target/Process.h
===================================================================
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -2542,6 +2542,18 @@
return Status("Not implemented");
}
+ /// Get the tracing type supported by the gdb-server for the current
+ /// inferior. Responses might be different depending on the architecture and
+ /// capabilities of the the underlying OS.
+ ///
+ /// \return
+ /// The supported trace type or \a lldb::eTraceTypeNone if tracing is not
+ /// supported for the inferior. In case of errors communicating with the
+ /// gdb-server, an \a llvm::Error object is returned.
+ virtual llvm::Expected<lldb::TraceType> GetSupportedTraceType() {
+ return lldb::eTraceTypeNone;
+ }
+
// This calls a function of the form "void * (*)(void)".
bool CallVoidArgVoidPtrReturn(const Address *address,
lldb::addr_t &returned_func,
Index: lldb/include/lldb/Host/common/NativeProcessProtocol.h
===================================================================
--- lldb/include/lldb/Host/common/NativeProcessProtocol.h
+++ lldb/include/lldb/Host/common/NativeProcessProtocol.h
@@ -392,6 +392,11 @@
return Status("Not implemented");
}
+ /// \copydoc Process::GetSupportedTraceType()
+ virtual lldb::TraceType GetSupportedTraceType() {
+ return lldb::eTraceTypeNone;
+ }
+
protected:
struct SoftwareBreakpoint {
uint32_t ref_count;
Index: lldb/docs/lldb-gdb-remote.txt
===================================================================
--- lldb/docs/lldb-gdb-remote.txt
+++ lldb/docs/lldb-gdb-remote.txt
@@ -234,6 +234,28 @@
send packet: QListThreadsInStopReply
read packet: OK
+//----------------------------------------------------------------------
+// jTraceSupportedTypes
+//
+// BRIEF
+// Get the processor tracing types supported by the gdb-server for the current
+// inferior. Responses might be different depending on the architecture and
+// capabilities of the underlying OS.
+//
+// See lldb::TraceType in lldb-enumerations.h for more information.
+//
+// The return packet is a JSON array of lldb::TraceType values represented in
+// decimal.
+//
+// If no tracing technology is supported for the inferior, then an empty list should
+// be returned.
+//
+// If there's no process running, an error should be returned.
+//----------------------------------------------------------------------
+
+send packet: jTraceSupportedType
+read packet: [<trace type 1>, <trace type 2>, ...]/E<error code>
+
//----------------------------------------------------------------------
// jTraceStart:
//
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits