mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
- Replace RtlpGetExceptionAddress by the _ReturnAddress intrinsic and add it to ARM intrin.h as it was missing.
- Simplify RtlpCheckForActiveDebugger: Remove the BOOLEAN parameter as we would always pass it FALSE. Always return FALSE false from kernel mode for simplicity. - Fix a critical flaw in our exception support: RtlRaiseException and RtlRaiseStatus were implemented in C on x86. This lead to unpredictable register corruption because the compiler could not know that it had to preserve non-volatile registers before calling RtlCaptureContext as the saved context is later used to restore the caller in case the exception is handled and execution is continued. This made the functions unsafe to return from as any non-volatile register could be corrupted. Implement them in assembly for x86 to safely capture the context using only EBP and ESP. The C versions of those routines are still used and shared for the other architectures we support -- needs to be determined if this is safe and correct for those architectures. - The ntdll exception Wine exposed this issue, and all tests now pass. The remaining failures on the build server are caused by missing or incomplete debug register support in KVM/QEMU. Run the test in another VM or on real hardware and all the tests will pass. - Implement Debug Prompt (DbgPrompt) support for KD and KDBG. The KDBG implementation reads the prompt from keyboard or serial depending on the mode so that sysreg and rosdbg can support it too. - Properly implement RtlAssert using DbgPrompt to prompt for the action to take instead of always doing a breakpoint. The new implementation is disabled until sysreg can support this. Also move RtlAssert to its own file as it has nothing to do with the error routines (nor does it belong in exception.c). - Note that DbgPrompt was already used in PspCatchCriticalBreak, and this would have resulted in a silent hang as BREAKPOINT_PROMPT wasn't handled at all by KDBG. - Implement KiRaiseAssertion (10 lines of code with the trap macros) and thus support NT_ASSERT. Add partial support for it to KDBG to print out a warning and the address of the failure, but don't do anything else. Also add NT_ASSERT to the DDK headers so that we can use it, but don't use it yet as the ARM method of performing this has not been decided nor implemented. - KiTrap3 doesn't set STATUS_SUCCESS but BREAKPOINT_BREAK. They have the same numerical value but very different meaning -- BREAKPOINT_BREAK means that the exception is a software breakpoint and not a debug service call. Fix some comments to document that this is what is checked for. - Fix inverted and broken logic in KdpReport. It would never pass second chance exceptions to the debugger, didn't respect the stop-on-exception flag properly and would always fail to handle some special exceptions in both first and second chance instead of just failing to handle it in first chance. Clean up, reformat and document what is going on. - The DebugPrint and DebugPrompt support routines only perform a 2D interrupt on x86; use more portable comments. - Add Alex to the programmer section of x86's kdsup.c -- he wrote KdpGetStateChange, KdpSetContextState and the code that was previously in KdpRead/WriteControlSpace. - Add my name to the parts of KD where I have made significant work on getting KD/WinDbg support up and running. - KD debugging is now quite functional and stable. Some bugs and stubs remain to be flushed out, but overall KD is now much better and easier to use than KDBG. svn path=/trunk/; revision=43705
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#error Unsupported compiler
|
||||
#endif
|
||||
|
||||
#define _ReturnAddress() (__builtin_return_address(0))
|
||||
#define _ReadWriteBarrier() __sync_synchronize()
|
||||
|
||||
__INTRIN_INLINE char _InterlockedCompareExchange8(volatile char * const Destination, const char Exchange, const char Comperand)
|
||||
|
||||
@@ -5796,6 +5796,25 @@ KeAcquireSpinLockRaiseToDpc(
|
||||
#define ROUND_TO_PAGES(Size) \
|
||||
((ULONG_PTR) (((ULONG_PTR) Size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))
|
||||
|
||||
|
||||
|
||||
#if defined(_X86_) || defined(_AMD64_)
|
||||
|
||||
//
|
||||
// x86 and x64 performs a 0x2C interrupt
|
||||
//
|
||||
#define DbgRaiseAssertionFailure __int2c
|
||||
|
||||
#elif defined(_ARM_)
|
||||
|
||||
//
|
||||
// TODO
|
||||
//
|
||||
|
||||
#else
|
||||
#error Unsupported Architecture
|
||||
#endif
|
||||
|
||||
#if DBG
|
||||
|
||||
#define ASSERT(exp) \
|
||||
@@ -5807,7 +5826,7 @@ KeAcquireSpinLockRaiseToDpc(
|
||||
RtlAssert( #exp, __FILE__, __LINE__, msg ), FALSE : TRUE)
|
||||
|
||||
#define RTL_SOFT_ASSERT(exp) \
|
||||
(VOID)((!(_exp)) ? \
|
||||
(VOID)((!(exp)) ? \
|
||||
DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
|
||||
|
||||
#define RTL_SOFT_ASSERTMSG(msg, exp) \
|
||||
@@ -5820,6 +5839,36 @@ KeAcquireSpinLockRaiseToDpc(
|
||||
#define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
|
||||
#define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#define NT_ASSERT(exp) \
|
||||
((!(exp)) ? \
|
||||
(__annotation(L"Debug", L"AssertFail", L#exp), \
|
||||
DbgRaiseAssertionFailure(), FALSE) : TRUE)
|
||||
|
||||
#define NT_ASSERTMSG(msg, exp) \
|
||||
((!(exp)) ? \
|
||||
(__annotation(L"Debug", L"AssertFail", L##msg), \
|
||||
DbgRaiseAssertionFailure(), FALSE) : TRUE)
|
||||
|
||||
#define NT_ASSERTMSGW(msg, exp) \
|
||||
((!(exp)) ? \
|
||||
(__annotation(L"Debug", L"AssertFail", msg), \
|
||||
DbgRaiseAssertionFailure(), FALSE) : TRUE)
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// GCC doesn't support __annotation (nor PDB)
|
||||
//
|
||||
#define NT_ASSERT(exp) \
|
||||
(VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
|
||||
|
||||
#define NT_ASSERTMSG NT_ASSERT
|
||||
#define NT_ASSERTMSGW NT_ASSERT
|
||||
|
||||
#endif
|
||||
|
||||
#else /* !DBG */
|
||||
|
||||
#define ASSERT(exp) ((VOID) 0)
|
||||
@@ -5834,6 +5883,10 @@ KeAcquireSpinLockRaiseToDpc(
|
||||
#define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
|
||||
#define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
|
||||
|
||||
#define NT_ASSERT(exp) ((VOID)0)
|
||||
#define NT_ASSERTMSG(exp) ((VOID)0)
|
||||
#define NT_ASSERTMSGW(exp) ((VOID)0)
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
|
||||
|
||||
@@ -376,6 +376,19 @@ Author:
|
||||
#define CONTEXT_FLOAT_SAVE_STATUS_WORD CONTEXT_FLOAT_SAVE + FP_STATUS_WORD
|
||||
#define CONTEXT_FLOAT_SAVE_TAG_WORD CONTEXT_FLOAT_SAVE + FP_TAG_WORD
|
||||
#define CONTEXT_ALIGNED_SIZE 0x2CC
|
||||
#define CONTEXT_FRAME_LENGTH 0x2D0
|
||||
|
||||
//
|
||||
// CONTEXT Flags
|
||||
//
|
||||
#ifdef __ASM__
|
||||
#define CONTEXT_CONTROL 0x10001
|
||||
#define CONTEXT_INTEGER 0x10002
|
||||
#define CONTEXT_SEGMENTS 0x10004
|
||||
#define CONTEXT_FLOATING_POINT 0x10008
|
||||
#define CONTEXT_DEBUG_REGISTERS 0x10010
|
||||
#define CONTEXT_FULL 0x10007
|
||||
#endif
|
||||
|
||||
//
|
||||
// EXCEPTION_RECORD Offsets
|
||||
@@ -527,7 +540,6 @@ Author:
|
||||
// NTSTATUS, Bugcheck Codes and Debug Codes
|
||||
//
|
||||
#ifdef __ASM__
|
||||
#define STATUS_SUCCESS 0x00000000
|
||||
#define STATUS_ACCESS_VIOLATION 0xC0000005
|
||||
#define STATUS_IN_PAGE_ERROR 0xC0000006
|
||||
#define STATUS_GUARD_PAGE_VIOLATION 0x80000001
|
||||
@@ -553,6 +565,7 @@ Author:
|
||||
#define STATUS_FLOAT_UNDERFLOW 0xC0000093
|
||||
#define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
|
||||
#define STATUS_FLOAT_MULTIPLE_TRAPS 0xC00002B5
|
||||
#define STATUS_ASSERTION_FAILURE 0xC0000420
|
||||
#define APC_INDEX_MISMATCH 0x01
|
||||
#define IRQL_NOT_GREATER_OR_EQUAL 0x09
|
||||
#define IRQL_NOT_LESS_OR_EQUAL 0x0A
|
||||
@@ -564,6 +577,11 @@ Author:
|
||||
#define HARDWARE_INTERRUPT_STORM 0xF2
|
||||
#define DBG_STATUS_CONTROL_C 0x01
|
||||
|
||||
//
|
||||
// DebugService Control Types
|
||||
//
|
||||
#define BREAKPOINT_BREAK 0x0
|
||||
|
||||
//
|
||||
// IRQL Levels
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user