From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id C4F9A385841C; Sat, 29 Oct 2022 17:34:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4F9A385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667064891; bh=X2Shi7IKxSaYxGLenRVIR6l6W9m+NH46SPZBc9XW4DQ=; h=From:To:Subject:Date:From; b=B0ZxALI4W2PFKmcEgH/Qk3eiq+r5o1hjzaPBMamdP8uv0hsF8keaeOneDksa+f6te Ftevsp4UAPjFX9T8DqBTDG74ouxAnShtXUuuGjtVTQgdJemTv+37rqkoVqULuKdUly 2tFX/gPCoR91USIDovAkeCyWXgf9kdLi7aJ7grmc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon TURNEY To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: Add loaded module base address list to stackdump X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/master X-Git-Oldrev: d59651d4daff0d31837ea852cd01404f8e10dca4 X-Git-Newrev: 9b89811c9fc0cc859c8d43a5a162e5fe8cc1ff2c Message-Id: <20221029173451.C4F9A385841C@sourceware.org> Date: Sat, 29 Oct 2022 17:34:41 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D9b89811c9fc= 0cc859c8d43a5a162e5fe8cc1ff2c commit 9b89811c9fc0cc859c8d43a5a162e5fe8cc1ff2c Author: Jon Turney Date: Fri Oct 28 13:35:13 2022 +0100 Cygwin: Add loaded module base address list to stackdump =20 This adds an extra section to the stackdump, which lists the loaded modules and their base address. This is perhaps useful as it makes it immediately clear if RandomCrashInjectedDll.dll is loaded... =20 Future work: It seems like the 'InMemoryOrder' part of 'InMemoryOrderModuleList' is a lie? =20 > Loaded modules > 000100400000 segv-test.exe > 7FFF2AC30000 ntdll.dll > 7FFF29050000 KERNEL32.DLL > 7FFF28800000 KERNELBASE.dll > 000180040000 cygwin1.dll > 7FFF28FA0000 advapi32.dll > 7FFF29F20000 msvcrt.dll > 7FFF299E0000 sechost.dll > 7FFF29B30000 RPCRT4.dll > 7FFF27C10000 CRYPTBASE.DLL > 7FFF28770000 bcryptPrimitives.dll Diff: --- winsup/cygwin/exceptions.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 1e9ea26bf..8cc454c90 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -383,6 +383,16 @@ cygwin_exception::dumpstack () small_printf ("End of stack trace%s\r\n", i =3D=3D DUMPSTACK_FRAME_LIMIT ? " (more stack frames may be present)" : ""); + + small_printf ("Loaded modules:\r\n"); + PLIST_ENTRY head =3D &NtCurrentTeb()->Peb->Ldr->InMemoryOrderModuleL= ist; + for (PLIST_ENTRY x =3D head->Flink; x !=3D head; x =3D x->Flink) + { + PLDR_DATA_TABLE_ENTRY mod =3D CONTAINING_RECORD (x, LDR_DATA_TABLE_ENTR= Y, + InMemoryOrderLinks); + small_printf ("%012X %S\r\n", mod->DllBase, &mod->BaseDllName); + } + if (h) NtClose (h); }