Project

General

Profile

Statistics
| Revision:

vdfsplat / AppSrc / cDebuggerEngine.pkg @ 72

History | View | Annotate | Download (33.7 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 Boolean pbLimitedBreakMode    False
283
    Property Boolean pbDebugRestart        False
284
    Property String[]       pAllMessages
285
    Property String[]       pAllProperties
286
    Property String[]       pLanguageKeywords
287
    Property tBreakPoints[] pBreakPoints
288
    
289
    Set Name To "oDebuggerEngine"
290
  End_Procedure // Construct_Object
291

    
292
  
293
  Procedure DetermineRuntimeVersion
294
    Integer iRuntime
295
    
296
    Get piDebugfileVersion to iRuntime
297
    Set piRuntimeVersion   to iRuntime
298
  End_Procedure // DetermineRuntimeVersion
299

    
300
    // Hackish way to determine the IdeSrc folder
301
  Procedure LocateIdeSrcFolder String sApplication
302
    String  sIdeSrcPath
303
    String  sFolderName
304
    String  sWSPath
305
    Boolean bExists
306
    
307
    Move "" To sIdeSrcPath
308
    If (sApplication<>"") Begin
309
      Get ParseFolderName sApplication To sFolderName
310
      Get vParentPath sFolderName To sWSPath
311
      Get vFolderFormat sWSPath To sWSPath
312
      Move (sWSPath+"IdeSrc\") To sIdeSrcPath
313
      Get vFolderExists sIdeSrcPath To bExists
314
      If (bExists=false) Begin
315
        Move "" To sIdeSrcPath
316
        Send Info_Box ("Not able to find IdeSrc Path from folder:\n"+sFoldername+"Some features such as load/save breakpoints will not work.") "Info"
317
      End
318
    End
319
    Set psIdeSrcPath To sIdeSrcPath
320
  End_Procedure
321
  
322
  Procedure Set ApplicationFileName String sApplication
323
    Set psApplicationFileName To sApplication
324
    Send LocateIdeSrcFolder sApplication
325
  End_Procedure
326
  //
327
  // Enumeraties the all messages array as it has all properties as well.
328
  // A property has 2 items in the array.
329
  // First a "get_<property name>"
330
  // followed up by a "set_<property name>"
331
  //
332
  // We simply create the array with "<property name>" based on what we find.
333
  //
334
  // All property names are in lower case (as is the message array)
335
  //
336
  Procedure getAllProperties
337
    Integer  iCount
338
    Integer  iMsg
339
    Integer  iProp
340
    String   sMessage
341
    String[] AllMessages
342
    String[] AllProperties
343

    
344
    Move 0 To iProp
345
    Move (ResizeArray(AllProperties,0)) To AllProperties
346
    Get pAllMessages to AllMessages
347
    Move (SizeOfArray(AllMessages)) To iCount
348
    Decrement iCount
349
    For iMsg from 1 to iCount
350
      if (iMsg<iCount) begin
351
        if (left(AllMessages[iMsg],4)="get_") Begin
352
          Move AllMessages[iMsg] To sMessage
353
          Move (replace("get_",sMessage,"set_")) To sMessage
354
          If (AllMessages[iMsg+1]=sMessage) Begin
355
            Move (replace("set_",sMessage,"")) To sMessage
356
            Move sMessage To AllProperties[iProp]
357
            Increment iProp
358
          End
359
          Else If (AllMessages[iMsg-1]=sMessage) Begin
360
            Move (replace("set_",sMessage,"")) To sMessage
361
            Move sMessage To AllProperties[iProp]
362
            Increment iProp
363
          End
364
        End
365
      End
366
    Loop
367
    // Add functions safe to evaluate. we'll do this different later on.. now testing
368
    // and the idea works.. hmmm :D
369
    Move "selectedrow" to AllProperties[iProp]
370
    Set pAllProperties to AllProperties
371
  End_Procedure
372
  
373
  Function IsLanguageKeyword String sKeyword Returns Boolean
374
    Boolean  bIsKeyword
375
    Integer  iCount
376
    Integer  iKeyword
377
    String[] Keywords
378
    
379
    Move false to bIsKeyword
380
    Move (lowercase(sKeyWord)) To sKeyword
381
    If (sKeyword<>"") Begin
382
      Get pLanguageKeywords To Keywords
383
      Move (SizeOfArray(Keywords)) To iCount
384
      Decrement iCount
385
      For iKeyWord From 0 To iCount
386
        If (Keywords[iKeyword]=sKeyword) Begin
387
          Move True To bIsKeyword
388
          Move iCount To iKeyword // stop
389
        End
390
      Loop
391
    End
392
    Function_Return bIsKeyword
393
  End_Function
394
  
395
  Function IsVariableProperty String sVariable Returns Boolean
396
    Integer  iCount
397
    Integer  iProp
398
    Boolean  bIsProperty
399
    String[] AllProperties
400
    
401
    Move false to bisProperty
402
    Move (lowercase(sVariable)) To sVariable
403
    If (sVariable<>"") Begin
404
      Get pAllProperties to AllProperties
405
      Move (SizeOfArray(AllProperties)) To iCount
406
      Decrement iCount
407
      For iProp From 0 To iCount
408
        If (AllProperties[iProp]=sVariable) Begin
409
          Move True To bIsProperty
410
          Move iCount To iProp // stop
411
        End
412
      Loop
413
    End
414
    Function_Return bIsProperty
415
  End_function
416
  
417
  Function IsVariableProcedure String sVariable Returns Boolean
418
    Integer  iCount
419
    Integer  iMethod
420
    Boolean  bIsMethod
421
    String[] AllMessages
422
    
423
    Move false to bisMethod
424
    Move (lowercase(sVariable)) To sVariable
425
    If (sVariable<>"") Begin
426
      Move ("msg_"+sVariable) to sVariable
427
      Get pAllMessages to AllMessages
428
      Move (SizeOfArray(AllMessages)) To iCount
429
      Decrement iCount
430
      For iMethod From 0 To iCount
431
        If (AllMessages[iMethod]=sVariable) Begin
432
          Move True To bIsMethod
433
          Move iCount To iMethod // stop
434
        End
435
      Loop
436
    End
437
    Function_Return bIsMethod
438
  End_Function
439
  
440
  //
441
  // This will treat functions and properties both as function, so first
442
  // test if the variable isn't a property to exclude that.
443
  //
444
  Function IsVariableFunction String sVariable Returns Boolean
445
    Integer  iCount
446
    Integer  iMethod
447
    Boolean  bIsMethod
448
    String[] AllMessages
449
    
450
    Move false to bisMethod
451
    Move (lowercase(sVariable)) To sVariable
452
    If (sVariable<>"") Begin
453
      Move ("get_"+sVariable) to sVariable
454
      Get pAllMessages to AllMessages
455
      Move (SizeOfArray(AllMessages)) To iCount
456
      Decrement iCount
457
      For iMethod From 0 To iCount
458
        If (AllMessages[iMethod]=sVariable) Begin
459
          Move True To bIsMethod
460
          Move iCount To iMethod // stop
461
        End
462
      Loop
463
    End
464
    Function_Return bIsMethod
465
  End_Function
466
  
467
  Procedure UpdateBreakPointsGrid
468
    Handle  hoGrid
469
    
470
    Get phoBreakpointsGrid To hoGrid
471
    If (hoGrid) Begin
472
      Send LoadData Of hoGrid
473
    End
474
  End_Procedure
475
  
476
  //
477
  // Tries to find the breakpoint in the array, returns -1 if not found
478
  //
479
  Function FindBreakPointinArray String sFile Uinteger iLine Returns integer
480
    Integer iPos
481
    Integer iBreak
482
    Integer iCount
483
    tBreakPoints[] BP
484
    
485
    Move -1 To iPos
486
    Get pBreakPoints To BP
487
    Move (Lowercase(sFile)) To sFile
488
    Move (SizeOfArray(BP)) To iCount
489
    For iBreak from 0 To (iCount-1)
490
      If (lowercase(BP[iBreak].sFileName)=sFile and BP[iBreak].iLine=iLine) Begin
491
        Move iBreak To iPos
492
        Move iCount To iBreak // stop
493
      End
494
    Loop
495
    Function_Return iPos
496
  End_Function
497

    
498
  
499
  //
500
  // Checks the breakpoint array to see if it has any breakpoints
501
  // for the filename passed and returns them as line numbers if they
502
  // do.
503
  //
504
  Function ListBreakPointsForFile String sFile Returns UInteger[]
505
    Integer iPos
506
    Integer iBreak
507
    Integer iCount
508
    UInteger iLine
509
    UInteger[] Lines
510
    tBreakPoints[] BP
511
    
512
    Move -1 To iPos
513
    Move (ResizeArray(Lines,0)) To Lines
514
    Get pBreakPoints To BP
515
    Move (Lowercase(sFile)) To sFile
516
    Move (SizeOfArray(BP)) To iCount
517
    For iBreak from 0 To (iCount-1)
518
      If (lowercase(BP[iBreak].sFileName)=sFile and BP[iBreak].bEnabled=True) Begin
519
        Move BP[iBreak].iLine to Lines[SizeOfArray(Lines)]
520
      End
521
    Loop
522
    Function_Return Lines
523
  End_Function
524

    
525
  Procedure AddBreakPointToArray String sFile UInteger iLine
526
    Integer iCount
527
    Integer iBreak
528
    String  sLine
529
    Handle  hoEditor
530
    tBreakPoints[] BP
531
    
532
    Get FindBreakPointInArray sFile iLine To iBreak
533
    If (iBreak=-1) Begin
534
      Get pBreakPoints To BP
535
      Move (SizeOfArray(BP)) To iCount
536
      Move True   To BP[iCount].bEnabled
537
      Move sFile  To BP[iCount].sFileName
538
      Move iline  To BP[iCount].iLine
539
      Move false  To BP[iCount].bHasCondition
540
      
541
      Get phoEditor To hoEditor
542
      If (hoEditor) begin
543
        Get ComGetLine of hoEditor iLine To sLine
544
        Move (Rtrim(sLine)) To sLine
545
        Move sLine To BP[iCount].sLine
546
      End
547
      Set pBreakPoints To BP
548
    End
549
  End_Procedure
550

    
551

    
552
  Procedure EnableBreakPoint String sFile UInteger iLine
553
    Integer iBreak
554
    Integer retVal
555
    tBreakPoints[] BP
556
    
557
    Get FindBreakPointInArray sFile iLine To iBreak
558
    If (iBreak<>-1) Begin
559
      Get pBreakPoints To BP
560
      If (BP[iBreak].bEnabled=false) Begin
561
        Move True   To BP[iBreak].bEnabled
562
        Get ComSetBreakPoint sFile iLine to retVal
563
        
564
        Set pBreakPoints To BP
565
        
566
        Send UpdateBreakPointsGrid
567
      End
568
    End
569
  End_Procedure
570

    
571

    
572
  Procedure DisableBreakPoint String sFile UInteger iLine
573
    Integer retVal
574
    Integer iBreak
575
    tBreakPoints[] BP
576
    
577
    Get FindBreakPointInArray sFile iLine To iBreak
578
    If (iBreak<>-1) Begin
579
      Get pBreakPoints To BP
580
      If (BP[iBreak].bEnabled) Begin
581
        Move False   To BP[iBreak].bEnabled
582
        Get ComRemoveBreakPoint sFile iLine to retVal
583
        Set pBreakPoints To BP
584
      
585
        Send UpdateBreakPointsGrid
586
      End
587
    End
588
  End_Procedure
589
  
590
  Procedure RemoveBreakPointFromArray integer iPos
591
    Integer iCount
592
    tBreakPoints[] BP
593

    
594
    If (iPos>-1) Begin
595
      Get pBreakPoints To BP
596
      Move (SizeOfArray(BP)) To iCount
597
      If (iPos<iCount) Begin
598
        Move (RemoveFromArray(BP,iPos)) To BP
599
        Set pBreakPoints To BP
600
      End
601
    End
602
  End_Procedure
603

    
604

    
605
  // Sets the specified breakpoint
606
  Function SetBreakPoint String llfile UInteger ByRef llline Returns Boolean
607
    Boolean retVal
608
    Integer iLine
609
    
610
    Move llline To iLine
611
    Get ComSetBreakPoint llfile (&llline) to retVal
612
    If (retVal) Begin
613
      Send AddBreakPointToArray llfile iLine
614
      
615
      Send UpdateBreakPointsGrid
616
    End
617
    Function_Return retVal
618
  End_Function
619

    
620
  // Removes the specified breakpoint
621
  Function RemoveBreakPoint String llfile UInteger llline Returns Boolean
622
    Integer iPos
623
    Boolean retVal
624
    
625
    Get ComRemoveBreakPoint llfile llline to retVal
626
    If (retVal) Begin
627
      Get FindBreakPointInArray llfile llline To iPos
628
      Send RemoveBreakPointFromArray iPos
629
      
630
      Send UpdateBreakPointsGrid
631
    End
632
    Function_Return retVal
633
  End_Function
634

    
635

    
636
  // Introduced in vdf15.0
637
  // Sets the specified conditional breakpoint expression
638
  Function SetBreakPointCondition String llfile UInteger ByRef llline String llexpr Returns Boolean
639
    Boolean retVal
640
    
641
    Get ComSetBreakPointCondition llfile (&llline) llexpr to retVal
642
    If (retVal) Begin
643
    End
644
    Function_Return retVal
645
  End_Function
646
  
647
  //
648
  // Loads the breakpoints from the array that got loaded from a disk file.
649
  //
650
  Procedure SetBreakPointsFromArray
651
    Integer  iBreak
652
    Integer  iCount
653
    String   sFileName
654
    UInteger iLine
655
    Boolean  retVal
656
    Boolean  bEnabled
657
    Boolean  bIsValid
658
    tBreakPoints[] BP
659
    
660
    Get pBreakPoints To BP
661
    Move (SizeOfArray(BP)) To iCount
662
    For iBreak from 0 To (iCount-1)
663
      Move BP[iBreak].bEnabled  To bEnabled
664
      If (bEnabled) Begin
665
        Move BP[iBreak].sFileName To sFileName
666
        Move BP[iBreak].iLine     To iLine
667
        Get ComIsValidSourceFile sFileName To bIsValid
668
        If (bIsValid) Begin
669
          Get ComSetBreakPoint sFileName (&iLine) to retVal
670
        End
671
      End
672
    Loop
673
  End_Procedure // SetBreakPointsFromArray
674
  
675
  Function HasBreakPoints Returns Boolean
676
    Integer  iCount
677
    Boolean  bHasBreakPoints
678
    tBreakPoints[] BP
679
    
680
    Get pBreakPoints To BP
681
    Move (SizeOfArray(BP)) To iCount
682
    If (iCount>0) Move True To bHasBreakPoints
683
    Else Move False To bHasBreakPoints
684
    Function_Return bHasBreakPoints
685
  End_Function
686
  
687
  Procedure LoadBreakPointsFromDisk
688
    Boolean bExists
689
    Integer iVoid
690
    Integer iPos
691
    Integer iBreak
692
    Integer iCount
693
    String  sPath
694
    String  sBPFile
695
    String  sSection
696
    String  sKey
697
    String  sValue
698
    Handle  hoSections
699
    Handle  hoIni
700
    tBreakPoints[] BP
701
    
702
    Get psIdeSrcPath To sPath
703
    If (sPath<>"") Begin     // Only try to save if we could find a matching IdeSrc path
704
      Get psBPFileName To sBPFile
705
      Get vFolderFormat sPath To sPath
706
      Move (sPath+sBPFile) to sBPFile
707

    
708
      Get Create (RefClass(cIniFile)) To hoIni
709
      If (hoIni) Begin
710
        Set psFileName of hoIni To sBPFile
711
        Get Create (RefClass(Array)) To hoSections
712
        If (hoSections) Begin
713
          Send ReadSections of hoIni hoSections
714
          Get Item_Count of hoSections To iCount
715
          For iBreak from 0 To (iCount-1)
716
            Get Value of hoSections Item iBreak To sSection
717
            //Move ("Breakpoint"+trim(iBreak)) To sSection
718
            Get ReadString of hoIni sSection "Enabled"      "0" To BP[iBreak].bEnabled
719
            Get ReadString of hoIni sSection "FileName"     ""  To BP[iBreak].sFileName
720
            Get ReadString of hoIni sSection "Line"         "0" To BP[iBreak].iLine
721
            Get ReadString of hoIni sSection "Source"       ""  To BP[iBreak].sLine
722
            Get ReadString of hoIni sSection "HasCondition" "0" To BP[iBreak].bHasCondition
723
            Get ReadString of hoIni sSection "Expression"   ""  To BP[iBreak].sExpression
724
          Loop
725
          Send Destroy of hoSections
726
        End
727
           
728
        Send Destroy of hoIni
729
      End
730
      Set pBreakPoints To BP
731
      Send SetBreakPointsFromArray
732
//      Move (SizeOfArray(BP)) To iCount
733
    End
734
  End_Procedure
735
  
736
  Procedure SaveBreakPointsToDisk
737
    Boolean bExists
738
    Integer iVoid
739
    Integer iPos
740
    Integer iBreak
741
    Integer iCount
742
    String  sPath
743
    String  sBPFile
744
    String  sSection
745
    String  sKey
746
    String  sValue
747
    Handle  hoIni
748
    tBreakPoints[] BP
749
    
750
    Get psIdeSrcPath To sPath
751
    If (sPath<>"") Begin     // Only try to save if we could find a matching IdeSrc path
752
      Get psBPFileName To sBPFile
753
      Get vFolderFormat sPath To sPath
754
      Move (sPath+sBPFile) to sBPFile
755
      // If it exists already, then delete it.
756
      Get vFilePathExists sBPFile To bExists
757
      If (bExists) Begin
758
        Get vDeleteFile sBPFile To iVoid
759
      End
760
      Get Create (RefClass(cIniFile)) To hoIni
761
      If (hoIni) Begin
762
        Set psFileName of hoIni To sBPFile
763
               
764
        
765
        Get pBreakPoints To BP
766
        Move (SizeOfArray(BP)) To iCount
767
        For iBreak from 0 To (iCount-1)
768
          Move ("Breakpoint"+trim(iBreak)) To sSection
769
          Send WriteString of hoIni sSection "Enabled"      BP[iBreak].bEnabled
770
          Send WriteString of hoIni sSection "FileName"     BP[iBreak].sFileName
771
          Send WriteString of hoIni sSection "Line"         BP[iBreak].iLine
772
          Send WriteString of hoIni sSection "Source"       BP[iBreak].sLine
773
          Send WriteString of hoIni sSection "HasCondition" BP[iBreak].bHasCondition
774
          Send WriteString of hoIni sSection "Expression"   BP[iBreak].sExpression
775
        Loop
776
           
777
        Send Destroy of hoIni
778
        
779
        // ToDo: Remove
780
        //Send info_Box "saved breakpoints"
781
      End
782
    End
783
  End_Procedure
784
  
785
  // Introduced in vdf15.0
786
  // Occurs if there was an error evaluating a conditional breakpoint
787
  Procedure OnComBreakPointError String lltext
788
    Send Info_Box lltext "VdfSplat Info Error on conditional breakpoint"
789
  End_Procedure
790

    
791

    
792
  // Occurs after program has been successfully initialized
793
  Procedure OnComProgramInit
794
    String[] AllMessages
795
    Set pbProgramStarted To True
796
    Set pbProgramPaused  To False
797

    
798
    Get ComGetAllMessages To AllMessages
799
    Set pAllMessages To AllMessages
800
    Send GetAllProperties
801
    Send LoadBreakPointsFromDisk
802
  End_Procedure
803

    
804
  // Occurs after the program exits
805
  Procedure OnComProgramExit
806
    Boolean  bStartedFromCLI
807
    Boolean  bRestartMode
808
    String[] Empty
809
    Set pbProgramStarted To False
810
    Set pbProgramPaused  To False
811
    Send SaveBreakPointsToDisk
812
    Set ApplicationFileName To ""
813
    Move (ResizeArray(Empty,0))   To Empty
814
    Set pAllMessages      To Empty
815
    Set pAllProperties    To Empty
816
    Set pLanguageKeywords To Empty
817
    Get pbDebugRestart to bRestartMode
818
    If (bRestartMode) Begin
819
      Send DoDebugRun
820
    End
821
    Else Begin
822
      Get pbStartedFromCLI of ghoApplication To bStartedFromCLI
823
      If (bStartedFromCli) Begin
824
        // debug session was started from the command line.
825
        // Stopping the debug session normally should stop the debugger as well.
826
        Send Exit_Application
827
      End
828
    End
829
  End_Procedure
830

    
831
  // Occurs if there is an error starting the program
832
  Procedure OnComProgramStartupError String llerrorMessage
833
    Set pbProgramStarted To False
834
    Send Info_Box llerrorMessage "start up error"
835
  End_Procedure
836

    
837
  // Occurs if there is an error initializing the program
838
  Procedure OnComProgramInitError String llerrorMessage
839
    Set pbProgramStarted To False
840
    Send Info_Box (llErrorMessage) "Custom Error INIT"
841
  End_Procedure
842
  
843
  Procedure SetDebuggerAsForegroundApp
844
    Handle  hoEditor
845
    Handle  hWnd
846
    Integer iVoid
847
    Get phoEditor To hoEditor
848
    If (hoEditor) Begin
849
      Get Window_Handle of hoEditor To hWnd
850
      If (hWnd) Begin
851
        Move (SetForegroundWindow(hWnd)) To iVoid
852
      End
853
    End
854
  End_Procedure // SetDebuggerAsForegroundApp
855
  
856
  //
857
  // Hook to be used
858
  // Called from OnComProgramPaused
859
  //
860
  // Occurs when the program execution is paused
861
  Procedure OnProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
862
    Handle hoEditor
863
    String sBreakMode
864
    
865
    Get phoEditor   To hoEditor
866
    If (hoEditor) Begin
867
      If lllimitedBreakMode Begin
868
        Move "limited Break mode" To sBreakMode
869
        //Else Move "Unlimited Break mode" to sBreakMode
870
        Send info_Box ("Pausing program\n"+sBreakMode) "VdfSplat Info"
871
      End
872
      Else Begin
873
        Send SetDebuggerAsForegroundApp
874
      End
875
      Send doOpenSourceFileAtLine of hoEditor llfile llline
876
      Send doActivateDebugPanels  // only displays if exists or not.
877
    End
878
  End_Procedure
879
  
880
  //
881
  // Occurs when the program execution is paused
882
  Procedure OnComProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
883
    Set pbProgramPaused    To True
884
    Set pbLimitedBreakMode To lllimitedBreakMode
885
    Send OnProgramPaused llfile llline lllimitedBreakMode
886
  End_Procedure
887

    
888
  // Occurs when the program execution resumes
889
  Procedure OnComProgramContinue
890
    Set pbProgramPaused    To False
891
    Set pbLimitedBreakMode To False
892
  End_Procedure
893

    
894
  // Occurs after a change requiring views to be refreshed
895
  Procedure OnUpdateView String sFileName UInteger iLine
896
    Handle hoEditor
897
    
898
    Get phoEditor To hoEditor
899
    If (hoEditor) begin
900
      //Send Info_Box "OnComUpdateView" (llfile*"llline = "*trim(llline))
901
      Send doOpenSourceFileAtLine of hoEditor sFileName iLine
902
    End
903
  End_Procedure
904

    
905
  // Occurs after a change requiring views to be refreshed
906
  Procedure OnComUpdateView String sFileName UInteger iLine
907
    Send OnUpdateView sFileName iLine
908
  End_Procedure
909

    
910
  // Occurs when a new message is executed
911
  Procedure OnComNewMessage Integer llbSteppin
912
  End_Procedure
913

    
914
  // Occurs if an unhandled program exception is detected
915
  Procedure OnComUnhandledProgramException String lldescription
916
    Send Info_box lldescription "FATAL Error"
917
  End_Procedure
918

    
919
  // 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
920
  Procedure OnComAcceptWebAppSession Boolean ByRef llacceptNewSession
921
  End_Procedure
922

    
923
  // Occurs if there is a fatal web app error
924
  Procedure OnComWebAppError String lldescription
925
    Send Info_box lldescription "WebApp FATAL Error"
926
  End_Procedure
927

    
928
  // Occurs when a new webapp event log entry is added
929
  Procedure OnComWebAppLog Integer lleventId String lltext
930
    //Send Info_box lldescription "WebApp FATAL Error"
931
    Showln lleventid lltext
932
  End_Procedure
933
  
934
  Procedure AddKeyword String sWord
935
    Integer  iCount
936
    String[] Keywords
937
    
938
    Get pLanguageKeywords To Keywords
939
    Move (SizeOfArray(Keywords)) To iCount
940
    Move (Lowercase(sWord)) To Keywords[iCount]
941
    Set pLanguageKeywords To Keywords
942
  End_Procedure
943
  
944
  // Language keywords are not evaluated in the tooltip
945
  Procedure AddLanguageKeywords
946
    Send AddKeyword "End_Function"
947
    Send AddKeyword "End_Procedure"
948
    Send AddKeyword "Function"
949
    Send AddKeyword "Move"
950
    Send AddKeyword "Procedure"
951
    Send AddKeyword "Send"
952
    Send AddKeyword "Showln"
953
    Send AddKeyword "To"
954
    Send AddKeyword "UChar[]"
955
  End_Procedure
956

    
957
  
958
  Procedure doCreateCallStack
959
    Handle  hoParent
960
    Handle  hoCallStack
961
    Boolean bCreated
962

    
963
    Get phoCallStackHost To hoParent
964
    If (hoParent) Begin
965
      Get Create Of hoParent U_cCallStack To hoCallStack
966
      If (hoCallStack) Begin
967
        Set Name               Of hoCallStack To "oCallStack"
968
        Send CreateComObject   Of hoCallStack
969
        Get IsComObjectCreated Of hoCallStack To bCreated
970
        If (bCreated) Begin
971
          Send SetControlColumnWidth of hoCallStack hoCallStack
972
        End
973
      End
974
    End
975
  End_Procedure // doCreateCallStack
976

    
977
  
978
  Procedure doCreateWatches
979
    Handle  hoParent
980
    Handle  hoWatches
981
    Boolean bCreated
982

    
983
    Get phoWatchesHost To hoParent
984
    If (hoParent) Begin
985
      Get Create Of hoParent U_cWatches To hoWatches
986
      If (hoWatches) Begin
987
        Set Name               Of hoWatches To "oWatches"
988
        Send CreateComObject   Of hoWatches
989
        Get IsComObjectCreated Of hoWatches To bCreated
990
        If (bCreated) Begin
991
        End
992
      End
993
    End
994
  End_Procedure // doCreateWatches
995

    
996
  
997
  Procedure doCreateMessageTrace
998
    Handle  hoParent
999
    Handle  hoTrace
1000
    Boolean bCreated
1001

    
1002
    Get phoTraceHost To hoParent
1003
    If (hoParent) Begin
1004
      Get Create Of hoParent U_cMessageTrace To hoTrace
1005
      If (hoTrace) Begin
1006
        Set Name               Of hoTrace To "oMessageTrace"
1007
        Send CreateComObject   Of hoTrace
1008
        Get IsComObjectCreated Of hoTrace To bCreated
1009
        If (bCreated) Begin
1010
        End
1011
      End
1012
    End
1013
  End_Procedure // doCreateMessageTrace
1014

    
1015
  
1016
  Procedure doCreateGlobalVariables
1017
    Handle  hoParent
1018
    Handle  hoVariables
1019
    Boolean bCreated
1020

    
1021
    Get phoGlobalVarHost To hoParent
1022
    If (hoParent) Begin
1023
      Get Create Of hoParent U_cVariablesWindow To hoVariables
1024
      If (hoVariables) Begin
1025
        Set phoGlobalVariables To hoVariables
1026
        Set Name               Of hoVariables To "oGlobalVariables"
1027
        Send CreateObjectCallback of hoParent hoVariables
1028
        
1029
        Send CreateComObject   Of hoVariables
1030
        Get IsComObjectCreated Of hoVariables To bCreated
1031
        If (bCreated) Begin
1032
          Set ComWindowType Of hoVariables To 1 // global
1033
        End
1034
      End
1035
    End
1036
  End_Procedure // doCreateGlobalVariables
1037

    
1038
  
1039
  Procedure doCreateLocalVariables
1040
    Handle  hoParent
1041
    Handle  hoVariables
1042
    Boolean bCreated
1043

    
1044
    Get phoLocalVarHost To hoParent
1045
    If (hoParent) Begin
1046
      Get Create Of hoParent U_cVariablesWindow To hoVariables
1047
      If (hoVariables) Begin
1048
        Set phoLocalVariables  To hoVariables
1049
        Set Name               Of hoVariables To "oLocalVariables"
1050
        
1051
        Send CreateComObject   Of hoVariables
1052
        Get IsComObjectCreated Of hoVariables To bCreated
1053
        If (bCreated) Begin
1054
          Set ComWindowType Of hoVariables To 0 // locals
1055
        End
1056
        Send CreateObjectCallback of hoParent hoVariables
1057
      End
1058
    End
1059
  End_Procedure // doCreateLocalVariables
1060

    
1061
  
1062
  Procedure doCreateTablesWindow
1063
    Handle  hoParent
1064
    Handle  hoTables
1065
    Boolean bCreated
1066

    
1067
    Get phoTablesHost To hoParent
1068
    If (hoParent) Begin
1069
      Get Create Of hoParent U_cTablesWindow To hoTables
1070
      If (hoTables) Begin
1071
        Set Name               Of hoTables To "oTablesWindow"
1072
        Send CreateComObject   Of hoTables
1073
        Get IsComObjectCreated Of hoTables To bCreated
1074
        If (bCreated) Begin
1075
        End
1076
      End
1077
    End
1078
  End_Procedure // doCreateTables
1079

    
1080

    
1081
  // we MUST send activate to the debug panels to make them display.
1082
  Procedure doActivateDebugPanels
1083
    Handle  hoCallStack
1084
    Handle  hoLocalVars
1085
    Handle  hoGlobalVars
1086
    Boolean bCreated
1087

    
1088
    Get phoCallStack To hoCallStack
1089
    If (hoCallStack) Begin
1090
      Get IsComObjectCreated Of hoCallStack To bCreated
1091
      If (bCreated) Begin
1092
        Send Activate of hoCallStack
1093
      End
1094
    End
1095

    
1096
    Get phoLocalVariables To hoLocalVars
1097
    If (hoLocalVars) Begin
1098
      Get IsComObjectCreated Of hoLocalVars To bCreated
1099
      If (bCreated) Begin
1100
        Send Activate of hoLocalVars
1101
      End
1102
    End
1103

    
1104
    Get phoGlobalVariables To hoGlobalVars
1105
    If (hoGlobalVars) Begin
1106
      Get IsComObjectCreated Of hoGlobalVars To bCreated
1107
      If (bCreated) Begin
1108
        Send Activate of hoGlobalVars
1109
      End
1110
    End
1111
  End_Procedure
1112

    
1113

    
1114
  
1115
  Procedure DoCreateEngine
1116
    Boolean bCreated
1117
    Handle  hoDebugger
1118
    Handle  hoEditor
1119
    
1120
    Send CreateComObject
1121
    Get IsComObjectCreated to bCreated
1122
    If (bCreated) Begin
1123

    
1124
      Move Self To hoDebugger
1125
      Set pbEngineActive To True
1126
      Set phoDebugger to hoDebugger
1127
    End
1128

    
1129
    Send DoCreateCallStack
1130
    
1131
    Send DoCreateWatches
1132
    
1133
    Send DoCreateMessageTrace
1134
    
1135
    Send DoCreateGlobalVariables
1136
    
1137
    Send doCreateLocalVariables
1138
    
1139
    Send doCreateTablesWindow
1140
    
1141
    Send AddLanguageKeywords
1142
  End_Procedure // DoCreateEngine
1143

    
1144
  
1145
  Procedure OnCreate
1146
    forward Send OnCreate
1147
  End_Procedure // OnCreate
1148
  
1149
  
1150
End_Class // cDebuggerEngine