Bug 1793834 - part 2/12: also log HWND in message logs r=handyman

This is helpful for the normal event log, and also necessary since we want to group the messages up by window in the about page.

Differential Revision: https://phabricator.services.mozilla.com/D161149
This commit is contained in:
Greg Stoll 2022-11-21 19:15:53 +00:00
parent 0e9cbaa4d2
commit 9f26e06933
3 changed files with 11 additions and 6 deletions

View File

@ -5174,7 +5174,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
LRESULT* aRetValue) {
// For some events we might change the parameter values, so log
// before and after we process them.
PrintEvent printEvent(msg, wParam, lParam, *aRetValue);
PrintEvent printEvent(mWnd, msg, wParam, lParam, *aRetValue);
bool result = ProcessMessageInternal(msg, wParam, lParam, aRetValue);
printEvent.SetResult(result);

View File

@ -39,8 +39,10 @@ std::unordered_set<UINT> gEventsToLogOriginalParams = {
WM_GETTEXT, WM_GETMINMAXINFO, WM_MEASUREITEM,
};
PrintEvent::PrintEvent(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT retValue)
: mMsg(msg),
PrintEvent::PrintEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
LRESULT retValue)
: mHwnd(hwnd),
mMsg(msg),
mWParam(wParam),
mLParam(lParam),
mRetValue(retValue),
@ -189,8 +191,9 @@ bool PrintEvent::PrintEventInternal() {
: "initial call";
MOZ_LOG(
gWindowsEventLog, LogLevel::Info,
("%6ld - 0x%04X %s %s: 0x%08llX (%s)\n",
mEventCounter.valueOr(gEventCounter), mMsg, paramInfo.get(),
("%6ld 0x%08llX - 0x%04X %s %s: 0x%08llX (%s)\n",
mEventCounter.valueOr(gEventCounter),
reinterpret_cast<uint64_t>(mHwnd), mMsg, paramInfo.get(),
msgText ? msgText : "Unknown",
mResult.isSome() ? static_cast<uint64_t>(mRetValue) : 0, resultMsg));
gLastEventMsg = mMsg;

View File

@ -43,12 +43,14 @@ extern std::unordered_map<UINT, EventMsgInfo> gAllEvents;
// RAII-style class to log before and after an event is handled.
class PrintEvent final {
public:
PrintEvent(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT retValue);
PrintEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
LRESULT retValue);
void SetResult(bool result) { mResult = mozilla::Some(result); }
~PrintEvent();
private:
bool PrintEventInternal();
const HWND mHwnd;
const UINT mMsg;
const WPARAM mWParam;
const LPARAM mLParam;