Project

General

Profile

Statistics
| Revision:

vdfsplat / AppSrc / cDebuggerEngine.pkg @ 58

History | View | Annotate | Download (30.8 KB)

1
//TH-Header
2
//*****************************************************************************************
3
// Copyright (c)  2013 Antwise Solutions
4
// All rights reserved.
5
//
6
// $FileName    : cDebuggerEngine
7
// $ProjectName : Splat ! Vdf Debugger
8
// $Authors     : Wil van Antwerpen
9
// $Created     : 12.14.2013  23:42
10
// $Type        : GPLv2
11
//
12
// Contents:
13
//
14
//*****************************************************************************************
15
//TH-RevisionStart
16
//TH-RevisionEnd
17

    
18
Use cIniFile.pkg
19
use VDFBase.pkg
20
Use vdfdebug.pkg
21
Use vWin32fh.pkg
22

    
23
Struct tBreakPoints
24
  Boolean  bEnabled
25
  String   sFileName
26
  UInteger iLine
27
  Boolean  bHasCondition
28
  String   sExpression
29
  String   sLine
30
End_Struct // tBreakPoints
31

    
32
//
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
  End_Procedure // DetermineRuntimeVersion
49
  
50
End_Class // cDebugComponentMixin
51

    
52

    
53
Class cCallStack is a cComCCallStack
54
  Import_Class_Protocol cDebugComponentMixin
55
  
56
  Procedure Construct_Object
57
    Forward Send Construct_Object
58
    
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
    Handle hoParent
68
    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
  End_Procedure // Construct_Object_Callback
77

    
78
// None of the below is being used
79
//
80
//  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
//  End_Procedure // Mouse_Click
84
//
85
//  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
//  End_Procedure // Mouse_Click
89
//
90
//  Procedure OnClick
91
//    Send info_box ("call THREE stack")
92
//    //Forward Send Mouse_Click2 iWindows iPos
93
//  End_Procedure // Mouse_Click
94
//
95
//  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
//  End_Procedure  // Mouse_Down
100
//
101
//   Procedure OnComMessageClicked UInteger llcommandNo
102
//     Send info_box ("call four stack")
103
//   End_Procedure
104
  
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
//
114
  Procedure Entering Returns Integer
115
    Integer Rval
116
    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
    If (Rval=0) Begin
122
      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
    End
127
    Procedure_Return Rval
128
  End_Procedure
129
  
130
End_Class // cCallStack
131

    
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
    Handle hoParent
148
    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
  End_Procedure // Construct_Object_Callback
157

    
158
        
159
  Procedure OnComMessageClicked UInteger llcommandNo
160
    Handle  hoDebugger
161
    Handle  hoEditor
162
    Integer iLine
163
    String  sFileName
164
    
165
    //send info_box ("OnComMessageClicked "*trim(llcommandNo))
166
    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
      //
171
      Get ComGetSourceLineFromCommand Of hoDebugger llcommandNo (&iLine) To sFileName
172
      //Send ComOpenFile of oCodeMax sFileName
173
      ////Set ComLanguage    of oCodeMax To "VDF"
174
      //Set ComReadOnly Of oCodeMax To True // NO changes allowed
175
      //Set ComColorSyntax of oCodeMax To True
176
      //Send doSetCaptionLabel sFileName
177
      Send doOpenSourceFileAtLine Of hoEditor sFileName iLine
178
      //If (iLine>10) Begin
179
      //  Move (iLine-4) To iLine // scroll up a bit
180
      //End
181
      //Send ComSetTopIndex of oCodeMax 0 iLine
182
      //send info_box ("OnComMessageClicked "*trim(llline)*sFileName)
183
    End
184
  End_Procedure
185
  
186
End_Class // cMessageTrace
187

    
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
    Handle hoParent
204
    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
  End_Procedure // Construct_Object_Callback
213
  
214
  Procedure OnComCmdAddWatch String llsExpression
215
    Handle hoWatches
216
    
217
    Get phoWatches To hoWatches
218
    If (hoWatches) Begin
219
      Send ComAddWatch Of hoWatches llsExpression
220
    End
221
  End_Procedure // OnComCmdAddWatch
222
End_Class // cTablesWindow
223

    
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
  Procedure OnComCmdAddWatch String llsExpression
232
    Handle hoWatches
233
    
234
    Get phoWatches To hoWatches
235
    If (hoWatches) Begin
236
      Send ComAddWatch Of hoWatches llsExpression
237
    End
238
  End_Procedure // OnComCmdAddWatch
239
  
240
End_Class // cVariablesWindow
241

    
242

    
243
Class cWatches is a cComCWatches
244
  Import_Class_Protocol cDebugComponentMixin
245

    
246
  Procedure Construct_Object
247
    Forward Send Construct_Object
248
    
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
    Handle hoParent
259
    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
  End_Procedure // Construct_Object_Callback
268

    
269

    
270
End_Class // cWatches
271

    
272

    
273
Class cDebuggerEngine is a cComCDebuggerEngine
274
  Procedure Construct_Object
275
    Forward Send Construct_Object
276
    Property String         psApplicationFileName ""
277
    Property String         psIdeSrcPath          ""
278
    Property String         psBPFileName          "Splat-Breakpoints.ini"
279
    Property Boolean        pbEngineActive        False
280
    Property Boolean pbProgramStarted      False
281
    Property Boolean pbProgramPaused       False
282
    Property String[]       pAllMessages
283
    Property String[]       pAllProperties
284
    Property tBreakPoints[] pBreakPoints
285
    
286
    Set Name To "oDebuggerEngine"
287
  End_Procedure // Construct_Object
288

    
289
  
290
  Procedure DetermineRuntimeVersion
291
    Integer iRuntime
292
    
293
    Get piDebugfileVersion to iRuntime
294
    Set piRuntimeVersion   to iRuntime
295
  End_Procedure // DetermineRuntimeVersion
296

    
297
    // 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
  //
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

    
341
    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
    For iMsg from 1 to iCount
347
      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
          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
        End
362
      End
363
    Loop
364
    // 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
    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
  
392
  Function IsVariableProcedure String sVariable Returns Boolean
393
    Integer  iCount
394
    Integer  iMethod
395
    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
      For iMethod From 0 To iCount
406
        If (AllMessages[iMethod]=sVariable) Begin
407
          Move True To bIsMethod
408
          Move iCount To iMethod // stop
409
        End
410
      Loop
411
    End
412
    Function_Return bIsMethod
413
  End_Function
414
  
415
  //
416
  // 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
  // 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
    Move (Lowercase(sFile)) To sFile
463
    Move (SizeOfArray(BP)) To iCount
464
    For iBreak from 0 To (iCount-1)
465
      If (lowercase(BP[iBreak].sFileName)=sFile and BP[iBreak].iLine=iLine) Begin
466
        Move iBreak To iPos
467
        Move iCount To iBreak // stop
468
      End
469
    Loop
470
    Function_Return iPos
471
  End_Function
472

    
473

    
474
  Procedure AddBreakPointToArray String sFile UInteger iLine
475
    Integer iCount
476
    Integer iBreak
477
    String  sLine
478
    Handle  hoEditor
479
    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
      
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
      Set pBreakPoints To BP
497
    End
498
  End_Procedure
499

    
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
  
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
    Integer iLine
558
    
559
    Move llline To iLine
560
    Get ComSetBreakPoint llfile (&llline) to retVal
561
    If (retVal) Begin
562
      Send AddBreakPointToArray llfile iLine
563
      
564
      Send UpdateBreakPointsGrid
565
    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
      
579
      Send UpdateBreakPointsGrid
580
    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
  
596
  //
597
  // Loads the breakpoints from the array that got loaded from a disk file.
598
  //
599
  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
  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
  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
            Get ReadString of hoIni sSection "Source"       ""  To BP[iBreak].sLine
671
            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
          Send WriteString of hoIni sSection "Source"       BP[iBreak].sLine
722
          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
        
728
        // ToDo: Remove
729
        //Send info_Box "saved breakpoints"
730
      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
  // Occurs after program has been successfully initialized
742
  Procedure OnComProgramInit
743
    String[] AllMessages
744
    Set pbProgramStarted To True
745
    Set pbProgramPaused  To False
746

    
747
    Get ComGetAllMessages To AllMessages
748
    Set pAllMessages To AllMessages
749
    Send GetAllProperties
750
    Send LoadBreakPointsFromDisk
751
  End_Procedure
752

    
753
  // Occurs after the program exits
754
  Procedure OnComProgramExit
755
    Boolean  bStartedFromCLI
756
    String[] AllMessages
757
    String[] AllProperties
758
    Set pbProgramStarted To False
759
    Set pbProgramPaused  To False
760
    Send SaveBreakPointsToDisk
761
    Set ApplicationFileName To ""
762
    Move (ResizeArray(Allmessages,0))   To AllMessages
763
    Move (ResizeArray(AllProperties,0)) To AllProperties
764
    Set pAllMessages   to AllMessages
765
    Set pAllProperties to AllProperties
766
    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
  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
  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
  //
800
  // Hook to be used
801
  // Called from OnComProgramPaused
802
  //
803
  // Occurs when the program execution is paused
804
  Procedure OnProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
805
    Handle hoEditor
806
    String sBreakMode
807
    
808
    Get phoEditor   To hoEditor
809
    If (hoEditor) Begin
810
      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
      Send doActivateCallStack  // only displays if exists or not.
820
    End
821
  End_Procedure
822
  
823
  //
824
  // Occurs when the program execution is paused
825
  Procedure OnComProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
826
    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
    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
    End
844
  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
  Procedure OnComWebAppError String lldescription
866
    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
  End_Procedure
874

    
875
  
876
  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
        If (bCreated) Begin
889
          Send SetControlColumnWidth of hoCallStack hoCallStack
890
        End
891
      End
892
    End
893
  End_Procedure // doCreateCallStack
894

    
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
        If (bCreated) Begin
909
        End
910
      End
911
    End
912
  End_Procedure // doCreateWatches
913

    
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
        If (bCreated) Begin
928
        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
        If (bCreated) Begin
950
          Set ComWindowType Of hoVariables To 1 // global
951
        End
952
      End
953
    End
954
  End_Procedure // doCreateGlobalVariables
955

    
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
        If (bCreated) Begin
973
          Set ComWindowType Of hoVariables To 0 // locals
974
        End
975
      End
976
    End
977
  End_Procedure // doCreateLocalVariables
978

    
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
        If (bCreated) Begin
993
        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
      If (bCreated) Begin
1008
        Send Activate of hoCallStack  // we MUST send activate to the callstack to make it display itself
1009
      End
1010
    End
1011
  End_Procedure // doActivateCallStack
1012

    
1013

    
1014
  
1015
  Procedure DoCreateEngine
1016
    Boolean bCreated
1017
    Handle  hoDebugger
1018
    Handle  hoEditor
1019
    
1020
    Send CreateComObject
1021
    Get IsComObjectCreated to bCreated
1022
    If (bCreated) Begin
1023

    
1024
      Move Self To hoDebugger
1025
      Set pbEngineActive To True
1026
      Set phoDebugger to hoDebugger
1027
    End
1028

    
1029
    Send DoCreateCallStack
1030
    
1031
    Send DoCreateWatches
1032
    
1033
    Send DoCreateMessageTrace
1034
    
1035
    Send DoCreateGlobalVariables
1036
    
1037
    Send doCreateLocalVariables
1038
    
1039
    Send doCreateTablesWindow
1040
  End_Procedure // DoCreateEngine
1041

    
1042
  
1043
  Procedure OnCreate
1044
    forward Send OnCreate
1045
  End_Procedure // OnCreate
1046
  
1047
  
1048
End_Class // cDebuggerEngine