summaryrefslogtreecommitdiff
path: root/lldb/source/Core/Module.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2022-06-24 09:36:29 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2022-06-24 09:46:26 -0700
commit6879391908cab68e8d43a0097fa8c9cd3b86eff9 (patch)
treed47680ae2bad7e146952befd6511fce6c1e05584 /lldb/source/Core/Module.cpp
parent2faacf61a50e7f23fd10927cbbb98c59799bfcd0 (diff)
[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
Diffstat (limited to 'lldb/source/Core/Module.cpp')
-rw-r--r--lldb/source/Core/Module.cpp51
1 files changed, 19 insertions, 32 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 7160c2386efd..41c21e1dc326 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -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()));
}
}