[trace][intel-pt] Create basic SB API

This adds a basic SB API for creating and stopping traces.
Note: This doesn't add any APIs for inspecting individual instructions. That'd be a more complicated change and it might be better to enhande the dump functionality to output the data in binary format. I'll leave that for a later diff.

This also enhances the existing tests so that they test the same flow using both the command interface and the SB API.

I also did some cleanup of legacy code.

Differential Revision: https://reviews.llvm.org/D103500
This commit is contained in:
Walter Erquinigo
2021-06-01 15:34:06 -07:00
parent c1360fd5fc
commit bf9f21a28b
53 changed files with 603 additions and 749 deletions

View File

@@ -44,7 +44,6 @@
#include "lldb/API/SBThread.h"
#include "lldb/API/SBThreadCollection.h"
#include "lldb/API/SBTrace.h"
#include "lldb/API/SBTraceOptions.h"
#include "lldb/API/SBUnixSignals.h"
using namespace lldb;
@@ -312,26 +311,6 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
return bytes_read;
}
lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options,
lldb::SBError &error) {
LLDB_RECORD_METHOD(lldb::SBTrace, SBProcess, StartTrace,
(lldb::SBTraceOptions &, lldb::SBError &), options, error);
ProcessSP process_sp(GetSP());
error.Clear();
SBTrace trace_instance;
trace_instance.SetSP(process_sp);
lldb::user_id_t uid = LLDB_INVALID_UID;
if (!process_sp) {
error.SetErrorString("invalid process");
} else {
uid = process_sp->StartTrace(*(options.m_traceoptions_sp), error.ref());
trace_instance.SetTraceUID(uid);
}
return LLDB_RECORD_RESULT(trace_instance);
}
void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const {
LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
(const SBEvent &, SBFile), event, out);
@@ -1338,8 +1317,6 @@ void RegisterMethods<SBProcess>(Registry &R) {
(lldb::tid_t, lldb::addr_t));
LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBProcess, GetTarget, ());
LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t));
LLDB_REGISTER_METHOD(lldb::SBTrace, SBProcess, StartTrace,
(lldb::SBTraceOptions &, lldb::SBError &));
LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
(const lldb::SBEvent &, FILE *));
LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,