Author: Jonas Devlieghere Date: 2023-09-13T09:14:54-07:00 New Revision: 4d10b9507dcf0dfe073b8642c5ade1d906e654ee
URL: https://github.com/llvm/llvm-project/commit/4d10b9507dcf0dfe073b8642c5ade1d906e654ee DIFF: https://github.com/llvm/llvm-project/commit/4d10b9507dcf0dfe073b8642c5ade1d906e654ee.diff LOG: [lldb] Fix formatting and whitespace in Debugger.{h,cpp} (NFC) This file is heavily trafficked and the various formatting and whitespace issues make it tedious to work on. Added: Modified: lldb/include/lldb/Core/Debugger.h lldb/source/Core/Debugger.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 5532cace606bfed..f0908eeca5f5cf5 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -417,55 +417,55 @@ class Debugger : public std::enable_shared_from_this<Debugger>, /// hand, use INTERRUPT_REQUESTED so this gets done consistently. /// /// \param[in] formatv - /// A formatv string for the interrupt message. If the elements of the + /// A formatv string for the interrupt message. If the elements of the /// message are expensive to compute, you can use the no-argument form of - /// InterruptRequested, then make up the report using REPORT_INTERRUPTION. - /// + /// InterruptRequested, then make up the report using REPORT_INTERRUPTION. + /// /// \return /// A boolean value, if \b true an interruptible operation should interrupt /// itself. template <typename... Args> - bool InterruptRequested(const char *cur_func, - const char *formatv, Args &&... args) { + bool InterruptRequested(const char *cur_func, const char *formatv, + Args &&...args) { bool ret_val = InterruptRequested(); if (ret_val) { if (!formatv) formatv = "Unknown message"; if (!cur_func) cur_func = "<UNKNOWN>"; - ReportInterruption(InterruptionReport(cur_func, - llvm::formatv(formatv, - std::forward<Args>(args)...))); + ReportInterruption(InterruptionReport( + cur_func, llvm::formatv(formatv, std::forward<Args>(args)...))); } return ret_val; } - - + /// This handy define will keep you from having to generate a report for the /// interruption by hand. Use this except in the case where the arguments to /// the message description are expensive to compute. -#define INTERRUPT_REQUESTED(debugger, ...) \ - (debugger).InterruptRequested(__func__, __VA_ARGS__) +#define INTERRUPT_REQUESTED(debugger, ...) \ + (debugger).InterruptRequested(__func__, __VA_ARGS__) // This form just queries for whether to interrupt, and does no reporting: bool InterruptRequested(); - + // FIXME: Do we want to capture a backtrace at the interruption point? class InterruptionReport { public: - InterruptionReport(std::string function_name, std::string description) : - m_function_name(std::move(function_name)), - m_description(std::move(description)), - m_interrupt_time(std::chrono::system_clock::now()), - m_thread_id(llvm::get_threadid()) {} - - InterruptionReport(std::string function_name, - const llvm::formatv_object_base &payload); - - template <typename... Args> - InterruptionReport(std::string function_name, - const char *format, Args &&... args) : - InterruptionReport(function_name, llvm::formatv(format, std::forward<Args>(args)...)) {} + InterruptionReport(std::string function_name, std::string description) + : m_function_name(std::move(function_name)), + m_description(std::move(description)), + m_interrupt_time(std::chrono::system_clock::now()), + m_thread_id(llvm::get_threadid()) {} + + InterruptionReport(std::string function_name, + const llvm::formatv_object_base &payload); + + template <typename... Args> + InterruptionReport(std::string function_name, const char *format, + Args &&...args) + : InterruptionReport( + function_name, + llvm::formatv(format, std::forward<Args>(args)...)) {} std::string m_function_name; std::string m_description; @@ -473,14 +473,13 @@ class Debugger : public std::enable_shared_from_this<Debugger>, const uint64_t m_thread_id; }; void ReportInterruption(const InterruptionReport &report); -#define REPORT_INTERRUPTION(debugger, ...) \ - (debugger).ReportInterruption(Debugger::InterruptionReport(__func__, \ - __VA_ARGS__)) +#define REPORT_INTERRUPTION(debugger, ...) \ + (debugger).ReportInterruption( \ + Debugger::InterruptionReport(__func__, __VA_ARGS__)) static DebuggerList DebuggersRequestingInterruption(); public: - // This is for use in the command interpreter, when you either want the // selected target, or if no target is present you want to prime the dummy // target with entities that will be copied over to new targets. diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 7ec1efc64fe9383..1e989e13d305eab 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -435,7 +435,7 @@ llvm::StringRef Debugger::GetAutosuggestionAnsiSuffix() const { } bool Debugger::GetShowDontUsePoHint() const { - const uint32_t idx = ePropertyShowDontUsePoHint; + const uint32_t idx = ePropertyShowDontUsePoHint; return GetPropertyAtIndexAs<bool>( idx, g_debugger_properties[idx].default_uint_value != 0); } @@ -1272,17 +1272,17 @@ bool Debugger::InterruptRequested() { return GetCommandInterpreter().WasInterrupted(); } -Debugger::InterruptionReport::InterruptionReport(std::string function_name, - const llvm::formatv_object_base &payload) : - m_function_name(std::move(function_name)), - m_interrupt_time(std::chrono::system_clock::now()), - m_thread_id(llvm::get_threadid()) { +Debugger::InterruptionReport::InterruptionReport( + std::string function_name, const llvm::formatv_object_base &payload) + : m_function_name(std::move(function_name)), + m_interrupt_time(std::chrono::system_clock::now()), + m_thread_id(llvm::get_threadid()) { llvm::raw_string_ostream desc(m_description); desc << payload << "\n"; } void Debugger::ReportInterruption(const InterruptionReport &report) { - // For now, just log the description: + // For now, just log the description: Log *log = GetLog(LLDBLog::Host); LLDB_LOG(log, "Interruption: {0}", report.m_description); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits