Skip to content

🍒 [windows][lldb] implement system logging on Windows (#150213) #11096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: swift/release/6.2
Choose a base branch
from

Conversation

charles-zablit
Copy link

This patch makes LLDB use the Event Viewer on Windows (equivalent of
system logging on Darwin) rather than piping to the standard output
(which was deactivated in ca0a524.
@charles-zablit
Copy link
Author

@swift-ci please test

2 similar comments
@charles-zablit
Copy link
Author

@swift-ci please test

@charles-zablit
Copy link
Author

@swift-ci please test

@charles-zablit
Copy link
Author

@swift-ci please test windows

@charles-zablit
Copy link
Author

@swift-ci please test

@charles-zablit
Copy link
Author

@swift-ci please test Windows

@charles-zablit
Copy link
Author

@swift-ci please test windows

@charles-zablit
Copy link
Author

@swift-ci please test Windows

event_type = EVENTLOG_INFORMATION_TYPE;
}

ReportEventW(h, event_type, 0, 0, nullptr, 1, 0, &msg_ptr, nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the best place to put the messages? The Event Log is for system events, this feels more developer oriented and feels like the kernel debug buffer might be better (OutputDebugStringA).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, the messages outputted through OutputDebugStringA are only accessible from an attached debugger or something like DebugView (which still requires attaching). The goal of this PR is to mimic what lldb does on Darwin with system logging, which does not require a debugger.

this feels more developer oriented

I think the health logs are useful for users as well to understand if their install is broken. I would say that they are also useful for lldb users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but I don't think that the event viewer is the right location for the logging. This log tends to be very very very very verbose. If this only was triggered in the case that lldb is dying, that would be one thing. But this is effectively triggered on each run of lldb.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log tends to be very very very very verbose.

Are you talking about the overall system events or just the lldb health logs? I agree that the overall system logs (the contents of the event viewer) has a lot of entries. However the UI and the search bar allow to filter them easily. The Console on macOS also has a lot of entries and we can filter messages fine. I assume it's the same on Linux.

My reasoning for using the event viewer is:

  1. Even though there are a lot of entries, the UI allows to quickly find lldb related entries.
  2. This is the closest match to how we log on other platforms. We could switch to using OutputDebugStringA however we should also do so on other platforms. I don't think it's a good UX for users to need to use a debugger on Windows to get the health logs, but to only have to open the Console to get them on macOS.

I would be in favor of taking this change in 6.2 and to propose a migration to another destination for health logs on all platforms on the forums further down the line. What do you think?

Copy link
Member

@compnerd compnerd Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am referring to the lldb side. I don't think that Linux is the same. syslog is just a flat file though these days you would find the logs somewhere in systemd I imagine which isn't really easy to filter.

This is too late for 6.2 IMO. So we are better off just changing this now before merging.

std::wstring unicode(unicode_length, L'\0');
MultiByteToWideChar(CP_ACP, 0, ansi.c_str(), -1, &unicode[0], unicode_length);
return unicode;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why re-implement UTF8ToUTF16 and UTF16ToUTF8 from LLVM?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants