forked from gphilippot/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Debugging.pb
616 lines (506 loc) · 26.2 KB
/
Debugging.pb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
;--------------------------------------------------------------------------------------------
; Copyright (c) Fantaisie Software. All rights reserved.
; Dual licensed under the GPL and Fantaisie Software licenses.
; See LICENSE and LICENSE-FANTAISIE in the project root for license information.
;--------------------------------------------------------------------------------------------
;
; For easier debugging of IDE internals.
;
; If the #DEBUG constant is set to 1, there is a new menu entry
; "Help->Debugging", which will open this window where some info
; can be viewed about the current source and settings etc.
;
; (more stuff can be added as needed while looking for bugs)
;
;
CompilerIf #DEBUG
Enumeration
#DEBUG_SourceTokens
#DEBUG_SortedTokens
#DEBUG_SortedIssues
#DEBUG_ProjectTokens
#DEBUG_CompilerDialog
#DEBUG_PreferencesDialog
#DEBUG_FindDialog
#DEBUG_GrepDialog
#DEBUG_AddToolsDialog
#DEBUG_EditToolsDialog
#DEBUG_MemoryStats
EndEnumeration
Global Debugging_Combo, Debugging_Editor, Debugging_Display
Declare.s DumpDialogHirachy(*Object.DlgBase, Indent)
CompilerIf #CompileWindows
Structure PROCESS_HEAP_ENTRY_Block
hMem.i
dwReserved.l[3]
EndStructure
Structure PROCESS_HEAP_ENTRY_Region
dwCommittedSize.l
dwUnCommittedSize.l
lpFirstBlock.i
lpLastBlock.i
EndStructure
Structure PROCESS_HEAP_ENTRY
lpData.i
cbData.l
cbOverhead.b
iRegionIndex.b
wFlags.w
StructureUnion
Block.PROCESS_HEAP_ENTRY_Block
Region.PROCESS_HEAP_ENTRY_Region
EndStructureUnion
EndStructure
#PROCESS_HEAP_ENTRY_BUSY = $0004
#PROCESS_HEAP_ENTRY_DDESHARE = $0020
#PROCESS_HEAP_ENTRY_MOVEABLE = $0010
#PROCESS_HEAP_REGION = $0001
#PROCESS_HEAP_UNCOMMITTED_RANGE = $0002
Procedure.s HeapStats(Heap)
Protected Entry.PROCESS_HEAP_ENTRY
Protected Blocks, Size, Overhead
Protected Uncommitted
HeapLock_(Heap)
While HeapWalk_(Heap, @Entry)
If Entry\wFlags & #PROCESS_HEAP_ENTRY_BUSY
Blocks + 1
Size + Entry\cbData
Overhead + Entry\cbOverhead
ElseIf Entry\wFlags & #PROCESS_HEAP_UNCOMMITTED_RANGE
Uncommitted + Entry\cbData
EndIf
Wend
HeapUnlock_(Heap)
Result$ = "Allocated Blocks : " + Str(Blocks) + #NewLine
If Blocks > 0
Result$ + "Avg. Block Size : " + StrByteSize(Size/Blocks) + #NewLine
EndIf
Result$ + "Total Memory : " + StrByteSize(Size) + #NewLine
Result$ + "Heap Overhead : " + StrByteSize(Overhead) + #NewLine
Result$ + "Uncommitted Memory: " + StrByteSize(Uncommitted) + #NewLine
If HeapValidate_(Heap, 0, #Null)
Result$ + "Heap valiadtion : Ok" + #NewLine
Else
Result$ + "Heap valiadtion : Failed !!!" + #NewLine
EndIf
ProcedureReturn Result$
EndProcedure
CompilerEndIf
Procedure.s DumpDlgBin(*Bin.DlgBinBase, Indent)
Text$ = Space(Indent) + "Margins = t:"+Str(*Bin\tMargin)+", b:"+Str(*Bin\bMargin)+", l:"+Str(*Bin\lMargin)+", r:"+Str(*Bin\rMargin)+#NewLine
Text$ + Space(Indent) + "Expand = v:"+Str(*Bin\vExpand)+", h:"+Str(*Bin\hExpand)+" Align = v:"+Str(*Bin\vAlign)+", h:"+Str(*Bin\hAlign)+#NewLine
Text$ + Space(Indent) + "Requested Size = "+Str(*Bin\RequestedWidth) + ", "+Str(*Bin\RequestedHeight) + #NewLine
If *Bin\Child
Text$ + DumpDialogHirachy(*Bin\Child, Indent+2)
Else
Text$ + Space(Indent) + "-- no child --"
EndIf
ProcedureReturn Text$
EndProcedure
Procedure.s DumpDlgBox(*Box.DlgBoxBase, Indent)
Text$ = ""
; those have extra data
If *Box\StaticData\type = #DIALOG_VBox Or *Box\StaticData\type = #DIALOG_HBox
*Box2.DlgBox = *Box
Text$ + Space(Indent) + "Spacing = "+Str(*Box2\Spacing)+", Expand = "+Str(*Box2\Expand)+", Item = "+Str(*Box2\ExpandItem) + ", Align = "+Str(*Box2\Align)+#NewLine
Text$ + Space(Indent) + "RequestedSize = "+Str(*Box2\RequestedSize) + #NewLine
Text$ + Space(Indent) + "ChildSizes ="
For i = 0 To *Box\NbChildren-1
Text$ + " " + Str(*Box2\ChildSizes[i])
Next i
Text$ + #NewLine
EndIf
If *Box\NbChildren = 0
Text$ + Space(Indent) + "-- no children --"
Else
For i = 0 To *Box\NbChildren-1
Text$ + DumpDialogHirachy(*Box\Children[i], Indent+2)
Next i
EndIf
ProcedureReturn Text$
EndProcedure
Procedure.s DumpDlgGadget(*Gadget.DlgGadget, Name$, Indent)
Text$ = "----- "+Name$+" -----"+#NewLine
Text$ + Space(Indent) + "Position = "+Str(GadgetX(*Gadget\Gadget)) + ", "+Str(GadgetY(*Gadget\Gadget)) + ", "+Str(GadgetWidth(*Gadget\Gadget)) + ", "+Str(GadgetHeight(*Gadget\Gadget))+#NewLine
If *Gadget\HasTitle
Text$ + Space(Indent) + "Text = "+ReplaceString(GetGadgetText(*Gadget\Gadget), #Newline, "\n") + #NewLine
EndIf
ProcedureReturn Text$
EndProcedure
Procedure.s DumpDialogHirachy(*Object.DlgBase, Indent)
Text$ = Space(Indent)
Select *Object\StaticData\type
Case #DIALOG_Window
*Window.DlgWindow = *Object
Text$ + "----- Window -----"+#NewLine
Text$ + Space(Indent) + "Size = "+Str(WindowWidth(*Window\Window)) + ", "+Str(WindowHeight(*Window\Window)) + #NewLine
Text$ + DumpDlgBin(*Object, Indent)
Case #DIALOG_VBox
Text$ + "----- VBox -----"+#NewLine
Text$ + DumpDlgBox(*Object, Indent)
Case #DIALOG_HBox
Text$ + "----- HBox -----"+#NewLine
Text$ + DumpDlgBox(*Object, Indent)
Case #DIALOG_Multibox
Text$ + "----- Multibox -----"+#NewLine
Text$ + DumpDlgBox(*Object, Indent)
Case #DIALOG_Singlebox
Text$ + "----- Singlebox -----"+#NewLine
Text$ + DumpDlgBin(*Object, Indent)
Case #DIALOG_Gridbox
*Grid.DlgGridBox = *Object
Text$ + "----- Gridbox -----"+#NewLine
Text$ + Space(Indent) + "NbColumns = "+Str(*Grid\NbColumns) + ", NbRows = "+Str(*Grid\NbRows) + #NewLine
Text$ + Space(Indent) + "Spacing = col:"+Str(*Grid\colSpacing)+" row:"+Str(*Grid\rowSpacing)+", Expand = col:"+Str(*Grid\colExpand)+" row:"+Str(*Grid\rowExpand)+", Item = col:"+Str(*Grid\colExpandItem)+" row:"+Str(*Grid\rowExpandItem)+#NewLine
Text$ + Space(Indent) + "RequestedWidth = "+Str(*Grid\RequestedWidth)+", RequestedHeight = "+Str(*Grid\RequestedHeight)+#NewLine
Text$ + Space(Indent) + "ColSizes ="
For i = 0 To *Grid\NbColumns-1
Text$ + " " + Str(*Grid\colSize[i])
Next i
Text$ + #NewLine + Space(Indent) + "RowSizes ="
For i = 0 To *Grid\NbRows-1
Text$ + " " + Str(*Grid\rowSize[i])
Next i
Text$ + #NewLine
For row = 0 To *Grid\NbRows-1
Text$ + Space(Indent+2) + "===== Gridbox new row =====" + #NewLine
For col = 0 To *Grid\NbColumns-1
Child.DialogObject = *GRid\Rows[row]\Cols[col]\Child
If Child <> #DlgGrid_Empty And Child <> #DlgGrid_Span
Text$ + DumpDialogHirachy(Child, Indent+2)
If *GRid\Rows[row]\Cols[col]\Colspan > 1 Or *GRid\Rows[row]\Cols[col]\Rowspan > 1
Text$ + Space(Indent+2)+"(Gridbox: Colspan = "+Str(*GRid\Rows[row]\Cols[col]\Colspan)+", Rowspan = "+Str(*GRid\Rows[row]\Cols[col]\Rowspan)+")"+#NewLine
EndIf
EndIf
Next col
Next row
Case #DIALOG_Empty
Text$ + "----- Empty -----"+#NewLine
Case #DIALOG_Button: Text$ + DumpDlgGadget(*Object, "Button", Indent)
Case #DIALOG_Checkbox: Text$ + DumpDlgGadget(*Object, "Checkbox", Indent)
Case #DIALOG_Image: Text$ + DumpDlgGadget(*Object, "Image", Indent)
Case #DIALOG_Option: Text$ + DumpDlgGadget(*Object, "Option", Indent)
Case #DIALOG_ListView: Text$ + DumpDlgGadget(*Object, "ListView", Indent) ; we ignore the <item> and <column> entries in this display
Case #DIALOG_ListIcon: Text$ + DumpDlgGadget(*Object, "ListIcon", Indent)
Case #DIALOG_Tree: Text$ + DumpDlgGadget(*Object, "Tree", Indent)
Case #DIALOG_ComboBox: Text$ + DumpDlgGadget(*Object, "ComboBox", Indent)
Case #DIALOG_Text: Text$ + DumpDlgGadget(*Object, "Text", Indent)
Case #DIALOG_String: Text$ + DumpDlgGadget(*Object, "String", Indent)
Case #DIALOG_Editor: Text$ + DumpDlgGadget(*Object, "Editor", Indent)
Case #DIALOG_Scintilla: Text$ + DumpDlgGadget(*Object, "Scintilla", Indent)
Case #DIALOG_ScrollBar: Text$ + DumpDlgGadget(*Object, "ScrollBar", Indent)
Case #DIALOG_ProgressBar: Text$ + DumpDlgGadget(*Object, "ProgressBar", Indent)
Case #DIALOG_Container
Text$ + "----- Container -----"+#NewLine
Text$ + DumpDlgBin(*Object, Indent)
Case #DIALOG_Panel
Text$ + "----- Panel -----"+#NewLine
Text$ + DumpDlgBox(*Object, Indent)
Case #DIALOG_Tab
*Tab.DlgTab = *Object
Text$ + "----- Tab -----"+#NewLine
Text$ + Space(Indent) + "Title = "+GetGadgetItemText(*Tab\ParentGadget, *Tab\ItemIndex) + #NewLine
Text$ + DumpDlgBin(*Object, Indent)
Case #DIALOG_Scroll
*Scroll.DlgScroll = *Object
Text$ + "----- ScrollArea -----"+#NewLine
Text$ + Space(Indent) + "InnerWidth = "+Str(*Scroll\InnerWidth) + ", InnerHeight = "+Str(*Scroll\InnerHeight) + ", Scrolling = "+Str(*Scroll\Scrolling)+#NewLine
Text$ + DumpDlgBin(*Object, Indent)
Case #DIALOG_Frame
*Frame.DlgFrame = *Object
Text$ + "----- Frame -----"+#NewLine
Text$ + Space(Indent) + "Title = "+GetGadgetText(*Frame\Gadget) + #NewLine
Text$ + Space(Indent) + "Boder = t:"+Str(*Frame\BorderTop)+", b:"+Str(*Frame\BorderBottom)+", l:"+Str(*Frame\BorderLeft)+", r:"+Str(*Frame\BorderRight)+#NewLine
Text$ + DumpDlgBin(*Object, Indent)
EndSelect
ProcedureReturn Text$
EndProcedure
Procedure DebuggingWindowEvents(EventID)
If EventID = #PB_Event_Gadget
If EventGadget() = Debugging_Display
Content$ = ""
Select GetGadgetState(Debugging_Combo) ; specifies the action
Case #DEBUG_SourceTokens ; sourcetoken list
If *ActiveSource\Parser\SourceItemArray
If *ActiveSource\Parser\SourceItemCount > 0
length = Len(Str(*ActiveSource\Parser\SourceItemCount))
For i = 0 To *ActiveSource\Parser\SourceItemCount-1
Content$ + RSet(Str(i+1), length, " ")
*Item.SourceItem = *ActiveSource\Parser\SourceItemArray\Line[i]\First
While *Item
Select *Item\Type
Case #ITEM_Keyword : Kind$ = "Keyword("+BasicKeywordsReal(*Item\Keyword)+")"
Case #ITEM_Procedure : Kind$ = "Procedure"
Case #ITEM_Macro : Kind$ = "Macro"
Case #ITEM_CommentMark : Kind$ = "Marker"
Case #ITEM_Issue : Kind$ = "Issue"
Case #ITEM_Structure : Kind$ = "Structure"
Case #ITEM_Interface : Kind$ = "Interface"
Case #ITEM_Constant : Kind$ = "Constant"
Case #ITEM_Variable : Kind$ = "Variable"
Case #ITEM_Array : Kind$ = "Array"
Case #ITEM_LinkedList : Kind$ = "LinkedList"
Case #ITEM_Import : Kind$ = "Import"
Case #ITEM_FoldStart : Kind$ = "FoldStart"
Case #ITEM_FoldEnd : Kind$ = "FoldEnd"
Case #ITEM_MacroEnd : Kind$ = "MacroEnd"
Case #ITEM_ProcedureEnd : Kind$ = "ProcedureEnd"
Case #ITEM_Declare : Kind$ = "Declare"
Case #ITEM_Define : Kind$ = "Define"
Case #ITEM_Prototype : Kind$ = "Prototype"
Case #ITEM_Label : Kind$ = "Label"
Case #ITEM_Map : Kind$ = "Map"
Case #ITEM_UnknownBraced : Kind$ = "UnknownBraced"
Case #ITEM_DeclareModule : Kind$ = "DeclareModule"
Case #ITEM_EndDeclareModule: Kind$ = "EndDeclareModule"
Case #ITEM_Module : Kind$ = "Module"
Case #ITEM_EndModule : Kind$ = "EndModule"
Case #ITEM_UseModule : Kind$ = "UseModule"
Case #ITEM_UnuseModule : Kind$ = "UnuseModule"
Default : Kind$ = "Unknown("+Str(*Item\Type)+")"
EndSelect
If *Item\ModulePrefix$ = ""
Prefix$ = ""
Else
Prefix$ = *Item\ModulePrefix$ + "::"
EndIf
Content$ + " -> ["+Str(*Item\Position)+"] "+Kind$+"="+Prefix$+*Item\Name$+" "+*Item\StringData$
*Item = *Item\Next
Wend
Content$ + #NewLine
Next i
Else
Content$ = "-- Array count is 0 --"
EndIf
Else
Content$ = "-- Array pointer is 0 --"
EndIf
Case #DEBUG_SortedTokens ; sorted source tokens
SortParserData(@*ActiveSource\Parser) ; ensure it is up to date
Content$ = ""
ForEach *ActiveSource\Parser\Modules()
Content$ + #NewLine + "=================== Module: " + MapKey(*ActiveSource\Parser\Modules()) + " =======================" + #NewLine
For Type = 0 To #ITEM_LastSorted
Select Type
Case #ITEM_Procedure : Title$ = "----- Procedures -----"
Case #ITEM_Macro : Title$ = "----- Macros -----"
Case #ITEM_Declare : Title$ = "----- Declares -----"
Case #ITEM_Structure : Title$ = "----- Structures -----"
Case #ITEM_Interface : Title$ = "----- Interfaces -----"
Case #ITEM_Prototype : Title$ = "----- Prototypes -----"
Case #ITEM_Constant : Title$ = "----- Constants -----"
Case #ITEM_Variable : Title$ = "----- Variables -----"
Case #ITEM_Array : Title$ = "----- Arrays -----"
Case #ITEM_LinkedList: Title$ = "----- LinkedLists -----"
Case #ITEM_Label : Title$ = "----- Labels -----"
Case #ITEM_Import : Title$ = "----- Imports -----"
Case #ITEM_Map : Title$ = "----- Maps -----"
Default : Title$ = "----- Unknown type -----"
EndSelect
First = #True
For Char = 0 To #PARSER_VTSize-1
*Item.SourceItem = *ActiveSource\Parser\Modules()\Indexed[Type]\Bucket[Char]
While *Item
If First
Content$ + #NewLine + Title$ + #NewLine
First = #False
EndIf
If Char = 0
Content$ + "_ "
Else
Content$ + Chr(Char-1+'A') + " "
EndIf
Content$ + *Item\Name$ + " " + *Item\StringData$ + #NewLine
*Item = *Item\NextSorted
Wend
Next Char
Next Type
Next *ActiveSource\Parser\Modules()
Case #DEBUG_SortedIssues
SortParserData(@*ActiveSource\Parser) ; ensure it is up to date
Content$ = ""
*Item.SourceItem = *ActiveSource\Parser\SortedIssues
While *Item
Content$ + "Line=" + Str(*Item\SortedLine + 1) + ", Issue=" + *Item\Issue + ", Text=" + *Item\Name$ + #NewLine
*Item = *Item\NextSorted
Wend
Case #DEBUG_ProjectTokens
Content$ = ""
If IsProject
If ListSize(ProjectFiles()) > 0
ForEach ProjectFiles()
Content$ + " #####################################################" + #NewLine
Content$ + " " + ProjectFiles()\FileName$
If ProjectFiles()\Source
Content$ + " (loaded)" + #NewLine
*Parser.ParserData = @ProjectFiles()\Source\Parser
SortParserData(*Parser, ProjectFiles()\Source)
Else
Content$ + #NewLine
*Parser.ParserData = @ProjectFiles()\Parser
SortParserData(*Parser)
EndIf
Content$ + " #####################################################" + #NewLine
ForEach *Parser\Modules()
Content$ + #NewLine + "=================== Module: " + MapKey(*Parser\Modules()) + " =======================" + #NewLine
For Type = 0 To #ITEM_LastSorted
Select Type
Case #ITEM_Procedure : Title$ = "----- Procedures -----"
Case #ITEM_Macro : Title$ = "----- Macros -----"
Case #ITEM_Declare : Title$ = "----- Declares -----"
Case #ITEM_Structure : Title$ = "----- Structures -----"
Case #ITEM_Interface : Title$ = "----- Interfaces -----"
Case #ITEM_Prototype : Title$ = "----- Prototypes -----"
Case #ITEM_Constant : Title$ = "----- Constants -----"
Case #ITEM_Variable : Title$ = "----- Variables -----"
Case #ITEM_Array : Title$ = "----- Arrays -----"
Case #ITEM_LinkedList: Title$ = "----- LinkedLists -----"
Case #ITEM_Label : Title$ = "----- Labels -----"
Case #ITEM_Import : Title$ = "----- Imports -----"
Case #ITEM_Map : Title$ = "----- Maps -----"
Default : Title$ = "----- Unknown type -----"
EndSelect
First = #True
For Char = 0 To #PARSER_VTSize-1
*Item.SourceItem = *Parser\Modules()\Indexed[Type]\Bucket[Char]
While *Item
If First
Content$ + #NewLine + Title$ + #NewLine
First = #False
EndIf
If Char = 0
Content$ + "_ "
Else
Content$ + Chr(Char-1+'A') + " "
EndIf
Content$ + *Item\Name$ + " " + *Item\StringData$ + #NewLine
*Item = *Item\NextSorted
Wend
Next Char
Next Type
Next *Parser\Modules()
Next ProjectFiles()
Else
Content$ = "-- No project files --"
EndIf
Else
Content$ = "-- No current project --"
EndIf
Case #DEBUG_CompilerDialog ; DialogHirachy - OptionWindow
If IsWindow(#WINDOW_Option)
Content$ = DumpDialogHirachy(OptionWindowDialog, 0) ; the main object is directly the DlgWindow object
Else
Content$ = "-- Compiler Window not open --"
EndIf
Case #DEBUG_PreferencesDialog ; DialogHirachy - Preferences
If IsWindow(#WINDOW_Preferences)
Content$ = DumpDialogHirachy(PreferenceWindowDialog, 0) ; the main object is directly the DlgWindow object
Else
Content$ = "-- Preferences Window not open --"
EndIf
Case #DEBUG_FindDialog ; DialogHirachy - Find
If IsWindow(#WINDOW_Find)
Content$ = DumpDialogHirachy(FindWindowDialog, 0) ; the main object is directly the DlgWindow object
Else
Content$ = "-- Find Window not open --"
EndIf
Case #DEBUG_GrepDialog ; DialogHirachy - Grep
If IsWindow(#WINDOW_Grep)
Content$ = DumpDialogHirachy(GrepWindowDialog, 0) ; the main object is directly the DlgWindow object
Else
Content$ = "-- Grep Window not open --"
EndIf
Case #DEBUG_AddToolsDialog ; DialogHirachy - AddTools
If IsWindow(#WINDOW_AddTools)
Content$ = DumpDialogHirachy(AddToolsWindowDialog, 0) ; the main object is directly the DlgWindow object
Else
Content$ = "-- AddTools Window not open --"
EndIf
Case #DEBUG_EditToolsDialog ; DialogHirachy - EditTools
If IsWindow(#WINDOW_EditTools)
Content$ = DumpDialogHirachy(EditToolsWindowDialog, 0) ; the main object is directly the DlgWindow object
Else
Content$ = "-- EditTools Window not open --"
EndIf
Case #DEBUG_MemoryStats ; memory stats
CompilerIf #CompileWindows
Protected StringHeap, MemoryBase, MemoryHeap
; The needed !extrn are in WindowsDebugging.pb already.
CompilerIf #CompileX86
!mov eax, dword [_PB_StringHeap]
!mov [p.v_StringHeap], eax
!mov eax, dword [_PB_MemoryBase]
!mov [p.v_MemoryBase], eax
!mov eax, dword [_PB_Memory_Heap]
!mov [p.v_MemoryHeap], eax
CompilerElse
!mov rax, qword [PB_StringHeap]
!mov [p.v_StringHeap], rax
!mov rax, qword [_PB_MemoryBase]
!mov [p.v_MemoryBase], rax
!mov rax, qword [PB_Memory_Heap]
!mov [p.v_MemoryHeap], rax
CompilerEndIf
Content$ = "Process Heap:"+#NewLine+"------------------------------"+#NewLine
Content$ + HeapStats(GetProcessHeap_())+#NewLine+#NewLine
Content$ + "String Heap:"+#NewLine+"------------------------------"+#NewLine
Content$ + HeapStats(StringHeap)+#NewLine+#NewLine
Content$ + "MemoryBase Heap:"+#NewLine+"------------------------------"+#NewLine
Content$ + HeapStats(MemoryBase)+#NewLine+#NewLine
Content$ + "AllocateMemory Heap:"+#NewLine+"------------------------------"+#NewLine
Content$ + HeapStats(MemoryHeap)+#NewLine+#NewLine
Dim AllHeaps.i(100)
NumHeaps = GetProcessHeaps_(101, @AllHeaps())
Unknown = 1
For i = 0 To NumHeaps-1
If AllHeaps(i) <> StringHeap And AllHeaps(i) <> MemoryBase And AllHeaps(i) <> MemoryHeap And AllHeaps(i) <> GetProcessHeap_()
Content$ + "Unknown Heap #"+Str(Unknown)+#NewLine+"------------------------------"+#NewLine
Content$ + HeapStats(AllHeaps(i))+#NewLine+#NewLine
Unknown + 1
EndIf
Next i
CompilerElse
Content$ = "-- Windows only --"
CompilerEndIf
EndSelect
SetGadgetText(Debugging_Editor, Content$)
EndIf
ElseIf EventID = #PB_Event_SizeWindow
w = WindowWidth(#WINDOW_Debugging)
h = WindowHeight(#WINDOW_Debugging)
c = GetRequiredHeight(Debugging_Combo)
ResizeGadget(Debugging_Combo, 10, 10, w-180, c)
ResizeGadget(Debugging_Display, w-160, 10, 150, c)
ResizeGadget(Debugging_Editor, 10, c+20, w-20, h-c-30)
ElseIf EventID = #PB_Event_CloseWindow
CloseWindow(#WINDOW_Debugging)
EndIf
EndProcedure
Procedure OpenDebuggingWindow()
If IsWindow(#WINDOW_Debugging)
SetWindowforeground(#WINDOW_Debugging)
ElseIf OpenWindow(#WINDOW_Debugging, 0, 0, 600, 400, #ProductName$ + " - IDE Debugging", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Invisible)
Debugging_Combo = ComboBoxGadget(#PB_Any, 0, 0, 0, 0)
Debugging_Display = ButtonGadget(#PB_Any, 0, 0, 0, 0, "Display")
Debugging_Editor = EditorGadget(#PB_Any, 0, 0, 0, 0, #PB_Editor_ReadOnly)
AddGadgetItem(Debugging_Combo, -1, "SourceToken Array")
AddGadgetItem(Debugging_Combo, -1, "SourceToken Sorted Lists")
AddGadgetItem(Debugging_Combo, -1, "SourceToken Sorted Issues")
AddGadgetItem(Debugging_Combo, -1, "ProjectFiles SourceToken Sorted Lists")
AddGadgetItem(Debugging_Combo, -1, "DialogManager - Compiler Options")
AddGadgetItem(Debugging_Combo, -1, "DialogManager - Preferences")
AddGadgetItem(Debugging_Combo, -1, "DialogManager - Find")
AddGadgetItem(Debugging_Combo, -1, "DialogManager - Grep")
AddGadgetItem(Debugging_Combo, -1, "DialogManager - Config Tools")
AddGadgetItem(Debugging_Combo, -1, "DialogManager - Edit Tool")
AddGadgetItem(Debugging_Combo, -1, "DialogManager - Sort Sources")
AddGadgetItem(Debugging_Combo, -1, "Memory Stats (Windows Only)")
SetGadgetState(Debugging_Combo, 0)
CompilerIf #CompileWindows
SetGadgetFont(Debugging_Editor, GetStockObject_(#ANSI_FIXED_FONT))
CompilerEndIf
DebuggingWindowEvents(#PB_Event_SizeWindow)
HideWindow(#WINDOW_Debugging, 0)
EndIf
EndProcedure
CompilerEndIf