ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
June 2021
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
19 participants
228 discussions
Start a n
N
ew thread
[reactos] 01/01: [SHELL32] Implement PathResolveA function (#3771)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=561fa8d29b562fd692eae…
commit 561fa8d29b562fd692eae0fb25c296d847e887ec Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Jul 1 08:42:29 2021 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Thu Jul 1 08:42:29 2021 +0900 [SHELL32] Implement PathResolveA function (#3771) - Follow-up of #3762. - Add PathResolveA implementation by ANSI/Unicode string conversion. CORE-12665 --- dll/win32/shell32/wine/shellpath.c | 44 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/dll/win32/shell32/wine/shellpath.c b/dll/win32/shell32/wine/shellpath.c index b0978280008..7745285af6e 100644 --- a/dll/win32/shell32/wine/shellpath.c +++ b/dll/win32/shell32/wine/shellpath.c @@ -631,8 +631,48 @@ VOID WINAPI PathQualifyAW(LPVOID pszPath) BOOL WINAPI PathResolveA(LPSTR path, LPCSTR *dirs, DWORD flags) { - FIXME("(%s,%p,0x%08x),stub!\n", debugstr_a(path), dirs, flags); - return FALSE; + BOOL ret = FALSE; + LPWSTR *dirsW = NULL; + DWORD iDir, cDirs, cbDirs; + WCHAR pathW[MAX_PATH]; + + TRACE("PathResolveA(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags); + + if (dirs) + { + for (cDirs = 0; dirs[cDirs]; ++cDirs) + ; + + cbDirs = (cDirs + 1) * sizeof(LPWSTR); + dirsW = SHAlloc(cbDirs); + if (!dirsW) + goto Cleanup; + + ZeroMemory(dirsW, cbDirs); + for (iDir = 0; iDir < cDirs; ++iDir) + { + __SHCloneStrAtoW(&dirsW[iDir], dirs[iDir]); + if (dirsW[iDir] == NULL) + goto Cleanup; + } + } + + SHAnsiToUnicode(path, pathW, _countof(pathW)); + + ret = PathResolveW(pathW, (LPCWSTR*)dirsW, flags); + if (ret) + SHUnicodeToAnsi(pathW, path, MAX_PATH); + +Cleanup: + if (dirsW) + { + for (iDir = 0; iDir < cDirs; ++iDir) + { + SHFree(dirsW[iDir]); + } + SHFree(dirsW); + } + return ret; } BOOL WINAPI PathResolveW(LPWSTR path, LPCWSTR *dirs, DWORD flags)
3 years, 5 months
1
0
0
0
[reactos] 01/01: [CRT] Revert unwanted part of f30136bc79109af5df33526974e24b39353773c7
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0ffbbab5a21d4f59a5ced…
commit 0ffbbab5a21d4f59a5ced8d04c532756bea9a275 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jun 29 12:48:25 2021 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Jun 29 12:48:25 2021 +0200 [CRT] Revert unwanted part of f30136bc79109af5df33526974e24b39353773c7 --- sdk/lib/crt/crt.cmake | 3 +-- sdk/lib/crt/libcntpr.cmake | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/lib/crt/crt.cmake b/sdk/lib/crt/crt.cmake index 1090ff33a78..f3b9160a9b5 100644 --- a/sdk/lib/crt/crt.cmake +++ b/sdk/lib/crt/crt.cmake @@ -117,7 +117,6 @@ list(APPEND CRT_SOURCE mem/memcmp.c mem/memccpy.c mem/memicmp.c - mem/memset.c misc/__crt_MessageBoxA.c misc/amsg.c misc/assert.c @@ -400,7 +399,7 @@ if(ARCH STREQUAL "i386") math/i386/fmodf_asm.s mem/i386/memchr_asm.s mem/i386/memmove_asm.s - # mem/i386/memset_asm.s + mem/i386/memset_asm.s misc/i386/readcr4.S setjmp/i386/setjmp.s string/i386/strcat_asm.s diff --git a/sdk/lib/crt/libcntpr.cmake b/sdk/lib/crt/libcntpr.cmake index cff2a2e7286..178a18cd704 100644 --- a/sdk/lib/crt/libcntpr.cmake +++ b/sdk/lib/crt/libcntpr.cmake @@ -9,7 +9,6 @@ list(APPEND LIBCNTPR_SOURCE mem/memccpy.c mem/memcmp.c mem/memicmp.c - mem/memset.c misc/fltused.c printf/_snprintf.c printf/_snwprintf.c @@ -187,7 +186,7 @@ if(ARCH STREQUAL "i386") list(APPEND LIBCNTPR_ASM_SOURCE mem/i386/memchr_asm.s mem/i386/memmove_asm.s - # mem/i386/memset_asm.s + mem/i386/memset_asm.s string/i386/strcat_asm.s string/i386/strchr_asm.s string/i386/strcmp_asm.s
3 years, 5 months
1
0
0
0
[reactos] 13/13: [NTOS:KE] Unconditionally check IRQL when acquiring & releasing spinlock at DISPATCH_LEVEL
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=37d0a9c3f45ec423eadb1…
commit 37d0a9c3f45ec423eadb14e17bf0ace3a1af7499 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri May 21 09:44:32 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [NTOS:KE] Unconditionally check IRQL when acquiring & releasing spinlock at DISPATCH_LEVEL --- ntoskrnl/include/internal/ke.h | 10 ++++++++-- ntoskrnl/ke/spinlock.c | 25 +++++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/include/internal/ke.h b/ntoskrnl/include/internal/ke.h index 92558517f0f..ae255961388 100644 --- a/ntoskrnl/include/internal/ke.h +++ b/ntoskrnl/include/internal/ke.h @@ -986,16 +986,22 @@ VOID NTAPI KeThawExecution(IN BOOLEAN Enable); +_IRQL_requires_min_(DISPATCH_LEVEL) +_Acquires_nonreentrant_lock_(*LockHandle->Lock) +_Acquires_exclusive_lock_(*LockHandle->Lock) VOID FASTCALL KeAcquireQueuedSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK_QUEUE LockQueue + _Inout_ PKSPIN_LOCK_QUEUE LockQueue ); +_IRQL_requires_min_(DISPATCH_LEVEL) +_Releases_nonreentrant_lock_(*LockHandle->Lock) +_Releases_exclusive_lock_(*LockHandle->Lock) VOID FASTCALL KeReleaseQueuedSpinLockFromDpcLevel( - IN OUT PKSPIN_LOCK_QUEUE LockQueue + _Inout_ PKSPIN_LOCK_QUEUE LockQueue ); VOID diff --git a/ntoskrnl/ke/spinlock.c b/ntoskrnl/ke/spinlock.c index deb52b85d29..d382cbf5055 100644 --- a/ntoskrnl/ke/spinlock.c +++ b/ntoskrnl/ke/spinlock.c @@ -94,11 +94,14 @@ KeReleaseQueuedSpinLockFromDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) // HACK: Hacked to work like normal spinlocks // +_IRQL_requires_min_(DISPATCH_LEVEL) +_Acquires_nonreentrant_lock_(*LockHandle->Lock) +_Acquires_exclusive_lock_(*LockHandle->Lock) VOID FASTCALL -KeAcquireQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) +KeAcquireQueuedSpinLockAtDpcLevel(_Inout_ PKSPIN_LOCK_QUEUE LockHandle) { -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) || DBG /* Make sure we are at DPC or above! */ if (KeGetCurrentIrql() < DISPATCH_LEVEL) { @@ -115,11 +118,14 @@ KeAcquireQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) KxAcquireSpinLock(LockHandle->Lock); } +_IRQL_requires_min_(DISPATCH_LEVEL) +_Releases_nonreentrant_lock_(*LockHandle->Lock) +_Releases_exclusive_lock_(*LockHandle->Lock) VOID FASTCALL -KeReleaseQueuedSpinLockFromDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) +KeReleaseQueuedSpinLockFromDpcLevel(_Inout_ PKSPIN_LOCK_QUEUE LockHandle) { -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) || DBG /* Make sure we are at DPC or above! */ if (KeGetCurrentIrql() < DISPATCH_LEVEL) { @@ -303,6 +309,17 @@ FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock) { #if DBG + /* Make sure we are at DPC or above! */ + if (KeGetCurrentIrql() < DISPATCH_LEVEL) + { + /* We aren't -- bugcheck */ + KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL, + (ULONG_PTR)SpinLock, + KeGetCurrentIrql(), + 0, + 0); + } + /* Make sure that we don't own the lock already */ if (((KSPIN_LOCK)KeGetCurrentThread() | 1) == *SpinLock) {
3 years, 5 months
1
0
0
0
[reactos] 12/13: [NTOS:KE] Test spinlock ownership on both UP & MP build
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f30136bc79109af5df335…
commit f30136bc79109af5df33526974e24b39353773c7 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu May 20 10:13:40 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [NTOS:KE] Test spinlock ownership on both UP & MP build There is no reason not to, and this avoids introducing bugs stupidly. --- boot/freeldr/freeldr/arch/i386/ntoskrnl.c | 8 ++++ ntoskrnl/include/internal/spinlock.h | 72 ++++++++++++++----------------- ntoskrnl/ke/spinlock.c | 25 +++++++---- sdk/lib/crt/crt.cmake | 3 +- sdk/lib/crt/libcntpr.cmake | 3 +- 5 files changed, 62 insertions(+), 49 deletions(-) diff --git a/boot/freeldr/freeldr/arch/i386/ntoskrnl.c b/boot/freeldr/freeldr/arch/i386/ntoskrnl.c index e44fa770771..4255e5cf0e0 100644 --- a/boot/freeldr/freeldr/arch/i386/ntoskrnl.c +++ b/boot/freeldr/freeldr/arch/i386/ntoskrnl.c @@ -28,6 +28,14 @@ FASTCALL KefAcquireSpinLockAtDpcLevel( IN PKSPIN_LOCK SpinLock) { +#if DBG + /* To be on par with HAL/NTOSKRNL */ +#ifdef _M_AMD64 + *SpinLock = (KSPIN_LOCK)KeGetCurrentThread() | 1; +#else + *SpinLock = (KSPIN_LOCK)(((PKIPCR)KeGetPcr())->PrcbData.CurrentThread) | 1; +#endif +#endif } VOID diff --git a/ntoskrnl/include/internal/spinlock.h b/ntoskrnl/include/internal/spinlock.h index e126dbe0b03..013ad913c34 100644 --- a/ntoskrnl/include/internal/spinlock.h +++ b/ntoskrnl/include/internal/spinlock.h @@ -6,50 +6,25 @@ * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) */ +#if defined(_M_IX86) VOID NTAPI Kii386SpinOnSpinLock(PKSPIN_LOCK SpinLock, ULONG Flags); - -#ifndef CONFIG_SMP - -// -// Spinlock Acquire at IRQL >= DISPATCH_LEVEL -// -FORCEINLINE -VOID -KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock) -{ - /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */ - UNREFERENCED_PARAMETER(SpinLock); - - /* Add an explicit memory barrier to prevent the compiler from reordering - memory accesses across the borders of spinlocks */ - KeMemoryBarrierWithoutFence(); -} - -// -// Spinlock Release at IRQL >= DISPATCH_LEVEL -// -FORCEINLINE -VOID -KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock) -{ - /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */ - UNREFERENCED_PARAMETER(SpinLock); - - /* Add an explicit memory barrier to prevent the compiler from reordering - memory accesses across the borders of spinlocks */ - KeMemoryBarrierWithoutFence(); -} - -#else +#endif // // Spinlock Acquisition at IRQL >= DISPATCH_LEVEL // +_Acquires_nonreentrant_lock_(SpinLock) FORCEINLINE VOID -KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock) +KxAcquireSpinLock( +#if defined(CONFIG_SMP) || DBG + _Inout_ +#else + _Unreferenced_parameter_ +#endif + PKSPIN_LOCK SpinLock) { #if DBG /* Make sure that we don't own the lock already */ @@ -60,6 +35,7 @@ KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock) } #endif +#ifdef CONFIG_SMP /* Try to acquire the lock */ while (InterlockedBitTestAndSet((PLONG)SpinLock, 0)) { @@ -75,6 +51,12 @@ KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock) } #endif } +#endif + + /* Add an explicit memory barrier to prevent the compiler from reordering + memory accesses across the borders of spinlocks */ + KeMemoryBarrierWithoutFence(); + #if DBG /* On debug builds, we OR in the KTHREAD */ *SpinLock = (KSPIN_LOCK)KeGetCurrentThread() | 1; @@ -84,9 +66,16 @@ KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock) // // Spinlock Release at IRQL >= DISPATCH_LEVEL // +_Releases_nonreentrant_lock_(SpinLock) FORCEINLINE VOID -KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock) +KxReleaseSpinLock( +#if defined(CONFIG_SMP) || DBG + _Inout_ +#else + _Unreferenced_parameter_ +#endif + PKSPIN_LOCK SpinLock) { #if DBG /* Make sure that the threads match */ @@ -96,12 +85,17 @@ KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock) KeBugCheckEx(SPIN_LOCK_NOT_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0); } #endif - /* Clear the lock */ + +#if defined(CONFIG_SMP) || DBG + /* Clear the lock */ #ifdef _WIN64 InterlockedAnd64((PLONG64)SpinLock, 0); #else InterlockedAnd((PLONG)SpinLock, 0); #endif -} - #endif + + /* Add an explicit memory barrier to prevent the compiler from reordering + memory accesses across the borders of spinlocks */ + KeMemoryBarrierWithoutFence(); +} diff --git a/ntoskrnl/ke/spinlock.c b/ntoskrnl/ke/spinlock.c index 6648f75e5a9..deb52b85d29 100644 --- a/ntoskrnl/ke/spinlock.c +++ b/ntoskrnl/ke/spinlock.c @@ -109,10 +109,10 @@ KeAcquireQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) 0, 0); } +#endif /* Do the inlined function */ KxAcquireSpinLock(LockHandle->Lock); -#endif } VOID @@ -130,10 +130,10 @@ KeReleaseQueuedSpinLockFromDpcLevel(IN PKSPIN_LOCK_QUEUE LockHandle) 0, 0); } +#endif /* Do the inlined function */ KxReleaseSpinLock(LockHandle->Lock); -#endif } #endif @@ -302,6 +302,15 @@ BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock) { +#if DBG + /* Make sure that we don't own the lock already */ + if (((KSPIN_LOCK)KeGetCurrentThread() | 1) == *SpinLock) + { + /* We do, bugcheck! */ + KeBugCheckEx(SPIN_LOCK_ALREADY_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0); + } +#endif + #ifdef CONFIG_SMP /* Check if it's already acquired */ if (!(*SpinLock)) @@ -318,11 +327,11 @@ KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock) /* It was already acquired */ return FALSE; } +#endif #if DBG /* On debug builds, we OR in the KTHREAD */ *SpinLock = (ULONG_PTR)KeGetCurrentThread() | 1; -#endif #endif /* All is well, return TRUE */ @@ -337,10 +346,10 @@ FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle) { -#ifdef CONFIG_SMP /* Set it up properly */ LockHandle->LockQueue.Next = NULL; LockHandle->LockQueue.Lock = SpinLock; +#ifdef CONFIG_SMP #if 0 KeAcquireQueuedSpinLockAtDpcLevel(LockHandle->LockQueue.Next); #else @@ -354,11 +363,11 @@ KeAcquireInStackQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock, 0, 0); } +#endif +#endif /* Acquire the lock */ KxAcquireSpinLock(LockHandle->LockQueue.Lock); // HACK -#endif -#endif } /* @@ -383,11 +392,11 @@ KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle) 0, 0); } +#endif +#endif /* Release the lock */ KxReleaseSpinLock(LockHandle->LockQueue.Lock); // HACK -#endif -#endif } /* diff --git a/sdk/lib/crt/crt.cmake b/sdk/lib/crt/crt.cmake index f3b9160a9b5..1090ff33a78 100644 --- a/sdk/lib/crt/crt.cmake +++ b/sdk/lib/crt/crt.cmake @@ -117,6 +117,7 @@ list(APPEND CRT_SOURCE mem/memcmp.c mem/memccpy.c mem/memicmp.c + mem/memset.c misc/__crt_MessageBoxA.c misc/amsg.c misc/assert.c @@ -399,7 +400,7 @@ if(ARCH STREQUAL "i386") math/i386/fmodf_asm.s mem/i386/memchr_asm.s mem/i386/memmove_asm.s - mem/i386/memset_asm.s + # mem/i386/memset_asm.s misc/i386/readcr4.S setjmp/i386/setjmp.s string/i386/strcat_asm.s diff --git a/sdk/lib/crt/libcntpr.cmake b/sdk/lib/crt/libcntpr.cmake index 178a18cd704..cff2a2e7286 100644 --- a/sdk/lib/crt/libcntpr.cmake +++ b/sdk/lib/crt/libcntpr.cmake @@ -9,6 +9,7 @@ list(APPEND LIBCNTPR_SOURCE mem/memccpy.c mem/memcmp.c mem/memicmp.c + mem/memset.c misc/fltused.c printf/_snprintf.c printf/_snwprintf.c @@ -186,7 +187,7 @@ if(ARCH STREQUAL "i386") list(APPEND LIBCNTPR_ASM_SOURCE mem/i386/memchr_asm.s mem/i386/memmove_asm.s - mem/i386/memset_asm.s + # mem/i386/memset_asm.s string/i386/strcat_asm.s string/i386/strchr_asm.s string/i386/strcmp_asm.s
3 years, 5 months
1
0
0
0
[reactos] 11/13: [NTOS:KD][NTOS:KD64][NTOS:KDBG] Fix IRQL & spinlock use
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=835c30232e42acd7143d5…
commit 835c30232e42acd7143d597bedf07e430232535d Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jun 22 19:46:27 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [NTOS:KD][NTOS:KD64][NTOS:KDBG] Fix IRQL & spinlock use KD64: Raise to HIGH_LEVEL when entering trap KDBG: lower to DISPATCH_LEVEL when applying IRQL hack & use a worker thread to load symbols KD&KDBG: Actually unload symbols when required --- ntoskrnl/include/internal/kd64.h | 5 + ntoskrnl/kd/kdio.c | 9 +- ntoskrnl/kd64/kdprint.c | 2 +- ntoskrnl/kd64/kdtrap.c | 10 +- ntoskrnl/kdbg/kdb.c | 9 +- ntoskrnl/kdbg/kdb.h | 4 +- ntoskrnl/kdbg/kdb_cli.c | 6 +- ntoskrnl/kdbg/kdb_symbols.c | 391 +++++++++++++++++---------------------- sdk/include/reactos/rossym.h | 7 +- sdk/lib/rossym/rossympriv.h | 7 - 10 files changed, 203 insertions(+), 247 deletions(-) diff --git a/ntoskrnl/include/internal/kd64.h b/ntoskrnl/include/internal/kd64.h index 4802c9c9f60..7e992e0b4ec 100644 --- a/ntoskrnl/include/internal/kd64.h +++ b/ntoskrnl/include/internal/kd64.h @@ -514,6 +514,11 @@ KdpDprintf( ... ); +BOOLEAN +NTAPI +KdpPrintString( + _In_ PSTRING Output); + // // Global KD Data // diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index 3dabd050d26..275971acd92 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -580,13 +580,10 @@ KdSendPacket( { #ifdef KDBG PLDR_DATA_TABLE_ENTRY LdrEntry; - if (!WaitStateChange->u.LoadSymbols.UnloadSymbols) + /* Load symbols. Currently implemented only for KDBG! */ + if (KdbpSymFindModule((PVOID)(ULONG_PTR)WaitStateChange->u.LoadSymbols.BaseOfDll, -1, &LdrEntry)) { - /* Load symbols. Currently implemented only for KDBG! */ - if (KdbpSymFindModule((PVOID)(ULONG_PTR)WaitStateChange->u.LoadSymbols.BaseOfDll, NULL, -1, &LdrEntry)) - { - KdbSymProcessSymbols(LdrEntry); - } + KdbSymProcessSymbols(LdrEntry, !WaitStateChange->u.LoadSymbols.UnloadSymbols); } #endif return; diff --git a/ntoskrnl/kd64/kdprint.c b/ntoskrnl/kd64/kdprint.c index a086652ddb3..83e2e2f3840 100644 --- a/ntoskrnl/kd64/kdprint.c +++ b/ntoskrnl/kd64/kdprint.c @@ -445,7 +445,7 @@ KdpDprintf( STRING String; USHORT Length; va_list ap; - CHAR Buffer[100]; + CHAR Buffer[512]; /* Format the string */ va_start(ap, Format); diff --git a/ntoskrnl/kd64/kdtrap.c b/ntoskrnl/kd64/kdtrap.c index b8314a94685..ed13f3f1971 100644 --- a/ntoskrnl/kd64/kdtrap.c +++ b/ntoskrnl/kd64/kdtrap.c @@ -144,10 +144,11 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, BOOLEAN Handled; NTSTATUS ReturnStatus; USHORT ReturnLength; - KIRQL OldIrql; + KIRQL OldIrql = DISPATCH_LEVEL; - /* Raise as high as we can. */ - KeRaiseIrql(HIGH_LEVEL, &OldIrql); + /* Raise if we have to. */ + if (KeGetCurrentIrql() < DISPATCH_LEVEL) + OldIrql = KeRaiseIrqlToDpcLevel(); /* * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or @@ -261,7 +262,8 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, SecondChanceException); } - KeLowerIrql(OldIrql); + if (OldIrql < DISPATCH_LEVEL) + KeLowerIrql(OldIrql); /* Return TRUE or FALSE to caller */ return Handled; diff --git a/ntoskrnl/kdbg/kdb.c b/ntoskrnl/kdbg/kdb.c index 8ec2e3bef1d..df1da7da3d2 100644 --- a/ntoskrnl/kdbg/kdb.c +++ b/ntoskrnl/kdbg/kdb.c @@ -1531,10 +1531,10 @@ KdbEnterDebuggerException( OldEflags = __readeflags(); _disable(); - /* HACK: Save the current IRQL and pretend we are at passive level, - * although interrupts are off. Needed because KDBG calls pageable code. */ + /* HACK: Save the current IRQL and pretend we are at dispatch level */ OldIrql = KeGetCurrentIrql(); - KeLowerIrql(PASSIVE_LEVEL); + if (OldIrql > DISPATCH_LEVEL) + KeLowerIrql(DISPATCH_LEVEL); /* Exception inside the debugger? Game over. */ if (InterlockedIncrement(&KdbEntryCount) > 1) @@ -1579,7 +1579,8 @@ KdbEnterDebuggerException( InterlockedDecrement(&KdbEntryCount); /* HACK: Raise back to old IRQL */ - KeRaiseIrql(OldIrql, &OldIrql); + if (OldIrql > DISPATCH_LEVEL) + KeRaiseIrql(OldIrql, &OldIrql); /* Leave critical section */ __writeeflags(OldEflags); diff --git a/ntoskrnl/kdbg/kdb.h b/ntoskrnl/kdbg/kdb.h index a496cc4a7b5..3ccd6fc49e0 100644 --- a/ntoskrnl/kdbg/kdb.h +++ b/ntoskrnl/kdbg/kdb.h @@ -148,7 +148,6 @@ KdbpRpnEvaluateParsedExpression( BOOLEAN KdbpSymFindModule( IN PVOID Address OPTIONAL, - IN LPCWSTR Name OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry); @@ -160,7 +159,8 @@ KdbSymPrintAddress( VOID KdbSymProcessSymbols( - IN PLDR_DATA_TABLE_ENTRY LdrEntry); + _Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, + _In_ BOOLEAN Load); /* from kdb.c */ diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c index 228bebffd4d..6c903f93695 100644 --- a/ntoskrnl/kdbg/kdb_cli.c +++ b/ntoskrnl/kdbg/kdb_cli.c @@ -1977,7 +1977,7 @@ KdbpCmdMod( Address = (ULONG_PTR)Result; - if (!KdbpSymFindModule((PVOID)Address, NULL, -1, &LdrEntry)) + if (!KdbpSymFindModule((PVOID)Address, -1, &LdrEntry)) { KdbpPrint("No module containing address 0x%p found!\n", Address); return TRUE; @@ -1987,7 +1987,7 @@ KdbpCmdMod( } else { - if (!KdbpSymFindModule(NULL, NULL, 0, &LdrEntry)) + if (!KdbpSymFindModule(NULL, 0, &LdrEntry)) { ULONG_PTR ntoskrnlBase = ((ULONG_PTR)KdbpCmdMod) & 0xfff00000; KdbpPrint(" Base Size Name\n"); @@ -2003,7 +2003,7 @@ KdbpCmdMod( { KdbpPrint(" %08x %08x %wZ\n", LdrEntry->DllBase, LdrEntry->SizeOfImage, &LdrEntry->BaseDllName); - if(DisplayOnlyOneModule || !KdbpSymFindModule(NULL, NULL, i++, &LdrEntry)) + if(DisplayOnlyOneModule || !KdbpSymFindModule(NULL, i++, &LdrEntry)) break; } diff --git a/ntoskrnl/kdbg/kdb_symbols.c b/ntoskrnl/kdbg/kdb_symbols.c index a066e39d8b7..997b55e5516 100644 --- a/ntoskrnl/kdbg/kdb_symbols.c +++ b/ntoskrnl/kdbg/kdb_symbols.c @@ -27,27 +27,19 @@ typedef struct _IMAGE_SYMBOL_INFO_CACHE IMAGE_SYMBOL_INFO_CACHE, *PIMAGE_SYMBOL_INFO_CACHE; static BOOLEAN LoadSymbols; -static LIST_ENTRY SymbolFileListHead; -static KSPIN_LOCK SymbolFileListLock; -BOOLEAN KdbpSymbolsInitialized = FALSE; +static LIST_ENTRY SymbolsToLoad; +static KSPIN_LOCK SymbolsToLoadLock; +static KEVENT SymbolsToLoadEvent; /* FUNCTIONS ****************************************************************/ -static NTSTATUS -KdbSymGetAddressInformation( - IN PROSSYM_INFO RosSymInfo, - IN ULONG_PTR RelativeAddress, - OUT PULONG LineNumber OPTIONAL, - OUT PCH FileName OPTIONAL, - OUT PCH FunctionName OPTIONAL); - -static BOOLEAN +static +BOOLEAN KdbpSymSearchModuleList( IN PLIST_ENTRY current_entry, IN PLIST_ENTRY end_entry, IN PLONG Count, IN PVOID Address, - IN LPCWSTR Name, IN INT Index, OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry) { @@ -56,7 +48,6 @@ KdbpSymSearchModuleList( *pLdrEntry = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); if ((Address && Address >= (PVOID)(*pLdrEntry)->DllBase && Address < (PVOID)((ULONG_PTR)(*pLdrEntry)->DllBase + (*pLdrEntry)->SizeOfImage)) || - (Name && !_wcsnicmp((*pLdrEntry)->BaseDllName.Buffer, Name, (*pLdrEntry)->BaseDllName.Length / sizeof(WCHAR))) || (Index >= 0 && (*Count)++ == Index)) { return TRUE; @@ -83,7 +74,6 @@ KdbpSymSearchModuleList( BOOLEAN KdbpSymFindModule( IN PVOID Address OPTIONAL, - IN LPCWSTR Name OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry) { @@ -91,16 +81,18 @@ KdbpSymFindModule( PEPROCESS CurrentProcess; /* First try to look up the module in the kernel module list. */ + KeAcquireSpinLockAtDpcLevel(&PsLoadedModuleSpinLock); if(KdbpSymSearchModuleList(PsLoadedModuleList.Flink, &PsLoadedModuleList, &Count, Address, - Name, Index, pLdrEntry)) { + KeReleaseSpinLockFromDpcLevel(&PsLoadedModuleSpinLock); return TRUE; } + KeReleaseSpinLockFromDpcLevel(&PsLoadedModuleSpinLock); /* That didn't succeed. Try the module list of the current process now. */ CurrentProcess = PsGetCurrentProcess(); @@ -112,11 +104,11 @@ KdbpSymFindModule( &CurrentProcess->Peb->Ldr->InLoadOrderModuleList, &Count, Address, - Name, Index, pLdrEntry); } +static PCHAR NTAPI KdbpSymUnicodeToAnsi(IN PUNICODE_STRING Unicode, @@ -159,233 +151,183 @@ KdbSymPrintAddress( { PLDR_DATA_TABLE_ENTRY LdrEntry; ULONG_PTR RelativeAddress; - NTSTATUS Status; - ULONG LineNumber; - CHAR FileName[256]; - CHAR FunctionName[256]; + BOOLEAN Printed = FALSE; CHAR ModuleNameAnsi[64]; - if (!KdbpSymbolsInitialized || !KdbpSymFindModule(Address, NULL, -1, &LdrEntry)) + if (!KdbpSymFindModule(Address, -1, &LdrEntry)) return FALSE; + RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase; + KdbpSymUnicodeToAnsi(&LdrEntry->BaseDllName, - ModuleNameAnsi, - sizeof(ModuleNameAnsi)); + ModuleNameAnsi, + sizeof(ModuleNameAnsi)); - RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase; - Status = KdbSymGetAddressInformation(LdrEntry->PatchInformation, - RelativeAddress, - &LineNumber, - FileName, - FunctionName); - if (NT_SUCCESS(Status)) + if (LdrEntry->PatchInformation) { - KdpDprintf("<%s:%x (%s:%d (%s))>", - ModuleNameAnsi, RelativeAddress, FileName, LineNumber, FunctionName); + ULONG LineNumber; + CHAR FileName[256]; + CHAR FunctionName[256]; + + if (RosSymGetAddressInformation(LdrEntry->PatchInformation, RelativeAddress, &LineNumber, FileName, FunctionName)) + { + STRING str; + /* Use KdpPrintString because KdpDprintf is limited wrt string size */ + KdpDprintf("<%s:%x (", ModuleNameAnsi, RelativeAddress); + str.Buffer = FileName; + str.Length = strnlen(FileName, sizeof(FileName)); + str.MaximumLength = sizeof(FileName); + KdpPrintString(&str); + KdpDprintf(":%d (%s))>", LineNumber, FunctionName); + + Printed = TRUE; + } } - else + + if (!Printed) { + /* Just print module & address */ KdpDprintf("<%s:%x>", ModuleNameAnsi, RelativeAddress); } return TRUE; } - -/*! \brief Get information for an address (source file, line number, - * function name) - * - * \param SymbolInfo Pointer to ROSSYM_INFO. - * \param RelativeAddress Relative address to look up. - * \param LineNumber Pointer to an ULONG which is filled with the line - * number (can be NULL) - * \param FileName Pointer to an array of CHARs which gets filled with - * the filename (can be NULL) - * \param FunctionName Pointer to an array of CHARs which gets filled with - * the function name (can be NULL) - * - * \returns NTSTATUS error code. - * \retval STATUS_SUCCESS At least one of the requested informations was found. - * \retval STATUS_UNSUCCESSFUL None of the requested information was found. - */ -static NTSTATUS -KdbSymGetAddressInformation( - IN PROSSYM_INFO RosSymInfo, - IN ULONG_PTR RelativeAddress, - OUT PULONG LineNumber OPTIONAL, - OUT PCH FileName OPTIONAL, - OUT PCH FunctionName OPTIONAL) -{ - if (!KdbpSymbolsInitialized || - !RosSymInfo || - !RosSymGetAddressInformation(RosSymInfo, RelativeAddress, LineNumber, FileName, FunctionName)) - { - return STATUS_UNSUCCESSFUL; - } - - return STATUS_SUCCESS; -} - -/*! \brief Find cached symbol file. - * - * Looks through the list of cached symbol files and tries to find an already - * loaded one. - * - * \param FileName FileName of the symbol file to look for. +static KSTART_ROUTINE LoadSymbolsRoutine; +/*! \brief The symbol loader thread routine. + * This opens the image file for reading and loads the symbols + * section from there. * - * \returns A pointer to the cached symbol info. - * \retval NULL No cached info found. + * \note We must do this because KdbSymProcessSymbols is + * called at high IRQL and we can't set the event from here * - * \sa KdbpSymAddCachedFile + * \param Context Unused */ -static PROSSYM_INFO -KdbpSymFindCachedFile( - IN PUNICODE_STRING FileName) +_Use_decl_annotations_ +VOID +NTAPI +LoadSymbolsRoutine( + _In_ PVOID Context) { - PIMAGE_SYMBOL_INFO_CACHE Current; - PLIST_ENTRY CurrentEntry; - - DPRINT("Looking for cached symbol file %wZ\n", FileName); + UNREFERENCED_PARAMETER(Context); - KeAcquireSpinLockAtDpcLevel(&SymbolFileListLock); - - CurrentEntry = SymbolFileListHead.Flink; - while (CurrentEntry != (&SymbolFileListHead)) + while (TRUE) { - Current = CONTAINING_RECORD(CurrentEntry, IMAGE_SYMBOL_INFO_CACHE, ListEntry); - - DPRINT("Current->FileName %wZ FileName %wZ\n", &Current->FileName, FileName); - if (RtlEqualUnicodeString(&Current->FileName, FileName, TRUE)) + PLIST_ENTRY ListEntry; + NTSTATUS Status = KeWaitForSingleObject(&SymbolsToLoadEvent, WrKernel, KernelMode, FALSE, NULL); + if (!NT_SUCCESS(Status)) { - Current->RefCount++; - KeReleaseSpinLockFromDpcLevel(&SymbolFileListLock); - DPRINT("Found cached file!\n"); - return Current->RosSymInfo; + DPRINT1("KeWaitForSingleObject failed?! 0x%08x\n", Status); + LoadSymbols = FALSE; + return; } - CurrentEntry = CurrentEntry->Flink; - } + while ((ListEntry = ExInterlockedRemoveHeadList(&SymbolsToLoad, &SymbolsToLoadLock))) + { + PLDR_DATA_TABLE_ENTRY LdrEntry = CONTAINING_RECORD(ListEntry, LDR_DATA_TABLE_ENTRY, InInitializationOrderLinks); + HANDLE FileHandle; + OBJECT_ATTRIBUTES Attrib; + IO_STATUS_BLOCK Iosb; + InitializeObjectAttributes(&Attrib, &LdrEntry->FullDllName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); + DPRINT1("Trying %wZ\n", &LdrEntry->FullDllName); + Status = ZwOpenFile(&FileHandle, + FILE_READ_ACCESS | SYNCHRONIZE, + &Attrib, + &Iosb, + FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT); + if (!NT_SUCCESS(Status)) + { + /* Try system paths */ + static const UNICODE_STRING System32Dir = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\"); + UNICODE_STRING ImagePath; + WCHAR ImagePathBuffer[256]; + RtlInitEmptyUnicodeString(&ImagePath, ImagePathBuffer, sizeof(ImagePathBuffer)); + RtlCopyUnicodeString(&ImagePath, &System32Dir); + RtlAppendUnicodeStringToString(&ImagePath, &LdrEntry->BaseDllName); + InitializeObjectAttributes(&Attrib, &ImagePath, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); + DPRINT1("Trying %wZ\n", &ImagePath); + Status = ZwOpenFile(&FileHandle, + FILE_READ_ACCESS | SYNCHRONIZE, + &Attrib, + &Iosb, + FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT); + if (!NT_SUCCESS(Status)) + { + static const UNICODE_STRING DriversDir= RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\drivers\\"); + + RtlInitEmptyUnicodeString(&ImagePath, ImagePathBuffer, sizeof(ImagePathBuffer)); + RtlCopyUnicodeString(&ImagePath, &DriversDir); + RtlAppendUnicodeStringToString(&ImagePath, &LdrEntry->BaseDllName); + InitializeObjectAttributes(&Attrib, &ImagePath, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); + DPRINT1("Trying %wZ\n", &ImagePath); + Status = ZwOpenFile(&FileHandle, + FILE_READ_ACCESS | SYNCHRONIZE, + &Attrib, + &Iosb, + FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT); + } + } - KeReleaseSpinLockFromDpcLevel(&SymbolFileListLock); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed opening file %wZ (%wZ) for reading symbols (0x%08x)\n", &LdrEntry->FullDllName, &LdrEntry->BaseDllName, Status); + /* We took a ref previously */ + MmUnloadSystemImage(LdrEntry); + continue; + } - DPRINT("Cached file not found!\n"); - return NULL; -} + /* Hand it to Rossym */ + if (!RosSymCreateFromFile(&FileHandle, (PROSSYM_INFO*)&LdrEntry->PatchInformation)) + LdrEntry->PatchInformation = NULL; -/*! \brief Add a symbol file to the cache. - * - * \param FileName Filename of the symbol file. - * \param RosSymInfo Pointer to the symbol info. - * - * \sa KdbpSymRemoveCachedFile - */ -static VOID -KdbpSymAddCachedFile( - IN PUNICODE_STRING FileName, - IN PROSSYM_INFO RosSymInfo) -{ - PIMAGE_SYMBOL_INFO_CACHE CacheEntry; - KIRQL Irql; - - DPRINT("Adding symbol file: RosSymInfo = %p\n", RosSymInfo); - - /* allocate entry */ - CacheEntry = ExAllocatePoolWithTag(NonPagedPool, sizeof (IMAGE_SYMBOL_INFO_CACHE), TAG_KDBS); - ASSERT(CacheEntry); - RtlZeroMemory(CacheEntry, sizeof (IMAGE_SYMBOL_INFO_CACHE)); - - /* fill entry */ - CacheEntry->FileName.Buffer = ExAllocatePoolWithTag(NonPagedPool, - FileName->Length, - TAG_KDBS); - RtlCopyUnicodeString(&CacheEntry->FileName, FileName); - ASSERT(CacheEntry->FileName.Buffer); - CacheEntry->RefCount = 1; - CacheEntry->RosSymInfo = RosSymInfo; - KeAcquireSpinLock(&SymbolFileListLock, &Irql); - InsertTailList(&SymbolFileListHead, &CacheEntry->ListEntry); - KeReleaseSpinLock(&SymbolFileListLock, Irql); + /* We're done for this one. */ + NtClose(FileHandle); + MmUnloadSystemImage(LdrEntry); + } + } } -/*! \brief Remove a symbol file (reference) from the cache. +/*! \brief Load symbols from image mapping. If this fails, * - * Tries to find a cache entry matching the given symbol info and decreases - * it's reference count. If the refcount is 0 after decreasing it the cache - * entry will be removed from the list and freed. - * - * \param RosSymInfo Pointer to the symbol info. - * - * \sa KdbpSymAddCachedFile + * \param LdrEntry The entry to load symbols from */ -static VOID -KdbpSymRemoveCachedFile( - IN PROSSYM_INFO RosSymInfo) +VOID +KdbSymProcessSymbols( + _Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, + _In_ BOOLEAN Load) { - PIMAGE_SYMBOL_INFO_CACHE Current; - PLIST_ENTRY CurrentEntry; - KIRQL Irql; - - KeAcquireSpinLock(&SymbolFileListLock, &Irql); + if (!LoadSymbols) + return; - CurrentEntry = SymbolFileListHead.Flink; - while (CurrentEntry != (&SymbolFileListHead)) + /* Check if this is unload */ + if (!Load) { - Current = CONTAINING_RECORD(CurrentEntry, IMAGE_SYMBOL_INFO_CACHE, ListEntry); - - if (Current->RosSymInfo == RosSymInfo) /* found */ + /* Did we process it */ + if (LdrEntry->PatchInformation) { - ASSERT(Current->RefCount > 0); - Current->RefCount--; - if (Current->RefCount < 1) - { - RemoveEntryList(&Current->ListEntry); - RosSymDelete(Current->RosSymInfo); - ExFreePool(Current); - } - - KeReleaseSpinLock(&SymbolFileListLock, Irql); - return; + RosSymDelete(LdrEntry->PatchInformation); + LdrEntry->PatchInformation = NULL; } - - CurrentEntry = CurrentEntry->Flink; + return; } - KeReleaseSpinLock(&SymbolFileListLock, Irql); - DPRINT1("Warning: Removing unknown symbol file: RosSymInfo = %p\n", RosSymInfo); -} - -VOID -KdbSymProcessSymbols( - IN PLDR_DATA_TABLE_ENTRY LdrEntry) -{ - if (!LoadSymbols) + if (RosSymCreateFromMem(LdrEntry->DllBase, LdrEntry->SizeOfImage, (PROSSYM_INFO*)&LdrEntry->PatchInformation)) { - LdrEntry->PatchInformation = NULL; return; } - /* Remove symbol info if it already exists */ - if (LdrEntry->PatchInformation) - KdbpSymRemoveCachedFile(LdrEntry->PatchInformation); - - /* Check cache */ - LdrEntry->PatchInformation = KdbpSymFindCachedFile(&LdrEntry->FullDllName); + /* Add a ref until we really process it */ + LdrEntry->LoadCount++; - if (!LdrEntry->PatchInformation) - { - /* Load new symbol information */ - if (RosSymCreateFromMem(LdrEntry->DllBase, LdrEntry->SizeOfImage, (PROSSYM_INFO*)&LdrEntry->PatchInformation)) - { - /* Add file to cache */ - KdbpSymAddCachedFile(&LdrEntry->FullDllName, LdrEntry->PatchInformation); - } - } + /* Tell our worker thread to read from it */ + KeAcquireSpinLockAtDpcLevel(&SymbolsToLoadLock); + InsertTailList(&SymbolsToLoad, &LdrEntry->InInitializationOrderLinks); + KeReleaseSpinLockFromDpcLevel(&SymbolsToLoadLock); - DPRINT("Installed symbols: %wZ@%p-%p %p\n", - &LdrEntry->BaseDllName, - LdrEntry->DllBase, - (PVOID)(LdrEntry->SizeOfImage + (ULONG_PTR)LdrEntry->DllBase), - LdrEntry->PatchInformation); + KeSetEvent(&SymbolsToLoadEvent, IO_NO_INCREMENT, FALSE); } VOID @@ -412,7 +354,6 @@ KdbInitialize( PCHAR p1, p2; SHORT Found = FALSE; CHAR YesNo; - PLDR_DATA_TABLE_ENTRY LdrEntry; DPRINT("KdbSymInit() BootPhase=%d\n", BootPhase); @@ -437,9 +378,6 @@ KdbInitialize( //NtoskrnlModuleObject->PatchInformation = NULL; //LdrHalModuleObject->PatchInformation = NULL; - InitializeListHead(&SymbolFileListHead); - KeInitializeSpinLock(&SymbolFileListLock); - /* Check the command line for /LOADSYMBOLS, /NOLOADSYMBOLS, * /LOADSYMBOLS={YES|NO}, /NOLOADSYMBOLS={YES|NO} */ ASSERT(KeLoaderBlock); @@ -481,24 +419,39 @@ KdbInitialize( } p1 = p2; } - - RosSymInitKernelMode(); } - else if (BootPhase == 1) + else if ((BootPhase == 1) && LoadSymbols) { + HANDLE Thread; + NTSTATUS Status; KIRQL OldIrql; - /* Load symbols for NTOSKRNL.EXE. - It is always the first module in PsLoadedModuleList. KeLoaderBlock can't be used here as its content is just temporary. */ - OldIrql = KeRaiseIrqlToDpcLevel(); - LdrEntry = CONTAINING_RECORD(PsLoadedModuleList.Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - KdbSymProcessSymbols(LdrEntry); - - /* Also load them for HAL.DLL. */ - LdrEntry = CONTAINING_RECORD(PsLoadedModuleList.Flink->Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); - KdbSymProcessSymbols(LdrEntry); - KeLowerIrql(OldIrql); - - KdbpSymbolsInitialized = TRUE; + + /* Launch our worker thread */ + InitializeListHead(&SymbolsToLoad); + KeInitializeSpinLock(&SymbolsToLoadLock); + KeInitializeEvent(&SymbolsToLoadEvent, SynchronizationEvent, FALSE); + + Status = PsCreateSystemThread(&Thread, THREAD_ALL_ACCESS, NULL, NULL, NULL, LoadSymbolsRoutine, NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed starting symbols loader thread: 0x%08x\n", Status); + LoadSymbols = FALSE; + return; + } + + RosSymInitKernelMode(); + + KeAcquireSpinLock(&PsLoadedModuleSpinLock, &OldIrql); + + PLIST_ENTRY ListEntry = PsLoadedModuleList.Flink; + while (ListEntry != &PsLoadedModuleList) + { + PLDR_DATA_TABLE_ENTRY LdrEntry = CONTAINING_RECORD(ListEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + KdbSymProcessSymbols(LdrEntry, TRUE); + ListEntry = ListEntry->Flink; + } + + KeReleaseSpinLock(&PsLoadedModuleSpinLock, OldIrql); } } diff --git a/sdk/include/reactos/rossym.h b/sdk/include/reactos/rossym.h index 91a7b9b0f02..e5e9e124a11 100644 --- a/sdk/include/reactos/rossym.h +++ b/sdk/include/reactos/rossym.h @@ -119,7 +119,12 @@ typedef struct _ROSSYM_OWN_FILECONTEXT { struct Dwarf; typedef struct Dwarf *PROSSYM_INFO; #else -typedef struct _ROSSYM_INFO *PROSSYM_INFO; +typedef struct _ROSSYM_INFO { + PROSSYM_ENTRY Symbols; + ULONG SymbolsCount; + PCHAR Strings; + ULONG StringsLength; +} ROSSYM_INFO, *PROSSYM_INFO; #endif VOID RosSymInit(PROSSYM_CALLBACKS Callbacks); diff --git a/sdk/lib/rossym/rossympriv.h b/sdk/lib/rossym/rossympriv.h index cc3f8ff2ff9..fb97019710a 100644 --- a/sdk/lib/rossym/rossympriv.h +++ b/sdk/lib/rossym/rossympriv.h @@ -9,13 +9,6 @@ #pragma once -typedef struct _ROSSYM_INFO { - PROSSYM_ENTRY Symbols; - ULONG SymbolsCount; - PCHAR Strings; - ULONG StringsLength; -} ROSSYM_INFO; - extern ROSSYM_CALLBACKS RosSymCallbacks; #define RosSymAllocMem(Size) (*RosSymCallbacks.AllocMemProc)(Size)
3 years, 5 months
1
0
0
0
[reactos] 10/13: [CMAKE:GCC] Produce RosSym data even when building with separate debug symbols
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=54ecf703f21001b58d8f7…
commit 54ecf703f21001b58d8f781c5043451de1733d9b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jun 22 15:31:18 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [CMAKE:GCC] Produce RosSym data even when building with separate debug symbols --- boot/freeldr/freeldr/CMakeLists.txt | 13 +++++-------- sdk/cmake/gcc.cmake | 29 ++++++++++++++++++----------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt index 880d949a780..678c20cafff 100644 --- a/boot/freeldr/freeldr/CMakeLists.txt +++ b/boot/freeldr/freeldr/CMakeLists.txt @@ -277,14 +277,11 @@ if(MSVC) else() target_link_options(freeldr_pe PRIVATE -Wl,--exclude-all-symbols,--file-alignment,0x200,--section-alignment,0x200) add_linker_script(freeldr_pe freeldr_gcc.lds) - if (NOT SEPARATE_DBG) - target_link_options(freeldr_pe PRIVATE -Wl,--strip-all) - else() - # Strip everything (more than objcopy --strip-debug does) - add_custom_command(TARGET freeldr_pe - POST_BUILD - COMMAND ${CMAKE_STRIP} --strip-all $<TARGET_FILE:freeldr_pe>) - endif() + # Strip everything, including rossym data + add_custom_command(TARGET freeldr_pe + POST_BUILD + COMMAND ${CMAKE_STRIP} --remove-section=.rossym $<TARGET_FILE:freeldr_pe> + COMMAND ${CMAKE_STRIP} --strip-all $<TARGET_FILE:freeldr_pe>) endif() set_image_base(freeldr_pe 0x10000) diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index fec53361b08..af04f616761 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -194,27 +194,34 @@ if(SEPARATE_DBG) else() set(SYMBOL_FILE <TARGET>) endif() - set(OBJCOPY ${CMAKE_OBJCOPY}) + + if (NOT NO_ROSSYM) + get_target_property(RSYM native-rsym IMPORTED_LOCATION) + set(strip_debug "${RSYM} -s ${REACTOS_SOURCE_DIR} <TARGET> <TARGET>") + else() + set(strip_debug "${CMAKE_STRIP} --strip-debug <TARGET>") + endif() + set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" - "${OBJCOPY} --only-keep-debug <TARGET> ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" - "${OBJCOPY} --strip-debug <TARGET>") + "${CMAKE_STRIP} --only-keep-debug <TARGET> -o ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" + ${strip_debug}) set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" - "${OBJCOPY} --only-keep-debug <TARGET> ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" - "${OBJCOPY} --strip-debug <TARGET>") + "${CMAKE_STRIP} --only-keep-debug <TARGET> -o ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" + ${strip_debug}) set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" - "${OBJCOPY} --only-keep-debug <TARGET> ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" - "${OBJCOPY} --strip-debug <TARGET>") + "${CMAKE_STRIP} --only-keep-debug <TARGET> -o ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" + ${strip_debug}) set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" - "${OBJCOPY} --only-keep-debug <TARGET> ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" - "${OBJCOPY} --strip-debug <TARGET>") + "${CMAKE_STRIP} --only-keep-debug <TARGET> -o ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" + ${strip_debug}) set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" - "${OBJCOPY} --only-keep-debug <TARGET> ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" - "${OBJCOPY} --strip-debug <TARGET>") + "${CMAKE_STRIP} --only-keep-debug <TARGET> -o ${REACTOS_BINARY_DIR}/symbols/${SYMBOL_FILE}" + ${strip_debug}) elseif(NO_ROSSYM) # Dwarf-based build message(STATUS "Generating a dwarf-based build (no rsym)")
3 years, 5 months
1
0
0
0
[reactos] 09/13: [NTOS:KD] Release lock before calling KdpPrint
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=79c29720352853f7d2e07…
commit 79c29720352853f7d2e0795f45811653c063ac2b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jun 22 12:00:46 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [NTOS:KD] Release lock before calling KdpPrint Avoiding resursive spinlock acquisition --- ntoskrnl/kd/kdio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index 9c35c9586e9..3dabd050d26 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -772,6 +772,9 @@ KdReceivePacket( OldIrql = KdpAcquireLock(&KdpSerialSpinLock); } + /* Release the spinlock */ + KdpReleaseLock(&KdpSerialSpinLock, OldIrql); + /* Print a new line */ *StringChar.Buffer = '\n'; KdpPrintString(&StringChar); @@ -783,9 +786,6 @@ KdReceivePacket( if (!(KdbDebugState & KD_DEBUG_KDSERIAL)) KbdEnableMouse(); - /* Release the spinlock */ - KdpReleaseLock(&KdpSerialSpinLock, OldIrql); - #endif return KdPacketReceived; }
3 years, 5 months
1
0
0
0
[reactos] 08/13: [NTOS:KD64][NTOS:KDBG] Fix spinlocks use
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=608032bd0833a4c6e769a…
commit 608032bd0833a4c6e769a68e57bfc4a45eed79b9 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Jun 22 11:41:25 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [NTOS:KD64][NTOS:KDBG] Fix spinlocks use Raise IRQL before entering debugger, so that KeAcquireSpinLockAtDpcLevel works as expected. - HIGH_LEVEL since we don't know where we are coming from. Do not try to read debug symbol from files in KDBG. - There is no reason that this works if Mm didn't map it in the first place. --- ntoskrnl/kd64/kdlock.c | 3 ++ ntoskrnl/kd64/kdtrap.c | 6 +++ ntoskrnl/kdbg/kdb_symbols.c | 108 ++++++-------------------------------------- 3 files changed, 24 insertions(+), 93 deletions(-) diff --git a/ntoskrnl/kd64/kdlock.c b/ntoskrnl/kd64/kdlock.c index 25e4cde3dc9..6b1512fa91b 100644 --- a/ntoskrnl/kd64/kdlock.c +++ b/ntoskrnl/kd64/kdlock.c @@ -92,7 +92,9 @@ KdPollBreakIn(VOID) } else { + KIRQL OldIrql; /* Try to acquire the lock */ + KeRaiseIrql(HIGH_LEVEL, &OldIrql); if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock)) { /* Now get a packet */ @@ -110,6 +112,7 @@ KdPollBreakIn(VOID) /* Let go of the port */ KdpPortUnlock(); } + KeLowerIrql(OldIrql); } /* Re-enable interrupts if they were enabled previously */ diff --git a/ntoskrnl/kd64/kdtrap.c b/ntoskrnl/kd64/kdtrap.c index dc78b11891e..b8314a94685 100644 --- a/ntoskrnl/kd64/kdtrap.c +++ b/ntoskrnl/kd64/kdtrap.c @@ -144,6 +144,10 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, BOOLEAN Handled; NTSTATUS ReturnStatus; USHORT ReturnLength; + KIRQL OldIrql; + + /* Raise as high as we can. */ + KeRaiseIrql(HIGH_LEVEL, &OldIrql); /* * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or @@ -257,6 +261,8 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, SecondChanceException); } + KeLowerIrql(OldIrql); + /* Return TRUE or FALSE to caller */ return Handled; } diff --git a/ntoskrnl/kdbg/kdb_symbols.c b/ntoskrnl/kdbg/kdb_symbols.c index e3673e8db6d..a066e39d8b7 100644 --- a/ntoskrnl/kdbg/kdb_symbols.c +++ b/ntoskrnl/kdbg/kdb_symbols.c @@ -244,11 +244,10 @@ KdbpSymFindCachedFile( { PIMAGE_SYMBOL_INFO_CACHE Current; PLIST_ENTRY CurrentEntry; - KIRQL Irql; DPRINT("Looking for cached symbol file %wZ\n", FileName); - KeAcquireSpinLock(&SymbolFileListLock, &Irql); + KeAcquireSpinLockAtDpcLevel(&SymbolFileListLock); CurrentEntry = SymbolFileListHead.Flink; while (CurrentEntry != (&SymbolFileListHead)) @@ -259,7 +258,7 @@ KdbpSymFindCachedFile( if (RtlEqualUnicodeString(&Current->FileName, FileName, TRUE)) { Current->RefCount++; - KeReleaseSpinLock(&SymbolFileListLock, Irql); + KeReleaseSpinLockFromDpcLevel(&SymbolFileListLock); DPRINT("Found cached file!\n"); return Current->RosSymInfo; } @@ -267,7 +266,7 @@ KdbpSymFindCachedFile( CurrentEntry = CurrentEntry->Flink; } - KeReleaseSpinLock(&SymbolFileListLock, Irql); + KeReleaseSpinLockFromDpcLevel(&SymbolFileListLock); DPRINT("Cached file not found!\n"); return NULL; @@ -355,81 +354,6 @@ KdbpSymRemoveCachedFile( DPRINT1("Warning: Removing unknown symbol file: RosSymInfo = %p\n", RosSymInfo); } -/*! \brief Loads a symbol file. - * - * \param FileName Filename of the symbol file to load. - * \param RosSymInfo Pointer to a ROSSYM_INFO which gets filled. - * - * \sa KdbpSymUnloadModuleSymbols - */ -static VOID -KdbpSymLoadModuleSymbols( - IN PUNICODE_STRING FileName, - OUT PROSSYM_INFO *RosSymInfo) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - HANDLE FileHandle; - NTSTATUS Status; - IO_STATUS_BLOCK IoStatusBlock; - BOOLEAN Result; - - /* Allow KDB to break on module load */ - KdbModuleLoaded(FileName); - - if (!LoadSymbols) - { - *RosSymInfo = NULL; - return; - } - - /* Try to find cached (already loaded) symbol file */ - *RosSymInfo = KdbpSymFindCachedFile(FileName); - if (*RosSymInfo) - { - DPRINT("Found cached symbol file %wZ\n", FileName); - return; - } - - /* Open the file */ - InitializeObjectAttributes(&ObjectAttributes, - FileName, - OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, - NULL, - NULL); - - DPRINT("Attempting to open image: %wZ\n", FileName); - - Status = ZwOpenFile(&FileHandle, - FILE_READ_ACCESS | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS(Status)) - { - DPRINT("Could not open image file: %wZ\n", FileName); - return; - } - - DPRINT("Loading symbols from %wZ...\n", FileName); - - Result = RosSymCreateFromFile(&FileHandle, RosSymInfo); - ZwClose(FileHandle); - - if (!Result) - { - DPRINT("Failed to load symbols from %wZ\n", FileName); - return; - } - - DPRINT("Symbols loaded.\n"); - - /* add file to cache */ - KdbpSymAddCachedFile(FileName, *RosSymInfo); - - DPRINT("Installed symbols: %wZ %p\n", FileName, *RosSymInfo); -} - VOID KdbSymProcessSymbols( IN PLDR_DATA_TABLE_ENTRY LdrEntry) @@ -444,21 +368,17 @@ KdbSymProcessSymbols( if (LdrEntry->PatchInformation) KdbpSymRemoveCachedFile(LdrEntry->PatchInformation); - /* Load new symbol information */ - if (! RosSymCreateFromMem(LdrEntry->DllBase, - LdrEntry->SizeOfImage, - (PROSSYM_INFO*)&LdrEntry->PatchInformation)) - { - /* Error loading symbol info, try to load it from file */ - KdbpSymLoadModuleSymbols(&LdrEntry->FullDllName, - (PROSSYM_INFO*)&LdrEntry->PatchInformation); + /* Check cache */ + LdrEntry->PatchInformation = KdbpSymFindCachedFile(&LdrEntry->FullDllName); - /* It already added symbols to cache */ - } - else + if (!LdrEntry->PatchInformation) { - /* Add file to cache */ - KdbpSymAddCachedFile(&LdrEntry->FullDllName, LdrEntry->PatchInformation); + /* Load new symbol information */ + if (RosSymCreateFromMem(LdrEntry->DllBase, LdrEntry->SizeOfImage, (PROSSYM_INFO*)&LdrEntry->PatchInformation)) + { + /* Add file to cache */ + KdbpSymAddCachedFile(&LdrEntry->FullDllName, LdrEntry->PatchInformation); + } } DPRINT("Installed symbols: %wZ@%p-%p %p\n", @@ -466,7 +386,6 @@ KdbSymProcessSymbols( LdrEntry->DllBase, (PVOID)(LdrEntry->SizeOfImage + (ULONG_PTR)LdrEntry->DllBase), LdrEntry->PatchInformation); - } VOID @@ -567,14 +486,17 @@ KdbInitialize( } else if (BootPhase == 1) { + KIRQL OldIrql; /* Load symbols for NTOSKRNL.EXE. It is always the first module in PsLoadedModuleList. KeLoaderBlock can't be used here as its content is just temporary. */ + OldIrql = KeRaiseIrqlToDpcLevel(); LdrEntry = CONTAINING_RECORD(PsLoadedModuleList.Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); KdbSymProcessSymbols(LdrEntry); /* Also load them for HAL.DLL. */ LdrEntry = CONTAINING_RECORD(PsLoadedModuleList.Flink->Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); KdbSymProcessSymbols(LdrEntry); + KeLowerIrql(OldIrql); KdbpSymbolsInitialized = TRUE; }
3 years, 5 months
1
0
0
0
[reactos] 07/13: [CMAKE] Get rid of freeldr_pe_dbg target
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5c332f6d36eed16ecbd42…
commit 5c332f6d36eed16ecbd424719eaf291a738f682b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Jun 21 14:57:45 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [CMAKE] Get rid of freeldr_pe_dbg target objcopy bug is now solved and I can't remember how this used to work anyway. Use strip instead. If you need to debug freeldr - set SEPARATE_DBG cmake var to TRUE - use qemu GDB stub - In GDB : add-symbol-file <build_dir>/symbols/freeldr_pe.exe --- boot/freeldr/freeldr/CMakeLists.txt | 40 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt index a76ce3e45e9..880d949a780 100644 --- a/boot/freeldr/freeldr/CMakeLists.txt +++ b/boot/freeldr/freeldr/CMakeLists.txt @@ -1,11 +1,4 @@ -if(SEPARATE_DBG) - # FIXME:
http://sourceware.org/bugzilla/show_bug.cgi?id=11822
- set(CMAKE_LDR_PE_HELPER_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") - set(CMAKE_LDR_PE_HELPER_STANDARD_LIBRARIES_INIT "") - set(CMAKE_LDR_PE_HELPER_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries") -endif() - if(MSVC) # Explicitly use string pooling add_compile_options("/GF") @@ -265,69 +258,56 @@ if(ARCH STREQUAL "i386") endif() add_executable(freeldr_pe ${FREELDR_BASE_SOURCE}) -add_executable(freeldr_pe_dbg EXCLUDE_FROM_ALL ${FREELDR_BASE_SOURCE}) -set_target_properties(freeldr_pe freeldr_pe_dbg +set_target_properties(freeldr_pe PROPERTIES ENABLE_EXPORTS TRUE DEFINE_SYMBOL "") -if(NOT MSVC AND SEPARATE_DBG) - set_target_properties(freeldr_pe PROPERTIES LINKER_LANGUAGE LDR_PE_HELPER) - set_target_properties(freeldr_pe_dbg PROPERTIES LINKER_LANGUAGE LDR_PE_HELPER) -endif() - if(MSVC) if(ARCH STREQUAL "arm") add_target_link_flags(freeldr_pe "/ignore:4078 /ignore:4254 /DRIVER") - add_target_link_flags(freeldr_pe_dbg "/ignore:4078 /ignore:4254 /DRIVER") else() target_link_options(freeldr_pe PRIVATE /ignore:4078 /ignore:4254 /DYNAMICBASE:NO /FIXED /FILEALIGN:512 /ALIGN:512) add_linker_script(freeldr_pe freeldr_i386.msvc.lds) - target_link_options(freeldr_pe_dbg PRIVATE /ignore:4078 /ignore:4254 /DYNAMICBASE:NO /FIXED /FILEALIGN:512 /ALIGN:512) - add_linker_script(freeldr_pe_dbg freeldr_i386.msvc.lds) endif() # We don't need hotpatching remove_target_compile_option(freeldr_pe "/hotpatch") - remove_target_compile_option(freeldr_pe_dbg "/hotpatch") remove_target_compile_option(freeldr_common "/hotpatch") else() - add_target_link_flags(freeldr_pe "-Wl,--strip-all,--exclude-all-symbols,--file-alignment,0x200,--section-alignment,0x200") + target_link_options(freeldr_pe PRIVATE -Wl,--exclude-all-symbols,--file-alignment,0x200,--section-alignment,0x200) add_linker_script(freeldr_pe freeldr_gcc.lds) - add_target_link_flags(freeldr_pe_dbg "-Wl,--exclude-all-symbols,--file-alignment,0x200,--section-alignment,0x200") - add_linker_script(freeldr_pe_dbg freeldr_gcc.lds) + if (NOT SEPARATE_DBG) + target_link_options(freeldr_pe PRIVATE -Wl,--strip-all) + else() + # Strip everything (more than objcopy --strip-debug does) + add_custom_command(TARGET freeldr_pe + POST_BUILD + COMMAND ${CMAKE_STRIP} --strip-all $<TARGET_FILE:freeldr_pe>) + endif() endif() set_image_base(freeldr_pe 0x10000) set_subsystem(freeldr_pe native) set_entrypoint(freeldr_pe RealEntryPoint) -set_image_base(freeldr_pe_dbg 0x10000) -set_subsystem(freeldr_pe_dbg native) -set_entrypoint(freeldr_pe_dbg RealEntryPoint) - if(ARCH STREQUAL "i386") target_link_libraries(freeldr_pe mini_hal) - target_link_libraries(freeldr_pe_dbg mini_hal) endif() target_link_libraries(freeldr_pe freeldr_common cportlib cmlib rtl libcntpr) -target_link_libraries(freeldr_pe_dbg freeldr_common cportlib cmlib rtl libcntpr) # dynamic analysis switches if(STACK_PROTECTOR) target_sources(freeldr_pe PRIVATE $<TARGET_OBJECTS:gcc_ssp_nt>) - target_sources(freeldr_pe_dbg PRIVATE $<TARGET_OBJECTS:gcc_ssp_nt>) endif() if(RUNTIME_CHECKS) target_link_libraries(freeldr_pe runtmchk) - target_link_libraries(freeldr_pe_dbg runtmchk) add_target_link_flags(freeldr_pe "/MERGE:.rtc=.text") endif() add_dependencies(freeldr_pe asm) -add_dependencies(freeldr_pe_dbg asm) if(SARCH STREQUAL "pc98") file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/PC98)
3 years, 5 months
1
0
0
0
[reactos] 06/13: [NTOS:KDBG] Use internal KdpDPrintf instead of DbgPrint
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=66dea86d68da1ec77934b…
commit 66dea86d68da1ec77934beb579df2a13417c7ff1 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Jun 18 18:14:51 2021 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Jun 29 11:49:20 2021 +0200 [NTOS:KDBG] Use internal KdpDPrintf instead of DbgPrint DbgPrint is implemented through a breakpoint, and then KD tries to recursively lock its own spinlock. Call a lower level routine instead. --- ntoskrnl/kdbg/i386/i386-dis.c | 4 ++-- ntoskrnl/kdbg/kdb_cli.c | 31 ++++++++++++++++--------------- ntoskrnl/kdbg/kdb_expr.c | 38 +++++++++++++++++++------------------- ntoskrnl/kdbg/kdb_symbols.c | 4 ++-- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/ntoskrnl/kdbg/i386/i386-dis.c b/ntoskrnl/kdbg/i386/i386-dis.c index f129d61e9b0..4b8a0d1ec3b 100644 --- a/ntoskrnl/kdbg/i386/i386-dis.c +++ b/ntoskrnl/kdbg/i386/i386-dis.c @@ -51,7 +51,7 @@ KdbpPrintDisasm(void* Ignored, const char* fmt, ...) va_start(ap, fmt); ret = vsprintf(buffer, fmt, ap); - DbgPrint("%s", buffer); + KdpDprintf("%s", buffer); va_end(ap); return(ret); } @@ -80,7 +80,7 @@ KdbpPrintAddressInCode(unsigned int Addr, struct disassemble_info * Ignored) { if (!KdbSymPrintAddress((void*)Addr, NULL)) { - DbgPrint("<%08x>", Addr); + KdpDprintf("<%08x>", Addr); } } diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c index ac43b48c5e1..228bebffd4d 100644 --- a/ntoskrnl/kdbg/kdb_cli.c +++ b/ntoskrnl/kdbg/kdb_cli.c @@ -2710,6 +2710,7 @@ KdbpCmdHelp( * \note Doesn't correctly handle \\t and terminal escape sequences when calculating the * number of lines required to print a single line from the Buffer in the terminal. * Prints maximum 4096 chars, because of its buffer size. + * Uses KdpDPrintf internally (NOT DbgPrint!). Callers must already hold the debugger lock. */ VOID KdbpPrint( @@ -2735,11 +2736,11 @@ KdbpPrint( /* Initialize the terminal */ if (!TerminalInitialized) { - DbgPrint("\x1b[7h"); /* Enable linewrap */ + KdpDprintf("\x1b[7h"); /* Enable linewrap */ /* Query terminal type */ /*DbgPrint("\x1b[Z");*/ - DbgPrint("\x05"); + KdpDprintf("\x05"); TerminalInitialized = TRUE; Length = 0; @@ -2770,7 +2771,7 @@ KdbpPrint( /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */ TerminalReportsSize = FALSE; KeStallExecutionProcessor(100000); - DbgPrint("\x1b[18t"); + KdpDprintf("\x1b[18t"); c = KdbpTryGetCharSerial(5000); if (c == KEY_ESC) @@ -2855,9 +2856,9 @@ KdbpPrint( KdbRepeatLastCommand = FALSE; if (KdbNumberOfColsPrinted > 0) - DbgPrint("\n"); + KdpDprintf("\n"); - DbgPrint("--- Press q to abort, any other key to continue ---"); + KdpDprintf("--- Press q to abort, any other key to continue ---"); RowsPrintedByTerminal++; /* added by Mna. */ if (KdbDebugState & KD_DEBUG_KDSERIAL) @@ -2876,7 +2877,7 @@ KdbpPrint( c = KdbpTryGetCharKeyboard(&ScanCode, 5); } - DbgPrint("\n"); + KdpDprintf("\n"); if (c == 'q') { KdbOutputAborted = TRUE; @@ -2917,7 +2918,7 @@ KdbpPrint( } } - DbgPrint("%s", p); + KdpDprintf("%s", p); if (c != '\0') p[i + 1] = c; @@ -3052,11 +3053,11 @@ KdbpPager( /* Initialize the terminal */ if (!TerminalInitialized) { - DbgPrint("\x1b[7h"); /* Enable linewrap */ + KdpDprintf("\x1b[7h"); /* Enable linewrap */ /* Query terminal type */ /*DbgPrint("\x1b[Z");*/ - DbgPrint("\x05"); + KdpDprintf("\x05"); TerminalInitialized = TRUE; Length = 0; @@ -3087,7 +3088,7 @@ KdbpPager( /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */ TerminalReportsSize = FALSE; KeStallExecutionProcessor(100000); - DbgPrint("\x1b[18t"); + KdpDprintf("\x1b[18t"); c = KdbpTryGetCharSerial(5000); if (c == KEY_ESC) @@ -3148,7 +3149,7 @@ KdbpPager( { if ( p > Buffer+BufLength) { - DbgPrint("Dmesg: error, p > Buffer+BufLength,d=%d", p - (Buffer+BufLength)); + KdpDprintf("Dmesg: error, p > Buffer+BufLength,d=%d", p - (Buffer+BufLength)); return; } i = strcspn(p, "\n"); @@ -3178,9 +3179,9 @@ KdbpPager( KdbRepeatLastCommand = FALSE; if (KdbNumberOfColsPrinted > 0) - DbgPrint("\n"); + KdpDprintf("\n"); - DbgPrint("--- Press q to abort, e/End,h/Home,u/PgUp, other key/PgDn ---"); + KdpDprintf("--- Press q to abort, e/End,h/Home,u/PgUp, other key/PgDn ---"); RowsPrintedByTerminal++; if (KdbDebugState & KD_DEBUG_KDSERIAL) @@ -3200,7 +3201,7 @@ KdbpPager( } //DbgPrint("\n"); //Consize version: don't show pressed key - DbgPrint(" '%c'/scan=%04x\n", c, ScanCode); // Shows pressed key + KdpDprintf(" '%c'/scan=%04x\n", c, ScanCode); // Shows pressed key if (c == 'q') { @@ -3264,7 +3265,7 @@ KdbpPager( } // The main printing of the current line: - DbgPrint(p); + KdpDprintf(p); // restore not null char with saved: if (c != '\0') diff --git a/ntoskrnl/kdbg/kdb_expr.c b/ntoskrnl/kdbg/kdb_expr.c index 69a57d8e8ae..348d71286c3 100644 --- a/ntoskrnl/kdbg/kdb_expr.c +++ b/ntoskrnl/kdbg/kdb_expr.c @@ -253,7 +253,7 @@ RpnpDumpStack( ULONG ul; ASSERT(Stack); - DbgPrint("\nStack size: %ld\n", Stack->Sp); + KdpDprintf("\nStack size: %ld\n", Stack->Sp); for (ul = 0; ul < Stack->Sp; ul++) { @@ -261,60 +261,60 @@ RpnpDumpStack( switch (Op->Type) { case RpnOpNop: - DbgPrint("NOP,"); + KdpDprintf("NOP,"); break; case RpnOpImmediate: - DbgPrint("0x%I64x,", Op->Data.Immediate); + KdpDprintf("0x%I64x,", Op->Data.Immediate); break; case RpnOpBinaryOperator: if (Op->Data.BinaryOperator == RpnBinaryOperatorAdd) - DbgPrint("+,"); + KdpDprintf("+,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorSub) - DbgPrint("-,"); + KdpDprintf("-,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorMul) - DbgPrint("*,"); + KdpDprintf("*,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorDiv) - DbgPrint("/,"); + KdpDprintf("/,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorMod) - DbgPrint("%%,"); + KdpDprintf("%%,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorEquals) - DbgPrint("==,"); + KdpDprintf("==,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorNotEquals) - DbgPrint("!=,"); + KdpDprintf("!=,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorLessThan) - DbgPrint("<,"); + KdpDprintf("<,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorLessThanOrEquals) - DbgPrint("<=,"); + KdpDprintf("<=,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorGreaterThan) - DbgPrint(">,"); + KdpDprintf(">,"); else if (Op->Data.BinaryOperator == RpnBinaryOperatorGreaterThanOrEquals) - DbgPrint(">=,"); + KdpDprintf(">=,"); else - DbgPrint("UNKNOWN OP,"); + KdpDprintf("UNKNOWN OP,"); break; case RpnOpRegister: - DbgPrint("%s,", RegisterToTrapFrame[Op->Data.Register].Name); + KdpDprintf("%s,", RegisterToTrapFrame[Op->Data.Register].Name); break; case RpnOpDereference: - DbgPrint("[%s],", + KdpDprintf("[%s],", (Op->Data.DerefMemorySize == 1) ? ("byte") : ((Op->Data.DerefMemorySize == 2) ? ("word") : ((Op->Data.DerefMemorySize == 4) ? ("dword") : ("qword")))); break; default: - DbgPrint("\nUnsupported Type: %d\n", Op->Type); + KdpDprintf("\nUnsupported Type: %d\n", Op->Type); ul = Stack->Sp; break; } } - DbgPrint("\n"); + KdpDprintf("\n"); } /*!\brief Clears the given RPN stack. diff --git a/ntoskrnl/kdbg/kdb_symbols.c b/ntoskrnl/kdbg/kdb_symbols.c index 299c93bd213..e3673e8db6d 100644 --- a/ntoskrnl/kdbg/kdb_symbols.c +++ b/ntoskrnl/kdbg/kdb_symbols.c @@ -180,12 +180,12 @@ KdbSymPrintAddress( FunctionName); if (NT_SUCCESS(Status)) { - DbgPrint("<%s:%x (%s:%d (%s))>", + KdpDprintf("<%s:%x (%s:%d (%s))>", ModuleNameAnsi, RelativeAddress, FileName, LineNumber, FunctionName); } else { - DbgPrint("<%s:%x>", ModuleNameAnsi, RelativeAddress); + KdpDprintf("<%s:%x>", ModuleNameAnsi, RelativeAddress); } return TRUE;
3 years, 5 months
1
0
0
0
← Newer
1
2
3
4
...
23
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Results per page:
10
25
50
100
200