Project

General

Profile

Statistics
| Revision:

vdfsplat / AppSrc / cDebuggerEngine.pkg @ 64

History | View | Annotate | Download (32.9 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
499
  Procedure AddBreakPointToArray String sFile UInteger iLine
500
    Integer iCount
501
    Integer iBreak
502 38 wil
    String  sLine
503
    Handle  hoEditor
504 28 wil
    tBreakPoints[] BP
505
506
    Get FindBreakPointInArray sFile iLine To iBreak
507
    If (iBreak=-1) Begin
508
      Get pBreakPoints To BP
509
      Move (SizeOfArray(BP)) To iCount
510
      Move True   To BP[iCount].bEnabled
511
      Move sFile  To BP[iCount].sFileName
512
      Move iline  To BP[iCount].iLine
513
      Move false  To BP[iCount].bHasCondition
514 38 wil
515
      Get phoEditor To hoEditor
516
      If (hoEditor) begin
517
        Get ComGetLine of hoEditor iLine To sLine
518
        Move (Rtrim(sLine)) To sLine
519
        Move sLine To BP[iCount].sLine
520
      End
521 28 wil
      Set pBreakPoints To BP
522
    End
523
  End_Procedure
524 43 wil
525
526
  Procedure EnableBreakPoint String sFile UInteger iLine
527
    Integer iBreak
528
    Integer retVal
529
    tBreakPoints[] BP
530
531
    Get FindBreakPointInArray sFile iLine To iBreak
532
    If (iBreak<>-1) Begin
533
      Get pBreakPoints To BP
534
      If (BP[iBreak].bEnabled=false) Begin
535
        Move True   To BP[iBreak].bEnabled
536
        Get ComSetBreakPoint sFile iLine to retVal
537
538
        Set pBreakPoints To BP
539
540
        Send UpdateBreakPointsGrid
541
      End
542
    End
543
  End_Procedure
544
545
546
  Procedure DisableBreakPoint String sFile UInteger iLine
547
    Integer retVal
548
    Integer iBreak
549
    tBreakPoints[] BP
550
551
    Get FindBreakPointInArray sFile iLine To iBreak
552
    If (iBreak<>-1) Begin
553
      Get pBreakPoints To BP
554
      If (BP[iBreak].bEnabled) Begin
555
        Move False   To BP[iBreak].bEnabled
556
        Get ComRemoveBreakPoint sFile iLine to retVal
557
        Set pBreakPoints To BP
558
559
        Send UpdateBreakPointsGrid
560
      End
561
    End
562
  End_Procedure
563 20 wil
564
  Procedure RemoveBreakPointFromArray integer iPos
565
    Integer iCount
566
    tBreakPoints[] BP
567
568
    If (iPos>-1) Begin
569
      Get pBreakPoints To BP
570
      Move (SizeOfArray(BP)) To iCount
571
      If (iPos<iCount) Begin
572
        Move (RemoveFromArray(BP,iPos)) To BP
573
        Set pBreakPoints To BP
574
      End
575
    End
576
  End_Procedure
577
578
579
  // Sets the specified breakpoint
580
  Function SetBreakPoint String llfile UInteger ByRef llline Returns Boolean
581
    Boolean retVal
582 43 wil
    Integer iLine
583 20 wil
584 43 wil
    Move llline To iLine
585 20 wil
    Get ComSetBreakPoint llfile (&llline) to retVal
586
    If (retVal) Begin
587 43 wil
      Send AddBreakPointToArray llfile iLine
588
589
      Send UpdateBreakPointsGrid
590 20 wil
    End
591
    Function_Return retVal
592
  End_Function
593
594
  // Removes the specified breakpoint
595
  Function RemoveBreakPoint String llfile UInteger llline Returns Boolean
596
    Integer iPos
597
    Boolean retVal
598
599
    Get ComRemoveBreakPoint llfile llline to retVal
600
    If (retVal) Begin
601
      Get FindBreakPointInArray llfile llline To iPos
602
      Send RemoveBreakPointFromArray iPos
603 43 wil
604
      Send UpdateBreakPointsGrid
605 20 wil
    End
606
    Function_Return retVal
607
  End_Function
608
609
610
  // Introduced in vdf15.0
611
  // Sets the specified conditional breakpoint expression
612
  Function SetBreakPointCondition String llfile UInteger ByRef llline String llexpr Returns Boolean
613
    Boolean retVal
614
615
    Get ComSetBreakPointCondition llfile (&llline) llexpr to retVal
616
    If (retVal) Begin
617
    End
618
    Function_Return retVal
619
  End_Function
620 38 wil
621
  //
622
  // Loads the breakpoints from the array that got loaded from a disk file.
623
  //
624 20 wil
  Procedure SetBreakPointsFromArray
625
    Integer  iBreak
626
    Integer  iCount
627
    String   sFileName
628
    UInteger iLine
629
    Boolean  retVal
630
    Boolean  bEnabled
631
    Boolean  bIsValid
632
    tBreakPoints[] BP
633
634
    Get pBreakPoints To BP
635
    Move (SizeOfArray(BP)) To iCount
636
    For iBreak from 0 To (iCount-1)
637
      Move BP[iBreak].bEnabled  To bEnabled
638
      If (bEnabled) Begin
639
        Move BP[iBreak].sFileName To sFileName
640
        Move BP[iBreak].iLine     To iLine
641
        Get ComIsValidSourceFile sFileName To bIsValid
642
        If (bIsValid) Begin
643
          Get ComSetBreakPoint sFileName (&iLine) to retVal
644
        End
645
      End
646
    Loop
647
  End_Procedure // SetBreakPointsFromArray
648
649 37 wil
  Function HasBreakPoints Returns Boolean
650
    Integer  iCount
651
    Boolean  bHasBreakPoints
652
    tBreakPoints[] BP
653
654
    Get pBreakPoints To BP
655
    Move (SizeOfArray(BP)) To iCount
656
    If (iCount>0) Move True To bHasBreakPoints
657
    Else Move False To bHasBreakPoints
658
    Function_Return bHasBreakPoints
659
  End_Function
660
661 20 wil
  Procedure LoadBreakPointsFromDisk
662
    Boolean bExists
663
    Integer iVoid
664
    Integer iPos
665
    Integer iBreak
666
    Integer iCount
667
    String  sPath
668
    String  sBPFile
669
    String  sSection
670
    String  sKey
671
    String  sValue
672
    Handle  hoSections
673
    Handle  hoIni
674
    tBreakPoints[] BP
675
676
    Get psIdeSrcPath To sPath
677
    If (sPath<>"") Begin     // Only try to save if we could find a matching IdeSrc path
678
      Get psBPFileName To sBPFile
679
      Get vFolderFormat sPath To sPath
680
      Move (sPath+sBPFile) to sBPFile
681
682
      Get Create (RefClass(cIniFile)) To hoIni
683
      If (hoIni) Begin
684
        Set psFileName of hoIni To sBPFile
685
        Get Create (RefClass(Array)) To hoSections
686
        If (hoSections) Begin
687
          Send ReadSections of hoIni hoSections
688
          Get Item_Count of hoSections To iCount
689
          For iBreak from 0 To (iCount-1)
690
            Get Value of hoSections Item iBreak To sSection
691
            //Move ("Breakpoint"+trim(iBreak)) To sSection
692
            Get ReadString of hoIni sSection "Enabled"      "0" To BP[iBreak].bEnabled
693
            Get ReadString of hoIni sSection "FileName"     ""  To BP[iBreak].sFileName
694
            Get ReadString of hoIni sSection "Line"         "0" To BP[iBreak].iLine
695 38 wil
            Get ReadString of hoIni sSection "Source"       ""  To BP[iBreak].sLine
696 20 wil
            Get ReadString of hoIni sSection "HasCondition" "0" To BP[iBreak].bHasCondition
697
            Get ReadString of hoIni sSection "Expression"   ""  To BP[iBreak].sExpression
698
          Loop
699
          Send Destroy of hoSections
700
        End
701
702
        Send Destroy of hoIni
703
      End
704
      Set pBreakPoints To BP
705
      Send SetBreakPointsFromArray
706
//      Move (SizeOfArray(BP)) To iCount
707
    End
708
  End_Procedure
709
710
  Procedure SaveBreakPointsToDisk
711
    Boolean bExists
712
    Integer iVoid
713
    Integer iPos
714
    Integer iBreak
715
    Integer iCount
716
    String  sPath
717
    String  sBPFile
718
    String  sSection
719
    String  sKey
720
    String  sValue
721
    Handle  hoIni
722
    tBreakPoints[] BP
723
724
    Get psIdeSrcPath To sPath
725
    If (sPath<>"") Begin     // Only try to save if we could find a matching IdeSrc path
726
      Get psBPFileName To sBPFile
727
      Get vFolderFormat sPath To sPath
728
      Move (sPath+sBPFile) to sBPFile
729
      // If it exists already, then delete it.
730
      Get vFilePathExists sBPFile To bExists
731
      If (bExists) Begin
732
        Get vDeleteFile sBPFile To iVoid
733
      End
734
      Get Create (RefClass(cIniFile)) To hoIni
735
      If (hoIni) Begin
736
        Set psFileName of hoIni To sBPFile
737
738
739
        Get pBreakPoints To BP
740
        Move (SizeOfArray(BP)) To iCount
741
        For iBreak from 0 To (iCount-1)
742
          Move ("Breakpoint"+trim(iBreak)) To sSection
743
          Send WriteString of hoIni sSection "Enabled"      BP[iBreak].bEnabled
744
          Send WriteString of hoIni sSection "FileName"     BP[iBreak].sFileName
745
          Send WriteString of hoIni sSection "Line"         BP[iBreak].iLine
746 38 wil
          Send WriteString of hoIni sSection "Source"       BP[iBreak].sLine
747 20 wil
          Send WriteString of hoIni sSection "HasCondition" BP[iBreak].bHasCondition
748
          Send WriteString of hoIni sSection "Expression"   BP[iBreak].sExpression
749
        Loop
750
751
        Send Destroy of hoIni
752 37 wil
753
        // ToDo: Remove
754 38 wil
        //Send info_Box "saved breakpoints"
755 20 wil
      End
756
    End
757
  End_Procedure
758
759
  // Introduced in vdf15.0
760
  // Occurs if there was an error evaluating a conditional breakpoint
761
  Procedure OnComBreakPointError String lltext
762
    Send Info_Box lltext "VdfSplat Info Error on conditional breakpoint"
763
  End_Procedure
764
765
766 7 wil
  // Occurs after program has been successfully initialized
767
  Procedure OnComProgramInit
768 27 wil
    String[] AllMessages
769 7 wil
    Set pbProgramStarted To True
770
    Set pbProgramPaused  To False
771 27 wil
772
    Get ComGetAllMessages To AllMessages
773
    Set pAllMessages To AllMessages
774
    Send GetAllProperties
775 20 wil
    Send LoadBreakPointsFromDisk
776 7 wil
  End_Procedure
777
778
  // Occurs after the program exits
779
  Procedure OnComProgramExit
780 38 wil
    Boolean  bStartedFromCLI
781 64 wil
    Boolean  bRestartMode
782
    String[] Empty
783 7 wil
    Set pbProgramStarted To False
784
    Set pbProgramPaused  To False
785 20 wil
    Send SaveBreakPointsToDisk
786 23 wil
    Set ApplicationFileName To ""
787 64 wil
    Move (ResizeArray(Empty,0))   To Empty
788
    Set pAllMessages      To Empty
789
    Set pAllProperties    To Empty
790
    Set pLanguageKeywords To Empty
791
    Get pbDebugRestart to bRestartMode
792
    If (bRestartMode) Begin
793
      Send DoDebugRun
794 38 wil
    End
795 64 wil
    Else Begin
796
      Get pbStartedFromCLI of ghoApplication To bStartedFromCLI
797
      If (bStartedFromCli) Begin
798
        // debug session was started from the command line.
799
        // Stopping the debug session normally should stop the debugger as well.
800
        Send Exit_Application
801
      End
802
    End
803 7 wil
  End_Procedure
804
805
  // Occurs if there is an error starting the program
806
  Procedure OnComProgramStartupError String llerrorMessage
807
    Set pbProgramStarted To False
808
    Send Info_Box llerrorMessage "start up error"
809
  End_Procedure
810
811
  // Occurs if there is an error initializing the program
812
  Procedure OnComProgramInitError String llerrorMessage
813
    Set pbProgramStarted To False
814
    Send Info_Box (llErrorMessage) "Custom Error INIT"
815
  End_Procedure
816
817 20 wil
  Procedure SetDebuggerAsForegroundApp
818
    Handle  hoEditor
819
    Handle  hWnd
820
    Integer iVoid
821
    Get phoEditor To hoEditor
822
    If (hoEditor) Begin
823
      Get Window_Handle of hoEditor To hWnd
824
      If (hWnd) Begin
825
        Move (SetForegroundWindow(hWnd)) To iVoid
826
      End
827
    End
828
  End_Procedure // SetDebuggerAsForegroundApp
829
830 7 wil
  //
831
  // Hook to be used
832
  // Called from OnComProgramPaused
833
  //
834 8 wil
  // Occurs when the program execution is paused
835 28 wil
  Procedure OnProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
836 20 wil
    Handle hoEditor
837
    String sBreakMode
838 8 wil
839
    Get phoEditor   To hoEditor
840
    If (hoEditor) Begin
841 20 wil
      If lllimitedBreakMode Begin
842
        Move "limited Break mode" To sBreakMode
843
        //Else Move "Unlimited Break mode" to sBreakMode
844
        Send info_Box ("Pausing program\n"+sBreakMode) "VdfSplat Info"
845
      End
846
      Else Begin
847
        Send SetDebuggerAsForegroundApp
848
      End
849
      Send doOpenSourceFileAtLine of hoEditor llfile llline
850 64 wil
      Send doActivateDebugPanels  // only displays if exists or not.
851 8 wil
    End
852 7 wil
  End_Procedure
853
854
  //
855
  // Occurs when the program execution is paused
856 28 wil
  Procedure OnComProgramPaused String llfile UInteger llline Boolean lllimitedBreakMode
857 64 wil
    Set pbProgramPaused    To True
858
    Set pbLimitedBreakMode To lllimitedBreakMode
859 7 wil
    Send OnProgramPaused llfile llline lllimitedBreakMode
860
  End_Procedure
861
862
  // Occurs when the program execution resumes
863
  Procedure OnComProgramContinue
864 64 wil
    Set pbProgramPaused    To False
865
    Set pbLimitedBreakMode To False
866 7 wil
  End_Procedure
867
868
  // Occurs after a change requiring views to be refreshed
869
  Procedure OnUpdateView String sFileName UInteger iLine
870 8 wil
    Handle hoEditor
871
872
    Get phoEditor To hoEditor
873
    If (hoEditor) begin
874
      //Send Info_Box "OnComUpdateView" (llfile*"llline = "*trim(llline))
875
      Send doOpenSourceFileAtLine of hoEditor sFileName iLine
876 28 wil
    End
877 7 wil
  End_Procedure
878
879
  // Occurs after a change requiring views to be refreshed
880
  Procedure OnComUpdateView String sFileName UInteger iLine
881
    Send OnUpdateView sFileName iLine
882
  End_Procedure
883
884
  // Occurs when a new message is executed
885
  Procedure OnComNewMessage Integer llbSteppin
886
  End_Procedure
887
888
  // Occurs if an unhandled program exception is detected
889
  Procedure OnComUnhandledProgramException String lldescription
890
    Send Info_box lldescription "FATAL Error"
891
  End_Procedure
892
893
  // 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
894
  Procedure OnComAcceptWebAppSession Boolean ByRef llacceptNewSession
895
  End_Procedure
896
897
  // Occurs if there is a fatal web app error
898 28 wil
  Procedure OnComWebAppError String lldescription
899 7 wil
    Send Info_box lldescription "WebApp FATAL Error"
900
  End_Procedure
901
902
  // Occurs when a new webapp event log entry is added
903
  Procedure OnComWebAppLog Integer lleventId String lltext
904
    //Send Info_box lldescription "WebApp FATAL Error"
905
    Showln lleventid lltext
906 28 wil
  End_Procedure
907 64 wil
908
  Procedure AddKeyword String sWord
909
    Integer  iCount
910
    String[] Keywords
911
912
    Get pLanguageKeywords To Keywords
913
    Move (SizeOfArray(Keywords)) To iCount
914
    Move (Lowercase(sWord)) To Keywords[iCount]
915
    Set pLanguageKeywords To Keywords
916
  End_Procedure
917
918
  // Language keywords are not evaluated in the tooltip
919
  Procedure AddLanguageKeywords
920
    Send AddKeyword "End_Function"
921
    Send AddKeyword "End_Procedure"
922
    Send AddKeyword "Function"
923
    Send AddKeyword "Move"
924
    Send AddKeyword "Procedure"
925
    Send AddKeyword "Send"
926
    Send AddKeyword "Showln"
927
    Send AddKeyword "To"
928
    Send AddKeyword "UChar[]"
929
  End_Procedure
930 8 wil
931 7 wil
932 8 wil
  Procedure doCreateCallStack
933
    Handle  hoParent
934
    Handle  hoCallStack
935
    Boolean bCreated
936
937
    Get phoCallStackHost To hoParent
938
    If (hoParent) Begin
939
      Get Create Of hoParent U_cCallStack To hoCallStack
940
      If (hoCallStack) Begin
941
        Set Name               Of hoCallStack To "oCallStack"
942
        Send CreateComObject   Of hoCallStack
943
        Get IsComObjectCreated Of hoCallStack To bCreated
944 28 wil
        If (bCreated) Begin
945 37 wil
          Send SetControlColumnWidth of hoCallStack hoCallStack
946 8 wil
        End
947
      End
948
    End
949 28 wil
  End_Procedure // doCreateCallStack
950 8 wil
951
952
  Procedure doCreateWatches
953
    Handle  hoParent
954
    Handle  hoWatches
955
    Boolean bCreated
956
957
    Get phoWatchesHost To hoParent
958
    If (hoParent) Begin
959
      Get Create Of hoParent U_cWatches To hoWatches
960
      If (hoWatches) Begin
961
        Set Name               Of hoWatches To "oWatches"
962
        Send CreateComObject   Of hoWatches
963
        Get IsComObjectCreated Of hoWatches To bCreated
964 28 wil
        If (bCreated) Begin
965 8 wil
        End
966
      End
967
    End
968 28 wil
  End_Procedure // doCreateWatches
969 8 wil
970
971
  Procedure doCreateMessageTrace
972
    Handle  hoParent
973
    Handle  hoTrace
974
    Boolean bCreated
975
976
    Get phoTraceHost To hoParent
977
    If (hoParent) Begin
978
      Get Create Of hoParent U_cMessageTrace To hoTrace
979
      If (hoTrace) Begin
980
        Set Name               Of hoTrace To "oMessageTrace"
981
        Send CreateComObject   Of hoTrace
982
        Get IsComObjectCreated Of hoTrace To bCreated
983 28 wil
        If (bCreated) Begin
984 8 wil
        End
985
      End
986
    End
987
  End_Procedure // doCreateMessageTrace
988
989
990
  Procedure doCreateGlobalVariables
991
    Handle  hoParent
992
    Handle  hoVariables
993
    Boolean bCreated
994
995
    Get phoGlobalVarHost To hoParent
996
    If (hoParent) Begin
997
      Get Create Of hoParent U_cVariablesWindow To hoVariables
998
      If (hoVariables) Begin
999
        Set phoGlobalVariables To hoVariables
1000
        Set Name               Of hoVariables To "oGlobalVariables"
1001
        Send CreateObjectCallback of hoParent hoVariables
1002
1003
        Send CreateComObject   Of hoVariables
1004
        Get IsComObjectCreated Of hoVariables To bCreated
1005 28 wil
        If (bCreated) Begin
1006
          Set ComWindowType Of hoVariables To 1 // global
1007 8 wil
        End
1008
      End
1009
    End
1010 28 wil
  End_Procedure // doCreateGlobalVariables
1011 8 wil
1012
1013
  Procedure doCreateLocalVariables
1014
    Handle  hoParent
1015
    Handle  hoVariables
1016
    Boolean bCreated
1017
1018
    Get phoLocalVarHost To hoParent
1019
    If (hoParent) Begin
1020
      Get Create Of hoParent U_cVariablesWindow To hoVariables
1021
      If (hoVariables) Begin
1022
        Set phoLocalVariables  To hoVariables
1023
        Set Name               Of hoVariables To "oLocalVariables"
1024
1025
        Send CreateComObject   Of hoVariables
1026
        Get IsComObjectCreated Of hoVariables To bCreated
1027 28 wil
        If (bCreated) Begin
1028 8 wil
          Set ComWindowType Of hoVariables To 0 // locals
1029
        End
1030 64 wil
        Send CreateObjectCallback of hoParent hoVariables
1031 8 wil
      End
1032
    End
1033 28 wil
  End_Procedure // doCreateLocalVariables
1034 8 wil
1035
1036
  Procedure doCreateTablesWindow
1037
    Handle  hoParent
1038
    Handle  hoTables
1039
    Boolean bCreated
1040
1041
    Get phoTablesHost To hoParent
1042
    If (hoParent) Begin
1043
      Get Create Of hoParent U_cTablesWindow To hoTables
1044
      If (hoTables) Begin
1045
        Set Name               Of hoTables To "oTablesWindow"
1046
        Send CreateComObject   Of hoTables
1047
        Get IsComObjectCreated Of hoTables To bCreated
1048 28 wil
        If (bCreated) Begin
1049 8 wil
        End
1050
      End
1051
    End
1052
  End_Procedure // doCreateTables
1053
1054
1055 64 wil
  // we MUST send activate to the debug panels to make them display.
1056
  Procedure doActivateDebugPanels
1057 8 wil
    Handle  hoCallStack
1058 64 wil
    Handle  hoLocalVars
1059
    Handle  hoGlobalVars
1060 8 wil
    Boolean bCreated
1061
1062
    Get phoCallStack To hoCallStack
1063
    If (hoCallStack) Begin
1064
      Get IsComObjectCreated Of hoCallStack To bCreated
1065 28 wil
      If (bCreated) Begin
1066 64 wil
        Send Activate of hoCallStack
1067 8 wil
      End
1068
    End
1069
1070 64 wil
    Get phoLocalVariables To hoLocalVars
1071
    If (hoLocalVars) Begin
1072
      Get IsComObjectCreated Of hoLocalVars To bCreated
1073
      If (bCreated) Begin
1074
        Send Activate of hoLocalVars
1075
      End
1076
    End
1077 8 wil
1078 64 wil
    Get phoGlobalVariables To hoGlobalVars
1079
    If (hoGlobalVars) Begin
1080
      Get IsComObjectCreated Of hoGlobalVars To bCreated
1081
      If (bCreated) Begin
1082
        Send Activate of hoGlobalVars
1083
      End
1084
    End
1085
  End_Procedure
1086
1087
1088 8 wil
1089
  Procedure DoCreateEngine
1090 28 wil
    Boolean bCreated
1091 8 wil
    Handle  hoDebugger
1092
    Handle  hoEditor
1093
1094 28 wil
    Send CreateComObject
1095
    Get IsComObjectCreated to bCreated
1096
    If (bCreated) Begin
1097 8 wil
1098
      Move Self To hoDebugger
1099
      Set pbEngineActive To True
1100
      Set phoDebugger to hoDebugger
1101 28 wil
    End
1102 8 wil
1103
    Send DoCreateCallStack
1104
1105
    Send DoCreateWatches
1106
1107
    Send DoCreateMessageTrace
1108
1109
    Send DoCreateGlobalVariables
1110
1111
    Send doCreateLocalVariables
1112
1113 28 wil
    Send doCreateTablesWindow
1114 64 wil
1115
    Send AddLanguageKeywords
1116 28 wil
  End_Procedure // DoCreateEngine
1117 8 wil
1118
1119 7 wil
  Procedure OnCreate
1120
    forward Send OnCreate
1121 28 wil
  End_Procedure // OnCreate
1122 7 wil
1123
1124 28 wil
End_Class // cDebuggerEngine