Project

General

Profile

Statistics
| Revision:

vdfsplat / AppSrc / cDebuggerEngine.pkg @ 63

History | View | Annotate | Download (30.8 KB)

1 7 wil
//TH-Header
2
//*****************************************************************************************
3
// Copyright (c)  2013 Antwise Solutions
4
// All rights reserved.
5
//
6
// $FileName    : cDebuggerEngine
7 28 wil
// $ProjectName : Splat ! Vdf Debugger
8 7 wil
// $Authors     : Wil van Antwerpen
9
// $Created     : 12.14.2013  23:42
10 8 wil
// $Type        : GPLv2
11 7 wil
//
12
// Contents:
13
//
14
//*****************************************************************************************
15
//TH-RevisionStart
16
//TH-RevisionEnd
17
18 20 wil
Use cIniFile.pkg
19
use VDFBase.pkg
20 8 wil
Use vdfdebug.pkg
21 20 wil
Use vWin32fh.pkg
22 7 wil
23 20 wil
Struct tBreakPoints
24
  Boolean  bEnabled
25
  String   sFileName
26
  UInteger iLine
27
  Boolean  bHasCondition
28
  String   sExpression
29 38 wil
  String   sLine
30 20 wil
End_Struct // tBreakPoints
31
32 8 wil
//
33
// This mixin makes sure that all of the components sync up to the
34
// correct debugger version by asking the main component what vdf
35
// version it is.
36
//
37
Class cDebugComponentMixin is a Mixin
38
39
  Procedure DetermineRuntimeVersion
40
    Integer iRuntimeVersion
41
    Handle  hoDebugger
42
43
    Get phoDebugger To hoDebugger
44
    If (hoDebugger) Begin
45
      Get piRuntimeVersion of hoDebugger To iRuntimeVersion
46
      Set piRuntimeVersion to iRuntimeVersion
47
    End
48 28 wil
  End_Procedure // DetermineRuntimeVersion
49 8 wil
50 28 wil
End_Class // cDebugComponentMixin
51 8 wil
52
53 28 wil
Class cCallStack is a cComCCallStack
54 8 wil
  Import_Class_Protocol cDebugComponentMixin
55
56
  Procedure Construct_Object
57 28 wil
    Forward Send Construct_Object
58 8 wil
59
    Send Construct_Object_Callback
60
  End_Procedure // Construct_Object
61
62
  //
63
  // Mechanism to have the ability to set normal properties for the object
64
  // in the parent object view.
65
  //
66
  Procedure Construct_Object_Callback
67 28 wil
    Handle hoParent
68 8 wil
    Handle hoSelf
69
70
    Move Self To hoSelf
71
    Set phoCallStack     To hoSelf
72
    Get phoCallStackHost To hoParent // parent object
73
    If (hoParent) Begin
74
      Send CreateObjectCallback of hoParent hoSelf
75
    End
76 28 wil
  End_Procedure // Construct_Object_Callback
77 8 wil
78
// None of the below is being used
79 28 wil
//
80 8 wil
//  Procedure Mouse_Click Integer iWindows Integer iPos
81
//    send info_box ("call stack"+trim(iWindows)*"("*trim(iPos))
82
//    Forward Send Mouse_Click iWindows iPos
83 28 wil
//  End_Procedure // Mouse_Click
84
//
85 8 wil
//  Procedure Mouse_Click2 Integer iWindows Integer iPos
86
//    Send info_box ("call TWO stack"+trim(iWindows)*"("*trim(iPos))
87
//    Forward Send Mouse_Click2 iWindows iPos
88 28 wil
//  End_Procedure // Mouse_Click
89
//
90
//  Procedure OnClick
91 8 wil
//    Send info_box ("call THREE stack")
92
//    //Forward Send Mouse_Click2 iWindows iPos
93 28 wil
//  End_Procedure // Mouse_Click
94
//
95 8 wil
//  Procedure Mouse_Down integer iWindowNumber integer iPosition
96
//    Send info_box ("call THREE stack")
97
//      forward send Mouse_Down iWindowNumber iPosition
98
//      //send DoSomething of oMyObject
99 28 wil
//  End_Procedure  // Mouse_Down
100
//
101 8 wil
//   Procedure OnComMessageClicked UInteger llcommandNo
102
//     Send info_box ("call four stack")
103 28 wil
//   End_Procedure
104 8 wil
105
   //Procedure RepaintCallStack
106
   //  Handle hWindow hVoid
107
   //  Get Window_Handle To hWindow
108
   //  If hWindow Move (InvalidateRect(hWindow,0,True)) To hVoid
109
   //End_Procedure // RepaintCallStack
110
111
//
112
// entering is being called, not yet found a way on getting the items in the list
113 28 wil
//
114 8 wil
  Procedure Entering Returns Integer
115 28 wil
    Integer Rval
116 8 wil
    Integer iItem
117
    Integer iCount
118
119
    Forward Get Msg_Entering To Rval  // Do Normal Entering
120
    // if entering is ok and single item check shadow state of that item.
121 28 wil
    If (Rval=0) Begin
122 8 wil
      Get Item_Count To iCount
123
      Get Current_Item To iItem
124
//      Showln ("entering stack "+trim(iCount)*"current"*trim(iItem))
125
      //  Get Shadow_State Item 0 To Rval
126 28 wil
    End
127 8 wil
    Procedure_Return Rval
128 28 wil
  End_Procedure
129 8 wil
130 28 wil
End_Class // cCallStack
131 8 wil
132
Class cMessageTrace is a cComCMessageTrace
133
  Import_Class_Protocol cDebugComponentMixin
134
135
  Procedure Construct_Object
136
    Forward Send Construct_Object
137
138
    Send Construct_Object_Callback
139
  End_Procedure // Construct_Object
140
141
142
  //
143
  // Mechanism to have the ability to set normal properties for the object
144
  // in the parent object view.
145
  //
146
  Procedure Construct_Object_Callback
147 28 wil
    Handle hoParent
148 8 wil
    Handle hoSelf
149
150
    Move Self To hoSelf
151
    Set phoTrace     To hoSelf
152
    Get phoTraceHost To hoParent // parent object
153
    If (hoParent) Begin
154
      Send CreateObjectCallback of hoParent hoSelf
155
    End
156 28 wil
  End_Procedure // Construct_Object_Callback
157 8 wil
158
159 28 wil
  Procedure OnComMessageClicked UInteger llcommandNo
160 8 wil
    Handle  hoDebugger
161 28 wil
    Handle  hoEditor
162 8 wil
    Integer iLine
163
    String  sFileName
164
165 28 wil
    //send info_box ("OnComMessageClicked "*trim(llcommandNo))
166 8 wil
    Get phoDebugger To hoDebugger
167
    Get phoEditor   To hoEditor
168
    If (hoDebugger and hoEditor and llcommandNo>0) Begin
169
      // Returns the source line from the specified command number
170 28 wil
      //
171 8 wil
      Get ComGetSourceLineFromCommand Of hoDebugger llcommandNo (&iLine) To sFileName
172 28 wil
      //Send ComOpenFile of oCodeMax sFileName
173
      ////Set ComLanguage    of oCodeMax To "VDF"
174 8 wil
      //Set ComReadOnly Of oCodeMax To True // NO changes allowed
175
      //Set ComColorSyntax of oCodeMax To True
176 28 wil
      //Send doSetCaptionLabel sFileName
177 8 wil
      Send doOpenSourceFileAtLine Of hoEditor sFileName iLine
178
      //If (iLine>10) Begin
179
      //  Move (iLine-4) To iLine // scroll up a bit
180 28 wil
      //End
181 8 wil
      //Send ComSetTopIndex of oCodeMax 0 iLine
182 28 wil
      //send info_box ("OnComMessageClicked "*trim(llline)*sFileName)
183
    End
184 8 wil
  End_Procedure
185
186 28 wil
End_Class // cMessageTrace
187 8 wil
188
Class cTablesWindow is a cComCTablesWindow
189
  Import_Class_Protocol cDebugComponentMixin
190
191
  Procedure Construct_Object
192
    Forward Send Construct_Object
193
194
    Send Construct_Object_Callback
195
  End_Procedure // Construct_Object
196
197
198
  //
199
  // Mechanism to have the ability to set normal properties for the object
200
  // in the parent object view.
201
  //
202
  Procedure Construct_Object_Callback
203 28 wil
    Handle hoParent
204 8 wil
    Handle hoSelf
205
206
    Move Self To hoSelf
207
    Set phoTablesWindow To hoSelf
208
    Get phoTablesHost   To hoParent // parent object
209
    If (hoParent) Begin
210
      Send CreateObjectCallback of hoParent hoSelf
211
    End
212 28 wil
  End_Procedure // Construct_Object_Callback
213 8 wil
214 28 wil
  Procedure OnComCmdAddWatch String llsExpression
215 8 wil
    Handle hoWatches
216
217
    Get phoWatches To hoWatches
218
    If (hoWatches) Begin
219
      Send ComAddWatch Of hoWatches llsExpression
220 28 wil
    End
221 8 wil
  End_Procedure // OnComCmdAddWatch
222 28 wil
End_Class // cTablesWindow
223 8 wil
224
Class cVariablesWindow is a cComCVariablesWindow
225
  Import_Class_Protocol cDebugComponentMixin
226
227
  Procedure Construct_Object
228
    Forward Send Construct_Object
229
  End_Procedure // Construct_Object
230
231 28 wil
  Procedure OnComCmdAddWatch String llsExpression
232 8 wil
    Handle hoWatches
233
234
    Get phoWatches To hoWatches
235
    If (hoWatches) Begin
236
      Send ComAddWatch Of hoWatches llsExpression
237 28 wil
    End
238 8 wil
  End_Procedure // OnComCmdAddWatch
239
240 28 wil
End_Class // cVariablesWindow
241 8 wil
242
243
Class cWatches is a cComCWatches
244
  Import_Class_Protocol cDebugComponentMixin
245
246
  Procedure Construct_Object
247 28 wil
    Forward Send Construct_Object
248 8 wil
249
    Send Construct_Object_Callback
250
  End_Procedure // Construct_Object
251
252
253
  //
254
  // Mechanism to have the ability to set normal properties for the object
255
  // in the parent object view.
256
  //
257
  Procedure Construct_Object_Callback
258 28 wil
    Handle hoParent
259 8 wil
    Handle hoSelf
260
261
    Move Self To hoSelf
262
    Set phoWatches     To hoSelf
263
    Get phoWatchesHost To hoParent // parent object
264
    If (hoParent) Begin
265
      Send CreateObjectCallback of hoParent hoSelf
266
    End
267 28 wil
  End_Procedure // Construct_Object_Callback
268 8 wil
269
270
End_Class // cWatches
271
272
273 7 wil
Class cDebuggerEngine is a cComCDebuggerEngine
274
  Procedure Construct_Object
275
    Forward Send Construct_Object
276 20 wil
    Property String         psApplicationFileName ""
277
    Property String         psIdeSrcPath          ""
278
    Property String         psBPFileName          "Splat-Breakpoints.ini"
279
    Property Boolean        pbEngineActive        False
280 7 wil
    Property Boolean pbProgramStarted      False
281
    Property Boolean pbProgramPaused       False
282 27 wil
    Property String[]       pAllMessages
283
    Property String[]       pAllProperties
284 20 wil
    Property tBreakPoints[] pBreakPoints
285 8 wil
286
    Set Name To "oDebuggerEngine"
287 7 wil
  End_Procedure // Construct_Object
288
289 8 wil
290
  Procedure DetermineRuntimeVersion
291 10 wil
    Integer iRuntime
292
293
    Get piDebugfileVersion to iRuntime
294
    Set piRuntimeVersion   to iRuntime
295 28 wil
  End_Procedure // DetermineRuntimeVersion
296 7 wil
297 20 wil
    // Hackish way to determine the IdeSrc folder
298
  Procedure LocateIdeSrcFolder String sApplication
299
    String  sIdeSrcPath
300
    String  sFolderName
301
    String  sWSPath
302
    Boolean bExists
303
304
    Move "" To sIdeSrcPath
305
    If (sApplication<>"") Begin
306
      Get ParseFolderName sApplication To sFolderName
307
      Get vParentPath sFolderName To sWSPath
308
      Get vFolderFormat sWSPath To sWSPath
309
      Move (sWSPath+"IdeSrc\") To sIdeSrcPath
310
      Get vFolderExists sIdeSrcPath To bExists
311
      If (bExists=false) Begin
312
        Move "" To sIdeSrcPath
313
        Send Info_Box ("Not able to find IdeSrc Path from folder:\n"+sFoldername+"Some features such as load/save breakpoints will not work.") "Info"
314
      End
315
    End
316
    Set psIdeSrcPath To sIdeSrcPath
317
  End_Procedure
318
319
  Procedure Set ApplicationFileName String sApplication
320
    Set psApplicationFileName To sApplication
321
    Send LocateIdeSrcFolder sApplication
322
  End_Procedure
323 27 wil
  //
324
  // Enumeraties the all messages array as it has all properties as well.
325
  // A property has 2 items in the array.
326
  // First a "get_<property name>"
327
  // followed up by a "set_<property name>"
328
  //
329
  // We simply create the array with "<property name>" based on what we find.
330
  //
331
  // All property names are in lower case (as is the message array)
332
  //
333
  Procedure getAllProperties
334
    Integer  iCount
335
    Integer  iMsg
336
    Integer  iProp
337
    String   sMessage
338
    String[] AllMessages
339
    String[] AllProperties
340 7 wil
341 27 wil
    Move 0 To iProp
342
    Move (ResizeArray(AllProperties,0)) To AllProperties
343
    Get pAllMessages to AllMessages
344
    Move (SizeOfArray(AllMessages)) To iCount
345
    Decrement iCount
346 42 wil
    For iMsg from 1 to iCount
347 27 wil
      if (iMsg<iCount) begin
348
        if (left(AllMessages[iMsg],4)="get_") Begin
349
          Move AllMessages[iMsg] To sMessage
350
          Move (replace("get_",sMessage,"set_")) To sMessage
351
          If (AllMessages[iMsg+1]=sMessage) Begin
352
            Move (replace("set_",sMessage,"")) To sMessage
353
            Move sMessage To AllProperties[iProp]
354
            Increment iProp
355
          End
356 42 wil
          Else If (AllMessages[iMsg-1]=sMessage) Begin
357
            Move (replace("set_",sMessage,"")) To sMessage
358
            Move sMessage To AllProperties[iProp]
359
            Increment iProp
360
          End
361 27 wil
        End
362
      End
363
    Loop
364 42 wil
    // Add functions safe to evaluate. we'll do this different later on.. now testing
365
    // and the idea works.. hmmm :D
366
    Move "selectedrow" to AllProperties[iProp]
367 27 wil
    Set pAllProperties to AllProperties
368
  End_Procedure
369
370
  Function IsVariableProperty String sVariable Returns Boolean
371
    Integer  iCount
372
    Integer  iProp
373
    Boolean  bIsProperty
374
    String[] AllProperties
375
376
    Move false to bisProperty
377
    Move (lowercase(sVariable)) To sVariable
378
    If (sVariable<>"") Begin
379
      Get pAllProperties to AllProperties
380
      Move (SizeOfArray(AllProperties)) To iCount
381
      Decrement iCount
382
      For iProp From 0 To iCount
383
        If (AllProperties[iProp]=sVariable) Begin
384
          Move True To bIsProperty
385
          Move iCount To iProp // stop
386
        End
387
      Loop
388
    End
389
    Function_Return bIsProperty
390
  End_function
391 20 wil
392 42 wil
  Function IsVariableProcedure String sVariable Returns Boolean
393
    Integer  iCount
394 43 wil
    Integer  iMethod
395 42 wil
    Boolean  bIsMethod
396
    String[] AllMessages
397
398
    Move false to bisMethod
399
    Move (lowercase(sVariable)) To sVariable
400
    If (sVariable<>"") Begin
401
      Move ("msg_"+sVariable) to sVariable
402
      Get pAllMessages to AllMessages
403
      Move (SizeOfArray(AllMessages)) To iCount
404
      Decrement iCount
405 43 wil
      For iMethod From 0 To iCount
406
        If (AllMessages[iMethod]=sVariable) Begin
407 42 wil
          Move True To bIsMethod
408 43 wil
          Move iCount To iMethod // stop
409 42 wil
        End
410
      Loop
411
    End
412
    Function_Return bIsMethod
413
  End_Function
414
415 20 wil
  //
416 43 wil
  // This will treat functions and properties both as function, so first
417
  // test if the variable isn't a property to exclude that.
418
  //
419
  Function IsVariableFunction String sVariable Returns Boolean
420
    Integer  iCount
421
    Integer  iMethod
422
    Boolean  bIsMethod
423
    String[] AllMessages
424
425
    Move false to bisMethod
426
    Move (lowercase(sVariable)) To sVariable
427
    If (sVariable<>"") Begin
428
      Move ("get_"+sVariable) to sVariable
429
      Get pAllMessages to AllMessages
430
      Move (SizeOfArray(AllMessages)) To iCount
431
      Decrement iCount
432
      For iMethod From 0 To iCount
433
        If (AllMessages[iMethod]=sVariable) Begin
434
          Move True To bIsMethod
435
          Move iCount To iMethod // stop
436
        End
437
      Loop
438
    End
439
    Function_Return bIsMethod
440
  End_Function
441
442
  Procedure UpdateBreakPointsGrid
443
    Handle  hoGrid
444
445
    Get phoBreakpointsGrid To hoGrid
446
    If (hoGrid) Begin
447
      Send LoadData Of hoGrid
448
    End
449
  End_Procedure
450
451
  //
452 20 wil
  // Tries to find the breakpoint in the array, returns -1 if not found
453
  //
454
  Function FindBreakPointinArray String sFile Uinteger iLine Returns integer
455
    Integer iPos
456
    Integer iBreak
457
    Integer iCount
458
    tBreakPoints[] BP
459
460
    Move -1 To iPos
461
    Get pBreakPoints To BP
462 28 wil
    Move (Lowercase(sFile)) To sFile
463 20 wil
    Move (SizeOfArray(BP)) To iCount
464
    For iBreak from 0 To (iCount-1)
465 28 wil
      If (lowercase(BP[iBreak].sFileName)=sFile and BP[iBreak].iLine=iLine) Begin
466 20 wil
        Move iBreak To iPos
467
        Move iCount To iBreak // stop
468
      End
469
    Loop
470
    Function_Return iPos
471
  End_Function
472 28 wil
473
474
  Procedure AddBreakPointToArray String sFile UInteger iLine
475
    Integer iCount
476
    Integer iBreak
477 38 wil
    String  sLine
478
    Handle  hoEditor
479 28 wil
    tBreakPoints[] BP
480
481
    Get FindBreakPointInArray sFile iLine To iBreak
482
    If (iBreak=-1) Begin
483
      Get pBreakPoints To BP
484
      Move (SizeOfArray(BP)) To iCount
485
      Move True   To BP[iCount].bEnabled
486
      Move sFile  To BP[iCount].sFileName
487
      Move iline  To BP[iCount].iLine
488
      Move false  To BP[iCount].bHasCondition
489 38 wil
490
      Get phoEditor To hoEditor
491
      If (hoEditor) begin
492
        Get ComGetLine of hoEditor iLine To sLine
493
        Move (Rtrim(sLine)) To sLine
494
        Move sLine To BP[iCount].sLine
495
      End
496 28 wil
      Set pBreakPoints To BP
497
    End
498
  End_Procedure
499 43 wil
500
501
  Procedure EnableBreakPoint String sFile UInteger iLine
502
    Integer iBreak
503
    Integer retVal
504
    tBreakPoints[] BP
505
506
    Get FindBreakPointInArray sFile iLine To iBreak
507
    If (iBreak<>-1) Begin
508
      Get pBreakPoints To BP
509
      If (BP[iBreak].bEnabled=false) Begin
510
        Move True   To BP[iBreak].bEnabled
511
        Get ComSetBreakPoint sFile iLine to retVal
512
513
        Set pBreakPoints To BP
514
515
        Send UpdateBreakPointsGrid
516
      End
517
    End
518
  End_Procedure
519
520
521
  Procedure DisableBreakPoint String sFile UInteger iLine
522
    Integer retVal
523
    Integer iBreak
524
    tBreakPoints[] BP
525
526
    Get FindBreakPointInArray sFile iLine To iBreak
527
    If (iBreak<>-1) Begin
528
      Get pBreakPoints To BP
529
      If (BP[iBreak].bEnabled) Begin
530
        Move False   To BP[iBreak].bEnabled
531
        Get ComRemoveBreakPoint sFile iLine to retVal
532
        Set pBreakPoints To BP
533
534
        Send UpdateBreakPointsGrid
535
      End
536
    End
537
  End_Procedure
538 20 wil
539
  Procedure RemoveBreakPointFromArray integer iPos
540
    Integer iCount
541
    tBreakPoints[] BP
542
543
    If (iPos>-1) Begin
544
      Get pBreakPoints To BP
545
      Move (SizeOfArray(BP)) To iCount
546
      If (iPos<iCount) Begin
547
        Move (RemoveFromArray(BP,iPos)) To BP
548
        Set pBreakPoints To BP
549
      End
550
    End
551
  End_Procedure
552
553
554
  // Sets the specified breakpoint
555
  Function SetBreakPoint String llfile UInteger ByRef llline Returns Boolean
556
    Boolean retVal
557 43 wil
    Integer iLine
558 20 wil
559 43 wil
    Move llline To iLine
560 20 wil
    Get ComSetBreakPoint llfile (&llline) to retVal
561
    If (retVal) Begin
562 43 wil
      Send AddBreakPointToArray llfile iLine
563
564
      Send UpdateBreakPointsGrid
565 20 wil
    End
566
    Function_Return retVal
567
  End_Function
568
569
  // Removes the specified breakpoint
570
  Function RemoveBreakPoint String llfile UInteger llline Returns Boolean
571
    Integer iPos
572
    Boolean retVal
573
574
    Get ComRemoveBreakPoint llfile llline to retVal
575
    If (retVal) Begin
576
      Get FindBreakPointInArray llfile llline To iPos
577
      Send RemoveBreakPointFromArray iPos
578 43 wil
579
      Send UpdateBreakPointsGrid
580 20 wil
    End
581
    Function_Return retVal
582
  End_Function
583
584
585
  // Introduced in vdf15.0
586
  // Sets the specified conditional breakpoint expression
587
  Function SetBreakPointCondition String llfile UInteger ByRef llline String llexpr Returns Boolean
588
    Boolean retVal
589
590
    Get ComSetBreakPointCondition llfile (&llline) llexpr to retVal
591
    If (retVal) Begin
592
    End
593
    Function_Return retVal
594
  End_Function
595 38 wil
596
  //
597
  // Loads the breakpoints from the array that got loaded from a disk file.
598
  //
599 20 wil
  Procedure SetBreakPointsFromArray
600
    Integer  iBreak
601
    Integer  iCount
602
    String   sFileName
603
    UInteger iLine
604
    Boolean  retVal
605
    Boolean  bEnabled
606
    Boolean  bIsValid
607
    tBreakPoints[] BP
608
609
    Get pBreakPoints To BP
610
    Move (SizeOfArray(BP)) To iCount
611
    For iBreak from 0 To (iCount-1)
612
      Move BP[iBreak].bEnabled  To bEnabled
613
      If (bEnabled) Begin
614
        Move BP[iBreak].sFileName To sFileName
615
        Move BP[iBreak].iLine     To iLine
616
        Get ComIsValidSourceFile sFileName To bIsValid
617
        If (bIsValid) Begin
618
          Get ComSetBreakPoint sFileName (&iLine) to retVal
619
        End
620
      End
621
    Loop
622
  End_Procedure // SetBreakPointsFromArray
623
624 37 wil
  Function HasBreakPoints Returns Boolean
625
    Integer  iCount
626
    Boolean  bHasBreakPoints
627
    tBreakPoints[] BP
628
629
    Get pBreakPoints To BP
630
    Move (SizeOfArray(BP)) To iCount
631
    If (iCount>0) Move True To bHasBreakPoints
632
    Else Move False To bHasBreakPoints
633
    Function_Return bHasBreakPoints
634
  End_Function
635
636 20 wil
  Procedure LoadBreakPointsFromDisk
637
    Boolean bExists
638
    Integer iVoid
639
    Integer iPos
640
    Integer iBreak
641
    Integer iCount
642
    String  sPath
643
    String  sBPFile
644
    String  sSection
645
    String  sKey
646
    String  sValue
647
    Handle  hoSections
648
    Handle  hoIni
649
    tBreakPoints[] BP
650
651
    Get psIdeSrcPath To sPath
652
    If (sPath<>"") Begin     // Only try to save if we could find a matching IdeSrc path
653
      Get psBPFileName To sBPFile
654
      Get vFolderFormat sPath To sPath
655
      Move (sPath+sBPFile) to sBPFile
656
657
      Get Create (RefClass(cIniFile)) To hoIni
658
      If (hoIni) Begin
659
        Set psFileName of hoIni To sBPFile
660
        Get Create (RefClass(Array)) To hoSections
661
        If (hoSections) Begin
662
          Send ReadSections of hoIni hoSections
663
          Get Item_Count of hoSections To iCount
664
          For iBreak from 0 To (iCount-1)
665
            Get Value of hoSections Item iBreak To sSection
666
            //Move ("Breakpoint"+trim(iBreak)) To sSection
667
            Get ReadString of hoIni sSection "Enabled"      "0" To BP[iBreak].bEnabled
668
            Get ReadString of hoIni sSection "FileName"     ""  To BP[iBreak].sFileName
669
            Get ReadString of hoIni sSection "Line"         "0" To BP[iBreak].iLine
670 38 wil
            Get ReadString of hoIni sSection "Source"       ""  To BP[iBreak].sLine
671 20 wil
            Get ReadString of hoIni sSection "HasCondition" "0" To BP[iBreak].bHasCondition
672
            Get ReadString of hoIni sSection "Expression"   ""  To BP[iBreak].sExpression
673
          Loop
674
          Send Destroy of hoSections
675
        End
676
677
        Send Destroy of hoIni
678
      End
679
      Set pBreakPoints To BP
680
      Send SetBreakPointsFromArray
681
//      Move (SizeOfArray(BP)) To iCount
682
    End
683
  End_Procedure
684
685
  Procedure SaveBreakPointsToDisk
686
    Boolean bExists
687
    Integer iVoid
688
    Integer iPos
689
    Integer iBreak
690
    Integer iCount
691
    String  sPath
692
    String  sBPFile
693
    String  sSection
694
    String  sKey
695
    String  sValue
696
    Handle  hoIni
697
    tBreakPoints[] BP
698
699
    Get psIdeSrcPath To sPath
700
    If (sPath<>"") Begin     // Only try to save if we could find a matching IdeSrc path
701
      Get psBPFileName To sBPFile
702
      Get vFolderFormat sPath To sPath
703
      Move (sPath+sBPFile) to sBPFile
704
      // If it exists already, then delete it.
705
      Get vFilePathExists sBPFile To bExists
706
      If (bExists) Begin
707
        Get vDeleteFile sBPFile To iVoid
708
      End
709
      Get Create (RefClass(cIniFile)) To hoIni
710
      If (hoIni) Begin
711
        Set psFileName of hoIni To sBPFile
712
713
714
        Get pBreakPoints To BP
715
        Move (SizeOfArray(BP)) To iCount
716
        For iBreak from 0 To (iCount-1)
717
          Move ("Breakpoint"+trim(iBreak)) To sSection
718
          Send WriteString of hoIni sSection "Enabled"      BP[iBreak].bEnabled
719
          Send WriteString of hoIni sSection "FileName"     BP[iBreak].sFileName
720
          Send WriteString of hoIni sSection "Line"         BP[iBreak].iLine
721 38 wil
          Send WriteString of hoIni sSection "Source"       BP[iBreak].sLine
722 20 wil
          Send WriteString of hoIni sSection "HasCondition" BP[iBreak].bHasCondition
723
          Send WriteString of hoIni sSection "Expression"   BP[iBreak].sExpression
724
        Loop
725
726
        Send Destroy of hoIni
727 37 wil
728
        // ToDo: Remove
729 38 wil
        //Send info_Box "saved breakpoints"
730 20 wil
      End
731
    End
732
  End_Procedure
733
734
  // Introduced in vdf15.0
735
  // Occurs if there was an error evaluating a conditional breakpoint
736
  Procedure OnComBreakPointError String lltext
737
    Send Info_Box lltext "VdfSplat Info Error on conditional breakpoint"
738
  End_Procedure
739
740
741 7 wil
  // Occurs after program has been successfully initialized
742
  Procedure OnComProgramInit
743 27 wil
    String[] AllMessages
744 7 wil
    Set pbProgramStarted To True
745
    Set pbProgramPaused  To False
746 27 wil
747
    Get ComGetAllMessages To AllMessages
748
    Set pAllMessages To AllMessages
749
    Send GetAllProperties
750 20 wil
    Send LoadBreakPointsFromDisk
751 7 wil
  End_Procedure
752
753
  // Occurs after the program exits
754
  Procedure OnComProgramExit
755 38 wil
    Boolean  bStartedFromCLI
756 27 wil
    String[] AllMessages
757
    String[] AllProperties
758 7 wil
    Set pbProgramStarted To False
759
    Set pbProgramPaused  To False
760 20 wil
    Send SaveBreakPointsToDisk
761 23 wil
    Set ApplicationFileName To ""
762 27 wil
    Move (ResizeArray(Allmessages,0))   To AllMessages
763
    Move (ResizeArray(AllProperties,0)) To AllProperties
764
    Set pAllMessages   to AllMessages
765
    Set pAllProperties to AllProperties
766 38 wil
    Get pbStartedFromCLI of ghoApplication To bStartedFromCLI
767
    If (bStartedFromCli) Begin
768
      // debug session was started from the command line.
769
      // Stopping the debug session normally should stop the debugger as well.
770
      Send Exit_Application
771
    End
772 7 wil
  End_Procedure
773
774
  // Occurs if there is an error starting the program
775
  Procedure OnComProgramStartupError String llerrorMessage
776
    Set pbProgramStarted To False
777
    Send Info_Box llerrorMessage "start up error"
778
  End_Procedure
779
780
  // Occurs if there is an error initializing the program
781
  Procedure OnComProgramInitError String llerrorMessage
782
    Set pbProgramStarted To False
783
    Send Info_Box (llErrorMessage) "Custom Error INIT"
784
  End_Procedure
785
786 20 wil
  Procedure SetDebuggerAsForegroundApp
787
    Handle  hoEditor
788
    Handle  hWnd
789
    Integer iVoid
790
    Get phoEditor To hoEditor
791
    If (hoEditor) Begin
792
      Get Window_Handle of hoEditor To hWnd
793
      If (hWnd) Begin
794
        Move (SetForegroundWindow(hWnd)) To iVoid
795
      End
796
    End
797
  End_Procedure // SetDebuggerAsForegroundApp
798
799 7 wil
  //
800
  // Hook to be used
801
  // Called from OnComProgramPaused
802
  //
803 8 wil
  // Occurs when the program execution is paused
804 28 wil
  Procedure OnProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
805 20 wil
    Handle hoEditor
806
    String sBreakMode
807 8 wil
808
    Get phoEditor   To hoEditor
809
    If (hoEditor) Begin
810 20 wil
      If lllimitedBreakMode Begin
811
        Move "limited Break mode" To sBreakMode
812
        //Else Move "Unlimited Break mode" to sBreakMode
813
        Send info_Box ("Pausing program\n"+sBreakMode) "VdfSplat Info"
814
      End
815
      Else Begin
816
        Send SetDebuggerAsForegroundApp
817
      End
818
      Send doOpenSourceFileAtLine of hoEditor llfile llline
819 8 wil
      Send doActivateCallStack  // only displays if exists or not.
820
    End
821 7 wil
  End_Procedure
822
823
  //
824
  // Occurs when the program execution is paused
825 28 wil
  Procedure OnComProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
826 7 wil
    Set pbProgramPaused  To True
827
    Send OnProgramPaused llfile llline lllimitedBreakMode
828
  End_Procedure
829
830
  // Occurs when the program execution resumes
831
  Procedure OnComProgramContinue
832
    Set pbProgramPaused  To False
833
  End_Procedure
834
835
  // Occurs after a change requiring views to be refreshed
836
  Procedure OnUpdateView String sFileName UInteger iLine
837 8 wil
    Handle hoEditor
838
839
    Get phoEditor To hoEditor
840
    If (hoEditor) begin
841
      //Send Info_Box "OnComUpdateView" (llfile*"llline = "*trim(llline))
842
      Send doOpenSourceFileAtLine of hoEditor sFileName iLine
843 28 wil
    End
844 7 wil
  End_Procedure
845
846
  // Occurs after a change requiring views to be refreshed
847
  Procedure OnComUpdateView String sFileName UInteger iLine
848
    Send OnUpdateView sFileName iLine
849
  End_Procedure
850
851
  // Occurs when a new message is executed
852
  Procedure OnComNewMessage Integer llbSteppin
853
  End_Procedure
854
855
  // Occurs if an unhandled program exception is detected
856
  Procedure OnComUnhandledProgramException String lldescription
857
    Send Info_box lldescription "FATAL Error"
858
  End_Procedure
859
860
  // Occurs if there is an incoming request for another web app session. You can abandon the current session and switch to the new session or deny the new session and continue debugging the current session
861
  Procedure OnComAcceptWebAppSession Boolean ByRef llacceptNewSession
862
  End_Procedure
863
864
  // Occurs if there is a fatal web app error
865 28 wil
  Procedure OnComWebAppError String lldescription
866 7 wil
    Send Info_box lldescription "WebApp FATAL Error"
867
  End_Procedure
868
869
  // Occurs when a new webapp event log entry is added
870
  Procedure OnComWebAppLog Integer lleventId String lltext
871
    //Send Info_box lldescription "WebApp FATAL Error"
872
    Showln lleventid lltext
873 28 wil
  End_Procedure
874 8 wil
875 7 wil
876 8 wil
  Procedure doCreateCallStack
877
    Handle  hoParent
878
    Handle  hoCallStack
879
    Boolean bCreated
880
881
    Get phoCallStackHost To hoParent
882
    If (hoParent) Begin
883
      Get Create Of hoParent U_cCallStack To hoCallStack
884
      If (hoCallStack) Begin
885
        Set Name               Of hoCallStack To "oCallStack"
886
        Send CreateComObject   Of hoCallStack
887
        Get IsComObjectCreated Of hoCallStack To bCreated
888 28 wil
        If (bCreated) Begin
889 37 wil
          Send SetControlColumnWidth of hoCallStack hoCallStack
890 8 wil
        End
891
      End
892
    End
893 28 wil
  End_Procedure // doCreateCallStack
894 8 wil
895
896
  Procedure doCreateWatches
897
    Handle  hoParent
898
    Handle  hoWatches
899
    Boolean bCreated
900
901
    Get phoWatchesHost To hoParent
902
    If (hoParent) Begin
903
      Get Create Of hoParent U_cWatches To hoWatches
904
      If (hoWatches) Begin
905
        Set Name               Of hoWatches To "oWatches"
906
        Send CreateComObject   Of hoWatches
907
        Get IsComObjectCreated Of hoWatches To bCreated
908 28 wil
        If (bCreated) Begin
909 8 wil
        End
910
      End
911
    End
912 28 wil
  End_Procedure // doCreateWatches
913 8 wil
914
915
  Procedure doCreateMessageTrace
916
    Handle  hoParent
917
    Handle  hoTrace
918
    Boolean bCreated
919
920
    Get phoTraceHost To hoParent
921
    If (hoParent) Begin
922
      Get Create Of hoParent U_cMessageTrace To hoTrace
923
      If (hoTrace) Begin
924
        Set Name               Of hoTrace To "oMessageTrace"
925
        Send CreateComObject   Of hoTrace
926
        Get IsComObjectCreated Of hoTrace To bCreated
927 28 wil
        If (bCreated) Begin
928 8 wil
        End
929
      End
930
    End
931
  End_Procedure // doCreateMessageTrace
932
933
934
  Procedure doCreateGlobalVariables
935
    Handle  hoParent
936
    Handle  hoVariables
937
    Boolean bCreated
938
939
    Get phoGlobalVarHost To hoParent
940
    If (hoParent) Begin
941
      Get Create Of hoParent U_cVariablesWindow To hoVariables
942
      If (hoVariables) Begin
943
        Set phoGlobalVariables To hoVariables
944
        Set Name               Of hoVariables To "oGlobalVariables"
945
        Send CreateObjectCallback of hoParent hoVariables
946
947
        Send CreateComObject   Of hoVariables
948
        Get IsComObjectCreated Of hoVariables To bCreated
949 28 wil
        If (bCreated) Begin
950
          Set ComWindowType Of hoVariables To 1 // global
951 8 wil
        End
952
      End
953
    End
954 28 wil
  End_Procedure // doCreateGlobalVariables
955 8 wil
956
957
  Procedure doCreateLocalVariables
958
    Handle  hoParent
959
    Handle  hoVariables
960
    Boolean bCreated
961
962
    Get phoLocalVarHost To hoParent
963
    If (hoParent) Begin
964
      Get Create Of hoParent U_cVariablesWindow To hoVariables
965
      If (hoVariables) Begin
966
        Set phoLocalVariables  To hoVariables
967
        Set Name               Of hoVariables To "oLocalVariables"
968
        Send CreateObjectCallback of hoParent hoVariables
969
970
        Send CreateComObject   Of hoVariables
971
        Get IsComObjectCreated Of hoVariables To bCreated
972 28 wil
        If (bCreated) Begin
973 8 wil
          Set ComWindowType Of hoVariables To 0 // locals
974
        End
975
      End
976
    End
977 28 wil
  End_Procedure // doCreateLocalVariables
978 8 wil
979
980
  Procedure doCreateTablesWindow
981
    Handle  hoParent
982
    Handle  hoTables
983
    Boolean bCreated
984
985
    Get phoTablesHost To hoParent
986
    If (hoParent) Begin
987
      Get Create Of hoParent U_cTablesWindow To hoTables
988
      If (hoTables) Begin
989
        Set Name               Of hoTables To "oTablesWindow"
990
        Send CreateComObject   Of hoTables
991
        Get IsComObjectCreated Of hoTables To bCreated
992 28 wil
        If (bCreated) Begin
993 8 wil
        End
994
      End
995
    End
996
  End_Procedure // doCreateTables
997
998
999
1000
  Procedure doActivateCallStack
1001
    Handle  hoCallStack
1002
    Boolean bCreated
1003
1004
    Get phoCallStack To hoCallStack
1005
    If (hoCallStack) Begin
1006
      Get IsComObjectCreated Of hoCallStack To bCreated
1007 28 wil
      If (bCreated) Begin
1008 8 wil
        Send Activate of hoCallStack  // we MUST send activate to the callstack to make it display itself
1009
      End
1010
    End
1011 28 wil
  End_Procedure // doActivateCallStack
1012 8 wil
1013
1014
1015
  Procedure DoCreateEngine
1016 28 wil
    Boolean bCreated
1017 8 wil
    Handle  hoDebugger
1018
    Handle  hoEditor
1019
1020 28 wil
    Send CreateComObject
1021
    Get IsComObjectCreated to bCreated
1022
    If (bCreated) Begin
1023 8 wil
1024
      Move Self To hoDebugger
1025
      Set pbEngineActive To True
1026
      Set phoDebugger to hoDebugger
1027 28 wil
    End
1028 8 wil
1029
    Send DoCreateCallStack
1030
1031
    Send DoCreateWatches
1032
1033
    Send DoCreateMessageTrace
1034
1035
    Send DoCreateGlobalVariables
1036
1037
    Send doCreateLocalVariables
1038
1039 28 wil
    Send doCreateTablesWindow
1040
  End_Procedure // DoCreateEngine
1041 8 wil
1042
1043 7 wil
  Procedure OnCreate
1044
    forward Send OnCreate
1045 28 wil
  End_Procedure // OnCreate
1046 7 wil
1047
1048 28 wil
End_Class // cDebuggerEngine