Project

General

Profile

Statistics
| Revision:

vdfsplat / AppSrc / cDebuggerEngine.pkg @ 72

History | View | Annotate | Download (33.7 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 64 wil
//      Get Item_Count To iCount
123
//      Get Current_Item To iItem
124 8 wil
//      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 64 wil
    Property Boolean pbLimitedBreakMode    False
283
    Property Boolean pbDebugRestart        False
284 27 wil
    Property String[]       pAllMessages
285
    Property String[]       pAllProperties
286 64 wil
    Property String[]       pLanguageKeywords
287 20 wil
    Property tBreakPoints[] pBreakPoints
288 8 wil
289
    Set Name To "oDebuggerEngine"
290 7 wil
  End_Procedure // Construct_Object
291
292 8 wil
293
  Procedure DetermineRuntimeVersion
294 10 wil
    Integer iRuntime
295
296
    Get piDebugfileVersion to iRuntime
297
    Set piRuntimeVersion   to iRuntime
298 28 wil
  End_Procedure // DetermineRuntimeVersion
299 7 wil
300 20 wil
    // 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 27 wil
  //
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 7 wil
344 27 wil
    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 42 wil
    For iMsg from 1 to iCount
350 27 wil
      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 42 wil
          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 27 wil
        End
365
      End
366
    Loop
367 42 wil
    // 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 27 wil
    Set pAllProperties to AllProperties
371
  End_Procedure
372
373 64 wil
  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 27 wil
  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 20 wil
417 42 wil
  Function IsVariableProcedure String sVariable Returns Boolean
418
    Integer  iCount
419 43 wil
    Integer  iMethod
420 42 wil
    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 43 wil
      For iMethod From 0 To iCount
431
        If (AllMessages[iMethod]=sVariable) Begin
432 42 wil
          Move True To bIsMethod
433 43 wil
          Move iCount To iMethod // stop
434 42 wil
        End
435
      Loop
436
    End
437
    Function_Return bIsMethod
438
  End_Function
439
440 20 wil
  //
441 43 wil
  // 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 20 wil
  // 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 28 wil
    Move (Lowercase(sFile)) To sFile
488 20 wil
    Move (SizeOfArray(BP)) To iCount
489
    For iBreak from 0 To (iCount-1)
490 28 wil
      If (lowercase(BP[iBreak].sFileName)=sFile and BP[iBreak].iLine=iLine) Begin
491 20 wil
        Move iBreak To iPos
492
        Move iCount To iBreak // stop
493
      End
494
    Loop
495
    Function_Return iPos
496
  End_Function
497 28 wil
498 72 wil
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 28 wil
525
  Procedure AddBreakPointToArray String sFile UInteger iLine
526
    Integer iCount
527
    Integer iBreak
528 38 wil
    String  sLine
529
    Handle  hoEditor
530 28 wil
    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 38 wil
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 28 wil
      Set pBreakPoints To BP
548
    End
549
  End_Procedure
550 43 wil
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 20 wil
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 43 wil
    Integer iLine
609 20 wil
610 43 wil
    Move llline To iLine
611 20 wil
    Get ComSetBreakPoint llfile (&llline) to retVal
612
    If (retVal) Begin
613 43 wil
      Send AddBreakPointToArray llfile iLine
614
615
      Send UpdateBreakPointsGrid
616 20 wil
    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 43 wil
630
      Send UpdateBreakPointsGrid
631 20 wil
    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 38 wil
647
  //
648
  // Loads the breakpoints from the array that got loaded from a disk file.
649
  //
650 20 wil
  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 37 wil
  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 20 wil
  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 38 wil
            Get ReadString of hoIni sSection "Source"       ""  To BP[iBreak].sLine
722 20 wil
            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 38 wil
          Send WriteString of hoIni sSection "Source"       BP[iBreak].sLine
773 20 wil
          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 37 wil
779
        // ToDo: Remove
780 38 wil
        //Send info_Box "saved breakpoints"
781 20 wil
      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 7 wil
  // Occurs after program has been successfully initialized
793
  Procedure OnComProgramInit
794 27 wil
    String[] AllMessages
795 7 wil
    Set pbProgramStarted To True
796
    Set pbProgramPaused  To False
797 27 wil
798
    Get ComGetAllMessages To AllMessages
799
    Set pAllMessages To AllMessages
800
    Send GetAllProperties
801 20 wil
    Send LoadBreakPointsFromDisk
802 7 wil
  End_Procedure
803
804
  // Occurs after the program exits
805
  Procedure OnComProgramExit
806 38 wil
    Boolean  bStartedFromCLI
807 64 wil
    Boolean  bRestartMode
808
    String[] Empty
809 7 wil
    Set pbProgramStarted To False
810
    Set pbProgramPaused  To False
811 20 wil
    Send SaveBreakPointsToDisk
812 23 wil
    Set ApplicationFileName To ""
813 64 wil
    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 38 wil
    End
821 64 wil
    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 7 wil
  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 20 wil
  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 7 wil
  //
857
  // Hook to be used
858
  // Called from OnComProgramPaused
859
  //
860 8 wil
  // Occurs when the program execution is paused
861 28 wil
  Procedure OnProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
862 20 wil
    Handle hoEditor
863
    String sBreakMode
864 8 wil
865
    Get phoEditor   To hoEditor
866
    If (hoEditor) Begin
867 20 wil
      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 64 wil
      Send doActivateDebugPanels  // only displays if exists or not.
877 8 wil
    End
878 7 wil
  End_Procedure
879
880
  //
881
  // Occurs when the program execution is paused
882 28 wil
  Procedure OnComProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
883 64 wil
    Set pbProgramPaused    To True
884
    Set pbLimitedBreakMode To lllimitedBreakMode
885 7 wil
    Send OnProgramPaused llfile llline lllimitedBreakMode
886
  End_Procedure
887
888
  // Occurs when the program execution resumes
889
  Procedure OnComProgramContinue
890 64 wil
    Set pbProgramPaused    To False
891
    Set pbLimitedBreakMode To False
892 7 wil
  End_Procedure
893
894
  // Occurs after a change requiring views to be refreshed
895
  Procedure OnUpdateView String sFileName UInteger iLine
896 8 wil
    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 28 wil
    End
903 7 wil
  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 28 wil
  Procedure OnComWebAppError String lldescription
925 7 wil
    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 28 wil
  End_Procedure
933 64 wil
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 8 wil
957 7 wil
958 8 wil
  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 28 wil
        If (bCreated) Begin
971 37 wil
          Send SetControlColumnWidth of hoCallStack hoCallStack
972 8 wil
        End
973
      End
974
    End
975 28 wil
  End_Procedure // doCreateCallStack
976 8 wil
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 28 wil
        If (bCreated) Begin
991 8 wil
        End
992
      End
993
    End
994 28 wil
  End_Procedure // doCreateWatches
995 8 wil
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 28 wil
        If (bCreated) Begin
1010 8 wil
        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 28 wil
        If (bCreated) Begin
1032
          Set ComWindowType Of hoVariables To 1 // global
1033 8 wil
        End
1034
      End
1035
    End
1036 28 wil
  End_Procedure // doCreateGlobalVariables
1037 8 wil
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 28 wil
        If (bCreated) Begin
1054 8 wil
          Set ComWindowType Of hoVariables To 0 // locals
1055
        End
1056 64 wil
        Send CreateObjectCallback of hoParent hoVariables
1057 8 wil
      End
1058
    End
1059 28 wil
  End_Procedure // doCreateLocalVariables
1060 8 wil
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 28 wil
        If (bCreated) Begin
1075 8 wil
        End
1076
      End
1077
    End
1078
  End_Procedure // doCreateTables
1079
1080
1081 64 wil
  // we MUST send activate to the debug panels to make them display.
1082
  Procedure doActivateDebugPanels
1083 8 wil
    Handle  hoCallStack
1084 64 wil
    Handle  hoLocalVars
1085
    Handle  hoGlobalVars
1086 8 wil
    Boolean bCreated
1087
1088
    Get phoCallStack To hoCallStack
1089
    If (hoCallStack) Begin
1090
      Get IsComObjectCreated Of hoCallStack To bCreated
1091 28 wil
      If (bCreated) Begin
1092 64 wil
        Send Activate of hoCallStack
1093 8 wil
      End
1094
    End
1095
1096 64 wil
    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 8 wil
1104 64 wil
    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 8 wil
1115
  Procedure DoCreateEngine
1116 28 wil
    Boolean bCreated
1117 8 wil
    Handle  hoDebugger
1118
    Handle  hoEditor
1119
1120 28 wil
    Send CreateComObject
1121
    Get IsComObjectCreated to bCreated
1122
    If (bCreated) Begin
1123 8 wil
1124
      Move Self To hoDebugger
1125
      Set pbEngineActive To True
1126
      Set phoDebugger to hoDebugger
1127 28 wil
    End
1128 8 wil
1129
    Send DoCreateCallStack
1130
1131
    Send DoCreateWatches
1132
1133
    Send DoCreateMessageTrace
1134
1135
    Send DoCreateGlobalVariables
1136
1137
    Send doCreateLocalVariables
1138
1139 28 wil
    Send doCreateTablesWindow
1140 64 wil
1141
    Send AddLanguageKeywords
1142 28 wil
  End_Procedure // DoCreateEngine
1143 8 wil
1144
1145 7 wil
  Procedure OnCreate
1146
    forward Send OnCreate
1147 28 wil
  End_Procedure // OnCreate
1148 7 wil
1149
1150 28 wil
End_Class // cDebuggerEngine