-
Notifications
You must be signed in to change notification settings - Fork 0
/
aux2svg.rex
4032 lines (3736 loc) · 152 KB
/
aux2svg.rex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*REXX 2.0.0
CICS Auxiliary Trace Visualizer V2.0
Copyright (C) 2005-2020 Andrew J. Armstrong
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Author:
Andrew J. Armstrong <androidarmstrong@gmail.com>
*/
/*REXX*****************************************************************
** **
** NAME - AUX2SVG **
** **
** FUNCTION - Creates a graphical representation of a CICS auxiliary **
** trace printout by using Scalable Vector Graphics (SVG).**
** The SVG markup represents the trace data in the form **
** of a Unified Modelling Language (UML) Sequence Diagram **
** (or at least something quite like it). **
** **
** The 'actors' (for example, programs) are listed side- **
** by-side at the top of the diagram. A life line is **
** drawn vertically below each actor. Interactions **
** between actors (for example, calls and returns) are **
** represented as arrows drawn between the life lines. **
** The vertical axis is time. Each interaction is labeled **
** on the left of the diagram with the relative time in **
** seconds since the start of the trace and the task id. **
** All the interactions for a task are assigned the same **
** unique color. Each interaction is annotated with the **
** trace sequence number, to enable you to refer back to **
** the original trace record for more detail, and a summ- **
** ary of the call and return values. Exception responses **
** are shown in red. **
** **
** You can choose which actors you are interested in by **
** specifying one or more domain names. For example, if **
** you wanted to visualize TCP/IP socket activity, you **
** would specify the PG (program) and SO (socket) domains:**
** **
** aux2svg mytrace.txt (PG SO **
** **
** If you wanted to examine a storage allocation problem **
** you would specify the SM (storage manager) domain: **
** **
** aux2svg mytrace.txt (SM **
** **
** By default, ALL domains are selected but this can take **
** a long time to process. It is best to restrict the **
** actors to a few domains that you are interested in. **
** **
** **
** USAGE - You can run this Rexx under IBM z/OS, or under Linux **
** or Windows using Regina Rexx from: **
** **
** http://regina-rexx.sourceforge.net **
** **
** If you run aux2svg under z/OS, then it will create **
** either output datasets or PDS members depending on **
** whether the input auxiliary trace print file is in **
** a sequential dataset or a partitioned dataset. **
** **
** For an input sequential dataset "dsn", the following **
** files will be created: **
** **
** dsn.HTML <-- Unless you specified the NOHTML option **
** dsn.XML <-- If you specified the XML option **
** **
** For an input PDS member "dsn(mem)", the following **
** members will be created: **
** **
** dsn(memH) <-- Unless you specified the NOHTML option **
** dsn(memX) <-- If you specified the XML option **
** **
** You should restrict the length of the member name to **
** no more than 7 characters to accommodate the H or X **
** suffix. **
** **
** You should then download the resulting html file to a **
** PC by: **
** **
** ftp yourmainframe **
** youruserid **
** yourpassword **
** quote site sbdataconn=(IBM-1047,ISO8859-1) **
** get 'your.output.html' your.output.html **
** **
** **
** However, it is probably quicker to download the CICS **
** auxiliary trace print file to you PC and process it **
** there by issuing: **
** **
** rexx aux2svg.rexx your.trace.txt (options... **
** **
** ...which will create the following files: **
** **
** your.trace.html <-- Unless you specified NOHTML **
** your.trace.xml <-- If you specified the XML option **
** **
** You can view the resulting HTML file using any modern **
** web browser. **
** **
** SYNTAX - AUX2SVG infile [(options...] **
** **
** Where, **
** **
** infile = Name of file to read auxtrace printout from.**
** **
** options = DETAIL - Include hex data for each record **
** in the xml output file. **
** HTML - Create html file from the input. **
** XML - Create xml file from input file. **
** EVENT - Process input EVENT trace records. **
** DATA - Process input DATA trace records. **
** xx - One or more 2-letter domain names **
** that you want to process. The **
** default is ALL trace domains and **
** can be much slower. For example, **
** to show socket activity you would **
** specify PG and SO. **
** **
** To negate any of the above options, prefix **
** the option with NO. For example, NOXML. **
** **
** The default options are: **
** **
** HTML EVENT DATA NOXML NODETAIL **
** **
** LOGIC - 1. Create an in-memory <html> document. **
** **
** 2. Create an in-memory <auxtrace> element, but do not **
** connect it to the <html> document. **
** **
** 3. Scan the auxiliary trace output and convert each **
** pair of ENTRY/EXIT trace entries into a single XML **
** <trace> element. Add each <trace> element to the **
** <auxtrace> element and nest the <trace> elements. **
** The <auxtrace> element is a temporary representation**
** of the auxiliary trace data and will be discarded **
** and/or written to an output file later. **
** **
** 4. Walk through the tree of <trace> elements and when **
** an interesting <trace> element is found, add **
** appropriate markup to the <html> element in order **
** to visualize the <trace> element. **
** **
** 5. Output an HTML document by using the PrettyPrinter **
** routine to 'print' the <html> element to a file. **
** **
** 6. Output an XML document by using the PrettyPrinter **
** routine to 'print' the <auxtrace> element (only if **
** the XML option was specified). **
** **
** EXAMPLE - 1. To investigate a socket programming problem: **
** **
** AUX2SVG auxtrace.txt (PG SO DETAIL XML **
** **
** This will create the following files: **
** auxtrace.html - HTML representation of the trace. **
** auxtrace.xml - XML representation of the trace. **
** **
** AUTHOR - Andrew J. Armstrong <androidarmstrong@gmail.com> **
** **
** HISTORY - Date By Reason (most recent at the top pls) **
** -------- -------- ------------------------------------ **
** 20200623 AJA Support for CICS TS 5.5. **
** Modernise the HTML output. **
** 20060120 AJA Conform to CSS2 requirements of **
** Mozilla Firefox 1.5 (font-size must **
** have a unit, stroke-dasharray must **
** use a comma as a delimiter). **
** 20051027 AJA Draw colored arrow heads. **
** 20051026 AJA Set xml name space to 'svg' (oops!). **
** 20051025 AJA Minor changes. Fixed bug in parsexml.**
** 20051018 AJA Documentation corrections. Enhanced **
** getDescriptionOfCall() for CC, GC, **
** DS and AP domains. **
** 20051014 AJA Intial version. **
** **
**********************************************************************/
parse arg sFileIn' ('sOptions')'
numeric digits 16
say 'AUX000I CICS Auxiliary Trace Visualizer v2.0'
sOptions = 'NOBLANKS' translate(sOptions)
call initParser sOptions /* DO THIS FIRST! Sets g. vars to '' */
parse source g.0ENV .
if g.0ENV = 'TSO'
then do
address ISPEXEC
'CONTROL ERRORS RETURN'
g.0LINES = 0
g.0NONRECURSIVE = 1
end
call setFileNames sFileIn
call setOptions sOptions
call Prolog
if sFileIn = ''
then do
say 'Syntax:'
say ' aux2svg infile [(options]'
say
say 'Where:'
say ' infile = CICS auxiliary trace print file'
say
say ' options = DETAIL - Include hex data for each record.'
say ' XML - Create xml file from input file.'
say ' EVENT - Include EVENT trace records.'
say ' DATA - Include DATA trace records.'
say
say ' To negate any of the above options, prefix'
say ' the option with NO. For example, NOXML.'
say
say ' xx - One or more 2-letter domain names'
say ' that you want to process. The'
say ' default is all trace domains and'
say ' can be much slower. For example,'
say ' to show socket activity you would'
say ' specify PG and SO.'
say
say 'Valid domain names are:'
do i = 1 to g.0DOMAIN.0
sDomain = g.0DOMAIN.i
say ' 'sDomain g.0DOMAIN.sDomain
end
exit
end
say 'AUX001I Scanning CICS auxiliary trace in' sFileIn
doc = createDocument('html')
call scanAuxTraceFile
if g.0OPTION.DUMP
then call _displayTree
if g.0OPTION.XML
then do
call setDocType /* we don't need a doctype declaration */
call prettyPrinter g.0FILEXML,,g.0AUXTRACE
end
if g.0OPTION.HTML
then do
call buildHTML
call setPreserveWhitespace 1 /* to keep newlines in <desc> tags */
g.0ESCAPETEXT = 0 /* suppress emitting entities */
call prettyPrinter g.0FILEHTM
end
call Epilog
exit
/* The auxtrace input filename is supplied by the user.
The names of the XML and HTML output files are automatically
generated from the input file filename. The generated file names also
depend on the operating system. Global variables are set as follows:
g.0FILETXT = name of input text file (e.g. auxtrace.txt)
g.0FILEHTM = name of output HTML file (e.g. auxtrace.html)
g.0FILEXML = name of output XML file (e.g. auxtrace.xml)
*/
setFileNames: procedure expose g.
parse arg sFileIn
if g.0ENV = 'TSO'
then do
parse var sFileIn sDataset'('sMember')'
if sMember <> ''
then do /* make output files members in the same PDS */
sPrefix = strip(left(sMember,7)) /* room for a suffix char */
sPrefix = translate(sPrefix) /* translate to upper case */
g.0FILETXT = translate(sFileIn)
/* squeeze the file extension into the member name...*/
g.0FILEHTM = sDataset'('strip(left(sPrefix'HTM',8))')'
g.0FILEXML = sDataset'('strip(left(sPrefix'XML',8))')'
end
else do /* make output files separate datasets */
g.0FILETXT = translate(sFileIn)
g.0FILEHTM = sDataset'.HTML'
g.0FILEXML = sDataset'.XML'
end
end
else do
sFileName = getFilenameWithoutExtension(sFileIn)
g.0FILETXT = sFileIn
g.0FILEHTM = sFileName'.html'
g.0FILEXML = sFileName'.xml'
end
return
getFilenameWithoutExtension: procedure expose g.
parse arg sFile
parse value reverse(sFile) with '.'sRest
return reverse(sRest)
scanAuxTraceFile: procedure expose g.
g.0ACTOR_NODES = ''
g.0AUXTRACE = createElement('auxtrace')
call saveActor g.0AUXTRACE,'root'
g.0FILEIN = openFile(g.0FILETXT)
g.0K = 0 /* Trace entry count */
g.0KD = 0 /* Trace entry delta since last progress message */
sLine = getLineContaining('CICS - AUXILIARY TRACE FROM')
parse var sLine 'CICS - AUXILIARY TRACE FROM ',
sDate ' - APPLID' sAppl .
call setAttributes g.0AUXTRACE,,
'date',sDate,,
'appl',sAppl
g.0ROWS = 0
bAllDomains = words(g.0DOMAIN_FILTER) = 0
sEntry = getFirstTraceEntry()
parse var g.0ENTRYDATA.1 '='g.0FIRSTSEQ'=' .
do while g.0RC = 0
parse var sEntry sDomain xType sModule sAction sParms
if sAction = '-' /* oddball format */
then parse var sEntry sDomain xType sModule '-' sAction sParms
if g.0FREQ.sDomain = ''
then do
g.0FREQ.sDomain = 0
if g.0DOMAIN.sDomain = ''
then do
say 'AUX002W Unknown domain "'sDomain'" found in' sEntry
call addDomain sDomain,'Unknown domain'
end
end
g.0FREQ.sDomain = g.0FREQ.sDomain + 1
if bAllDomains | wordpos(sDomain,g.0DOMAIN_FILTER) > 0
then do
parse var g.0ENTRYDATA.1 'TASK-'nTaskId . 'TIME-'sTime .,
'INTERVAL-'nInterval . '='nSeq'=' .
if g.0TASK.nTaskId = '' /* if task is new */
then do
call initStack nTaskId
e = createElement('task')
call pushStack nTaskId,e
g.0TASK.nTaskId = e
call appendChild e,g.0AUXTRACE
call setAttribute e,'taskid',nTaskId
end
task = g.0TASK.nTaskId
nElapsed = getElapsed(sTime)
select
when sAction = 'ENTRY' then do
g.0ROWS = g.0ROWS + 1 /* row to draw arrow on */
sParms = strip(sParms)
select
when left(sParms,1) = '-' then do /* if new style parms */
/* ENTRY - FUNCTION(xxx) yyy(xxx) ... */
sParms = space(strip(sParms,'LEADING','-'))
if pos('FUNCTION(',sParms) > 0
then do
parse var sParms 'FUNCTION('sFunction')'
n = wordpos('FUNCTION('sFunction')',sParms)
if n > 0 then sParms = delword(sParms,n,1)
end
else do
if left(sParms,1) = '*'
/* e.g. '** Decode of parameter list failed **' */
then sFunction = sParms
else parse var sParms sFunction sParms
end
end
when pos('REQ(',sParms) > 0 then do /* old style parms */
/* ENTRY function REQ(xxx) ... */
parse var sParms sFixed'REQ('sParms
sParms = 'REQ('sParms
parse var sFixed sFunction sRest
sParms = 'PARMS('sRest')'
end
otherwise do /* old style parms */
/* ENTRY function parms */
/* ENTRY FUNCTION(function) parms */
if pos('FUNCTION(',sParms) > 0
then do
parse var sParms 'FUNCTION('sFunction')'
n = wordpos('FUNCTION('sFunction')',sParms)
if n > 0 then sParms = delword(sParms,n,1)
end
else do
parse var sParms sFunction sParms
end
end
end
parent = peekStack(nTaskId)
e = createElement('trace')
call appendChild e,parent
call setAttributes e,,
'seq',nSeq,,
'row',g.0ROWS,,
'elapsed',nElapsed,,
'interval',getInterval(sTime),,
'domain',sDomain,,
'module','DFH'sModule,,
'function',sFunction,,
'taskid',nTaskId
call setParmAttributes e,'entryparms',sParms
if g.0OPTION.DETAIL & g.0ENTRYDATA.0 > 1
then call appendDetail e,'on-entry'
call pushStack nTaskId,e
call saveActor e,'trace'
end
when sAction = 'EXIT' then do
g.0ROWS = g.0ROWS + 1 /* row to draw arrow on */
sParms = strip(sParms)
sReason = ''
sAbend = ''
select
when left(sParms,1) = '-' then do
/* EXIT - FUNCTION(xxx) yyy(xxx) ... */
sParms = space(strip(sParms,'LEADING','-'))
if pos('FUNCTION(',sParms) > 0
then do
parse var sParms 'FUNCTION('sFunction')',
1 'RESPONSE('sResponse')',
1 'REASON('sReason')',
1 'ABEND_CODE('sAbend')'
n = wordpos('FUNCTION('sFunction')',sParms)
if n > 0 then sParms = delword(sParms,n,1)
n = wordpos('RESPONSE('sResponse')',sParms)
if n > 0 then sParms = delword(sParms,n,1)
end
else do
if left(sParms,1) = '*'
/* e.g. '** Decode of parameter list failed **' */
then do
sFunction = ''
sResponse = ''
end
else parse var sParms sFunction sResponse sParms
sReason = ''
sAbend = ''
end
end
when pos('REQ(',sParms) > 0 then do
/* EXIT function response REQ(xxx) ... */
/* EXIT response REQ(xxx) ... */
parse var sParms sFixed'REQ('sParms
sParms = 'REQ('sParms
if words(sFixed) = 1
then do
sFunction = ''
sResponse = strip(sFixed)
end
else do
parse var sFixed sFunction sResponse .
end
end
when pos('FUNCTION(',sParms) > 0 then do
/* EXIT FUNCTION(xxx) RESPONSE(xxx) parms ... */
parse var sParms 'FUNCTION('sFunction')',
1 'RESPONSE('sResponse')'
n = wordpos('FUNCTION('sFunction')',sParms)
if n > 0 then sParms = delword(sParms,n,1)
n = wordpos('RESPONSE('sResponse')',sParms)
if n > 0 then sParms = delword(sParms,n,1)
end
otherwise do
parse var sParms sFunction sParms
end
end
parent = popStack(nTaskId)
if parent <> g.0AUXTRACE
then do
call setAttributes parent,,
'exitrow',g.0ROWS,,
'response',sResponse,,
'exitseq',nSeq
sCompoundReason = strip(sReason sAbend)
if sCompoundReason <> ''
then call setAttribute parent,'reason',sCompoundReason
call setParmAttributes parent,'exitparms',sParms
call saveActor e,'exit'
end
if g.0OPTION.DETAIL & g.0ENTRYDATA.0 > 1
then call appendDetail parent,'on-exit'
end
when sAction = 'EVENT' then do
if g.0OPTION.EVENT
then do
g.0ROWS = g.0ROWS + 1 /* row to draw arrow on */
sParms = space(strip(strip(sParms),'LEADING','-'))
parse var sParms sFunction sParms
parent = peekStack(nTaskId)
e = createElement('event')
call appendChild e,parent
call setAttributes e,,
'seq',nSeq,,
'row',g.0ROWS,,
'elapsed',nElapsed,,
'interval',getInterval(sTime),,
'domain',sDomain,,
'module','DFH'sModule,,
'function',sFunction,,
'parms',sParms,,
'taskid',nTaskId
if g.0OPTION.DETAIL & g.0ENTRYDATA.0 > 1
then call appendDetail e,'detail'
call saveActor e,'event'
end
end
when sAction = 'CALL' then do
sParms = space(strip(strip(sParms),'LEADING','-'))
parse var sParms sFunction sParms
parent = peekStack(nTaskId)
e = createElement('call')
call appendChild e,parent
call setAttributes e,,
'seq',nSeq,,
'row',g.0ROWS,,
'elapsed',nElapsed,,
'interval',getInterval(sTime),,
'domain',sDomain,,
'module','DFH'sModule,,
'function',sFunction,,
'taskid',nTaskId
call setParmAttributes e,'entryparms',sParms
call saveActor e,'call'
end
when sAction = 'RETURN' | sAction = 'RETRN' then do
sParms = space(strip(strip(sParms),'LEADING','-'))
parse var sParms sFunction sParms
parent = peekStack(nTaskId)
e = createElement('return')
call appendChild e,parent
call setAttributes e,,
'seq',nSeq,,
'row',g.0ROWS,,
'elapsed',nElapsed,,
'interval',getInterval(sTime),,
'domain',sDomain,,
'module','DFH'sModule,,
'function',sFunction,,
'taskid',nTaskId
call setParmAttributes e,'exitparms',sParms
call saveActor e,'return'
end
when sAction = '*EXC*' then do
g.0ROWS = g.0ROWS + 1 /* row to draw arrow on */
sParms = space(strip(sParms,'LEADING','-'))
parse var sParms sFunction sParms
parent = peekStack(nTaskId)
e = createElement('exception')
call appendChild e,parent
call setAttributes e,,
'seq',nSeq,,
'row',g.0ROWS,,
'elapsed',nElapsed,,
'interval',getInterval(sTime),,
'domain',sDomain,,
'module','DFH'sModule,,
'function',sFunction,,
'parms',sParms,,
'taskid',nTaskId
call saveActor e,'exception'
end
when sAction = 'DATA' then do
if g.0OPTION.DATA
then do
g.0ROWS = g.0ROWS + 1 /* row to draw arrow on */
sParms = space(strip(strip(sParms),'LEADING','-'))
parse var sParms sFunction sParms
parent = peekStack(nTaskId)
e = createElement('data')
call appendChild e,parent
call setAttributes e,,
'seq',nSeq,,
'row',g.0ROWS,,
'elapsed',nElapsed,,
'interval',getInterval(sTime),,
'domain',sDomain,,
'module','DFH'sModule,,
'function',sFunction,,
'taskid',nTaskId
if g.0OPTION.DETAIL & g.0ENTRYDATA.0 > 1
then call appendDetail e,'detail'
call saveActor e,'data'
end
end
when sAction = 'RESUMED' then do
g.0ROWS = g.0ROWS + 1 /* row to draw arrow on */
sParms = space(strip(strip(sParms),'LEADING','-'))
parse var sParms sFunction sParms
parent = peekStack(nTaskId)
e = createElement('resumed')
call appendChild e,parent
call setAttributes e,,
'seq',nSeq,,
'row',g.0ROWS,,
'elapsed',nElapsed,,
'interval',getInterval(sTime),,
'domain',sDomain,,
'module','DFH'sModule,,
'function',sFunction,,
'taskid',nTaskId
call setParmAttributes e,'exitparms',sParms
call saveActor e,'resumed'
end
when sAction = 'PC' then do
/* this trace type does not seem to add any value */
end
otherwise do
parent = peekStack(nTaskId)
call appendTextNode sEntry,parent
say 'AUX003E Unknown trace entry <'sAction'>:' sEntry
end
end
end
sEntry = getTraceEntry()
end
rc = closeFile(g.0FILEIN)
say 'AUX004I Processed' g.0K-1 'trace entries'
say 'AUX005I Domain processing summary:'
do i = 1 to g.0DOMAIN.0
sDomain = g.0DOMAIN.i
sDesc = g.0DOMAIN.sDomain
if bAllDomains | wordpos(sDomain,g.0DOMAIN_FILTER) > 0
then sFilter = 'Requested'
else sFilter = ' '
if g.0FREQ.sDomain > 0
then sFound = 'Found' right(g.0FREQ.sDomain,5)
else sFound = ' '
say 'AUX006I 'sFilter sFound sDomain sDesc
end
return
saveActor: procedure expose g.
parse arg node,sType
sActorName = getActorName(node)
if g.0ACTOR.sActorName = ''
then do
g.0ACTOR_NODES = g.0ACTOR_NODES node
g.0ACTOR.sActorName = 1 /* we've seen this actor now */
end
return
initStack: procedure expose g.
parse arg task
g.0T.task = 0 /* set top of stack index for task */
return
pushStack: procedure expose g.
parse arg task,item
tos = g.0T.task + 1 /* get new top of stack index for task */
g.0E.task.tos = item /* set new top of stack item */
g.0T.task = tos /* set new top of stack index */
return
popStack: procedure expose g.
parse arg task
tos = g.0T.task /* get top of stack index for task */
item = g.0E.task.tos /* get item at top of stack */
g.0T.task = max(tos-1,1)
return item
peekStack: procedure expose g.
parse arg task
tos = g.0T.task /* get top of stack index for task */
item = g.0E.task.tos /* get item at top of stack */
return item
getLineContaining: procedure expose g.
parse arg sSearchArg
sLine = getLine(g.0FILEIN)
do while g.0RC = 0 & pos(sSearchArg, sLine) = 0
sLine = getLine(g.0FILEIN)
end
return sLine
getNextLine: procedure expose g.
sLine = getLine(g.0FILEIN)
if g.0RC = 0
then do
cc = left(sLine,1)
select
when cc = '0' then sLine = '' /* ASA double space */
when cc = '1' then do /* ASA page eject */
sLine = getLine(g.0FILEIN) /* skip blank line after title */
if sLine <> ''
then say 'AUX007W Line after heading is not blank:' sLine
sLine = getLine(g.0FILEIN) /* read next data line */
end
when sLine = '<<<< STARTING DATA FROM NEXT EXTENT >>>>' then,
sLine = ''
otherwise nop
end
end
return sLine
getFirstTraceEntry: procedure expose g.
sLine = getNextLine()
parse var sLine sDomain xType sModule .
do while g.0RC = 0 & length(sDomain) <> 2
sLine = getNextLine()
parse var sLine sDomain xType sModule .
end
return getTraceEntry(sLine)
getTraceEntry: procedure expose g.
parse arg sEntry
/* The general format of a trace entry is something like:
Old style:
dd tttt mmmm action ...fixed_width_stuff... parms...
moreparms...
TASK-nnnnn ....timing info etc........... =seqno=
1-0000 ...hex dump.... *...character dump...*
2-0000 ...hex dump.... *...character dump...*
0020 ...hex dump.... *...character dump...*
.
.
n-0000 ...hex dump.... *...character dump...*
.
.
New style:
dd tttt mmmm action - parms...
moreparms...
TASK-nnnnn ....timing info etc........... =seqno=
1-0000 ...hex dump.... *...character dump...*
2-0000 ...hex dump.... *...character dump...*
0020 ...hex dump.... *...character dump...*
.
.
n-0000 ...hex dump.... *...character dump...*
.
.
*/
sLine = getNextLine()
do while g.0RC = 0 & left(strip(sLine),5) <> 'TASK-'
sEntry = sEntry strip(sLine)
sLine = getNextLine()
end
g.0ENTRYDATA.0 = 0
do i = 1 while g.0RC = 0 & sLine <> ''
g.0ENTRYDATA.i = sLine
g.0ENTRYDATA.0 = i
sLine = getNextLine()
end
g.0K = g.0K + 1
g.0KD = g.0KD + 1
if g.0KD >= 1000
then do
say 'AUX008I Processed' g.0K 'trace entries'
g.0KD = 0
end
return sEntry
getElapsed: procedure expose g.
parse arg nHH':'nMM':'nSS
nThisOffset = ((nHH*60)+nMM)*60+nSS
if g.0FIRSTOFFSET = ''
then g.0FIRSTOFFSET = nThisOffset
return nThisOffset - g.0FIRSTOFFSET
getInterval: procedure expose g.
parse arg sTime
nThisOffset = getElapsed(sTime) /* seconds from start of trace */
if g.0PREVOFFSET = ''
then nInterval = 0
else nInterval = nThisOffset - g.0PREVOFFSET
g.0PREVOFFSET = nThisOffset
return nInterval
setParmAttributes: procedure expose g.
parse arg e,sAttrName,sParms
/* Set parms="full list of parameters" */
if sParms <> ''
then call setAttribute e,sAttrName,space(sParms)
/* Set individual name="value" attributes */
if pos('(',sParms) > 0
then do while sParms <> ''
parse var sParms sName'('sValue')'sParms
sName = getValidAttributeName(sName)
if wordpos(sName,'FIELD-A FIELD-B') > 0
then parse var sValue sValue .
call setAttribute e,space(sName,0),strip(sValue)
end
return
buildHTML: procedure expose g.
say 'AUX009I Building HTML'
g.0LINEDEPTH = 12
html = getDocumentElement()
head = createElement('head')
call appendChild head,html
body = createElement('body')
call appendChild body,html
/* Build styles */
g.0STYLE = newElement('style','type','text/css')
call appendChild g.0STYLE,head
queue '.background {fill:white;}'
queue '.top {background-color:gray; color:white; text-align:center;}'
queue '.sticky {background-color:white; position:sticky; top:0;}'
queue 'h3 {font-family:sans-serif; font-size:smaller;',
'margin-top:0; margin-bottom:0;}'
queue 'p {font-family:sans-serif; font-size:xx-small;',
'margin:0 0 0 0;}'
queue '.actors {background-color:white; padding-left:0;',
'text-anchor:middle;}'
queue '.content {background-color:white;}'
queue '.lifeline {stroke:lightgray; stroke-dasharray:5,2; fill:none;}'
queue '.seq {fill:gray;}'
queue '.arrows {stroke-width:2; fill:none;}'
queue '.return {stroke-dasharray:2,3;}'
queue '.annotation {stroke:none; font-size:6px;}'
queue '.ltr {text-anchor:start;}'
queue '.rtl {text-anchor:end;}'
queue '.error {fill:red;}'
queue 'text.dump {font-family:monospace; font-size:10px;}'
queue 'text {font-family:Arial; font-size:10px; fill:black;',
'stroke:none;}'
queue '.domain {fill:whitesmoke;}'
do queued()
parse pull sText
call appendTextNode sText,g.0STYLE
end
do i = 1 to g.0DOMAIN.0
sDomain = g.0DOMAIN.i
if g.0FREQ.sDomain > 0
then do
sColor = hsv2rgba(getHue(i),0.9,0.9,0.5)
call appendTextNode '.domain'sDomain' {fill:'sColor';}',g.0STYLE
end
end
/* Build sticky header */
divTop = newElement('div','class','top')
call appendChild divTop,body
h3 = createElement('h3')
sAppl = getAttribute(g.0AUXTRACE,'appl')
sDate = getAttribute(g.0AUXTRACE,'date')
sTitle = 'CICS auxiliary trace of' sAppl 'captured on' sDate
call appendTextNode sTitle,h3
call appendChild h3,divTop
p = createElement('p')
call appendTextNode 'Created by',p
a = newElement('a','href','https://github.com/abend0c1/aux2svg')
call appendTextNode 'CICS Auxiliary Trace Visualizer',a
call appendChild a,p
call appendTextNode 'by Andrew J. Armstrong (androidarmstrong@gmail.com)',p
call appendChild p,divTop
divHeader = newElement('div','class','sticky')
call appendChild divHeader,body
svgHeader = newElement('svg','class','sticky','height',30)
call appendChild svgHeader,divHeader
call appendComment ' Actor headings',svgHeader
actors = newElement('g','class','actors')
call appendChild actors,svgHeader
divContent = newElement('div','class','content')
call appendChild divContent,body
svgContent = createElement('svg')
call appendChild svgContent,divContent
/* Build SVG constant definitions */
defs = createElement('defs')
call appendChild defs,svgContent
path = createElement('path')
call appendChild path,defs
call setAttributes path,,
'id','arrow',,
'd','M 0 0 L 10 5 L 0 10 z'
/* Build actor headings and vertical life lines */
call appendComment ' Life lines',svgContent
lifelines = newElement('g','class','lifeline')
call appendChild lifelines,svgContent
w = 60 /* width of an actor rectangle */
h = 22 /* height of an actor rectangle */
x = w /* horizontal position of actor rectangle */
do i = 1 to words(g.0ACTOR_NODES) /* for each actor... */
node = word(g.0ACTOR_NODES,i)
sActorName = getActorName(node)
sDomain = getAttribute(node,'domain')
xMid = x + w/2
/* Draw the life line */
call appendComment sActorName,lifelines
line = newElement('line','x1',xMid,'y1',h,'x2',xMid,'y2',0)
call appendChild line,lifelines
g.0X.sActorName = xMid /* remember where this actor is by name */
/* Draw the rectangle to contain the actor name */
actor = newElement('g','class','domain'sDomain)
call appendChild actor,actors
call addToolTip g.0DOMAIN.sDomain,actor /* Show domain desc on hover */
rect = newElement('rect','x',x,'y',0,'width',w,'height',h,'rx',5,'ry',5)
call appendChild rect,actor
/* Draw the domain name and actor name within the rectangle */
text = newElement('text','y',9)
call appendChild text,actor
domain = newElement('tspan','x',xMid)
call appendChild domain,text
tspan = newElement('tspan','x',xMid,'dy',10)
call appendTextNode sActorName,tspan
call appendChild tspan,text
select
when isProgram(node) then call appendTextNode 'program',domain
when isSocket(node) then call appendTextNode 'socket',domain
otherwise call appendTextNode sDomain,domain
end
x = x + w + 5
end
nImageWidth = x + w /* room on the right for a longish message */
/* Build arrows between actors */
call appendComment ' Actor relationships',svgContent
arrows = newElement('g','class','arrows')
call appendChild arrows,svgContent
g.0FIRSTARROW = 2 * g.0LINEDEPTH /* vertical offset of first arrow */
tasks = getChildren(g.0AUXTRACE)
do i = 1 to words(tasks)
task = word(tasks,i)
nTaskId = getAttribute(task,'taskid')
h = getHue(i)
s = getSaturation(i)
v = getValue(i)
sColor = hsv2rgba(h,s,v)
call appendTextNode '.task'nTaskId ' {stroke:'sColor';}',g.0STYLE
call appendTextNode '.fill'nTaskId ' {fill:'sColor';}',g.0STYLE
call createMarkers defs,nTaskId /* Create colored arrowhead for this task */
call drawArrowsForTask arrows,task
end
/* Now we know the image height we can set the viewbox */
nImageHeight = (2 + g.0ROWS + 1 ) * g.0LINEDEPTH
call setAttributes svgContent,,
'height',nImageHeight,,
'width',nImageWidth,,
'viewBox','0 22' nImageWidth nImageHeight
g.0WIDTH = nImageWidth
g.0HEIGHT = nImageHeight
call setAttributes svgHeader,,
'width',nImageWidth,,
'viewbox','0 0' nImageWidth '22'
/* Update the lifeline depth */
nodes = getElementsByTagName(lifelines,'line')
do i = 1 to words(nodes)
node = word(nodes,i)