From d179ea12fd3186690cb9c630be03ab98b42c5448 Mon Sep 17 00:00:00 2001 From: Walter Erquinigo Date: Tue, 2 Aug 2022 21:15:17 -0700 Subject: [PATCH] [NFC][trace] format source files Cleanup formatting diff --- .../Plugins/Trace/intel-pt/LibiptDecoder.cpp | 1 - lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h | 21 +++++++++------- .../Plugins/Trace/intel-pt/ThreadDecoder.cpp | 25 ++++++++++--------- .../source/Plugins/Trace/intel-pt/TraceIntelPT.cpp | 14 ++++++----- lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h | 9 ++++--- .../Trace/intel-pt/TraceIntelPTBundleLoader.cpp | 13 +++++----- .../Trace/intel-pt/TraceIntelPTBundleLoader.h | 22 +++++++++-------- .../Trace/intel-pt/TraceIntelPTBundleSaver.cpp | 9 +++---- .../Trace/intel-pt/TraceIntelPTJSONStructs.cpp | 28 ++++++++++++---------- .../Trace/intel-pt/TraceIntelPTJSONStructs.h | 3 ++- .../Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp | 3 +-- 11 files changed, 80 insertions(+), 68 deletions(-) diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp index 234b9f9..16f5744 100644 --- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp @@ -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) { diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h index 66f3798..14bbecb 100644 --- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h +++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h @@ -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> &buffers, const std::vector &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> SplitTraceInContinuousExecutions(TraceIntelPT &trace_intel_pt, llvm::ArrayRef buffer); diff --git a/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp index 920992d..c88daf7 100644 --- a/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp @@ -51,19 +51,18 @@ Expected ThreadDecoder::Decode() { llvm::Expected ThreadDecoder::DoDecode() { return m_trace.GetThreadTimer(m_thread_sp->GetID()) - .TimeTask( - "Decoding instructions", [&]() -> Expected { - DecodedThreadSP decoded_thread_sp = std::make_shared( - m_thread_sp, m_trace.GetPerfZeroTscConversion()); + .TimeTask("Decoding instructions", [&]() -> Expected { + DecodedThreadSP decoded_thread_sp = std::make_shared( + m_thread_sp, m_trace.GetPerfZeroTscConversion()); - Error err = m_trace.OnThreadBufferRead( - m_thread_sp->GetID(), [&](llvm::ArrayRef data) { - return DecodeSingleTraceForThread(*decoded_thread_sp, m_trace, - data); - }); + Error err = m_trace.OnThreadBufferRead( + m_thread_sp->GetID(), [&](llvm::ArrayRef 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; + }); } diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp index 18b15f2..029f1b3 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp @@ -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 TraceIntelPT::SaveToDisk(FileSpec directory, bool compact) { Expected 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 traced_processes, + JSONTraceBundleDescription &bundle_description, + ArrayRef traced_processes, ArrayRef 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 cpus; diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h index b104a8a..7e8f030 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h @@ -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 - CreateInstanceForTraceBundle(const llvm::json::Value &trace_bundle_description, - llvm::StringRef bundle_dir, - Debugger &debugger); + static llvm::Expected CreateInstanceForTraceBundle( + const llvm::json::Value &trace_bundle_description, + llvm::StringRef bundle_dir, Debugger &debugger); static llvm::Expected CreateInstanceForLiveProcess(Process &process); diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp index 3715e46..d1d762b 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp @@ -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(thread.tid); Optional trace_file; @@ -260,8 +260,8 @@ Error TraceIntelPTBundleLoader::AugmentThreadsFromContextSwitches( FileSpec(cpu.context_switch_trace), [&](ArrayRef data) -> Error { Expected> 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 TraceIntelPTBundleLoader::CreateTraceIntelPTInstance( - JSONTraceBundleDescription &bundle_description, std::vector &parsed_processes) { + JSONTraceBundleDescription &bundle_description, + std::vector &parsed_processes) { std::vector threads; std::vector processes; for (const ParsedProcess &parsed_process : parsed_processes) { diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h index b0b926e..7fb4a6b 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h @@ -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 Load(); private: @@ -73,7 +74,8 @@ private: /// The JSON process definition llvm::Expected 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 diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp index f35914f..f3d1c67 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp @@ -359,9 +359,10 @@ Expected 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); } diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp index ca98136..e1ed248 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp @@ -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; } diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h index 687c0a7..d86c6ee 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h @@ -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 diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp index 08f54b5..f7cb166 100644 --- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp +++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp @@ -63,8 +63,7 @@ Expected TraceIntelPTMultiCpuDecoder::Decode(Thread &thread) { TraceIntelPTSP trace_sp = GetTrace(); - return trace_sp - ->GetThreadTimer(thread.GetID()) + return trace_sp->GetThreadTimer(thread.GetID()) .TimeTask("Decoding instructions", [&]() -> Expected { auto it = m_decoded_threads.find(thread.GetID()); if (it != m_decoded_threads.end()) -- 2.7.4