Author: tkreuzer
Date: Fri Mar 14 18:51:27 2008
New Revision: 32680
URL:
http://svn.reactos.org/svn/reactos?rev=3D32680&view=3Drev
Log:
- modify the way the way the Frames parameter in KeRosDumpStackFrames() is =
handled, wasn't used so far
- remove some code duplication
Modified:
trunk/reactos/ntoskrnl/ke/bug.c
Modified: trunk/reactos/ntoskrnl/ke/bug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=
=3D32680&r1=3D32679&r2=3D32680&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/ntoskrnl/ke/bug.c (original)
+++ trunk/reactos/ntoskrnl/ke/bug.c Fri Mar 14 18:51:27 2008
@@ -227,41 +227,39 @@
return (USHORT)i;
}
=
+
VOID
-NTAPI
-KeRosDumpStackFrames(IN PULONG Frame OPTIONAL,
- IN ULONG FrameCount OPTIONAL)
-{
- ULONG Frames[32];
+FASTCALL
+KeRosDumpStackFrameArray(IN PULONG Frames,
+ IN ULONG FrameCount)
+{
ULONG i, Addr;
BOOLEAN InSystem;
+ PVOID p;
PLDR_DATA_TABLE_ENTRY LdrEntry;
=
- /* If the caller didn't ask, assume 32 frames */
- if (!FrameCount || FrameCount > 32) FrameCount =3D 32;
-
- /* Get the current frames */
- FrameCount =3D RtlCaptureStackBackTrace(2, FrameCount, (PVOID*)Frames,=
NULL);
-
- /* Now loop them (skip the two. One for the dumper, one for the caller=
) */
+ /* Loop them */
for (i =3D 0; i < FrameCount; i++)
{
/* Get the EIP */
Addr =3D Frames[i];
-
- /* If we had a custom frame, make sure we've reached it first */
- if ((Frame) && (Frame[1] =3D=3D Addr))
- {
- Frame =3D NULL;
- }
- else if (Frame)
- {
- /* Skip this entry */
- continue;
+ if (!Addr)
+ {
+ break;
}
=
/* Get the base for this file */
- if (KiPcToFileHeader((PVOID)Addr, &LdrEntry, FALSE, &InSystem))
+ if (Addr > (ULONG_PTR)MmHighestUserAddress)
+ {
+ /* We are in kernel */
+ p =3D KiPcToFileHeader((PVOID)Addr, &LdrEntry, FALSE, &InSyste=
m);
+ }
+ else
+ {
+ /* We are in user land */
+ p =3D KiRosPcToUserFileHeader((PVOID)Addr, &LdrEntry);
+ }
+ if (p)
{
#ifdef KDBG
if (!KdbSymPrintAddress((PVOID)Addr))
@@ -269,53 +267,54 @@
{
/* Print out the module name */
Addr -=3D (ULONG_PTR)LdrEntry->DllBase;
- DbgPrint("<%wZ: %x>", &LdrEntry->FullDllName,
Addr);
- }
- }
- else if (Addr)
+ DbgPrint("<%wZ: %x>\n", &LdrEntry->FullDllName,
Addr);
+ }
+ }
+ else
{
/* Print only the address */
- DbgPrint("<%x>", Addr);
+ DbgPrint("<%x>\n", Addr);
}
=
/* Go to the next frame */
DbgPrint("\n");
}
-
- /* Get the current frames */
- FrameCount =3D KeRosCaptureUserStackBackTrace(-1, 32, (PVOID*)Frames, =
NULL);
-
- /* Now loop them */
- for (i =3D 0; i < FrameCount; i++)
- {
- /* Get the EIP */
- Addr =3D Frames[i];
-
- /* Get the base for this file */
- if (KiRosPcToUserFileHeader((PVOID)Addr, &LdrEntry))
- {
- /* Print out the module name */
-#ifdef KDBG
- if (!KdbSymPrintAddress((PVOID)Addr))
-#endif
- {
- /* Fall back to usual printing */
- Addr -=3D (ULONG_PTR)LdrEntry->DllBase;
- DbgPrint("<%wZ: %x>", &LdrEntry->FullDllName,
Addr);
- }
- }
- else if (Addr)
- {
- /* Print only the address */
- DbgPrint("<%x>", Addr);
- }
-
- /* Go to the next frame */
- DbgPrint("\n");
- }
-
- /* Finish the output */
- DbgPrint("\n");
+}
+
+VOID
+NTAPI
+KeRosDumpStackFrames(IN PULONG Frame OPTIONAL,
+ IN ULONG FrameCount OPTIONAL)
+{
+ ULONG Frames[32];
+ ULONG RealFrameCount;
+
+ /* If the caller didn't ask, assume 32 frames */
+ if (!FrameCount || FrameCount > 32) FrameCount =3D 32;
+
+ if (Frame)
+ {
+ /* Dump them */
+ KeRosDumpStackFrameArray(Frame, FrameCount);
+ }
+ else
+ {
+ /* Get the current frames (skip the two. One for the dumper, one f=
or the caller) */
+ RealFrameCount =3D RtlCaptureStackBackTrace(2, FrameCount, (PVOID*=
)Frames, NULL);
+
+ /* Dump them */
+ KeRosDumpStackFrameArray(Frames, RealFrameCount);
+
+ /* Count left for user mode? */
+ if (FrameCount - RealFrameCount > 0)
+ {
+ /* Get the current frames */
+ RealFrameCount =3D KeRosCaptureUserStackBackTrace(-1, FrameCou=
nt - RealFrameCount, (PVOID*)Frames, NULL);
+
+ /* Dump them */
+ KeRosDumpStackFrameArray(Frames, RealFrameCount);
+ }
+ }
}
=
VOID