added new command "process trace save -d <directory>". -it saves a JSON file as <directory>/trace.json, with the main properties of the trace session. -it saves binary Intel-pt trace as <directory>/thread_id.trace; each file saves each thread. -it saves modules to the directory <directory>/modules . -it only works for live process and it only support Intel-pt right now. Example: ``` b main run process trace start n process trace save -d /tmp/mytrace ``` A file named trace.json and xxx.trace should be generated in /tmp/mytrace. To load the trace that was just saved: ``` trace load /tmp/mytrace thread trace dump instructions ``` You should see the instructions of the trace got printed. To run a test: ``` cd ~/llvm-sand/build/Release/fbcode-x86_64/toolchain ninja lldb-dotest ./bin/lldb-dotest -p TestTraceSave ``` Reviewed By: wallace Differential Revision: https://reviews.llvm.org/D107669
59 lines
2.0 KiB
C++
59 lines
2.0 KiB
C++
//===-- TraceIntelPTSessionFileParser.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.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTSESSIONFILEPARSER_H
|
|
#define LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTSESSIONFILEPARSER_H
|
|
|
|
#include "../common/TraceSessionFileParser.h"
|
|
#include "TraceIntelPT.h"
|
|
#include "TraceIntelPTJSONStructs.h"
|
|
|
|
namespace lldb_private {
|
|
namespace trace_intel_pt {
|
|
|
|
class TraceIntelPT;
|
|
|
|
class TraceIntelPTSessionFileParser : public TraceSessionFileParser {
|
|
public:
|
|
|
|
/// See \a TraceSessionFileParser::TraceSessionFileParser for the description
|
|
/// of these fields.
|
|
TraceIntelPTSessionFileParser(Debugger &debugger,
|
|
const llvm::json::Value &trace_session_file,
|
|
llvm::StringRef session_file_dir)
|
|
: TraceSessionFileParser(debugger, session_file_dir, GetSchema()),
|
|
m_trace_session_file(trace_session_file) {}
|
|
|
|
/// \return
|
|
/// The JSON schema for the session data.
|
|
static llvm::StringRef GetSchema();
|
|
|
|
/// Parse the structured data trace session and create the corresponding \a
|
|
/// Target objects. In case of an error, no targets are created.
|
|
///
|
|
/// \return
|
|
/// A \a lldb::TraceSP instance with the trace session data. In case of
|
|
/// errors, return a null pointer.
|
|
llvm::Expected<lldb::TraceSP> Parse();
|
|
|
|
lldb::TraceSP
|
|
CreateTraceIntelPTInstance(const pt_cpu &cpu_info,
|
|
std::vector<ParsedProcess> &parsed_processes);
|
|
|
|
private:
|
|
static pt_cpu ParsePTCPU(const JSONTraceIntelPTCPUInfo &cpu_info);
|
|
|
|
const llvm::json::Value &m_trace_session_file;
|
|
};
|
|
|
|
} // namespace trace_intel_pt
|
|
} // namespace lldb_private
|
|
|
|
|
|
#endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTSESSIONFILEPARSER_H
|