mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 13:35:38 +08:00
[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.
This commit is contained in:
@@ -417,55 +417,55 @@ public:
|
||||
/// 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);
|
||||
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()) {}
|
||||
|
||||
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,
|
||||
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 @@ public:
|
||||
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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user