https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4e4c47cccc5658977e7ef…
commit 4e4c47cccc5658977e7ef923262fe4b5bb2b56ab
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue Mar 2 13:03:37 2021 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Tue Mar 2 14:37:39 2021 +0100
[NTOS:KE] Generate proper frame info for trap handler in GCC builds
CORE-8531
---
ntoskrnl/include/internal/i386/asmmacro.S | 23 +++++++++++++++++++++++
ntoskrnl/ke/i386/trap.s | 2 ++
2 files changed, 25 insertions(+)
diff --git a/ntoskrnl/include/internal/i386/asmmacro.S
b/ntoskrnl/include/internal/i386/asmmacro.S
index 543ce3f1bc4..4a3dd56d623 100644
--- a/ntoskrnl/include/internal/i386/asmmacro.S
+++ b/ntoskrnl/include/internal/i386/asmmacro.S
@@ -217,6 +217,29 @@ set_sane_segs:
mov [esp + KTRAP_FRAME_DEBUGEIP], eax
mov [esp + KTRAP_FRAME_DEBUGEBP], ebp
mov ebp, esp
+
+ /* Tell GDB what just happened */
+ CFI_DEF_CFA_REGISTER ebp
+ CFI_ADJUST_CFA_OFFSET FrameSize
+ CFI_REL_OFFSET ss, KTRAP_FRAME_SS
+ CFI_REL_OFFSET gs, KTRAP_FRAME_GS
+ CFI_REL_OFFSET fs, KTRAP_FRAME_FS
+ CFI_REL_OFFSET es, KTRAP_FRAME_ES
+ CFI_REL_OFFSET ds, KTRAP_FRAME_DS
+ CFI_REL_OFFSET cs, KTRAP_FRAME_CS
+
+ CFI_REL_OFFSET edi, KTRAP_FRAME_EDI
+ CFI_REL_OFFSET esi, KTRAP_FRAME_ESI
+ CFI_REL_OFFSET ebx, KTRAP_FRAME_EBX
+ CFI_REL_OFFSET ebp, KTRAP_FRAME_EBP
+ CFI_REL_OFFSET eip, KTRAP_FRAME_EIP
+ CFI_REL_OFFSET esp, KTRAP_FRAME_ESP
+
+if (NOT (Flags AND KI_NONVOLATILES_ONLY))
+ CFI_REL_OFFSET eax, KTRAP_FRAME_EAX
+ CFI_REL_OFFSET ecx, KTRAP_FRAME_ECX
+ CFI_REL_OFFSET edx, KTRAP_FRAME_EDX
+endif
#endif
/* Set parameter 1 (ECX) to point to the frame */
diff --git a/ntoskrnl/ke/i386/trap.s b/ntoskrnl/ke/i386/trap.s
index 2f8070725d5..c4b2e168c54 100644
--- a/ntoskrnl/ke/i386/trap.s
+++ b/ntoskrnl/ke/i386/trap.s
@@ -125,6 +125,7 @@ ALIGN 4
EXTERN @KiInterruptTemplateHandler@8:PROC
PUBLIC _KiInterruptTemplate
_KiInterruptTemplate:
+ CFI_STARTPROC
KiEnterTrap KI_PUSH_FAKE_ERROR_CODE
PUBLIC _KiInterruptTemplate2ndDispatch
_KiInterruptTemplate2ndDispatch:
@@ -135,6 +136,7 @@ _KiInterruptTemplateObject:
jmp eax
PUBLIC _KiInterruptTemplateDispatch
_KiInterruptTemplateDispatch:
+ CFI_ENDPROC
EXTERN @KiSystemServiceHandler@8:PROC
PUBLIC _KiSystemService