[lldb] Replace Host::SystemLog with Debugger::Report{Error,Warning}
As it exists today, Host::SystemLog is used exclusively for error reporting. With the introduction of diagnostic events, we have a better way of reporting those. Instead of printing directly to stderr, these messages now get printed to the debugger's error stream (when using the default event handler). Alternatively, if someone is listening for these events, they can decide how to display them, for example in the context of an IDE such as Xcode. This change also means we no longer write these messages to the system log on Darwin. As far as I know, nobody is relying on this, but I think this is something we could add to the diagnostic event mechanism. Differential revision: https://reviews.llvm.org/D128480
This commit is contained in:
@@ -1107,27 +1107,6 @@ void Module::GetDescription(llvm::raw_ostream &s,
|
||||
s << llvm::formatv("({0})", object_name);
|
||||
}
|
||||
|
||||
void Module::ReportError(const char *format, ...) {
|
||||
if (format && format[0]) {
|
||||
StreamString strm;
|
||||
strm.PutCString("error: ");
|
||||
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
|
||||
strm.PutChar(' ');
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
strm.PrintfVarArg(format, args);
|
||||
va_end(args);
|
||||
|
||||
const int format_len = strlen(format);
|
||||
if (format_len > 0) {
|
||||
const char last_char = format[format_len - 1];
|
||||
if (last_char != '\n' && last_char != '\r')
|
||||
strm.EOL();
|
||||
}
|
||||
Host::SystemLog(Host::eSystemLogError, "%s", strm.GetData());
|
||||
}
|
||||
}
|
||||
|
||||
bool Module::FileHasChanged() const {
|
||||
// We have provided the DataBuffer for this module to avoid accessing the
|
||||
// filesystem. We never want to reload those files.
|
||||
@@ -1170,7 +1149,7 @@ void Module::ReportErrorIfModifyDetected(const char *format, ...) {
|
||||
m_first_file_changed_log = true;
|
||||
if (format) {
|
||||
StreamString strm;
|
||||
strm.PutCString("error: the object file ");
|
||||
strm.PutCString("the object file ");
|
||||
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
|
||||
strm.PutCString(" has been modified\n");
|
||||
|
||||
@@ -1186,17 +1165,31 @@ void Module::ReportErrorIfModifyDetected(const char *format, ...) {
|
||||
strm.EOL();
|
||||
}
|
||||
strm.PutCString("The debug session should be aborted as the original "
|
||||
"debug information has been overwritten.\n");
|
||||
Host::SystemLog(Host::eSystemLogError, "%s", strm.GetData());
|
||||
"debug information has been overwritten.");
|
||||
Debugger::ReportError(std::string(strm.GetString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Module::ReportError(const char *format, ...) {
|
||||
if (format && format[0]) {
|
||||
StreamString strm;
|
||||
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelBrief);
|
||||
strm.PutChar(' ');
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
strm.PrintfVarArg(format, args);
|
||||
va_end(args);
|
||||
|
||||
Debugger::ReportError(std::string(strm.GetString()));
|
||||
}
|
||||
}
|
||||
|
||||
void Module::ReportWarning(const char *format, ...) {
|
||||
if (format && format[0]) {
|
||||
StreamString strm;
|
||||
strm.PutCString("warning: ");
|
||||
GetDescription(strm.AsRawOstream(), lldb::eDescriptionLevelFull);
|
||||
strm.PutChar(' ');
|
||||
|
||||
@@ -1205,13 +1198,7 @@ void Module::ReportWarning(const char *format, ...) {
|
||||
strm.PrintfVarArg(format, args);
|
||||
va_end(args);
|
||||
|
||||
const int format_len = strlen(format);
|
||||
if (format_len > 0) {
|
||||
const char last_char = format[format_len - 1];
|
||||
if (last_char != '\n' && last_char != '\r')
|
||||
strm.EOL();
|
||||
}
|
||||
Host::SystemLog(Host::eSystemLogWarning, "%s", strm.GetData());
|
||||
Debugger::ReportWarning(std::string(strm.GetString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user