2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include "intuition_intern.h"
9 static void ShowSemaphore(const char *, struct SignalSemaphore
*);
10 static void ShowLayer(struct Layer
*);
12 /*****************************************************************************
15 #include <proto/intuition.h>
17 AROS_LH0(void, DumpIntuiState
,
22 struct IntuitionBase
*, IntuitionBase
, 152, Intuition
)
25 Private: dump the internal state of intuition.
42 *****************************************************************************/
48 struct IntIntuitionBase
*IBase
= GetPrivIBase(IntuitionBase
);
54 dprintf("----------------------------------------------------------------\n");
55 dprintf("IntuitionBase 0x%lx\n", (ULONG
) IntuitionBase
);
56 ShowSemaphore("IBaseLock", IBase
->IBaseLock
);
57 ShowSemaphore("PubScrListLock", &IBase
->PubScrListLock
);
58 ShowSemaphore("GadgetLock", &IBase
->GadgetLock
);
59 ShowSemaphore("MenuLock", &IBase
->MenuLock
);
60 ShowSemaphore("IntuiActionLock", &IBase
->IntuiActionLock
);
61 ShowSemaphore("InputHandlerLock", &IBase
->InputHandlerLock
);
62 ShowSemaphore("ClassListLock", &IBase
->ClassListLock
);
64 dprintf("\nScreens:\n");
66 for (scr
= IntuitionBase
->FirstScreen
; scr
; scr
= scr
->NextScreen
)
68 dprintf("\nScreen 0x%lx <%s>\n", (ULONG
) scr
, scr
->Title
? scr
->Title
: (UBYTE
*)"NULL");
70 dprintf("LayerInfo 0x%lx LockLayersCount %ld\n",
71 (ULONG
) &scr
->LayerInfo
, (LONG
) scr
->LayerInfo
.LockLayersCount
);
72 ShowSemaphore("LayerInfo", &scr
->LayerInfo
.Lock
);
73 ShowLayer(GetPrivScreen(scr
)->rootLayer
);
74 ShowLayer(scr
->BarLayer
);
76 for (win
= scr
->FirstWindow
; win
; win
= win
->NextWindow
)
78 dprintf("\nWindow 0x%lx <%s>\n", (ULONG
) win
, win
->Title
? win
->Title
: (UBYTE
*)"NULL");
80 ShowLayer(WLAYER(win
));
82 if (IS_GZZWINDOW(win
))
84 ShowLayer(BLAYER(win
));
89 dprintf("----------------------------------------------------------------\n");
100 void *CheckValidPtr(void *Ptr
)
102 if (((ULONG
) Ptr
>= 0x20000000UL
) &&
103 ((ULONG
) Ptr
< 0x30000000UL
))
107 if (((ULONG
) Ptr
>= 0x7000000UL
) &&
108 ((ULONG
) Ptr
< 0xb510000UL
))
112 else if (((ULONG
) Ptr
>= ((ULONG
) 0x11000000)) &&
113 ((ULONG
) Ptr
< ((ULONG
) 0x14000000)))
117 else if (((ULONG
) Ptr
>= ((ULONG
) 0x10100000)) &&
118 ((ULONG
) Ptr
< ((ULONG
) 0x10400000)))
122 else if (((ULONG
) Ptr
>= ((ULONG
) 0x10800000)) &&
123 ((ULONG
) Ptr
< ((ULONG
) 0x10900000)))
127 else if (((ULONG
) Ptr
>= 0x1000) &&
128 ((ULONG
) Ptr
< 0x00200000))
132 else if (((ULONG
) Ptr
>= 0x00f80000) &&
133 ((ULONG
) Ptr
< 0x01000000))
137 else if ((ULONG
) Ptr
== (ULONG
) 0x100000f0)
145 struct SegTrackerSemaphore
147 struct SignalSemaphore Semaphore
;
148 void (*Search
)(void);
158 struct SegTrackerNode
162 struct SegArray Array
[1];
166 static struct SegTrackerSemaphore
*MySegInfo
;
168 #define DEBUG_SEGTRACKER(x) ;
172 char *FindAddress(ULONG Address
,
176 struct SegTrackerNode
*MyNode
;
180 DEBUG_SEGTRACKER(dprintf("FindAddress(Address 0x%lx Hunk 0x%lx Offset 0x%lx)\n",
185 /* MySegInfo isn`t valid after a coldreboot
186 * therefore scan for it everytime
188 if (TRUE
)//(MySegInfo==NULL)
190 struct ExecBase
*SysBase
= *(struct ExecBase
**)4;
191 MySegInfo
=(struct SegTrackerSemaphore
*) FindSemaphore("SegTracker");
192 DEBUG_SEGTRACKER(dprintf("FindAddress: SegInfo 0x%lx\n",
197 if (CheckValidPtr(MySegInfo
))
199 MyNode
=(struct SegTrackerNode
*) MySegInfo
->List
.mlh_Head
;
200 DEBUG_SEGTRACKER(dprintf("FindAddress: 1st Node 0x%lx\n",
202 while ((CheckValidPtr(MyNode
)) &&
203 (MyNode
->Node
.mln_Succ
) &&
207 DEBUG_SEGTRACKER(dprintf("FindAddress: Current Segment %s\n",
210 while (MyNode
->Array
[Count
].Address
)
212 DEBUG_SEGTRACKER(dprintf("FindAddress: Current Address 0x%lx Size 0x%lx\n",
213 MyNode
->Array
[Count
].Address
,
214 MyNode
->Array
[Count
].Size
));
216 if ((Address
> MyNode
->Array
[Count
].Address
) &&
217 (Address
< (MyNode
->Array
[Count
].Address
+ MyNode
->Array
[Count
].Size
)))
220 *Offset
= Address
- MyNode
->Array
[Count
].Address
- 4;
225 *Hunk
= MyNode
->Array
[0].Address
;
227 DEBUG_SEGTRACKER(dprintf("FindAddress: Found %s\n",
232 MyNode
=(struct SegTrackerNode
*) MyNode
->Node
.mln_Succ
;
239 void ShowStack(ULONG Address
,
247 if (CheckValidPtr((ULONG
*) Address
))
250 while (Ptr
< (Address
+Size
))
252 if ((MyName
=FindAddress(*((ULONG
*) Ptr
),
256 dprintf("\t\t0x%lx -> %s Hunk %ld Offset 0x%08lx\n",
272 #define DEBUG_SHOWHISTORY(x) ;
274 void ShowPPCStackHistory(ULONG
*Stack
,
286 CurrentStack
= Stack
;
288 DEBUG_SHOWHISTORY(dprintf("ShowPPCStackHistory: Stack 0x%lx StackEnd 0x%lx\n",
292 while (CurrentStack
< StackEnd
)
294 StackPtr
=(ULONG
*) CurrentStack
[0]; /* Get previous stackframe */
295 DEBUG_SHOWHISTORY(dprintf("ShowPPCStackHistory: StackPtr 0x%lx\n",
297 if ((StackPtr
>= Stack
) &&
298 (StackPtr
< StackEnd
))
300 if (CheckValidPtr((ULONG
*) StackPtr
[1]))
304 if ((MyName
=FindAddress(StackPtr
[1],
308 dprintf("\t\tStackFrame[%ld].LR-> Address 0x%08lx -> %s Hunk %ld Offset 0x%08lx\n",
317 dprintf("\t\tStackFrame[%ld].LR-> Address 0x%08lx\n",
322 PPCDissasemble((APTR
) StackPtr
[1],
329 dprintf("\t\tStackFrame[%ld].LR-> Address 0x%08lx **Not Valid**\n\n",
334 CurrentStack
= StackPtr
;
337 DEBUG_SHOWHISTORY(dprintf("ShowPPCStackHistory: MaxLevel end\n"));
343 DEBUG_SHOWHISTORY(dprintf("ShowPPCStackHistory: address outside\n"));
352 typedef unsigned int u_int32_t
;
353 typedef double float64_t
;
362 typedef struct __QVector vector128_t
;
367 * Yeah yeah, this is ugly.. who cares..
369 typedef unsigned int u_int32_t
;
370 typedef double float64_t
;
378 typedef struct __QVector vector128_t
;
383 u_int32_t StackGap
[4]; /* StackFrame Gap..so a function working
384 * with the PPCRegFrame as the GPR1 doesn`t
385 * overwrite any contents with a LR store at 4(1)
388 u_int32_t Version
; /* Version of the structure */
389 u_int32_t Type
; /* Type of the regframe */
390 u_int32_t Flags
; /* The filled up registers */
391 u_int32_t State
; /* State of the Thread(only used for Get) */
417 void ShowTaskState(struct Task
*task
)
419 struct PPCRegFrame
*frame
= task
->tc_ETask
->PPCRegFrame
;
420 struct EmulHandle
*emul
= (APTR
)frame
->GPR
[2];
424 dprintf("\t\tSRR0 0x%lx LR 0x%lx CTR 0x%lx PC 0x%lx\n",
425 (ULONG
) frame
->SRR0
, (ULONG
) frame
->LR
, (ULONG
) frame
->CTR
,
426 emul
->Flags
& EMULFLAGSF_PPC
? (ULONG
) emul
->PC
: (ULONG
) frame
->GPR
[13]);
428 if (emul
->Flags
& EMULFLAGSF_PPC
)
430 if ((MyName
=FindAddress((ULONG
) frame
->SRR0
,
434 dprintf("\t\tSRR0 -> %s Hunk %ld Offset 0x%08lx\n",
440 if ((MyName
=FindAddress((ULONG
) frame
->LR
,
444 dprintf("\t\t LR -> %s Hunk %ld Offset 0x%08lx\n",
450 if ((MyName
=FindAddress((ULONG
) frame
->CTR
,
454 dprintf("\t\t CTR -> %s Hunk %ld Offset 0x%08lx\n",
461 ShowPPCStackHistory((ULONG
*) frame
->GPR
[1],
462 (ULONG
*) (frame
->GPR
[1] + 1000));
464 if ((MyName
=FindAddress((ULONG
) emul
->PC
,
468 dprintf("\t\tPC -> %s Hunk %ld Offset 0x%08lx\n",
473 ShowStack(emul
->An
[7],
478 if ((MyName
=FindAddress((ULONG
) frame
->GPR
[13],
482 dprintf("\t\tPC -> %s Hunk %ld Offset 0x%08lx\n",
487 ShowStack(frame
->GPR
[31],
492 void ShowSemaphore(const char *name
, struct SignalSemaphore
*sem
)
494 struct SemaphoreRequest
*req
;
497 dprintf("Semaphore %s:\n", name
);
499 dprintf("Semaphore 0x%lx NestCount %d QueueCount %d Owner 0x%lx <%s>\n",
500 (ULONG
) sem
, sem
->ss_NestCount
, sem
->ss_QueueCount
,
501 (ULONG
) sem
->ss_Owner
, sem
->ss_Owner
&& sem
->ss_Owner
->tc_Node
.ln_Name
?
502 sem
->ss_Owner
->tc_Node
.ln_Name
: "NULL");
504 ShowTaskState(sem
->ss_Owner
);
506 ForeachNode(&sem
->ss_WaitQueue
, req
)
508 dprintf("\tTask 0x%lx <%s>\n", (ULONG
) req
->sr_Waiter
,
509 req
->sr_Waiter
->tc_Node
.ln_Name
? req
->sr_Waiter
->tc_Node
.ln_Name
: "NULL");
510 ShowTaskState(req
->sr_Waiter
);
514 void ShowLayer(struct Layer
*layer
)
518 dprintf("Layer 0x%lx\n", (ULONG
) layer
);
519 ShowSemaphore(NULL
, &layer
->Lock
);