mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-10-07 19:03:57 +00:00
[NFC][trace] format source files
Cleanup formatting diff
This commit is contained in:
parent
2d3d0f50ce
commit
d179ea12fd
@ -285,7 +285,6 @@ Error lldb_private::trace_intel_pt::DecodeSystemWideTraceForThread(
|
||||
for (size_t i = 0; i < executions.size(); i++) {
|
||||
const IntelPTThreadContinousExecution &execution = executions[i];
|
||||
|
||||
|
||||
auto variant = execution.thread_execution.variant;
|
||||
// We report the TSCs we are sure of
|
||||
switch (variant) {
|
||||
|
@ -18,10 +18,12 @@
|
||||
namespace lldb_private {
|
||||
namespace trace_intel_pt {
|
||||
|
||||
/// This struct represents a point in the intel pt trace that the decoder can start decoding from without errors.
|
||||
/// This struct represents a point in the intel pt trace that the decoder can
|
||||
/// start decoding from without errors.
|
||||
struct IntelPTThreadSubtrace {
|
||||
/// The memory offset of a PSB packet that is a synchronization point for the decoder. A decoder normally looks first
|
||||
/// for a PSB packet and then it starts decoding.
|
||||
/// The memory offset of a PSB packet that is a synchronization point for the
|
||||
/// decoder. A decoder normally looks first for a PSB packet and then it
|
||||
/// starts decoding.
|
||||
uint64_t psb_offset;
|
||||
/// The timestamp associated with the PSB packet above.
|
||||
uint64_t tsc;
|
||||
@ -79,17 +81,20 @@ llvm::Error DecodeSystemWideTraceForThread(
|
||||
const llvm::DenseMap<lldb::cpu_id_t, llvm::ArrayRef<uint8_t>> &buffers,
|
||||
const std::vector<IntelPTThreadContinousExecution> &executions);
|
||||
|
||||
/// Given an intel pt trace, split it in chunks delimited by PSB packets. Each of these chunks
|
||||
/// is guaranteed to have been executed continuously.
|
||||
/// Given an intel pt trace, split it in chunks delimited by PSB packets. Each
|
||||
/// of these chunks is guaranteed to have been executed continuously.
|
||||
///
|
||||
/// \param[in] trace_intel_pt
|
||||
/// The main Trace object that contains all the information related to the trace session.
|
||||
/// The main Trace object that contains all the information related to the
|
||||
/// trace session.
|
||||
///
|
||||
/// \param[in] buffer
|
||||
/// The intel pt buffer that belongs to a single thread or to a single cpu core.
|
||||
/// The intel pt buffer that belongs to a single thread or to a single cpu
|
||||
/// core.
|
||||
///
|
||||
/// \return
|
||||
/// A list of continuous executions sorted by time, or an \a llvm::Error in case of failures.
|
||||
/// A list of continuous executions sorted by time, or an \a llvm::Error in
|
||||
/// case of failures.
|
||||
llvm::Expected<std::vector<IntelPTThreadSubtrace>>
|
||||
SplitTraceInContinuousExecutions(TraceIntelPT &trace_intel_pt,
|
||||
llvm::ArrayRef<uint8_t> buffer);
|
||||
|
@ -51,19 +51,18 @@ Expected<DecodedThreadSP> ThreadDecoder::Decode() {
|
||||
|
||||
llvm::Expected<DecodedThreadSP> ThreadDecoder::DoDecode() {
|
||||
return m_trace.GetThreadTimer(m_thread_sp->GetID())
|
||||
.TimeTask(
|
||||
"Decoding instructions", [&]() -> Expected<DecodedThreadSP> {
|
||||
DecodedThreadSP decoded_thread_sp = std::make_shared<DecodedThread>(
|
||||
m_thread_sp, m_trace.GetPerfZeroTscConversion());
|
||||
.TimeTask("Decoding instructions", [&]() -> Expected<DecodedThreadSP> {
|
||||
DecodedThreadSP decoded_thread_sp = std::make_shared<DecodedThread>(
|
||||
m_thread_sp, m_trace.GetPerfZeroTscConversion());
|
||||
|
||||
Error err = m_trace.OnThreadBufferRead(
|
||||
m_thread_sp->GetID(), [&](llvm::ArrayRef<uint8_t> data) {
|
||||
return DecodeSingleTraceForThread(*decoded_thread_sp, m_trace,
|
||||
data);
|
||||
});
|
||||
Error err = m_trace.OnThreadBufferRead(
|
||||
m_thread_sp->GetID(), [&](llvm::ArrayRef<uint8_t> data) {
|
||||
return DecodeSingleTraceForThread(*decoded_thread_sp, m_trace,
|
||||
data);
|
||||
});
|
||||
|
||||
if (err)
|
||||
return std::move(err);
|
||||
return decoded_thread_sp;
|
||||
});
|
||||
if (err)
|
||||
return std::move(err);
|
||||
return decoded_thread_sp;
|
||||
});
|
||||
}
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include "../common/ThreadPostMortemTrace.h"
|
||||
#include "CommandObjectTraceStartIntelPT.h"
|
||||
#include "DecodedThread.h"
|
||||
#include "TraceIntelPTConstants.h"
|
||||
#include "TraceIntelPTBundleLoader.h"
|
||||
#include "TraceIntelPTBundleSaver.h"
|
||||
#include "TraceIntelPTConstants.h"
|
||||
#include "lldb/Core/PluginManager.h"
|
||||
#include "lldb/Target/Process.h"
|
||||
#include "lldb/Target/Target.h"
|
||||
@ -65,8 +65,7 @@ Expected<FileSpec> TraceIntelPT::SaveToDisk(FileSpec directory, bool compact) {
|
||||
Expected<TraceSP> TraceIntelPT::CreateInstanceForTraceBundle(
|
||||
const json::Value &bundle_description, StringRef bundle_dir,
|
||||
Debugger &debugger) {
|
||||
return TraceIntelPTBundleLoader(debugger, bundle_description,
|
||||
bundle_dir)
|
||||
return TraceIntelPTBundleLoader(debugger, bundle_description, bundle_dir)
|
||||
.Load();
|
||||
}
|
||||
|
||||
@ -81,10 +80,13 @@ TraceIntelPTSP TraceIntelPT::GetSharedPtr() {
|
||||
}
|
||||
|
||||
TraceIntelPTSP TraceIntelPT::CreateInstanceForPostmortemTrace(
|
||||
JSONTraceBundleDescription &bundle_description, ArrayRef<ProcessSP> traced_processes,
|
||||
JSONTraceBundleDescription &bundle_description,
|
||||
ArrayRef<ProcessSP> traced_processes,
|
||||
ArrayRef<ThreadPostMortemTraceSP> traced_threads) {
|
||||
TraceIntelPTSP trace_sp(new TraceIntelPT(bundle_description, traced_processes));
|
||||
trace_sp->m_storage.tsc_conversion = bundle_description.tsc_perf_zero_conversion;
|
||||
TraceIntelPTSP trace_sp(
|
||||
new TraceIntelPT(bundle_description, traced_processes));
|
||||
trace_sp->m_storage.tsc_conversion =
|
||||
bundle_description.tsc_perf_zero_conversion;
|
||||
|
||||
if (bundle_description.cpus) {
|
||||
std::vector<cpu_id_t> cpus;
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
#include "TaskTimer.h"
|
||||
#include "ThreadDecoder.h"
|
||||
#include "TraceIntelPTMultiCpuDecoder.h"
|
||||
#include "TraceIntelPTBundleLoader.h"
|
||||
#include "TraceIntelPTMultiCpuDecoder.h"
|
||||
|
||||
#include "lldb/Utility/FileSpec.h"
|
||||
#include "lldb/lldb-types.h"
|
||||
@ -52,10 +52,9 @@ public:
|
||||
///
|
||||
/// \return
|
||||
/// A trace instance or an error in case of failures.
|
||||
static llvm::Expected<lldb::TraceSP>
|
||||
CreateInstanceForTraceBundle(const llvm::json::Value &trace_bundle_description,
|
||||
llvm::StringRef bundle_dir,
|
||||
Debugger &debugger);
|
||||
static llvm::Expected<lldb::TraceSP> CreateInstanceForTraceBundle(
|
||||
const llvm::json::Value &trace_bundle_description,
|
||||
llvm::StringRef bundle_dir, Debugger &debugger);
|
||||
|
||||
static llvm::Expected<lldb::TraceSP>
|
||||
CreateInstanceForLiveProcess(Process &process);
|
||||
|
@ -30,7 +30,7 @@ FileSpec TraceIntelPTBundleLoader::NormalizePath(const std::string &path) {
|
||||
}
|
||||
|
||||
Error TraceIntelPTBundleLoader::ParseModule(Target &target,
|
||||
const JSONModule &module) {
|
||||
const JSONModule &module) {
|
||||
auto do_parse = [&]() -> Error {
|
||||
FileSpec system_file_spec(module.system_path);
|
||||
|
||||
@ -64,7 +64,7 @@ Error TraceIntelPTBundleLoader::ParseModule(Target &target,
|
||||
}
|
||||
|
||||
Error TraceIntelPTBundleLoader::CreateJSONError(json::Path::Root &root,
|
||||
const json::Value &value) {
|
||||
const json::Value &value) {
|
||||
std::string err;
|
||||
raw_string_ostream os(err);
|
||||
root.printErrorContext(value, os);
|
||||
@ -75,7 +75,7 @@ Error TraceIntelPTBundleLoader::CreateJSONError(json::Path::Root &root,
|
||||
|
||||
ThreadPostMortemTraceSP
|
||||
TraceIntelPTBundleLoader::ParseThread(Process &process,
|
||||
const JSONThread &thread) {
|
||||
const JSONThread &thread) {
|
||||
lldb::tid_t tid = static_cast<lldb::tid_t>(thread.tid);
|
||||
|
||||
Optional<FileSpec> trace_file;
|
||||
@ -260,8 +260,8 @@ Error TraceIntelPTBundleLoader::AugmentThreadsFromContextSwitches(
|
||||
FileSpec(cpu.context_switch_trace),
|
||||
[&](ArrayRef<uint8_t> data) -> Error {
|
||||
Expected<std::vector<ThreadContinuousExecution>> executions =
|
||||
DecodePerfContextSwitchTrace(data, cpu.id,
|
||||
*bundle_description.tsc_perf_zero_conversion);
|
||||
DecodePerfContextSwitchTrace(
|
||||
data, cpu.id, *bundle_description.tsc_perf_zero_conversion);
|
||||
if (!executions)
|
||||
return executions.takeError();
|
||||
for (const ThreadContinuousExecution &execution : *executions)
|
||||
@ -275,7 +275,8 @@ Error TraceIntelPTBundleLoader::AugmentThreadsFromContextSwitches(
|
||||
}
|
||||
|
||||
Expected<TraceSP> TraceIntelPTBundleLoader::CreateTraceIntelPTInstance(
|
||||
JSONTraceBundleDescription &bundle_description, std::vector<ParsedProcess> &parsed_processes) {
|
||||
JSONTraceBundleDescription &bundle_description,
|
||||
std::vector<ParsedProcess> &parsed_processes) {
|
||||
std::vector<ThreadPostMortemTraceSP> threads;
|
||||
std::vector<ProcessSP> processes;
|
||||
for (const ParsedProcess &parsed_process : parsed_processes) {
|
||||
|
@ -29,13 +29,14 @@ public:
|
||||
/// The debugger that will own the targets to create.
|
||||
///
|
||||
/// \param[in] bundle_description
|
||||
/// The JSON description of a trace bundle that follows the schema of the intel pt trace plug-in.
|
||||
/// The JSON description of a trace bundle that follows the schema of the
|
||||
/// intel pt trace plug-in.
|
||||
///
|
||||
/// \param[in] bundle_dir
|
||||
/// The folder where the trace bundle is located.
|
||||
TraceIntelPTBundleLoader(Debugger &debugger,
|
||||
const llvm::json::Value &bundle_description,
|
||||
llvm::StringRef bundle_dir)
|
||||
const llvm::json::Value &bundle_description,
|
||||
llvm::StringRef bundle_dir)
|
||||
: m_debugger(debugger), m_bundle_description(bundle_description),
|
||||
m_bundle_dir(bundle_dir) {}
|
||||
|
||||
@ -47,8 +48,8 @@ public:
|
||||
/// Target objects. In case of an error, no targets are created.
|
||||
///
|
||||
/// \return
|
||||
/// A \a lldb::TraceSP instance created according to the trace bundle information. In case of
|
||||
/// errors, return a null pointer.
|
||||
/// A \a lldb::TraceSP instance created according to the trace bundle
|
||||
/// information. In case of errors, return a null pointer.
|
||||
llvm::Expected<lldb::TraceSP> Load();
|
||||
|
||||
private:
|
||||
@ -73,7 +74,8 @@ private:
|
||||
/// The JSON process definition
|
||||
llvm::Expected<ParsedProcess> ParseProcess(const JSONProcess &process);
|
||||
|
||||
/// Create a module associated with the given \p target using the definition from \p module.
|
||||
/// Create a module associated with the given \p target using the definition
|
||||
/// from \p module.
|
||||
llvm::Error ParseModule(Target &target, const JSONModule &module);
|
||||
|
||||
/// Create a user-friendly error message upon a JSON-parsing failure using the
|
||||
@ -102,10 +104,11 @@ private:
|
||||
/// \return
|
||||
/// An \a llvm::Error in case if failures, or \a llvm::Error::success
|
||||
/// otherwise.
|
||||
llvm::Error AugmentThreadsFromContextSwitches(JSONTraceBundleDescription &bundle_description);
|
||||
llvm::Error AugmentThreadsFromContextSwitches(
|
||||
JSONTraceBundleDescription &bundle_description);
|
||||
|
||||
/// Modifiy the bundle description by normalizing all the paths relative to the
|
||||
/// session file directory.
|
||||
/// Modifiy the bundle description by normalizing all the paths relative to
|
||||
/// the session file directory.
|
||||
void NormalizeAllPaths(JSONTraceBundleDescription &bundle_description);
|
||||
|
||||
Debugger &m_debugger;
|
||||
@ -116,5 +119,4 @@ private:
|
||||
} // namespace trace_intel_pt
|
||||
} // namespace lldb_private
|
||||
|
||||
|
||||
#endif // LLDB_SOURCE_PLUGINS_TRACE_INTEL_PT_TRACEINTELPTBUNDLELOADER_H
|
||||
|
@ -359,9 +359,10 @@ Expected<FileSpec> TraceIntelPTBundleSaver::SaveToDisk(TraceIntelPT &trace_ipt,
|
||||
if (!json_cpus)
|
||||
return json_cpus.takeError();
|
||||
|
||||
JSONTraceBundleDescription json_intel_pt_bundle_desc{"intel-pt", *cpu_info, *json_processes,
|
||||
*json_cpus,
|
||||
trace_ipt.GetPerfZeroTscConversion()};
|
||||
JSONTraceBundleDescription json_intel_pt_bundle_desc{
|
||||
"intel-pt", *cpu_info, *json_processes, *json_cpus,
|
||||
trace_ipt.GetPerfZeroTscConversion()};
|
||||
|
||||
return SaveTraceBundleDescription(toJSON(json_intel_pt_bundle_desc), directory);
|
||||
return SaveTraceBundleDescription(toJSON(json_intel_pt_bundle_desc),
|
||||
directory);
|
||||
}
|
||||
|
@ -117,20 +117,24 @@ bool fromJSON(const json::Value &value, pt_cpu &cpu_info, Path path) {
|
||||
}
|
||||
|
||||
json::Value toJSON(const JSONTraceBundleDescription &bundle_description) {
|
||||
return Object{{"type", bundle_description.type},
|
||||
{"processes", bundle_description.processes},
|
||||
// We have to do this because the compiler fails at doing it
|
||||
// automatically because pt_cpu is not in a namespace
|
||||
{"cpuInfo", toJSON(bundle_description.cpu_info)},
|
||||
{"cpus", bundle_description.cpus},
|
||||
{"tscPerfZeroConversion", bundle_description.tsc_perf_zero_conversion}};
|
||||
return Object{
|
||||
{"type", bundle_description.type},
|
||||
{"processes", bundle_description.processes},
|
||||
// We have to do this because the compiler fails at doing it
|
||||
// automatically because pt_cpu is not in a namespace
|
||||
{"cpuInfo", toJSON(bundle_description.cpu_info)},
|
||||
{"cpus", bundle_description.cpus},
|
||||
{"tscPerfZeroConversion", bundle_description.tsc_perf_zero_conversion}};
|
||||
}
|
||||
|
||||
bool fromJSON(const json::Value &value, JSONTraceBundleDescription &bundle_description, Path path) {
|
||||
bool fromJSON(const json::Value &value,
|
||||
JSONTraceBundleDescription &bundle_description, Path path) {
|
||||
ObjectMapper o(value, path);
|
||||
if (!(o && o.map("processes", bundle_description.processes) &&
|
||||
o.map("type", bundle_description.type) && o.map("cpus", bundle_description.cpus) &&
|
||||
o.map("tscPerfZeroConversion", bundle_description.tsc_perf_zero_conversion)))
|
||||
o.map("type", bundle_description.type) &&
|
||||
o.map("cpus", bundle_description.cpus) &&
|
||||
o.map("tscPerfZeroConversion",
|
||||
bundle_description.tsc_perf_zero_conversion)))
|
||||
return false;
|
||||
if (bundle_description.cpus && !bundle_description.tsc_perf_zero_conversion) {
|
||||
path.report(
|
||||
@ -139,8 +143,8 @@ bool fromJSON(const json::Value &value, JSONTraceBundleDescription &bundle_descr
|
||||
}
|
||||
// We have to do this because the compiler fails at doing it automatically
|
||||
// because pt_cpu is not in a namespace
|
||||
if (!fromJSON(*value.getAsObject()->get("cpuInfo"), bundle_description.cpu_info,
|
||||
path.field("cpuInfo")))
|
||||
if (!fromJSON(*value.getAsObject()->get("cpuInfo"),
|
||||
bundle_description.cpu_info, path.field("cpuInfo")))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -84,7 +84,8 @@ bool fromJSON(const llvm::json::Value &value, JSONCpu &cpu,
|
||||
bool fromJSON(const llvm::json::Value &value, pt_cpu &cpu_info,
|
||||
llvm::json::Path path);
|
||||
|
||||
bool fromJSON(const llvm::json::Value &value, JSONTraceBundleDescription &bundle_description,
|
||||
bool fromJSON(const llvm::json::Value &value,
|
||||
JSONTraceBundleDescription &bundle_description,
|
||||
llvm::json::Path path);
|
||||
} // namespace trace_intel_pt
|
||||
} // namespace lldb_private
|
||||
|
@ -63,8 +63,7 @@ Expected<DecodedThreadSP> TraceIntelPTMultiCpuDecoder::Decode(Thread &thread) {
|
||||
|
||||
TraceIntelPTSP trace_sp = GetTrace();
|
||||
|
||||
return trace_sp
|
||||
->GetThreadTimer(thread.GetID())
|
||||
return trace_sp->GetThreadTimer(thread.GetID())
|
||||
.TimeTask("Decoding instructions", [&]() -> Expected<DecodedThreadSP> {
|
||||
auto it = m_decoded_threads.find(thread.GetID());
|
||||
if (it != m_decoded_threads.end())
|
||||
|
Loading…
Reference in New Issue
Block a user