[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:
Jonas Devlieghere
2022-06-24 09:36:29 -07:00
parent 2faacf61a5
commit 6879391908
13 changed files with 98 additions and 184 deletions

View File

@@ -1932,10 +1932,10 @@ public:
if (first_section_sp)
filename = first_section_sp->GetObjectFile()->GetFileSpec().GetPath();
Host::SystemLog(Host::eSystemLogError,
"error: unable to find section %d for a symbol in "
"%s, corrupt file?\n",
n_sect, filename.c_str());
Debugger::ReportError(
llvm::formatv("unable to find section {0} for a symbol in "
"{1}, corrupt file?",
n_sect, filename));
}
}
if (m_section_infos[n_sect].vm_range.Contains(file_addr)) {
@@ -2804,12 +2804,11 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
// No symbol should be NULL, even the symbols with no
// string values should have an offset zero which
// points to an empty C-string
Host::SystemLog(
Host::eSystemLogError,
"error: DSC unmapped local symbol[%u] has invalid "
"string table offset 0x%x in %s, ignoring symbol\n",
Debugger::ReportError(llvm::formatv(
"DSC unmapped local symbol[{0}] has invalid "
"string table offset {1:x} in {2}, ignoring symbol",
nlist_index, nlist.n_strx,
module_sp->GetFileSpec().GetPath().c_str());
module_sp->GetFileSpec().GetPath());
continue;
}
if (symbol_name[0] == '\0')
@@ -3730,11 +3729,10 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
if (symbol_name == nullptr) {
// No symbol should be NULL, even the symbols with no string values
// should have an offset zero which points to an empty C-string
Host::SystemLog(Host::eSystemLogError,
"error: symbol[%u] has invalid string table offset "
"0x%x in %s, ignoring symbol\n",
nlist_idx, nlist.n_strx,
module_sp->GetFileSpec().GetPath().c_str());
Debugger::ReportError(llvm::formatv(
"symbol[{0}] has invalid string table offset {1:x} in {2}, "
"ignoring symbol",
nlist_idx, nlist.n_strx, module_sp->GetFileSpec().GetPath()));
return true;
}
if (symbol_name[0] == '\0')