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
2025
April
March
February
January
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
November 2020
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 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
18 participants
162 discussions
Start a n
N
ew thread
[reactos] 06/19: [NTOSKRNL] Link memcmp to the import lib when using CLang
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e00922a0fe09687bbd751…
commit e00922a0fe09687bbd7518aa95a9142e457d82d3 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Nov 9 09:41:48 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Mon Nov 16 16:58:10 2020 +0100 [NTOSKRNL] Link memcmp to the import lib when using CLang CLang performs some optimisations on e.g. strcmp, but memcmp is not exported by ntoskrnl --- ntoskrnl/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ntoskrnl/CMakeLists.txt b/ntoskrnl/CMakeLists.txt index 13ca75e351a..84125c75c9b 100644 --- a/ntoskrnl/CMakeLists.txt +++ b/ntoskrnl/CMakeLists.txt @@ -12,6 +12,11 @@ set(NTKRNLMP_ASM_SOURCE ${ASM_SOURCE}) spec2def(ntoskrnl.exe ntoskrnl.spec ADD_IMPORTLIB) add_asm_files(ntoskrnl_asm ${NTOSKRNL_ASM_SOURCE}) +if (GCC AND CLANG) + # Clang optimises strcmp calls to memcmp. + target_link_libraries(libntoskrnl INTERFACE memcmp) +endif() + list(APPEND PCH_SKIP_SOURCE guid.c)
4 years, 4 months
1
0
0
0
[reactos] 05/19: [NDIS] Use FORCEINLINE instead of __inline
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=378642eb4f4ea1122e41b…
commit 378642eb4f4ea1122e41bf61bd7323f0fb9d5ccb Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Mon Nov 9 09:15:57 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Mon Nov 16 16:58:10 2020 +0100 [NDIS] Use FORCEINLINE instead of __inline --- drivers/network/ndis/ndis/buffer.c | 8 +++++--- drivers/network/ndis/ndis/misc.c | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/network/ndis/ndis/buffer.c b/drivers/network/ndis/ndis/buffer.c index 4c00fa96d6f..f03f52ae94d 100644 --- a/drivers/network/ndis/ndis/buffer.c +++ b/drivers/network/ndis/ndis/buffer.c @@ -10,7 +10,9 @@ #include <ndissys.h> -__inline ULONG SkipToOffset( +FORCEINLINE +ULONG +SkipToOffset( IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, @@ -481,7 +483,7 @@ NdisAllocatePacketPoolEx( NumberOfDescriptors = 0xffff; } - Length = sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + + Length = sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + sizeof(NDIS_PACKET_EXTENSION) + ProtocolReservedLength; Size = sizeof(NDISI_PACKET_POOL) + Length * NumberOfDescriptors; @@ -1163,7 +1165,7 @@ EXPORT NdisPacketSize( IN UINT ProtocolReservedSize) { - return sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + + return sizeof(NDIS_PACKET) + sizeof(NDIS_PACKET_OOB_DATA) + sizeof(NDIS_PACKET_EXTENSION) + ProtocolReservedSize; } diff --git a/drivers/network/ndis/ndis/misc.c b/drivers/network/ndis/ndis/misc.c index 19755c5ed87..71e64c12cde 100644 --- a/drivers/network/ndis/ndis/misc.c +++ b/drivers/network/ndis/ndis/misc.c @@ -125,14 +125,14 @@ typedef struct _NDIS_HANDLE_OBJECT PVOID MapBuffer; } NDIS_HANDLE_OBJECT, *PNDIS_HANDLE_OBJECT; -__inline +FORCEINLINE PNDIS_HANDLE_OBJECT NDIS_HANDLE_TO_POBJECT ( NDIS_HANDLE handle ) { return (PNDIS_HANDLE_OBJECT)handle; } -__inline +FORCEINLINE NDIS_HANDLE NDIS_POBJECT_TO_HANDLE ( PNDIS_HANDLE_OBJECT obj ) { @@ -289,7 +289,7 @@ NdisOpenFile( FILE_SYNCHRONOUS_IO_NONALERT, // ULONG CreateOptions 0, // PVOID EaBuffer 0 ); // ULONG EaLength - + if ( !NT_SUCCESS(*Status) ) { NDIS_DbgPrint(MIN_TRACE, ("ZwCreateFile failed (%x) Name %wZ\n", *Status, FileName)); @@ -346,7 +346,7 @@ NdisGetCurrentProcessorCounts( { NDIS_DbgPrint(MAX_TRACE, ("Called.\n")); - ExGetCurrentProcessorCounts( (PULONG) pIdleCount, (PULONG) pKernelAndUser, (PULONG) pIndex); + ExGetCurrentProcessorCounts( (PULONG) pIdleCount, (PULONG) pKernelAndUser, (PULONG) pIndex); } @@ -356,7 +356,7 @@ NdisGetCurrentProcessorCounts( VOID EXPORT NdisGetSystemUpTime(OUT PULONG pSystemUpTime) -{ +{ ULONG Increment; LARGE_INTEGER TickCount;
4 years, 4 months
1
0
0
0
[reactos] 04/19: [MSVCRTEX] Add some floating point functions for CLang build
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=15c9f63b659fbd3d688e4…
commit 15c9f63b659fbd3d688e4f22e925fe89d656304f Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Nov 6 21:39:00 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Mon Nov 16 16:58:10 2020 +0100 [MSVCRTEX] Add some floating point functions for CLang build Clang makes optimisations requiring functions not present in msvcrt --- sdk/lib/crt/math/i386/exp2_asm.s | 38 ++++++++++++++++++++++++++++++++++++++ sdk/lib/crt/msvcrtex.cmake | 9 +++++++++ 2 files changed, 47 insertions(+) diff --git a/sdk/lib/crt/math/i386/exp2_asm.s b/sdk/lib/crt/math/i386/exp2_asm.s new file mode 100644 index 00000000000..d2ab14d63b1 --- /dev/null +++ b/sdk/lib/crt/math/i386/exp2_asm.s @@ -0,0 +1,38 @@ +#include <asm.inc> + +PUBLIC _exp2 + +/* FUNCTIONS ***************************************************************/ +.code + +_exp2: + push ebp + mov ebp, esp + + fld qword ptr [ebp + 8] + fxam + fstsw ax + fwait + sahf + jnp .not_inf + jnc .not_inf + test ah, 2 + jz .done + fstp st + fldz + jmp .done +.not_inf: + fst st(1) + frndint + fxch st(1) + fsub st, st(1) + f2xm1 + fld1 + faddp st(1), st + fscale + fstp st(1) +.done: + pop ebp + ret + +END diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index 593622e277d..0b6bff8520d 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -58,6 +58,15 @@ if(ARCH STREQUAL "i386") math/i386/cipow.c math/i386/cisin.c math/i386/cisqrt.c) + if (GCC AND CLANG) + # CLang performs some optimisations requiring those funtions + list(APPEND MSVCRTEX_ASM_SOURCE + math/i386/ceilf.S + math/i386/exp2_asm.s + math/i386/floorf.S) + list(APPEND MSVCRTEX_SOURCE + math/i386/sqrtf.c) + endif() elseif(ARCH STREQUAL "amd64") list(APPEND MSVCRTEX_ASM_SOURCE except/amd64/chkstk_ms.s)
4 years, 4 months
1
0
0
0
[reactos] 03/19: [CRT] Fix __forceinline definition for clang
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3936c3f19ec17028f3ba7…
commit 3936c3f19ec17028f3ba74bac0e1839305462181 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Nov 6 17:27:32 2020 +0100 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CRT] Fix __forceinline definition for clang --- sdk/include/crt/_mingw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/include/crt/_mingw.h b/sdk/include/crt/_mingw.h index 06a304d9605..a0da23de0f2 100644 --- a/sdk/include/crt/_mingw.h +++ b/sdk/include/crt/_mingw.h @@ -193,7 +193,7 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */ # ifdef __cplusplus # define __forceinline inline __attribute__((__always_inline__)) # else -# if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) +# if (( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) || defined(__clang__)) # define __forceinline extern inline __attribute__((__always_inline__,__gnu_inline__)) # else # define __forceinline extern __inline__ __attribute__((__always_inline__))
4 years, 4 months
1
0
0
0
[reactos] 02/19: [CRT] Fix intrinsics definition with clang
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f96e47db439ec7eb867e9…
commit f96e47db439ec7eb867e9cf7f52086cad20c76c1 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Sep 10 23:24:59 2020 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CRT] Fix intrinsics definition with clang --- sdk/include/crt/mingw32/intrin.h | 22 +++++++++----- sdk/include/crt/mingw32/intrin_x86.h | 50 +++++++++++++++++++++---------- sdk/include/crt/xmmintrin.h | 57 ++++++++++++++++++++++-------------- 3 files changed, 84 insertions(+), 45 deletions(-) diff --git a/sdk/include/crt/mingw32/intrin.h b/sdk/include/crt/mingw32/intrin.h index d1377939f46..c7c6b6a0d29 100644 --- a/sdk/include/crt/mingw32/intrin.h +++ b/sdk/include/crt/mingw32/intrin.h @@ -30,13 +30,21 @@ #ifndef RC_INVOKED -#ifdef __clang__ -#define __INTRIN_INLINE __forceinline -#define HAS_BUILTIN(x) __has_builtin(x) -#else -#define HAS_BUILTIN(x) 0 -#define __ATTRIBUTE_ARTIFICIAL __attribute__((artificial)) -#define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) __ATTRIBUTE_ARTIFICIAL +#ifndef __INTRIN_INLINE +# ifdef __clang__ +# define __ATTRIBUTE_ARTIFICIAL +# else +# define __ATTRIBUTE_ARTIFICIAL __attribute__((artificial)) +# endif +# define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) __ATTRIBUTE_ARTIFICIAL +#endif + +#ifndef HAS_BUILTIN +# ifdef __clang__ +# define HAS_BUILTIN(x) __has_builtin(x) +# else +# define HAS_BUILTIN(x) 0 +# endif #endif #ifndef _SIZE_T_DEFINED diff --git a/sdk/include/crt/mingw32/intrin_x86.h b/sdk/include/crt/mingw32/intrin_x86.h index 424bbc61d06..600402bce66 100644 --- a/sdk/include/crt/mingw32/intrin_x86.h +++ b/sdk/include/crt/mingw32/intrin_x86.h @@ -133,15 +133,19 @@ __INTRIN_INLINE void __faststorefence(void) #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 +#if !HAS_BUILTIN(_InterlockedCompareExchange8) __INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * Destination, char Exchange, char Comperand) { return __sync_val_compare_and_swap(Destination, Comperand, Exchange); } +#endif +#if !HAS_BUILTIN(_InterlockedCompareExchange16) __INTRIN_INLINE short _InterlockedCompareExchange16(volatile short * Destination, short Exchange, short Comperand) { return __sync_val_compare_and_swap(Destination, Comperand, Exchange); } +#endif #if !HAS_BUILTIN(_InterlockedCompareExchange) __INTRIN_INLINE long __cdecl _InterlockedCompareExchange(volatile long * Destination, long Exchange, long Comperand) @@ -157,19 +161,23 @@ __INTRIN_INLINE void * _InterlockedCompareExchangePointer(void * volatile * Dest } #endif +#if !HAS_BUILTIN(_InterlockedExchange8) __INTRIN_INLINE char _InterlockedExchange8(volatile char * Target, char Value) { /* NOTE: __sync_lock_test_and_set would be an acquire barrier, so we force a full barrier */ __sync_synchronize(); return __sync_lock_test_and_set(Target, Value); } +#endif +#if !HAS_BUILTIN(_InterlockedExchange16) __INTRIN_INLINE short _InterlockedExchange16(volatile short * Target, short Value) { /* NOTE: __sync_lock_test_and_set would be an acquire barrier, so we force a full barrier */ __sync_synchronize(); return __sync_lock_test_and_set(Target, Value); } +#endif #if !HAS_BUILTIN(_InterlockedExchange) __INTRIN_INLINE long __cdecl _InterlockedExchange(volatile long * Target, long Value) @@ -198,15 +206,19 @@ __INTRIN_INLINE long long _InterlockedExchange64(volatile long long * Target, lo } #endif +#if !HAS_BUILTIN(_InterlockedExchangeAdd8) __INTRIN_INLINE char _InterlockedExchangeAdd8(char volatile * Addend, char Value) { return __sync_fetch_and_add(Addend, Value); } +#endif +#if !HAS_BUILTIN(_InterlockedExchangeAdd16) __INTRIN_INLINE short _InterlockedExchangeAdd16(volatile short * Addend, short Value) { return __sync_fetch_and_add(Addend, Value); } +#endif #if !HAS_BUILTIN(_InterlockedExchangeAdd) __INTRIN_INLINE long __cdecl _InterlockedExchangeAdd(volatile long * Addend, long Value) @@ -222,20 +234,26 @@ __INTRIN_INLINE long long _InterlockedExchangeAdd64(volatile long long * Addend, } #endif +#if !HAS_BUILTIN(_InterlockedAnd8) __INTRIN_INLINE char _InterlockedAnd8(volatile char * value, char mask) { return __sync_fetch_and_and(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedAnd16) __INTRIN_INLINE short _InterlockedAnd16(volatile short * value, short mask) { return __sync_fetch_and_and(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedAnd) __INTRIN_INLINE long _InterlockedAnd(volatile long * value, long mask) { return __sync_fetch_and_and(value, mask); } +#endif #if defined(__x86_64__) __INTRIN_INLINE long long _InterlockedAnd64(volatile long long * value, long long mask) @@ -244,20 +262,26 @@ __INTRIN_INLINE long long _InterlockedAnd64(volatile long long * value, long lon } #endif +#if !HAS_BUILTIN(_InterlockedOr8) __INTRIN_INLINE char _InterlockedOr8(volatile char * value, char mask) { return __sync_fetch_and_or(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedOr16) __INTRIN_INLINE short _InterlockedOr16(volatile short * value, short mask) { return __sync_fetch_and_or(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedOr) __INTRIN_INLINE long _InterlockedOr(volatile long * value, long mask) { return __sync_fetch_and_or(value, mask); } +#endif #if defined(__x86_64__) __INTRIN_INLINE long long _InterlockedOr64(volatile long long * value, long long mask) @@ -266,20 +290,26 @@ __INTRIN_INLINE long long _InterlockedOr64(volatile long long * value, long long } #endif +#if !HAS_BUILTIN(_InterlockedXor8) __INTRIN_INLINE char _InterlockedXor8(volatile char * value, char mask) { return __sync_fetch_and_xor(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedXor16) __INTRIN_INLINE short _InterlockedXor16(volatile short * value, short mask) { return __sync_fetch_and_xor(value, mask); } +#endif +#if !HAS_BUILTIN(_InterlockedXor) __INTRIN_INLINE long _InterlockedXor(volatile long * value, long mask) { return __sync_fetch_and_xor(value, mask); } +#endif #if defined(__x86_64__) __INTRIN_INLINE long long _InterlockedXor64(volatile long long * value, long long mask) @@ -302,15 +332,19 @@ __INTRIN_INLINE long __cdecl _InterlockedIncrement(volatile long * lpAddend) } #endif +#if !HAS_BUILTIN(_InterlockedDecrement16) __INTRIN_INLINE short _InterlockedDecrement16(volatile short * lpAddend) { return __sync_sub_and_fetch(lpAddend, 1); } +#endif +#if !HAS_BUILTIN(_InterlockedIncrement16) __INTRIN_INLINE short _InterlockedIncrement16(volatile short * lpAddend) { return __sync_add_and_fetch(lpAddend, 1); } +#endif #if defined(__x86_64__) __INTRIN_INLINE long long _InterlockedDecrement64(volatile long long * lpAddend) @@ -1696,13 +1730,6 @@ __INTRIN_INLINE void __writecr4(unsigned int Data) __asm__("mov %[Data], %%cr4" : : [Data] "r" (Data) : "memory"); } -#if !HAS_BUILTIN(__writecr8) -__INTRIN_INLINE void __writecr8(unsigned int Data) -{ - __asm__("mov %[Data], %%cr8" : : [Data] "r" (Data) : "memory"); -} -#endif - __INTRIN_INLINE unsigned long __readcr0(void) { unsigned long value; @@ -1731,15 +1758,6 @@ __INTRIN_INLINE unsigned long __readcr4(void) return value; } -#if !HAS_BUILTIN(__readcr8) -__INTRIN_INLINE unsigned long __readcr8(void) -{ - unsigned long value; - __asm__ __volatile__("mov %%cr8, %[value]" : [value] "=r" (value)); - return value; -} -#endif - #endif /* __x86_64__ */ #ifdef __x86_64__ diff --git a/sdk/include/crt/xmmintrin.h b/sdk/include/crt/xmmintrin.h index d84f8350a1f..61ed2c9dcf6 100644 --- a/sdk/include/crt/xmmintrin.h +++ b/sdk/include/crt/xmmintrin.h @@ -55,49 +55,62 @@ void _mm_setcsr(unsigned int); #ifndef __clang__ #pragma intrinsic(_mm_xor_ps) #pragma intrinsic(_mm_div_ps) +#else + +/* + * Clang implements these as inline functions in the header instead of real builtins + */ +__forceinline __m128 _mm_xor_ps(__m128 a, __m128 b) +{ + return (__m128)((__v4su)a ^ (__v4su)b); +} + +__forceinline __m128 _mm_div_ps(__m128 a, __m128 b) +{ + return (__m128)((__v4sf)a / (__v4sf)b); +} #endif /* __clang__ */ #else /* _MSC_VER */ -#if !defined(__INTRIN_INLINE) && !defined(__clang__) -#define __ATTRIBUTE_ARTIFICIAL __attribute__((artificial)) -#define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) __ATTRIBUTE_ARTIFICIAL -#endif /* !__INTRIN_INLINE && !__clang__ */ +#if !defined(__INTRIN_INLINE) +# ifdef __clang__ +# define __ATTRIBUTE_ARTIFICIAL +# else +# define __ATTRIBUTE_ARTIFICIAL __attribute__((artificial)) +# endif +# define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) __ATTRIBUTE_ARTIFICIAL +#endif /* !__INTRIN_INLINE */ + +#ifndef HAS_BUILTIN +#ifdef __clang__ +#define HAS_BUILTIN(x) __has_builtin(x) +#else +#define HAS_BUILTIN(x) 0 +#endif +#endif -/* +/* * We can't use __builtin_ia32_* functions, * are they are only available with the -msse2 compiler switch */ +#if !HAS_BUILTIN(_mm_getcsr) __INTRIN_INLINE unsigned int _mm_getcsr(void) { unsigned int retval; __asm__ __volatile__("stmxcsr %0" : "=m"(retval)); return retval; } +#endif +#if !HAS_BUILTIN(_mm_setcsr) __INTRIN_INLINE void _mm_setcsr(unsigned int val) { __asm__ __volatile__("ldmxcsr %0" : : "m"(val)); } +#endif #endif /* _MSC_VER */ -#ifdef __clang__ -#define __INTRIN_INLINE __forceinline - -/* - * Clang implements these as inline functions in the header instead of real builtins - */ -__INTRIN_INLINE __m128 _mm_xor_ps(__m128 a, __m128 b) -{ - return (__m128)((__v4su)a ^ (__v4su)b); -} - -__INTRIN_INLINE __m128 _mm_div_ps(__m128 a, __m128 b) -{ - return (__m128)((__v4sf)a / (__v4sf)b); -} -#endif /* __clang__ */ - /* Alternate names */ #define _mm_cvtss_si32 _mm_cvt_ss2si
4 years, 4 months
1
0
0
0
[reactos] 01/19: [CMAKE] Fix use of CLang - Updated toolchain file - set GCC variable when using CLang in "GCC mode" - Properly retrieve GCC support libraries - Various flags needed to get this going
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=edc1f3ca56bb67213c613…
commit edc1f3ca56bb67213c613e7215ad6e44d8075bc6 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Sep 10 23:23:14 2020 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Mon Nov 16 16:58:10 2020 +0100 [CMAKE] Fix use of CLang - Updated toolchain file - set GCC variable when using CLang in "GCC mode" - Properly retrieve GCC support libraries - Various flags needed to get this going --- CMakeLists.txt | 5 +-- sdk/cmake/CMakeMacros.cmake | 5 ++- sdk/cmake/config.cmake | 7 +++- sdk/cmake/gcc.cmake | 45 +++++++++++++++++-------- toolchain-clang.cmake | 81 +++++++++++++++++++++++++-------------------- 5 files changed, 90 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 103b1c5bf90..e3dff10c6c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,8 @@ add_definitions(-D__REACTOS__) # There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime. file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR}) -if (GCC AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")) +if (GCC AND ((CMAKE_C_COMPILER_ID STREQUAL "GNU") AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") + OR ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0")))) # Thankfully, GCC has this add_compile_options(-ffile-prefix-map=${REACTOS_SOURCE_DIR}=) add_compile_options(-ffile-prefix-map=${_PATH_PREFIX}=) @@ -63,7 +64,7 @@ else() string(LENGTH ${_PATH_PREFIX} _PATH_PREFIX_LENGTH) string(LENGTH ${REACTOS_SOURCE_DIR} REACTOS_SOURCE_DIR_LENGTH) math(EXPR REACTOS_SOURCE_DIR_LENGTH "${REACTOS_SOURCE_DIR_LENGTH} + 1") - add_compile_definitions("__RELFILE__=&__FILE__[__FILE__[0] == '.' ? ${_PATH_PREFIX_LENGTH} : ${REACTOS_SOURCE_DIR_LENGTH}]") + add_compile_definitions("$<$<COMPILE_LANGUAGE:C,CXX>:__RELFILE__=&__FILE__[__FILE__[0] == '.' ? ${_PATH_PREFIX_LENGTH} : ${REACTOS_SOURCE_DIR_LENGTH}]>") endif() if(MSVC_IDE) diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index 6458e75fdaf..6c72d553c22 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -705,7 +705,10 @@ endfunction() function(get_defines OUTPUT_VAR) get_directory_property(_defines COMPILE_DEFINITIONS) foreach(arg ${_defines}) - list(APPEND __tmp_var -D${arg}) + # Skip generator expressions + if (NOT arg MATCHES [[^\$<.*>$]]) + list(APPEND __tmp_var -D${arg}) + endif() endforeach() set(${OUTPUT_VAR} ${__tmp_var} PARENT_SCOPE) endfunction() diff --git a/sdk/cmake/config.cmake b/sdk/cmake/config.cmake index 01c1ac760db..37a6f949901 100644 --- a/sdk/cmake/config.cmake +++ b/sdk/cmake/config.cmake @@ -40,7 +40,12 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(GCC TRUE CACHE BOOL "The compiler is GCC") set(CLANG FALSE CACHE BOOL "The compiler is LLVM Clang") elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang") - set(GCC FALSE CACHE BOOL "The compiler is GCC") + # We can use LLVM Clang mimicking CL or GCC. Account for this + if (MSVC) + set(GCC FALSE CACHE BOOL "The compiler is GCC") + else() + set(GCC TRUE CACHE BOOL "The compiler is GCC") + endif() set(CLANG TRUE CACHE BOOL "The compiler is LLVM Clang") elseif(MSVC) # aka CMAKE_C_COMPILER_ID STEQUAL "MSVC" set(GCC FALSE CACHE BOOL "The compiler is GCC") diff --git a/sdk/cmake/gcc.cmake b/sdk/cmake/gcc.cmake index 5fac4f059f4..278e8b5f092 100644 --- a/sdk/cmake/gcc.cmake +++ b/sdk/cmake/gcc.cmake @@ -45,10 +45,18 @@ add_compile_options(-pipe -fms-extensions -fno-strict-aliasing) # The case for C++ is handled through the reactos_c++ INTERFACE library add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:CXX>>:-nostdinc>") -add_compile_options(-mstackrealign -fno-aggressive-loop-optimizations) +add_compile_options(-mstackrealign) -if(CMAKE_C_COMPILER_ID STREQUAL "Clang") +if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") + add_compile_options(-fno-aggressive-loop-optimizations) + if (DBG) + add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wold-style-declaration>") + endif() +else() add_compile_options("$<$<COMPILE_LANGUAGE:C>:-std=gnu99;-Wno-microsoft>") + add_compile_options(-Wno-pragma-pack) + add_compile_options(-fno-associative-math) + add_compile_options(-fcommon) set(CMAKE_LINK_DEF_FILE_FLAG "") set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") set(CMAKE_LINK_LIBRARY_SUFFIX "") @@ -62,12 +70,6 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS_DEBUG "") endif() -if(DBG) - if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") - add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wold-style-declaration>") - endif() -endif() - # Debugging if(NOT CMAKE_BUILD_TYPE STREQUAL "Release") if(SEPARATE_DBG) @@ -252,7 +254,13 @@ set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${_compress_debug_sections_flag} -x assembler-with-cpp -o <OBJECT> -I${REACTOS_SOURCE_DIR}/sdk/include/asm -I${REACTOS_BINARY_DIR}/sdk/include/asm <INCLUDES> <FLAGS> <DEFINES> -D__ASM__ -c <SOURCE>") set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <INCLUDES> <FLAGS> -DRC_INVOKED -D__WIN32__=1 -D__FLAT__=1 ${I18N_DEFS} <DEFINES> <SOURCE> <OBJECT>") -set(CMAKE_DEPFILE_FLAGS_RC "--preprocessor \"${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX} -E -xc-header -MMD -MF <DEPFILE> -MT <OBJECT>\" ") +if (CLANG) + set(GCC_EXECUTABLE ${CMAKE_C_COMPILER_TARGET}-gcc) +else() + set(GCC_EXECUTABLE ${CMAKE_C_COMPILER}) +endif() + +set(CMAKE_DEPFILE_FLAGS_RC "--preprocessor \"${GCC_EXECUTABLE} -E -xc-header -MMD -MF <DEPFILE> -MT <OBJECT>\" ") # Optional 3rd parameter: stdcall stack bytes function(set_entrypoint MODULE ENTRYPOINT) @@ -423,30 +431,41 @@ add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WIT # We disable exceptions, unless said so add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:$<IF:$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>,-fexceptions,-fno-exceptions>>") +# G++ shipped with ROSBE uses sjlj exceptions. Tell Clang it is so +if (CLANG) + add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<BOOL:$<TARGET_PROPERTY:WITH_CXX_EXCEPTIONS>>>:-fsjlj-exceptions>") +endif() + # Find default G++ libraries +if (CLANG) + set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER_TARGET}-g++) +else() + set(GXX_EXECUTABLE ${CMAKE_CXX_COMPILER}) +endif() + add_library(libgcc STATIC IMPORTED) -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libgcc.a OUTPUT_VARIABLE LIBGCC_LOCATION) +execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libgcc.a OUTPUT_VARIABLE LIBGCC_LOCATION) string(STRIP ${LIBGCC_LOCATION} LIBGCC_LOCATION) set_target_properties(libgcc PROPERTIES IMPORTED_LOCATION ${LIBGCC_LOCATION}) # libgcc needs kernel32 imports, a CRT and msvcrtex target_link_libraries(libgcc INTERFACE libkernel32 libmsvcrt msvcrtex) add_library(libsupc++ STATIC IMPORTED GLOBAL) -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libsupc++.a OUTPUT_VARIABLE LIBSUPCXX_LOCATION) +execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libsupc++.a OUTPUT_VARIABLE LIBSUPCXX_LOCATION) string(STRIP ${LIBSUPCXX_LOCATION} LIBSUPCXX_LOCATION) set_target_properties(libsupc++ PROPERTIES IMPORTED_LOCATION ${LIBSUPCXX_LOCATION}) # libsupc++ requires libgcc target_link_libraries(libsupc++ INTERFACE libgcc) add_library(libmingwex STATIC IMPORTED) -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libmingwex.a OUTPUT_VARIABLE LIBMINGWEX_LOCATION) +execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libmingwex.a OUTPUT_VARIABLE LIBMINGWEX_LOCATION) string(STRIP ${LIBMINGWEX_LOCATION} LIBMINGWEX_LOCATION) set_target_properties(libmingwex PROPERTIES IMPORTED_LOCATION ${LIBMINGWEX_LOCATION}) # libmingwex requires a CRT and imports from kernel32 target_link_libraries(libmingwex INTERFACE libmsvcrt libkernel32) add_library(libstdc++ STATIC IMPORTED GLOBAL) -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCCXX_LOCATION) +execute_process(COMMAND ${GXX_EXECUTABLE} -print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCCXX_LOCATION) string(STRIP ${LIBSTDCCXX_LOCATION} LIBSTDCCXX_LOCATION) set_target_properties(libstdc++ PROPERTIES IMPORTED_LOCATION ${LIBSTDCCXX_LOCATION}) # libstdc++ requires libsupc++ and mingwex provided by GCC diff --git a/toolchain-clang.cmake b/toolchain-clang.cmake index da3ffc782e7..826f45f6b9a 100644 --- a/toolchain-clang.cmake +++ b/toolchain-clang.cmake @@ -3,53 +3,62 @@ if(NOT ARCH) set(ARCH i386) endif() -# Choose the right MinGW toolchain prefix -if(NOT DEFINED MINGW_TOOLCHAIN_PREFIX) - if(ARCH STREQUAL "i386") - - if(CMAKE_HOST_WIN32) - set(MINGW_TOOLCHAIN_PREFIX "" CACHE STRING "MinGW Toolchain Prefix") - else() - set(MINGW_TOOLCHAIN_PREFIX "i686-w64-mingw32-" CACHE STRING "MinGW-W64 Toolchain Prefix") - endif() - - elseif(ARCH STREQUAL "amd64") - set(MINGW_TOOLCHAIN_PREFIX "x86_64-w64-mingw32-" CACHE STRING "MinGW Toolchain Prefix") - elseif(ARCH STREQUAL "arm") - set(MINGW_TOOLCHAIN_PREFIX "arm-mingw32ce-" CACHE STRING "MinGW Toolchain Prefix") - endif() -endif() - -if(NOT DEFINED MINGW_TOOLCHAIN_SUFFIX) - set(MINGW_TOOLCHAIN_SUFFIX "" CACHE STRING "MinGW Toolchain Suffix") +if(DEFINED ENV{_ROSBE_ROSSCRIPTDIR}) + set(CMAKE_SYSROOT $ENV{_ROSBE_ROSSCRIPTDIR}/$ENV{ROS_ARCH}) endif() # The name of the target operating system set(CMAKE_SYSTEM_NAME Windows) -set(CMAKE_SYSTEM_PROCESSOR i686) +# The processor we are targeting +if (ARCH STREQUAL "i386") + set(CMAKE_SYSTEM_PROCESSOR i686) +elseif (ARCH STREQUAL "amd64") + set(CMAKE_SYSTEM_PROCESSOR x86_64) +elseif(ARCH STREQUAL "arm") + set(CMAKE_SYSTEM_PROCESSOR arm) +else() + message(ERROR "Unsupported ARCH: ${ARCH}") +endif() + +if (DEFINED CLANG_VERSION) + set(CLANG_SUFFIX "-${CLANG_VERSION}") +else() + set(CLANG_SUFFIX "") +endif() # Which tools to use -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER ${MINGW_TOOLCHAIN_PREFIX}g++${MINGW_TOOLCHAIN_SUFFIX}) -set(CMAKE_ASM_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX}) -set(CMAKE_ASM_COMPILER_ID "GNU") -set(CMAKE_MC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windmc) -set(CMAKE_RC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windres) -set(CMAKE_DLLTOOL ${MINGW_TOOLCHAIN_PREFIX}dlltool) - -if(CMAKE_HOST_WIN32) - set(CMAKE_AR ar) +set(triplet ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32) +if (CMAKE_HOST_WIN32) + set(GCC_TOOLCHAIN_PREFIX "") +else() + set(GCC_TOOLCHAIN_PREFIX "${triplet}-") endif() -set(CMAKE_C_CREATE_STATIC_LIBRARY "${CMAKE_AR} crT <TARGET> <LINK_FLAGS> <OBJECTS>") +set(CMAKE_C_COMPILER clang${CLANG_SUFFIX}) +set(CMAKE_C_COMPILER_TARGET ${triplet}) +set(CMAKE_CXX_COMPILER clang++${CLANG_SUFFIX}) +set(CMAKE_CXX_COMPILER_TARGET ${triplet}) +set(CMAKE_ASM_COMPILER ${GCC_TOOLCHAIN_PREFIX}gcc) +set(CMAKE_ASM_COMPILER_ID GNU) +set(CMAKE_MC_COMPILER ${GCC_TOOLCHAIN_PREFIX}windmc) +set(CMAKE_RC_COMPILER ${GCC_TOOLCHAIN_PREFIX}windres) +# set(CMAKE_AR ${triplet}-ar) +# set(CMAKE_DLLTOOL ${triplet}-dlltool) + +# This allows to have CMake test the compiler without linking +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY}) set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY}) -# Don't link with anything by default unless we say so set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries") - -#MARK_AS_ADVANCED(CLEAR CMAKE_CXX_STANDARD_LIBRARIES) set(CMAKE_CXX_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C++ Libraries") -set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import") -set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${CMAKE_SYSROOT}/bin/${triplet}-ld") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${CMAKE_SYSROOT}/bin/${triplet}-ld") +if (DEFINED CMAKE_SYSROOT) + set(CMAKE_EXE_LINKER_FLAGS_INIT "-nostdlib -fuse-ld=${CMAKE_SYSROOT}/bin/${GCC_TOOLCHAIN_PREFIX}ld") +else() + set(CMAKE_EXE_LINKER_FLAGS_INIT "-nostdlib -fuse-ld=${GCC_TOOLCHAIN_PREFIX}ld") +endif()
4 years, 4 months
1
0
0
0
[reactos] 32/32: [NTOS:KD] Move some KDBG-specific variables to KDBG-specific file
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d6d5caec7c24c7cd18664…
commit d6d5caec7c24c7cd186648a2f3c3a272d2b1b4a6 Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Sun Apr 12 09:30:32 2020 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Mon Nov 16 08:55:04 2020 +0100 [NTOS:KD] Move some KDBG-specific variables to KDBG-specific file --- ntoskrnl/kd/kdio.c | 9 +++++++++ ntoskrnl/kd64/kddata.c | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index 20b3c142972..22842942596 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -43,6 +43,15 @@ volatile ULONG KdbDmesgTotalWritten = 0; volatile BOOLEAN KdbpIsInDmesgMode = FALSE; static KSPIN_LOCK KdpDmesgLogSpinLock; +KDP_DEBUG_MODE KdpDebugMode; +LIST_ENTRY KdProviders = {&KdProviders, &KdProviders}; +KD_DISPATCH_TABLE DispatchTable[KdMax]; + +PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit, + KdpSerialInit, + KdpDebugLogInit, + KdpKdbgInit}; + static ULONG KdbgNextApiNumber = DbgKdContinueApi; static CONTEXT KdbgContext; static EXCEPTION_RECORD64 KdbgExceptionRecord; diff --git a/ntoskrnl/kd64/kddata.c b/ntoskrnl/kd64/kddata.c index c83f9f6665b..46254df19a2 100644 --- a/ntoskrnl/kd64/kddata.c +++ b/ntoskrnl/kd64/kddata.c @@ -137,17 +137,6 @@ PCHAR KdPrintCircularBuffer = KdPrintDefaultCircularBuffer; ULONG KdPrintBufferSize = sizeof(KdPrintDefaultCircularBuffer); ULONG KdPrintBufferChanges = 0; -#ifndef _WINKD_ -KDP_DEBUG_MODE KdpDebugMode; -LIST_ENTRY KdProviders = {&KdProviders, &KdProviders}; -KD_DISPATCH_TABLE DispatchTable[KdMax]; - -PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit, - KdpSerialInit, - KdpDebugLogInit, - KdpKdbgInit}; -#endif - // // Debug Filter Masks //
4 years, 4 months
1
0
0
0
[reactos] 31/32: [NTOS:KD] Merge KdpReportExceptionStateChange() with kd64 version
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0c76bbfe98d8dae267496…
commit 0c76bbfe98d8dae26749670cba355136413ba3ce Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Thu Apr 9 14:31:47 2020 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Mon Nov 16 08:55:04 2020 +0100 [NTOS:KD] Merge KdpReportExceptionStateChange() with kd64 version --- ntoskrnl/include/internal/kd64.h | 4 --- ntoskrnl/kd/kdio.c | 76 +++++++++++++++++++++++++++++++++++++++- ntoskrnl/kd/kdmain.c | 46 ------------------------ ntoskrnl/kd64/kdapi.c | 6 ---- ntoskrnl/kd64/kdtrap.c | 4 --- 5 files changed, 75 insertions(+), 61 deletions(-) diff --git a/ntoskrnl/include/internal/kd64.h b/ntoskrnl/include/internal/kd64.h index 1806b2fcd09..4802c9c9f60 100644 --- a/ntoskrnl/include/internal/kd64.h +++ b/ntoskrnl/include/internal/kd64.h @@ -281,10 +281,6 @@ NTAPI KdpReportExceptionStateChange( IN PEXCEPTION_RECORD ExceptionRecord, IN OUT PCONTEXT Context, -#ifndef _WINKD_ - IN PKTRAP_FRAME TrapFrame, - IN KPROCESSOR_MODE PreviousMode, -#endif IN BOOLEAN SecondChanceException ); diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index d98ab455419..20b3c142972 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -43,6 +43,12 @@ volatile ULONG KdbDmesgTotalWritten = 0; volatile BOOLEAN KdbpIsInDmesgMode = FALSE; static KSPIN_LOCK KdpDmesgLogSpinLock; +static ULONG KdbgNextApiNumber = DbgKdContinueApi; +static CONTEXT KdbgContext; +static EXCEPTION_RECORD64 KdbgExceptionRecord; +static BOOLEAN KdbgFirstChanceException; +static NTSTATUS KdbgContinueStatus = STATUS_SUCCESS; + /* LOCKING FUNCTIONS *********************************************************/ KIRQL @@ -560,6 +566,50 @@ KdSendPacket( #endif return; } + else if (WaitStateChange->NewState == DbgKdExceptionStateChange) + { + KdbgNextApiNumber = DbgKdGetContextApi; + KdbgExceptionRecord = WaitStateChange->u.Exception.ExceptionRecord; + KdbgFirstChanceException = WaitStateChange->u.Exception.FirstChance; + return; + } + } + else if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE) + { + PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer; + if (ManipulateState->ApiNumber == DbgKdGetContextApi) + { + KD_CONTINUE_TYPE Result; + +#ifdef KDBG + /* Check if this is an assertion failure */ + if (KdbgExceptionRecord.ExceptionCode == STATUS_ASSERTION_FAILURE) + { + /* Bump EIP to the instruction following the int 2C */ + KdbgContext.Eip += 2; + } + + Result = KdbEnterDebuggerException(&KdbgExceptionRecord, + KernelMode, // FIXME + &KdbgContext, + KdbgFirstChanceException); +#else + /* We'll manually dump the stack for the user... */ + KeRosDumpStackFrames(NULL, 0); + Result = kdHandleException; +#endif + if (Result != kdHandleException) + KdbgContinueStatus = STATUS_SUCCESS; + else + KdbgContinueStatus = STATUS_UNSUCCESSFUL; + KdbgNextApiNumber = DbgKdSetContextApi; + return; + } + else if (ManipulateState->ApiNumber == DbgKdSetContextApi) + { + KdbgNextApiNumber = DbgKdContinueApi; + return; + } } UNIMPLEMENTED; } @@ -586,8 +636,32 @@ KdReceivePacket( if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE) { PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer; + RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength); + if (KdbgNextApiNumber == DbgKdGetContextApi) + { + ManipulateState->ApiNumber = DbgKdGetContextApi; + MessageData->Length = 0; + MessageData->Buffer = (PCHAR)&KdbgContext; + return KdPacketReceived; + } + else if (KdbgNextApiNumber == DbgKdSetContextApi) + { + ManipulateState->ApiNumber = DbgKdSetContextApi; + MessageData->Length = sizeof(KdbgContext); + MessageData->Buffer = (PCHAR)&KdbgContext; + return KdPacketReceived; + } + else if (KdbgNextApiNumber != DbgKdContinueApi) + { + UNIMPLEMENTED; + } ManipulateState->ApiNumber = DbgKdContinueApi; - ManipulateState->u.Continue.ContinueStatus = STATUS_SUCCESS; + ManipulateState->u.Continue.ContinueStatus = KdbgContinueStatus; + + /* Prepare for next time */ + KdbgNextApiNumber = DbgKdContinueApi; + KdbgContinueStatus = STATUS_SUCCESS; + return KdPacketReceived; } diff --git a/ntoskrnl/kd/kdmain.c b/ntoskrnl/kd/kdmain.c index dde2e1d67e7..76e28962a98 100644 --- a/ntoskrnl/kd/kdmain.c +++ b/ntoskrnl/kd/kdmain.c @@ -17,52 +17,6 @@ VOID NTAPI PspDumpThreads(BOOLEAN SystemThreads); extern ANSI_STRING KdpLogFileName; -/* PRIVATE FUNCTIONS *********************************************************/ - -BOOLEAN -NTAPI -KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, - IN OUT PCONTEXT ContextRecord, - IN PKTRAP_FRAME TrapFrame, - IN KPROCESSOR_MODE PreviousMode, - IN BOOLEAN SecondChanceException) -{ - KD_CONTINUE_TYPE Return = kdHandleException; -#ifdef KDBG - EXCEPTION_RECORD64 ExceptionRecord64; - - /* Check if this is an assertion failure */ - if (ExceptionRecord->ExceptionCode == STATUS_ASSERTION_FAILURE) - { - /* Bump EIP to the instruction following the int 2C */ - ContextRecord->Eip += 2; - } - - ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord, - &ExceptionRecord64); -#endif - - /* Get out of here if the Debugger isn't connected */ - if (KdDebuggerNotPresent) return FALSE; - -#ifdef KDBG - /* Call KDBG if available */ - Return = KdbEnterDebuggerException(&ExceptionRecord64, - PreviousMode, - ContextRecord, - !SecondChanceException); -#else /* not KDBG */ - /* We'll manually dump the stack for the user... */ - KeRosDumpStackFrames(NULL, 0); -#endif /* not KDBG */ - - /* Debugger didn't handle it, please handle! */ - if (Return == kdHandleException) return FALSE; - - /* Debugger handled it */ - return TRUE; -} - /* PUBLIC FUNCTIONS *********************************************************/ static PCHAR diff --git a/ntoskrnl/kd64/kdapi.c b/ntoskrnl/kd64/kdapi.c index f2c07de2f21..28438a699a2 100644 --- a/ntoskrnl/kd64/kdapi.c +++ b/ntoskrnl/kd64/kdapi.c @@ -1725,7 +1725,6 @@ KdpReportCommandStringStateChange(IN PSTRING NameString, } while (Status == ContinueProcessorReselected); } -#ifdef _WINKD_ BOOLEAN NTAPI KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, @@ -1780,7 +1779,6 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, /* Return */ return Status; } -#endif VOID NTAPI @@ -1844,10 +1842,6 @@ KdpSwitchProcessor(IN PEXCEPTION_RECORD ExceptionRecord, /* Report a state change */ Status = KdpReportExceptionStateChange(ExceptionRecord, ContextRecord, -#ifndef _WINKD_ - NULL, - KernelMode, -#endif SecondChanceException); /* Restore the port data and return */ diff --git a/ntoskrnl/kd64/kdtrap.c b/ntoskrnl/kd64/kdtrap.c index 8f098952ee2..dc78b11891e 100644 --- a/ntoskrnl/kd64/kdtrap.c +++ b/ntoskrnl/kd64/kdtrap.c @@ -116,10 +116,6 @@ KdpReport(IN PKTRAP_FRAME TrapFrame, Handled = KdpReportExceptionStateChange(ExceptionRecord, &Prcb->ProcessorState. ContextFrame, -#ifndef _WINKD_ - TrapFrame, - PreviousMode, -#endif SecondChanceException); /* Now restore the processor state, manually again. */
4 years, 4 months
1
0
0
0
[reactos] 30/32: [NTOS:KD] Use a PCONTEXT instead of a PKTRAP_FRAME in KDBG
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=baa47fa5e06948b7e76ba…
commit baa47fa5e06948b7e76ba820f7a342547eaf0cde Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Wed Apr 8 23:08:57 2020 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Mon Nov 16 08:55:03 2020 +0100 [NTOS:KD] Use a PCONTEXT instead of a PKTRAP_FRAME in KDBG --- ntoskrnl/kd/kdmain.c | 8 +- ntoskrnl/kdbg/i386/kdb_help.S | 8 +- ntoskrnl/kdbg/kdb.c | 225 +++++++++++++++++------------------------- ntoskrnl/kdbg/kdb.h | 26 +++-- ntoskrnl/kdbg/kdb_cli.c | 137 ++++++++----------------- ntoskrnl/kdbg/kdb_expr.c | 48 +++++---- ntoskrnl/kdbg/kdb_symbols.c | 2 +- 7 files changed, 170 insertions(+), 284 deletions(-) diff --git a/ntoskrnl/kd/kdmain.c b/ntoskrnl/kd/kdmain.c index 9ae8552758c..dde2e1d67e7 100644 --- a/ntoskrnl/kd/kdmain.c +++ b/ntoskrnl/kd/kdmain.c @@ -29,12 +29,17 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, { KD_CONTINUE_TYPE Return = kdHandleException; #ifdef KDBG + EXCEPTION_RECORD64 ExceptionRecord64; + /* Check if this is an assertion failure */ if (ExceptionRecord->ExceptionCode == STATUS_ASSERTION_FAILURE) { /* Bump EIP to the instruction following the int 2C */ ContextRecord->Eip += 2; } + + ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord, + &ExceptionRecord64); #endif /* Get out of here if the Debugger isn't connected */ @@ -42,10 +47,9 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, #ifdef KDBG /* Call KDBG if available */ - Return = KdbEnterDebuggerException(ExceptionRecord, + Return = KdbEnterDebuggerException(&ExceptionRecord64, PreviousMode, ContextRecord, - TrapFrame, !SecondChanceException); #else /* not KDBG */ /* We'll manually dump the stack for the user... */ diff --git a/ntoskrnl/kdbg/i386/kdb_help.S b/ntoskrnl/kdbg/i386/kdb_help.S index 9884c66e1c5..47564a43b45 100644 --- a/ntoskrnl/kdbg/i386/kdb_help.S +++ b/ntoskrnl/kdbg/i386/kdb_help.S @@ -2,7 +2,7 @@ #include <asm.inc> #include <ks386.inc> -EXTERN _KdbEnterDebuggerException:PROC +EXTERN _KdbEnterDebuggerFirstChanceException:PROC .code @@ -61,12 +61,8 @@ _KdbEnter: * Call KDB */ mov eax, esp - push 1 /* FirstChance */ push eax /* Push a pointer to the trap frame */ - push 0 /* Context */ - push 0 /* PreviousMode (KernelMode) */ - push 0 /* ExceptionRecord */ - call _KdbEnterDebuggerException + call _KdbEnterDebuggerFirstChanceException /* * Pop the arguments and unused portions of the trap frame: diff --git a/ntoskrnl/kdbg/kdb.c b/ntoskrnl/kdbg/kdb.c index 2698190ccce..f9a3b8792bb 100644 --- a/ntoskrnl/kdbg/kdb.c +++ b/ntoskrnl/kdbg/kdb.c @@ -49,8 +49,8 @@ PEPROCESS KdbOriginalProcess = NULL; /* The process in whichs context KDB was in PETHREAD KdbCurrentThread = NULL; /* The current thread context in which KDB runs */ PETHREAD KdbOriginalThread = NULL; /* The thread in whichs context KDB was entered */ PKDB_KTRAP_FRAME KdbCurrentTrapFrame = NULL; /* Pointer to the current trapframe */ -static KDB_KTRAP_FRAME KdbTrapFrame = { { 0 } }; /* The trapframe which was passed to KdbEnterDebuggerException */ -static KDB_KTRAP_FRAME KdbThreadTrapFrame = { { 0 } }; /* The trapframe of the current thread (KdbCurrentThread) */ +static KDB_KTRAP_FRAME KdbTrapFrame = { 0 }; /* The trapframe which was passed to KdbEnterDebuggerException */ +static KDB_KTRAP_FRAME KdbThreadTrapFrame = { 0 }; /* The trapframe of the current thread (KdbCurrentThread) */ static KAPC_STATE KdbApcState; extern BOOLEAN KdbpBugCheckRequested; @@ -108,68 +108,8 @@ static const CHAR *ExceptionNrToString[] = "Assertion Failure" }; -ULONG -NTAPI -KiSsFromTrapFrame( - IN PKTRAP_FRAME TrapFrame); - -ULONG -NTAPI -KiEspFromTrapFrame( - IN PKTRAP_FRAME TrapFrame); - -VOID -NTAPI -KiSsToTrapFrame( - IN PKTRAP_FRAME TrapFrame, - IN ULONG Ss); - -VOID -NTAPI -KiEspToTrapFrame( - IN PKTRAP_FRAME TrapFrame, - IN ULONG Esp); - /* FUNCTIONS *****************************************************************/ -static VOID -KdbpTrapFrameToKdbTrapFrame( - PKTRAP_FRAME TrapFrame, - PKDB_KTRAP_FRAME KdbTrapFrame) -{ - /* Copy the TrapFrame only up to Eflags and zero the rest*/ - RtlCopyMemory(&KdbTrapFrame->Tf, TrapFrame, FIELD_OFFSET(KTRAP_FRAME, HardwareEsp)); - RtlZeroMemory((PVOID)((ULONG_PTR)&KdbTrapFrame->Tf + FIELD_OFFSET(KTRAP_FRAME, HardwareEsp)), - sizeof(KTRAP_FRAME) - FIELD_OFFSET(KTRAP_FRAME, HardwareEsp)); - - KdbTrapFrame->Cr0 = __readcr0(); - KdbTrapFrame->Cr2 = __readcr2(); - KdbTrapFrame->Cr3 = __readcr3(); - KdbTrapFrame->Cr4 = __readcr4(); - - KdbTrapFrame->Tf.HardwareEsp = KiEspFromTrapFrame(TrapFrame); - KdbTrapFrame->Tf.HardwareSegSs = (USHORT)(KiSsFromTrapFrame(TrapFrame) & 0xFFFF); - - - /* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */ -} - -static VOID -KdbpKdbTrapFrameToTrapFrame( - PKDB_KTRAP_FRAME KdbTrapFrame, - PKTRAP_FRAME TrapFrame) -{ - /* Copy the TrapFrame only up to Eflags and zero the rest*/ - RtlCopyMemory(TrapFrame, &KdbTrapFrame->Tf, FIELD_OFFSET(KTRAP_FRAME, HardwareEsp)); - - /* FIXME: write cr0, cr2, cr3 and cr4 (not needed atm) */ - - KiSsToTrapFrame(TrapFrame, KdbTrapFrame->Tf.HardwareSegSs); - KiEspToTrapFrame(TrapFrame, KdbTrapFrame->Tf.HardwareEsp); - - /* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */ -} - static VOID KdbpKdbTrapFrameFromKernelStack( PVOID KernelStack, @@ -180,17 +120,17 @@ KdbpKdbTrapFrameFromKernelStack( RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME)); StackPtr = (ULONG_PTR *) KernelStack; #ifdef _M_IX86 - KdbTrapFrame->Tf.Ebp = StackPtr[3]; - KdbTrapFrame->Tf.Edi = StackPtr[4]; - KdbTrapFrame->Tf.Esi = StackPtr[5]; - KdbTrapFrame->Tf.Ebx = StackPtr[6]; - KdbTrapFrame->Tf.Eip = StackPtr[7]; - KdbTrapFrame->Tf.HardwareEsp = (ULONG) (StackPtr + 8); - KdbTrapFrame->Tf.HardwareSegSs = KGDT_R0_DATA; - KdbTrapFrame->Tf.SegCs = KGDT_R0_CODE; - KdbTrapFrame->Tf.SegDs = KGDT_R0_DATA; - KdbTrapFrame->Tf.SegEs = KGDT_R0_DATA; - KdbTrapFrame->Tf.SegGs = KGDT_R0_DATA; + KdbTrapFrame->Ebp = StackPtr[3]; + KdbTrapFrame->Edi = StackPtr[4]; + KdbTrapFrame->Esi = StackPtr[5]; + KdbTrapFrame->Ebx = StackPtr[6]; + KdbTrapFrame->Eip = StackPtr[7]; + KdbTrapFrame->Esp = (ULONG) (StackPtr + 8); + KdbTrapFrame->SegSs = KGDT_R0_DATA; + KdbTrapFrame->SegCs = KGDT_R0_CODE; + KdbTrapFrame->SegDs = KGDT_R0_DATA; + KdbTrapFrame->SegEs = KGDT_R0_DATA; + KdbTrapFrame->SegGs = KGDT_R0_DATA; #endif /* FIXME: what about the other registers??? */ @@ -374,7 +314,7 @@ KdbpStepIntoInstruction( IntVect = 3; else if (Mem[0] == 0xcd) IntVect = Mem[1]; - else if (Mem[0] == 0xce && KdbCurrentTrapFrame->Tf.EFlags & (1<<11)) /* 1 << 11 is the overflow flag */ + else if (Mem[0] == 0xce && KdbCurrentTrapFrame->EFlags & (1<<11)) /* 1 << 11 is the overflow flag */ IntVect = 4; else return FALSE; @@ -703,14 +643,14 @@ KdbpDeleteBreakPoint( static LONG KdbpIsBreakPointOurs( IN NTSTATUS ExceptionCode, - IN PKTRAP_FRAME TrapFrame) + IN PCONTEXT Context) { ULONG i; ASSERT(ExceptionCode == STATUS_SINGLE_STEP || ExceptionCode == STATUS_BREAKPOINT); if (ExceptionCode == STATUS_BREAKPOINT) /* Software interrupt */ { - ULONG_PTR BpEip = (ULONG_PTR)TrapFrame->Eip - 1; /* Get EIP of INT3 instruction */ + ULONG_PTR BpEip = (ULONG_PTR)Context->Eip - 1; /* Get EIP of INT3 instruction */ for (i = 0; i < KdbSwBreakPointCount; i++) { ASSERT((KdbSwBreakPoints[i]->Type == KdbBreakPointSoftware || @@ -733,7 +673,7 @@ KdbpIsBreakPointOurs( KdbHwBreakPoints[i]->Enabled); DebugReg = KdbHwBreakPoints[i]->Data.Hw.DebugReg; - if ((TrapFrame->Dr6 & (1 << DebugReg)) != 0) + if ((Context->Dr6 & (1 << DebugReg)) != 0) { return KdbHwBreakPoints[i] - KdbBreakPoints; } @@ -832,7 +772,7 @@ KdbpEnableBreakPoint( ASSERT(KDB_MAXIMUM_HW_BREAKPOINT_COUNT == 4); for (i = 0; i < KDB_MAXIMUM_HW_BREAKPOINT_COUNT; i++) { - if ((KdbTrapFrame.Tf.Dr7 & (0x3 << (i * 2))) == 0) + if ((KdbTrapFrame.Dr7 & (0x3 << (i * 2))) == 0) break; } @@ -842,27 +782,27 @@ KdbpEnableBreakPoint( switch (i) { case 0: - KdbTrapFrame.Tf.Dr0 = BreakPoint->Address; + KdbTrapFrame.Dr0 = BreakPoint->Address; break; case 1: - KdbTrapFrame.Tf.Dr1 = BreakPoint->Address; + KdbTrapFrame.Dr1 = BreakPoint->Address; break; case 2: - KdbTrapFrame.Tf.Dr2 = BreakPoint->Address; + KdbTrapFrame.Dr2 = BreakPoint->Address; break; case 3: - KdbTrapFrame.Tf.Dr3 = BreakPoint->Address; + KdbTrapFrame.Dr3 = BreakPoint->Address; break; } /* Enable the global breakpoint */ - KdbTrapFrame.Tf.Dr7 |= (0x2 << (i * 2)); + KdbTrapFrame.Dr7 |= (0x2 << (i * 2)); /* Enable the exact match bits. */ - KdbTrapFrame.Tf.Dr7 |= 0x00000300; + KdbTrapFrame.Dr7 |= 0x00000300; /* Clear existing state. */ - KdbTrapFrame.Tf.Dr7 &= ~(0xF << (16 + (i * 4))); + KdbTrapFrame.Dr7 &= ~(0xF << (16 + (i * 4))); /* Set the breakpoint type. */ switch (BreakPoint->Data.Hw.AccessType) @@ -883,20 +823,20 @@ KdbpEnableBreakPoint( break; } - KdbTrapFrame.Tf.Dr7 |= (ul << (16 + (i * 4))); + KdbTrapFrame.Dr7 |= (ul << (16 + (i * 4))); /* Set the breakpoint length. */ - KdbTrapFrame.Tf.Dr7 |= ((BreakPoint->Data.Hw.Size - 1) << (18 + (i * 4))); + KdbTrapFrame.Dr7 |= ((BreakPoint->Data.Hw.Size - 1) << (18 + (i * 4))); /* Update KdbCurrentTrapFrame - values are taken from there by the CLI */ if (&KdbTrapFrame != KdbCurrentTrapFrame) { - KdbCurrentTrapFrame->Tf.Dr0 = KdbTrapFrame.Tf.Dr0; - KdbCurrentTrapFrame->Tf.Dr1 = KdbTrapFrame.Tf.Dr1; - KdbCurrentTrapFrame->Tf.Dr2 = KdbTrapFrame.Tf.Dr2; - KdbCurrentTrapFrame->Tf.Dr3 = KdbTrapFrame.Tf.Dr3; - KdbCurrentTrapFrame->Tf.Dr6 = KdbTrapFrame.Tf.Dr6; - KdbCurrentTrapFrame->Tf.Dr7 = KdbTrapFrame.Tf.Dr7; + KdbCurrentTrapFrame->Dr0 = KdbTrapFrame.Dr0; + KdbCurrentTrapFrame->Dr1 = KdbTrapFrame.Dr1; + KdbCurrentTrapFrame->Dr2 = KdbTrapFrame.Dr2; + KdbCurrentTrapFrame->Dr3 = KdbTrapFrame.Dr3; + KdbCurrentTrapFrame->Dr6 = KdbTrapFrame.Dr6; + KdbCurrentTrapFrame->Dr7 = KdbTrapFrame.Dr7; } BreakPoint->Data.Hw.DebugReg = i; @@ -988,11 +928,11 @@ KdbpDisableBreakPoint( ASSERT(BreakPoint->Type == KdbBreakPointHardware); /* Clear the breakpoint. */ - KdbTrapFrame.Tf.Dr7 &= ~(0x3 << (BreakPoint->Data.Hw.DebugReg * 2)); - if ((KdbTrapFrame.Tf.Dr7 & 0xFF) == 0) + KdbTrapFrame.Dr7 &= ~(0x3 << (BreakPoint->Data.Hw.DebugReg * 2)); + if ((KdbTrapFrame.Dr7 & 0xFF) == 0) { /* If no breakpoints are enabled then clear the exact match flags. */ - KdbTrapFrame.Tf.Dr7 &= 0xFFFFFCFF; + KdbTrapFrame.Dr7 &= 0xFFFFFCFF; } for (i = 0; i < KdbHwBreakPointCount; i++) @@ -1316,10 +1256,9 @@ KdbpGetExceptionNumberFromStatus( */ KD_CONTINUE_TYPE KdbEnterDebuggerException( - IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL, + IN PEXCEPTION_RECORD64 ExceptionRecord, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT Context, - IN OUT PKTRAP_FRAME TrapFrame, IN BOOLEAN FirstChance) { KDB_ENTER_CONDITION EnterCondition; @@ -1361,7 +1300,7 @@ KdbEnterDebuggerException( KdbEnteredOnSingleStep = FALSE; if (FirstChance && (ExceptionCode == STATUS_SINGLE_STEP || ExceptionCode == STATUS_BREAKPOINT) && - (KdbLastBreakPointNr = KdbpIsBreakPointOurs(ExceptionCode, TrapFrame)) >= 0) + (KdbLastBreakPointNr = KdbpIsBreakPointOurs(ExceptionCode, Context)) >= 0) { BreakPoint = KdbBreakPoints + KdbLastBreakPointNr; @@ -1382,7 +1321,7 @@ KdbEnterDebuggerException( KiDispatchException accounts for that. Whatever we do here with the TrapFrame does not matter anyway, since KiDispatchException will overwrite it with the values from the Context! */ - TrapFrame->Eip--; + Context->Eip--; } if ((BreakPoint->Type == KdbBreakPointHardware) && @@ -1399,15 +1338,15 @@ KdbEnterDebuggerException( else if (BreakPoint->Type == KdbBreakPointTemporary && BreakPoint->Process == KdbCurrentProcess) { - ASSERT((TrapFrame->EFlags & EFLAGS_TF) == 0); + ASSERT((Context->EFlags & EFLAGS_TF) == 0); /* Delete the temporary breakpoint which was used to step over or into the instruction */ KdbpDeleteBreakPoint(-1, BreakPoint); if (--KdbNumSingleSteps > 0) { - if ((KdbSingleStepOver && !KdbpStepOverInstruction(TrapFrame->Eip)) || - (!KdbSingleStepOver && !KdbpStepIntoInstruction(TrapFrame->Eip))) + if ((KdbSingleStepOver && !KdbpStepOverInstruction(Context->Eip)) || + (!KdbSingleStepOver && !KdbpStepIntoInstruction(Context->Eip))) { Context->EFlags |= EFLAGS_TF; } @@ -1440,7 +1379,7 @@ KdbEnterDebuggerException( if (BreakPoint->Condition) { /* Setup the KDB trap frame */ - KdbpTrapFrameToKdbTrapFrame(TrapFrame, &KdbTrapFrame); + KdbTrapFrame = *Context; ull = 0; if (!KdbpRpnEvaluateParsedExpression(BreakPoint->Condition, &KdbTrapFrame, &ull, NULL, NULL)) @@ -1456,7 +1395,7 @@ KdbEnterDebuggerException( if (BreakPoint->Type == KdbBreakPointSoftware) { KdbpPrint("\nEntered debugger on breakpoint #%d: EXEC 0x%04x:0x%08x\n", - KdbLastBreakPointNr, TrapFrame->SegCs & 0xffff, TrapFrame->Eip); + KdbLastBreakPointNr, Context->SegCs & 0xffff, Context->Eip); } else if (BreakPoint->Type == KdbBreakPointHardware) { @@ -1471,7 +1410,7 @@ KdbEnterDebuggerException( else if (ExceptionCode == STATUS_SINGLE_STEP) { /* Silently ignore a debugger initiated single step. */ - if ((TrapFrame->Dr6 & 0xf) == 0 && KdbBreakPointToReenable) + if ((Context->Dr6 & 0xf) == 0 && KdbBreakPointToReenable) { /* FIXME: Make sure that the breakpoint was really hit (check bp->Address vs. tf->Eip) */ BreakPoint = KdbBreakPointToReenable; @@ -1504,13 +1443,13 @@ KdbEnterDebuggerException( KdbpEvenThoughWeHaveABreakPointToReenableWeAlsoHaveARealSingleStep = FALSE; /* Check if we expect a single step */ - if ((TrapFrame->Dr6 & 0xf) == 0 && KdbNumSingleSteps > 0) + if ((Context->Dr6 & 0xf) == 0 && KdbNumSingleSteps > 0) { /*ASSERT((Context->Eflags & EFLAGS_TF) != 0);*/ if (--KdbNumSingleSteps > 0) { - if ((KdbSingleStepOver && KdbpStepOverInstruction(TrapFrame->Eip)) || - (!KdbSingleStepOver && KdbpStepIntoInstruction(TrapFrame->Eip))) + if ((KdbSingleStepOver && KdbpStepOverInstruction(Context->Eip)) || + (!KdbSingleStepOver && KdbpStepIntoInstruction(Context->Eip))) { Context->EFlags &= ~EFLAGS_TF; } @@ -1550,7 +1489,7 @@ KdbEnterDebuggerException( } KdbpPrint("\nEntered debugger on embedded INT3 at 0x%04x:0x%08x.\n", - TrapFrame->SegCs & 0xffff, TrapFrame->Eip - 1); + Context->SegCs & 0xffff, Context->Eip - 1); } else { @@ -1569,26 +1508,11 @@ KdbEnterDebuggerException( if (ExceptionCode == STATUS_ACCESS_VIOLATION && ExceptionRecord && ExceptionRecord->NumberParameters != 0) { - /* FIXME: Add noexec memory stuff */ ULONG_PTR TrapCr2; - ULONG Err; TrapCr2 = __readcr2(); - Err = TrapFrame->ErrCode; - KdbpPrint("Memory at 0x%p could not be %s: ", TrapCr2, (Err & (1 << 1)) ? "written" : "read"); - - if ((Err & (1 << 0)) == 0) - { - KdbpPrint("Page not present.\n"); - } - else - { - if ((Err & (1 << 3)) != 0) - KdbpPrint("Reserved bits in page directory set.\n"); - else - KdbpPrint("Page protection violation.\n"); - } + KdbpPrint("Memory at 0x%p could not be accessed\n", TrapCr2); } } @@ -1601,7 +1525,7 @@ KdbEnterDebuggerException( KdbCurrentTrapFrame = &KdbTrapFrame; /* Setup the KDB trap frame */ - KdbpTrapFrameToKdbTrapFrame(TrapFrame, &KdbTrapFrame); + KdbTrapFrame = *Context; /* Enter critical section */ OldEflags = __readeflags(); @@ -1628,15 +1552,15 @@ KdbEnterDebuggerException( /* Variable explains itself! */ KdbpEvenThoughWeHaveABreakPointToReenableWeAlsoHaveARealSingleStep = TRUE; - if ((KdbSingleStepOver && KdbpStepOverInstruction(KdbCurrentTrapFrame->Tf.Eip)) || - (!KdbSingleStepOver && KdbpStepIntoInstruction(KdbCurrentTrapFrame->Tf.Eip))) + if ((KdbSingleStepOver && KdbpStepOverInstruction(KdbCurrentTrapFrame->Eip)) || + (!KdbSingleStepOver && KdbpStepIntoInstruction(KdbCurrentTrapFrame->Eip))) { - ASSERT((KdbCurrentTrapFrame->Tf.EFlags & EFLAGS_TF) == 0); - /*KdbCurrentTrapFrame->Tf.EFlags &= ~EFLAGS_TF;*/ + ASSERT((KdbCurrentTrapFrame->EFlags & EFLAGS_TF) == 0); + /*KdbCurrentTrapFrame->EFlags &= ~EFLAGS_TF;*/ } else { - Context->EFlags |= EFLAGS_TF; + KdbTrapFrame.EFlags |= EFLAGS_TF; } } @@ -1648,8 +1572,8 @@ KdbEnterDebuggerException( KeUnstackDetachProcess(&KdbApcState); } - /* Update the exception TrapFrame */ - KdbpKdbTrapFrameToTrapFrame(&KdbTrapFrame, TrapFrame); + /* Update the exception Context */ + *Context = KdbTrapFrame; /* Decrement the entry count */ InterlockedDecrement(&KdbEntryCount); @@ -1675,11 +1599,11 @@ continue_execution: /* Set the RF flag so we don't trigger the same breakpoint again. */ if (Resume) { - TrapFrame->EFlags |= EFLAGS_RF; + Context->EFlags |= EFLAGS_RF; } /* Clear dr6 status flags. */ - TrapFrame->Dr6 &= ~0x0000e00f; + Context->Dr6 &= ~0x0000e00f; if (!(KdbEnteredOnSingleStep && KdbSingleStepOver)) { @@ -1691,6 +1615,35 @@ continue_execution: return ContinueType; } +KD_CONTINUE_TYPE +KdbEnterDebuggerFirstChanceException( + IN OUT PKTRAP_FRAME TrapFrame) +{ + EXCEPTION_RECORD64 ExceptionRecord; + KD_CONTINUE_TYPE Return; + CONTEXT Context; + + /* Copy TrapFrame to Context */ + RtlZeroMemory(&Context, sizeof(CONTEXT)); + Context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_EXTENDED_REGISTERS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS; + KeTrapFrameToContext(TrapFrame, NULL, &Context); + + /* Create ExceptionRecord (assume breakpoint) */ + RtlZeroMemory(&ExceptionRecord, sizeof(EXCEPTION_RECORD64)); + ExceptionRecord.ExceptionCode = STATUS_BREAKPOINT; + + /* Call real function */ + Return = KdbEnterDebuggerException(&ExceptionRecord, + KernelMode, + &Context, + TRUE); + + /* Copy back Context to TrapFrame */ + KeContextToTrapFrame(&Context, NULL, TrapFrame, Context.ContextFlags, KernelMode); + + return Return; +} + VOID NTAPI KdbpGetCommandLineSettings( diff --git a/ntoskrnl/kdbg/kdb.h b/ntoskrnl/kdbg/kdb.h index 85c980b8250..a496cc4a7b5 100644 --- a/ntoskrnl/kdbg/kdb.h +++ b/ntoskrnl/kdbg/kdb.h @@ -10,15 +10,7 @@ /* TYPES *********************************************************************/ /* from kdb.c */ -typedef struct _KDB_KTRAP_FRAME -{ - KTRAP_FRAME Tf; - ULONG Cr0; - ULONG Cr1; /* reserved/unused */ - ULONG Cr2; - ULONG Cr3; - ULONG Cr4; -} KDB_KTRAP_FRAME, *PKDB_KTRAP_FRAME; +typedef CONTEXT KDB_KTRAP_FRAME, *PKDB_KTRAP_FRAME; typedef enum _KDB_BREAKPOINT_TYPE { @@ -163,7 +155,7 @@ KdbpSymFindModule( BOOLEAN KdbSymPrintAddress( IN PVOID Address, - IN PKTRAP_FRAME Context + IN PCONTEXT Context ); VOID @@ -247,11 +239,15 @@ NTAPI KdbpGetCommandLineSettings(PCHAR p1); KD_CONTINUE_TYPE -KdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, - KPROCESSOR_MODE PreviousMode, - PCONTEXT Context, - PKTRAP_FRAME TrapFrame, - BOOLEAN FirstChance); +KdbEnterDebuggerException(IN PEXCEPTION_RECORD64 ExceptionRecord, + IN KPROCESSOR_MODE PreviousMode, + IN OUT PCONTEXT Context, + IN BOOLEAN FirstChance); + +KD_CONTINUE_TYPE +KdbEnterDebuggerFirstChanceException( + IN OUT PKTRAP_FRAME TrapFrame); + /* other functions */ NTSTATUS diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c index bcb30f84e7e..50805fe9f66 100644 --- a/ntoskrnl/kdbg/kdb_cli.c +++ b/ntoskrnl/kdbg/kdb_cli.c @@ -345,7 +345,6 @@ static const struct { "disasm", "disasm [address] [L count]", "Disassemble count instructions at address.", KdbpCmdDisassembleX }, { "x", "x [address] [L count]", "Display count dwords, starting at address.", KdbpCmdDisassembleX }, { "regs", "regs", "Display general purpose registers.", KdbpCmdRegs }, - { "cregs", "cregs", "Display control, descriptor table and task segment registers.", KdbpCmdRegs }, { "sregs", "sregs", "Display status registers.", KdbpCmdRegs }, { "dregs", "dregs", "Display debug registers.", KdbpCmdRegs }, { "bt", "bt [*frameaddr|thread id]", "Prints current backtrace or from given frame address.", KdbpCmdBackTrace }, @@ -794,7 +793,7 @@ KdbpCmdDisassembleX( ULONG ul; INT i; ULONGLONG Result = 0; - ULONG_PTR Address = KdbCurrentTrapFrame->Tf.Eip; + ULONG_PTR Address = KdbCurrentTrapFrame->Eip; LONG InstLen; if (Argv[0][0] == 'x') /* display memory */ @@ -911,7 +910,7 @@ KdbpCmdRegs( ULONG Argc, PCHAR Argv[]) { - PKTRAP_FRAME Tf = &KdbCurrentTrapFrame->Tf; + PCONTEXT Context = KdbCurrentTrapFrame; INT i; static const PCHAR EflagsBits[32] = { " CF", NULL, " PF", " BIT3", " AF", " BIT5", " ZF", " SF", " TF", " IF", " DF", " OF", @@ -929,109 +928,51 @@ KdbpCmdRegs( " ECX 0x%08x EDX 0x%08x\n" " ESI 0x%08x EDI 0x%08x\n" " EBP 0x%08x\n", - Tf->SegCs & 0xFFFF, Tf->Eip, - Tf->HardwareSegSs, Tf->HardwareEsp, - Tf->Eax, Tf->Ebx, - Tf->Ecx, Tf->Edx, - Tf->Esi, Tf->Edi, - Tf->Ebp); + Context->SegCs & 0xFFFF, Context->Eip, + Context->SegSs, Context->Esp, + Context->Eax, Context->Ebx, + Context->Ecx, Context->Edx, + Context->Esi, Context->Edi, + Context->Ebp); /* Display the EFlags */ - KdbpPrint("EFLAGS 0x%08x ", Tf->EFlags); + KdbpPrint("EFLAGS 0x%08x ", Context->EFlags); for (i = 0; i < 32; i++) { if (i == 1) { - if ((Tf->EFlags & (1 << 1)) == 0) + if ((Context->EFlags & (1 << 1)) == 0) KdbpPrint(" !BIT1"); } else if (i == 12) { - KdbpPrint(" IOPL%d", (Tf->EFlags >> 12) & 3); + KdbpPrint(" IOPL%d", (Context->EFlags >> 12) & 3); } else if (i == 13) { } - else if ((Tf->EFlags & (1 << i)) != 0) + else if ((Context->EFlags & (1 << i)) != 0) { KdbpPrint(EflagsBits[i]); } } KdbpPrint("\n"); } - else if (Argv[0][0] == 'c') /* cregs */ - { - ULONG Cr0, Cr2, Cr3, Cr4; - KDESCRIPTOR Gdtr = {0, 0, 0}, Idtr = {0, 0, 0}; - USHORT Ldtr, Tr; - static const PCHAR Cr0Bits[32] = { " PE", " MP", " EM", " TS", " ET", " NE", NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - " WP", NULL, " AM", NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, " NW", " CD", " PG" }; - static const PCHAR Cr4Bits[32] = { " VME", " PVI", " TSD", " DE", " PSE", " PAE", " MCE", " PGE", - " PCE", " OSFXSR", " OSXMMEXCPT", NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; - - /* Retrieve the control registers */ - Cr0 = KdbCurrentTrapFrame->Cr0; - Cr2 = KdbCurrentTrapFrame->Cr2; - Cr3 = KdbCurrentTrapFrame->Cr3; - Cr4 = KdbCurrentTrapFrame->Cr4; - - /* Retrieve the descriptor table and task segment registers */ - Ke386GetGlobalDescriptorTable(&Gdtr.Limit); - Ldtr = Ke386GetLocalDescriptorTable(); - __sidt(&Idtr.Limit); - Tr = Ke386GetTr(); - - /* Display the control registers */ - KdbpPrint("CR0 0x%08x ", Cr0); - for (i = 0; i < 32; i++) - { - if (!Cr0Bits[i]) - continue; - - if ((Cr0 & (1 << i)) != 0) - KdbpPrint(Cr0Bits[i]); - } - KdbpPrint("\n"); - - KdbpPrint("CR2 0x%08x\n", Cr2); - KdbpPrint("CR3 0x%08x Pagedir-Base 0x%08x %s%s\n", Cr3, (Cr3 & 0xfffff000), - (Cr3 & (1 << 3)) ? " PWT" : "", (Cr3 & (1 << 4)) ? " PCD" : "" ); - KdbpPrint("CR4 0x%08x ", Cr4); - for (i = 0; i < 32; i++) - { - if (!Cr4Bits[i]) - continue; - - if ((Cr4 & (1 << i)) != 0) - KdbpPrint(Cr4Bits[i]); - } - KdbpPrint("\n"); - - /* Display the descriptor table and task segment registers */ - KdbpPrint("GDTR Base 0x%08x Size 0x%04x\n", Gdtr.Base, Gdtr.Limit); - KdbpPrint("LDTR 0x%04x\n", Ldtr); - KdbpPrint("IDTR Base 0x%08x Size 0x%04x\n", Idtr.Base, Idtr.Limit); - KdbpPrint("TR 0x%04x\n", Tr); - } else if (Argv[0][0] == 's') /* sregs */ { KdbpPrint("CS 0x%04x Index 0x%04x %cDT RPL%d\n", - Tf->SegCs & 0xffff, (Tf->SegCs & 0xffff) >> 3, - (Tf->SegCs & (1 << 2)) ? 'L' : 'G', Tf->SegCs & 3); + Context->SegCs & 0xffff, (Context->SegCs & 0xffff) >> 3, + (Context->SegCs & (1 << 2)) ? 'L' : 'G', Context->SegCs & 3); KdbpPrint("DS 0x%04x Index 0x%04x %cDT RPL%d\n", - Tf->SegDs, Tf->SegDs >> 3, (Tf->SegDs & (1 << 2)) ? 'L' : 'G', Tf->SegDs & 3); + Context->SegDs, Context->SegDs >> 3, (Context->SegDs & (1 << 2)) ? 'L' : 'G', Context->SegDs & 3); KdbpPrint("ES 0x%04x Index 0x%04x %cDT RPL%d\n", - Tf->SegEs, Tf->SegEs >> 3, (Tf->SegEs & (1 << 2)) ? 'L' : 'G', Tf->SegEs & 3); + Context->SegEs, Context->SegEs >> 3, (Context->SegEs & (1 << 2)) ? 'L' : 'G', Context->SegEs & 3); KdbpPrint("FS 0x%04x Index 0x%04x %cDT RPL%d\n", - Tf->SegFs, Tf->SegFs >> 3, (Tf->SegFs & (1 << 2)) ? 'L' : 'G', Tf->SegFs & 3); + Context->SegFs, Context->SegFs >> 3, (Context->SegFs & (1 << 2)) ? 'L' : 'G', Context->SegFs & 3); KdbpPrint("GS 0x%04x Index 0x%04x %cDT RPL%d\n", - Tf->SegGs, Tf->SegGs >> 3, (Tf->SegGs & (1 << 2)) ? 'L' : 'G', Tf->SegGs & 3); + Context->SegGs, Context->SegGs >> 3, (Context->SegGs & (1 << 2)) ? 'L' : 'G', Context->SegGs & 3); KdbpPrint("SS 0x%04x Index 0x%04x %cDT RPL%d\n", - Tf->HardwareSegSs, Tf->HardwareSegSs >> 3, (Tf->HardwareSegSs & (1 << 2)) ? 'L' : 'G', Tf->HardwareSegSs & 3); + Context->SegSs, Context->SegSs >> 3, (Context->SegSs & (1 << 2)) ? 'L' : 'G', Context->SegSs & 3); } else /* dregs */ { @@ -1042,8 +983,8 @@ KdbpCmdRegs( "DR3 0x%08x\n" "DR6 0x%08x\n" "DR7 0x%08x\n", - Tf->Dr0, Tf->Dr1, Tf->Dr2, Tf->Dr3, - Tf->Dr6, Tf->Dr7); + Context->Dr0, Context->Dr1, Context->Dr2, Context->Dr3, + Context->Dr6, Context->Dr7); } return TRUE; @@ -1117,8 +1058,8 @@ KdbpIsNestedTss( } static BOOLEAN -KdbpTrapFrameFromPrevTss( - IN OUT PKTRAP_FRAME TrapFrame, +KdbpContextFromPrevTss( + IN OUT PCONTEXT Context, OUT PUSHORT TssSelector, IN OUT PKTSS* pTss, IN PKDESCRIPTOR pGdtr) @@ -1157,8 +1098,8 @@ KdbpTrapFrameFromPrevTss( /* Return the parent TSS and its trap frame */ *TssSelector = Backlink; *pTss = Tss; - TrapFrame->Eip = Eip; - TrapFrame->Ebp = Ebp; + Context->Eip = Eip; + Context->Ebp = Ebp; return TRUE; } @@ -1171,8 +1112,8 @@ KdbpCmdBackTrace( { ULONG ul; ULONGLONG Result = 0; - KTRAP_FRAME TrapFrame = KdbCurrentTrapFrame->Tf; - ULONG_PTR Frame = TrapFrame.Ebp; + CONTEXT Context = *KdbCurrentTrapFrame; + ULONG_PTR Frame = Context.Ebp; ULONG_PTR Address; KDESCRIPTOR Gdtr; USHORT TssSelector; @@ -1247,8 +1188,8 @@ KdbpCmdBackTrace( if (Argc <= 1) { KdbpPrint("Eip:\n"); - if (!KdbSymPrintAddress((PVOID)TrapFrame.Eip, &TrapFrame)) - KdbpPrint("<%08x>\n", TrapFrame.Eip); + if (!KdbSymPrintAddress((PVOID)Context.Eip, &Context)) + KdbpPrint("<%08x>\n", Context.Eip); else KdbpPrint("\n"); } @@ -1274,12 +1215,12 @@ KdbpCmdBackTrace( GotNextFrame = NT_SUCCESS(KdbpSafeReadMemory(&Frame, (PVOID)Frame, sizeof(ULONG_PTR))); if (GotNextFrame) - TrapFrame.Ebp = Frame; + Context.Ebp = Frame; // else // Frame = 0; /* Print the location of the call instruction (assumed 5 bytes length) */ - if (!KdbSymPrintAddress((PVOID)(Address - 5), &TrapFrame)) + if (!KdbSymPrintAddress((PVOID)(Address - 5), &Context)) KdbpPrint("<%08x>\n", Address); else KdbpPrint("\n"); @@ -1304,18 +1245,18 @@ CheckForParentTSS: if (!KdbpIsNestedTss(TssSelector, Tss)) break; // The TSS is not nested, we stop there. - GotNextFrame = KdbpTrapFrameFromPrevTss(&TrapFrame, &TssSelector, &Tss, &Gdtr); + GotNextFrame = KdbpContextFromPrevTss(&Context, &TssSelector, &Tss, &Gdtr); if (!GotNextFrame) { KdbpPrint("Couldn't access parent TSS 0x%04x\n", Tss->Backlink); break; // Cannot retrieve the parent TSS, we stop there. } - Address = TrapFrame.Eip; - Frame = TrapFrame.Ebp; + Address = Context.Eip; + Frame = Context.Ebp; KdbpPrint("[Parent TSS 0x%04x @ 0x%p]\n", TssSelector, Tss); - if (!KdbSymPrintAddress((PVOID)Address, &TrapFrame)) + if (!KdbSymPrintAddress((PVOID)Address, &Context)) KdbpPrint("<%08x>\n", Address); else KdbpPrint("\n"); @@ -3672,13 +3613,13 @@ KdbpCliMainLoop( if (EnteredOnSingleStep) { - if (!KdbSymPrintAddress((PVOID)KdbCurrentTrapFrame->Tf.Eip, &KdbCurrentTrapFrame->Tf)) + if (!KdbSymPrintAddress((PVOID)KdbCurrentTrapFrame->Eip, KdbCurrentTrapFrame)) { - KdbpPrint("<%08x>", KdbCurrentTrapFrame->Tf.Eip); + KdbpPrint("<%08x>", KdbCurrentTrapFrame->Eip); } KdbpPrint(": "); - if (KdbpDisassemble(KdbCurrentTrapFrame->Tf.Eip, KdbUseIntelSyntax) < 0) + if (KdbpDisassemble(KdbCurrentTrapFrame->Eip, KdbUseIntelSyntax) < 0) { KdbpPrint("<INVALID>"); } @@ -3862,7 +3803,7 @@ KdbpCliInit(VOID) /* Interpret the init file... */ KdbInitFileBuffer = FileBuffer; - KdbEnter(); + //KdbEnter(); // FIXME KdbInitFileBuffer = NULL; /* Leave critical section */ diff --git a/ntoskrnl/kdbg/kdb_expr.c b/ntoskrnl/kdbg/kdb_expr.c index de856536e08..9a1924852b6 100644 --- a/ntoskrnl/kdbg/kdb_expr.c +++ b/ntoskrnl/kdbg/kdb_expr.c @@ -111,32 +111,28 @@ static const struct } RegisterToTrapFrame[] = { - {"eip", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Eip), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Eip)}, - {"eflags", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.EFlags), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.EFlags)}, - {"eax", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Eax), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Eax)}, - {"ebx", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Ebx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Ebx)}, - {"ecx", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Ecx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Ecx)}, - {"edx", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Edx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Edx)}, - {"esi", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Esi), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Esi)}, - {"edi", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Edi), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Edi)}, - {"esp", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.HardwareEsp), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.HardwareEsp)}, - {"ebp", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Ebp), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Ebp)}, - {"cs", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegCs), 2 }, /* Use only the lower 2 bytes */ - {"ds", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegDs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegDs)}, - {"es", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegEs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegEs)}, - {"fs", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegFs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegFs)}, - {"gs", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegGs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegGs)}, - {"ss", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.HardwareSegSs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.HardwareSegSs)}, - {"dr0", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr0), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr0)}, - {"dr1", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr1), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr1)}, - {"dr2", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr2), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr2)}, - {"dr3", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr3), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr3)}, - {"dr6", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr6), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr6)}, - {"dr7", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr7), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr7)}, - {"cr0", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr0), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr0)}, - {"cr2", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr2), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr2)}, - {"cr3", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr3), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr3)}, - {"cr4", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr4), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr4)} + {"eip", FIELD_OFFSET(KDB_KTRAP_FRAME, Eip), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Eip)}, + {"eflags", FIELD_OFFSET(KDB_KTRAP_FRAME, EFlags), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, EFlags)}, + {"eax", FIELD_OFFSET(KDB_KTRAP_FRAME, Eax), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Eax)}, + {"ebx", FIELD_OFFSET(KDB_KTRAP_FRAME, Ebx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Ebx)}, + {"ecx", FIELD_OFFSET(KDB_KTRAP_FRAME, Ecx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Ecx)}, + {"edx", FIELD_OFFSET(KDB_KTRAP_FRAME, Edx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Edx)}, + {"esi", FIELD_OFFSET(KDB_KTRAP_FRAME, Esi), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Esi)}, + {"edi", FIELD_OFFSET(KDB_KTRAP_FRAME, Edi), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Edi)}, + {"esp", FIELD_OFFSET(KDB_KTRAP_FRAME, Esp), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Esp)}, + {"ebp", FIELD_OFFSET(KDB_KTRAP_FRAME, Ebp), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Ebp)}, + {"cs", FIELD_OFFSET(KDB_KTRAP_FRAME, SegCs), 2 }, /* Use only the lower 2 bytes */ + {"ds", FIELD_OFFSET(KDB_KTRAP_FRAME, SegDs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, SegDs)}, + {"es", FIELD_OFFSET(KDB_KTRAP_FRAME, SegEs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, SegEs)}, + {"fs", FIELD_OFFSET(KDB_KTRAP_FRAME, SegFs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, SegFs)}, + {"gs", FIELD_OFFSET(KDB_KTRAP_FRAME, SegGs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, SegGs)}, + {"ss", FIELD_OFFSET(KDB_KTRAP_FRAME, SegSs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, SegSs)}, + {"dr0", FIELD_OFFSET(KDB_KTRAP_FRAME, Dr0), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Dr0)}, + {"dr1", FIELD_OFFSET(KDB_KTRAP_FRAME, Dr1), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Dr1)}, + {"dr2", FIELD_OFFSET(KDB_KTRAP_FRAME, Dr2), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Dr2)}, + {"dr3", FIELD_OFFSET(KDB_KTRAP_FRAME, Dr3), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Dr3)}, + {"dr6", FIELD_OFFSET(KDB_KTRAP_FRAME, Dr6), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Dr6)}, + {"dr7", FIELD_OFFSET(KDB_KTRAP_FRAME, Dr7), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Dr7)} }; static const INT RegisterToTrapFrameCount = sizeof (RegisterToTrapFrame) / sizeof (RegisterToTrapFrame[0]); diff --git a/ntoskrnl/kdbg/kdb_symbols.c b/ntoskrnl/kdbg/kdb_symbols.c index 7dae01e780f..ea2afc00c16 100644 --- a/ntoskrnl/kdbg/kdb_symbols.c +++ b/ntoskrnl/kdbg/kdb_symbols.c @@ -155,7 +155,7 @@ KdbpSymUnicodeToAnsi(IN PUNICODE_STRING Unicode, BOOLEAN KdbSymPrintAddress( IN PVOID Address, - IN PKTRAP_FRAME Context) + IN PCONTEXT Context) { PLDR_DATA_TABLE_ENTRY LdrEntry; ULONG_PTR RelativeAddress;
4 years, 4 months
1
0
0
0
[reactos] 29/32: [NTOS:KD] Move some declarations where they belong
by Hervé Poussineau
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba37323a62b23425eb912…
commit ba37323a62b23425eb912de30a40e4cbe01493b9 Author: Hervé Poussineau <hpoussin(a)reactos.org> AuthorDate: Tue Mar 31 23:40:14 2020 +0200 Commit: Hervé Poussineau <hpoussin(a)reactos.org> CommitDate: Mon Nov 16 08:55:03 2020 +0100 [NTOS:KD] Move some declarations where they belong --- ntoskrnl/include/internal/kd.h | 42 ------------------------------------------ ntoskrnl/kdbg/kdb.h | 16 ++++++++++++++++ ntoskrnl/kdbg/kdb_cli.c | 7 +++++++ ntoskrnl/kdbg/kdb_symbols.c | 10 +++++++++- 4 files changed, 32 insertions(+), 43 deletions(-) diff --git a/ntoskrnl/include/internal/kd.h b/ntoskrnl/include/internal/kd.h index 4a7ba13b382..6a509de9db0 100644 --- a/ntoskrnl/include/internal/kd.h +++ b/ntoskrnl/include/internal/kd.h @@ -30,48 +30,6 @@ KdPortPutByteEx( /* SYMBOL ROUTINES **********************************************************/ #ifdef __NTOSKRNL__ -#if defined(KDBG) || DBG - -#if defined(KDBG) -typedef -BOOLEAN -(NTAPI *PKDBG_CLI_ROUTINE)( - IN PCHAR Command, - IN ULONG Argc, - IN PCH Argv[]); - -BOOLEAN -NTAPI -KdbRegisterCliCallback( - PVOID Callback, - BOOLEAN Deregister); -#endif - -VOID -KdbSymProcessSymbols( - IN PLDR_DATA_TABLE_ENTRY LdrEntry); - - -BOOLEAN -KdbSymPrintAddress( - IN PVOID Address, - IN PKTRAP_FRAME Context -); - -NTSTATUS -KdbSymGetAddressInformation( - IN PROSSYM_INFO RosSymInfo, - IN ULONG_PTR RelativeAddress, -#ifdef __ROS_DWARF__ - IN PROSSYM_LINEINFO RosSymLineInfo -#else - OUT PULONG LineNumber OPTIONAL, - OUT PCH FileName OPTIONAL, - OUT PCH FunctionName OPTIONAL -#endif -); -#endif - #ifdef KDBG # define KdbInit() KdbpCliInit() # define KdbModuleLoaded(FILENAME) KdbpCliModuleLoaded(FILENAME) diff --git a/ntoskrnl/kdbg/kdb.h b/ntoskrnl/kdbg/kdb.h index b6419079e61..85c980b8250 100644 --- a/ntoskrnl/kdbg/kdb.h +++ b/ntoskrnl/kdbg/kdb.h @@ -96,6 +96,12 @@ KdbpStackSwitchAndCall( extern PCHAR KdbInitFileBuffer; +BOOLEAN +NTAPI +KdbRegisterCliCallback( + PVOID Callback, + BOOLEAN Deregister); + VOID KdbpCliInit(VOID); @@ -154,6 +160,16 @@ KdbpSymFindModule( IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry); +BOOLEAN +KdbSymPrintAddress( + IN PVOID Address, + IN PKTRAP_FRAME Context +); + +VOID +KdbSymProcessSymbols( + IN PLDR_DATA_TABLE_ENTRY LdrEntry); + /* from kdb.c */ extern PEPROCESS KdbCurrentProcess; diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c index 7314086c2f6..bcb30f84e7e 100644 --- a/ntoskrnl/kdbg/kdb_cli.c +++ b/ntoskrnl/kdbg/kdb_cli.c @@ -105,6 +105,13 @@ static BOOLEAN KdbpCmdPrintStruct(ULONG Argc, PCHAR Argv[]); /* GLOBALS *******************************************************************/ +typedef +BOOLEAN +(NTAPI *PKDBG_CLI_ROUTINE)( + IN PCHAR Command, + IN ULONG Argc, + IN PCH Argv[]); + static PKDBG_CLI_ROUTINE KdbCliCallbacks[10]; static BOOLEAN KdbUseIntelSyntax = FALSE; /* Set to TRUE for intel syntax */ static BOOLEAN KdbBreakOnModuleLoad = FALSE; /* Set to TRUE to break into KDB when a module is loaded */ diff --git a/ntoskrnl/kdbg/kdb_symbols.c b/ntoskrnl/kdbg/kdb_symbols.c index a3db0abe7fc..7dae01e780f 100644 --- a/ntoskrnl/kdbg/kdb_symbols.c +++ b/ntoskrnl/kdbg/kdb_symbols.c @@ -33,6 +33,14 @@ BOOLEAN KdbpSymbolsInitialized = FALSE; /* 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 KdbpSymSearchModuleList( IN PLIST_ENTRY current_entry, @@ -200,7 +208,7 @@ KdbSymPrintAddress( * \retval STATUS_SUCCESS At least one of the requested informations was found. * \retval STATUS_UNSUCCESSFUL None of the requested information was found. */ -NTSTATUS +static NTSTATUS KdbSymGetAddressInformation( IN PROSSYM_INFO RosSymInfo, IN ULONG_PTR RelativeAddress,
4 years, 4 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
17
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Results per page:
10
25
50
100
200