Fix GDB backtrace
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
_____
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
--- trunk/reactos/ntoskrnl/ke/i386/syscall.S 2005-09-24 23:45:05 UTC
(rev 18037)
+++ trunk/reactos/ntoskrnl/ke/i386/syscall.S 2005-09-25 00:00:03 UTC
(rev 18038)
@@ -255,6 +255,22 @@
mov ebx, [ebp+KTRAP_FRAME_EBP]
mov edi, [ebp+KTRAP_FRAME_EIP]
+#ifdef DBG
+ /*
+ * We want to know the address from where the syscall stub was
called.
+ * If PrevMode is KernelMode, that address is stored in our own
(kernel)
+ * stack, at location KTRAP_FRAME_ESP.
+ * If we're coming from UserMode, we load the usermode stack
pointer
+ * and go back two frames (first frame is the syscall stub, second
call
+ * is the caller of the stub).
+ */
+ mov edi, [ebp+KTRAP_FRAME_ESP]
+ test byte ptr [esi+KTHREAD_PREVIOUS_MODE], 0x01
+ jz PrevWasKernelMode
+ mov edi, [edi+4]
+PrevWasKernelMode:
+#endif
+
/* Write the debug data */
mov [ebp+KTRAP_FRAME_DEBUGPOINTER], edx
mov dword ptr [ebp+KTRAP_FRAME_DEBUGARGMARK], 0xBADB0D00
@@ -334,6 +350,22 @@
mov edi, esp
rep movsd
+#ifdef DBG
+ /*
+ * The following lines are for the benefit of GDB. It will see the
return
+ * address of the "call ebx" below, find the last label before it
and
+ * thinks that that's the start of the function. It will then check
to see
+ * if it starts with a standard function prolog (push ebp, mov
ebp,esp).
+ * When that standard function prolog is not found, it will stop
the
+ * stack backtrace. Since we do want to backtrace into usermode,
let's
+ * make GDB happy and create a standard prolog.
+ */
+KiSystemService:
+ push ebp
+ mov ebp,esp
+ pop ebp
+#endif
+
/* Do the System Call */
call ebx
Allow the system process and a process without a parent process to use
all cpus on a smp machine, even if only the boot cpu is running.
Modified: trunk/reactos/ntoskrnl/ps/process.c
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c
_____
Modified: trunk/reactos/ntoskrnl/ps/process.c
--- trunk/reactos/ntoskrnl/ps/process.c 2005-09-24 19:30:12 UTC (rev
18034)
+++ trunk/reactos/ntoskrnl/ps/process.c 2005-09-24 19:34:54 UTC (rev
18035)
@@ -220,7 +220,14 @@
else
{
pParentProcess = NULL;
+#ifdef CONFIG_SMP
+ /* FIXME:
+ * Only the boot cpu is initialized in the early boot phase.
+ */
+ Affinity = 0xffffffff;
+#else
Affinity = KeActiveProcessors;
+#endif
}
/* Add the debug port */
_____
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c
--- trunk/reactos/ntoskrnl/ps/psmgr.c 2005-09-24 19:30:12 UTC (rev
18034)
+++ trunk/reactos/ntoskrnl/ps/psmgr.c 2005-09-24 19:34:54 UTC (rev
18035)
@@ -220,7 +220,15 @@
/* System threads may run on any processor. */
RtlZeroMemory(PsInitialSystemProcess, sizeof(EPROCESS));
+#ifdef CONFIG_SMP
+ /* FIXME:
+ * Only the boot cpu is initialized. Threads of the
+ * system process should be able to run on all cpus.
+ */
+ PsInitialSystemProcess->Pcb.Affinity = 0xffffffff;
+#else
PsInitialSystemProcess->Pcb.Affinity = KeActiveProcessors;
+#endif
PsInitialSystemProcess->Pcb.IopmOffset = 0xffff;
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIORITY_NORMAL;
PsInitialSystemProcess->Pcb.QuantumReset = 6;