mirror of
https://github.com/reactos/reactos.git
synced 2025-07-16 01:54:02 +00:00
[RTL]
Add some temp AVL debugging code: In case an AVL table gets unbalanced, dump the table and a backtrace. svn path=/trunk/; revision=56249
This commit is contained in:
parent
6fcb5fd53c
commit
98a00b314d
1 changed files with 78 additions and 24 deletions
|
@ -203,6 +203,46 @@ RtlpRebalanceAvlTreeNode(IN PRTL_BALANCED_LINKS Node)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FORCEINLINE
|
||||||
|
Indent(ULONG Level)
|
||||||
|
{
|
||||||
|
while (Level--)
|
||||||
|
{
|
||||||
|
DbgPrint(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
FORCEINLINE
|
||||||
|
DbgDumpAvlNodes(
|
||||||
|
PRTL_BALANCED_LINKS Node,
|
||||||
|
ULONG Level)
|
||||||
|
{
|
||||||
|
#ifdef PRTL_BALANCED_LINKS
|
||||||
|
if (Level == 0)
|
||||||
|
{
|
||||||
|
DbgPrint("++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
||||||
|
DbgPrint("Root = %p\n", Node);
|
||||||
|
}
|
||||||
|
|
||||||
|
Indent(Level+1); DbgPrint("LetChid = %p", Node->LeftChild);
|
||||||
|
if (Node->LeftChild)
|
||||||
|
{
|
||||||
|
DbgPrint("(%lx, %lx)\n", Node->LeftChild->StartingVpn,Node->LeftChild->EndingVpn);
|
||||||
|
DbgDumpAvlNodes(Node->LeftChild, Level+1);
|
||||||
|
}
|
||||||
|
else DbgPrint("\n");
|
||||||
|
Indent(Level+1); DbgPrint("RightChild = %p\n", Node->RightChild);
|
||||||
|
if (Node->RightChild)
|
||||||
|
{
|
||||||
|
DbgPrint("(%lx, %lx)\n", Node->RightChild->StartingVpn,Node->RightChild->EndingVpn);
|
||||||
|
DbgDumpAvlNodes(Node->RightChild, Level+1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table,
|
RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table,
|
||||||
|
@ -225,7 +265,14 @@ RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table,
|
||||||
/* This is the new root node */
|
/* This is the new root node */
|
||||||
RtlInsertAsRightChildAvl(&Table->BalancedRoot, NewNode);
|
RtlInsertAsRightChildAvl(&Table->BalancedRoot, NewNode);
|
||||||
//MI_ASSERT(RtlBalance(NewNode) == RtlBalancedAvlTree);
|
//MI_ASSERT(RtlBalance(NewNode) == RtlBalancedAvlTree);
|
||||||
if (RtlBalance(NewNode) != RtlBalancedAvlTree) DPRINT1("Warning: Root node unbalanced?\n");
|
if (RtlBalance(NewNode) != RtlBalancedAvlTree)
|
||||||
|
{
|
||||||
|
DPRINT1("Warning: Root node unbalanced?\n");
|
||||||
|
DbgDumpAvlNodes(&Table->BalancedRoot, 0);
|
||||||
|
#ifdef PRTL_BALANCED_LINKS
|
||||||
|
KeRosDumpStackFrames(NULL, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* On AVL trees, we also update the depth */
|
/* On AVL trees, we also update the depth */
|
||||||
ASSERT(Table->DepthOfTree == 0);
|
ASSERT(Table->DepthOfTree == 0);
|
||||||
|
@ -245,7 +292,14 @@ RtlpInsertAvlTreeNode(IN PRTL_AVL_TABLE Table,
|
||||||
|
|
||||||
/* Little cheat to save on loop processing, taken from Timo */
|
/* Little cheat to save on loop processing, taken from Timo */
|
||||||
//MI_ASSERT(RtlBalance(NewNode) == RtlBalancedAvlTree);
|
//MI_ASSERT(RtlBalance(NewNode) == RtlBalancedAvlTree);
|
||||||
if (RtlBalance(NewNode) != RtlBalancedAvlTree) DPRINT1("Warning: Root node unbalanced?\n");
|
if (RtlBalance(NewNode) != RtlBalancedAvlTree)
|
||||||
|
{
|
||||||
|
DPRINT1("Warning: Root node unbalanced?\n");
|
||||||
|
DbgDumpAvlNodes(&Table->BalancedRoot, 0);
|
||||||
|
#ifdef PRTL_BALANCED_LINKS
|
||||||
|
KeRosDumpStackFrames(NULL, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
RtlSetBalance(&Table->BalancedRoot, RtlLeftHeavyAvlTree);
|
RtlSetBalance(&Table->BalancedRoot, RtlLeftHeavyAvlTree);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue