This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Replace Host::SystemLog with Debugger::Report{Error,Warning}
ClosedPublic

Authored by JDevlieghere on Jun 23 2022, 4:36 PM.

Details

Summary

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. By switching over, we print these error messages to the debugger's error stream (when using the default event handler) or report them to an IDE such as Xcode (if they have subscribed to these events). It also means we nog longer write the messages to the system log on Darwin, but as far as I know, nobody is relying on this functionality today. If this is deemed important externally, I can add it again when I add the system logging functionality again in the context of D128321.

Diff Detail

Event Timeline

JDevlieghere created this revision.Jun 23 2022, 4:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 4:36 PM
JDevlieghere requested review of this revision.Jun 23 2022, 4:36 PM
mib added inline comments.Jun 23 2022, 4:57 PM
lldb/source/Core/Module.cpp
1187

It's unrelated to this patch, but it looks like Debugger::HandleDiagnosticEvent dumps everything to the error stream without checking if the event is a warning or an error. I'm mentioning that here because if we did that distinction at the event handling level, we could get rid of strm.PutCString("error: ").

Note however, the reason I'm bringing this up, is that the error message prefix is not consistent with ReportErrorIfModifyDetected, since it's not prepended by error: .

We should at least fix that for this patch before before making it consistent at the event handler level.

mib added inline comments.Jun 23 2022, 4:59 PM
lldb/source/Core/Module.cpp
1187

I hadn't looked at the rest of the patch and this looks very inconsistent throughout the other files as well ... may be we should just leave that for a follow-up patch

JDevlieghere added inline comments.Jun 23 2022, 5:18 PM
lldb/source/Core/Module.cpp
1187

Yeah this is an oversight. The prefix will get printed when the event gets handled (or by the IDE) so it shouldn't be part of the message. I'll fix that here.

I don't have anything against this, though I still think the LogHandlers should use the Host layer by making the LogHandler objects into real LLDB plug-ins. But if everyone else feels otherwise, I won't object.

I don't have anything against this, though I still think the LogHandlers should use the Host layer by making the LogHandler objects into real LLDB plug-ins. But if everyone else feels otherwise, I won't object.

This patch is meant to be entirely orthogonal to that. I was still going to add (what I believe is a better) implementation of SystemLog. In D128321 I said:

But if we really want this to live in Host (and deal with the dependency issues later) I can implement a new Host::SystemLog variant that essentially does what the SystemLogHander is doing and implement the log handler in Host based on that.

So that's what I was alluding to.

Remove spurious "error:" strings.

I don't have anything against this, though I still think the LogHandlers should use the Host layer by making the LogHandler objects into real LLDB plug-ins. But if everyone else feels otherwise, I won't object.

This patch is meant to be entirely orthogonal to that. I was still going to add (what I believe is a better) implementation of SystemLog. In D128321 I said:

But if we really want this to live in Host (and deal with the dependency issues later) I can implement a new Host::SystemLog variant that essentially does what the SystemLogHander is doing and implement the log handler in Host based on that.

So that's what I was alluding to.

I've updated D128321 with the new ConsoleLog implementation.

labath accepted this revision.Jun 24 2022, 3:39 AM
This revision is now accepted and ready to land.Jun 24 2022, 3:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 9:46 AM