-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcommand_line.ads
1690 lines (1603 loc) · 73.5 KB
/
command_line.ads
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
------------------------------------------------------------------------------
-- --
-- GNATcoverage --
-- --
-- Copyright (C) 2015-2024, AdaCore --
-- --
-- GNATcoverage is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This software is distributed in the hope that it will be useful --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
with GPR2.Options;
with Argparse;
with Coverage_Options; use Coverage_Options;
package Command_Line is
type Command_Type is
(None,
Cmd_Help,
Cmd_Help_Internal,
Cmd_Version,
Cmd_List_Logs,
Cmd_Print_GPR_Registry,
Cmd_Run,
Cmd_Convert,
Cmd_Coverage,
Cmd_Extract_Base64_Trace,
Cmd_Scan_Decisions,
Cmd_Disp_Routines,
Cmd_Map_Routines,
Cmd_Check_SCOs,
Cmd_Dump_Trace,
Cmd_Dump_Trace_Raw,
Cmd_Dump_Trace_Base,
Cmd_Dump_Trace_Asm,
Cmd_Dump_Src_Trace,
Cmd_Dump_Sections,
Cmd_Dump_Symbols,
Cmd_Dump_Compile_Units,
Cmd_Dump_Subprograms,
Cmd_Dump_Inlined_Subprograms,
Cmd_Dump_Lines,
Cmd_Dump_CFG,
Cmd_Dump_Pragmas,
Cmd_Disassemble_Insn_Properties,
Cmd_Disassemble_Raw,
Cmd_Disassemble,
Cmd_Scan_Objects,
Cmd_Setup,
Cmd_Instrument_Project,
Cmd_Instrument_Source,
Cmd_Instrument_Main,
Cmd_Setup_Integration,
Cmd_Gcc_Wrapper,
Cmd_Add_Annotation,
Cmd_Delete_Annotation,
Cmd_Show_Annotations);
-- Set of commands we support. More complete descriptions below.
type Bool_Options is
(Opt_Verbose,
Opt_Quiet,
Opt_Recursive,
Opt_No_Subprojects,
Opt_All_Decisions,
Opt_All_Messages,
Opt_Include,
Opt_Exclude,
Opt_Excluded_SCOs,
Opt_Keep_Edges,
Opt_Pretty_Print,
Opt_Keep_Reading_Traces,
Opt_Externally_Built_Projects,
Opt_GNAT_Pragmas,
Opt_Show_MCDC_Vectors,
Opt_Show_Condition_Vectors,
Opt_Dump_Filename_Simple,
Opt_Allow_Mix_Trace_Kind,
Opt_Boolean_Short_Circuit_And_Or,
Opt_Cancel_Annotate,
Opt_All_Warnings,
Opt_Save_Temps,
Opt_SPARK_Compat,
Opt_Full_Slugs,
Opt_Relocate_Build_Tree,
Opt_Warnings_As_Errors,
Opt_Instrument_Block,
Opt_Force,
Opt_Annotate_After,
Opt_No_Stdlib);
-- Set of boolean options we support. More complete descriptions below.
type String_Options is
(Opt_Project,
Opt_Root_Dir,
Opt_Subdirs,
Opt_Target,
Opt_Runtime,
Opt_Config,
Opt_Output,
Opt_Output_Directory,
Opt_Tag,
Opt_Kernel,
Opt_Coverage_Level,
Opt_Text_Start,
Opt_Exec_Prefix,
Opt_HW_Trigger_Traces,
Opt_Input,
Opt_Separate,
Opt_Output_Format,
Opt_Trace_Source,
Opt_Save_Checkpoint,
Opt_Report_Title,
Opt_Dump_Trigger,
Opt_Dump_Channel,
Opt_Dump_Filename_Env_Var,
Opt_Dump_Filename_Prefix,
Opt_Dump_Filename_Tag,
Opt_Ada,
Opt_Dump_Units_To,
Opt_Timezone,
Opt_Prefix,
Opt_RTS_Profile,
Opt_Path_Count_Limit,
Opt_Install_Name,
Opt_Runtime_Project,
Opt_Lang,
Opt_Parallelism_Level,
Opt_Compiler_Driver,
Opt_Spec_Suffix,
Opt_Body_Suffix,
Opt_Dot_Replacement,
Opt_Gnatem,
Opt_Config_Pragmas_Mapping,
Opt_Ada_Preprocessor_Data,
Opt_Project_Name,
Opt_Source_Root,
Opt_Db,
Opt_GPR_Registry_Format,
Opt_Annotation_Kind,
Opt_Annotation_Id,
Opt_Location,
Opt_Start_Location,
Opt_End_Location,
Opt_Justification,
Opt_SS_Backend,
Opt_Source_Encoding);
-- Set of string options we support. More complete descriptions below.
type String_List_Options is
(Opt_Log,
Opt_Projects,
Opt_Scenario_Var,
Opt_Cargs,
Opt_Eargs,
Opt_Gargs,
Opt_Scos,
Opt_Units,
Opt_SID,
Opt_Subp_Of_Interest,
Opt_Routines,
Opt_Routines_List,
Opt_Exec,
Opt_Source_Rebase,
Opt_Source_Search,
Opt_Trace,
Opt_Checkpoint,
Opt_Ignore_Source_Files,
Opt_Shared_Object,
Opt_Restricted_To_Languages,
Opt_Annotation_Format,
Opt_C_Opts,
Opt_CPP_Opts,
Opt_Files,
Opt_Runtime_Dir,
Opt_Compiler_Wrappers,
Opt_Ext_Annotations);
-- Set of string list options we support. More complete descriptions below.
subtype Cmd_Instrument is Command_Type
range Cmd_Instrument_Project .. Cmd_Instrument_Main;
subtype Cmd_Instrument_With_Setup is Command_Type
range Cmd_Instrument_Project .. Cmd_Setup_Integration;
subtype Cmd_All_Setups is Command_Type
with Static_Predicate =>
Cmd_All_Setups in Cmd_Setup | Cmd_Setup_Integration;
subtype Cmd_All_Annotate is Command_Type
range Cmd_Add_Annotation .. Cmd_Show_Annotations;
package Parser is new Argparse
(Command_Type, Bool_Options, String_Options, String_List_Options);
use Parser;
Command_Infos : constant Command_Info_Array :=
(Cmd_Help => Create
(Name => "--help",
Description => ("Display help for command line commands and"
& " arguments."),
Internal => False),
Cmd_Help_Internal => Create
(Name => "--help-internal",
Description => ("Display help for internal command line commands and"
& "arguments."),
Internal => True),
Cmd_Version => Create
(Name => "--version",
Description => "Display the version.",
Internal => False),
Cmd_List_Logs => Create
(Name => "list-logs",
Pattern => "",
Description =>
"Dump the list of GNATcov available logs (GNATCOLL traces).",
Internal => True),
Cmd_Print_GPR_Registry => Create
(Name => GPR2.Options.Print_GPR_Registry_Option,
Pattern => "",
Description => "Print the GPR registry.",
Internal => True),
Cmd_Run => Create
(Name => "run",
Pattern => "[OPTIONS] [EXE] [-eargs [EXE] EARGS...]",
Description => "Run a program and generate a trace file.",
Internal => False),
Cmd_Convert => Create
(Name => "convert",
Pattern => ("[OPTIONS] --trace-source=SOURCE_ID --exec=EXECUTABLE"
& " --input=INPUT_TRACE"),
Description => ("Convert vendor-specific trace files into"
& " GNATcoverage-compatible ones."
& ASCII.LF
& " SOURCE_ID specifies source of trace data (e.g."
& " iSystem-5634)." & ASCII.LF
& " EXECUTABLE is name of executable which generated"
& " data." & ASCII.LF
& " INPUT_TRACE is file containing trace data to be"
& " converted."),
Internal => False),
Cmd_Extract_Base64_Trace => Create
(Name => "extract-base64-trace",
Pattern => ("[OPTIONS] INPUT_BASE64_FILE OUTPUT_TRACE_FILE"),
Description => ("Extract a trace file from a log file that contains"
& " Base64-encoded traces."),
Internal => False),
Cmd_Coverage => Create
(Name => "coverage",
Pattern => ("[OPTIONS] TRACE_FILEs"),
Description => "Generate a coverage report with TRACE_FILEs.",
Internal => False),
Cmd_Scan_Decisions => Create
(Name => "scan-decisions",
Pattern => ("--scos=[SCOs] [OPTIONS]"),
Description => ("Scan source coverage obligations for multiple paths"
& " decisions."),
Internal => False),
Cmd_Disp_Routines => Create
(Name => "disp-routines",
Pattern => "{[--exclude|--include] FILEs}",
Description => "Build a list of routines from object FILEs.",
Internal => False),
Cmd_Map_Routines => Create
(Name => "map-routines",
Pattern => "--scos=[SCOs] [EXE]",
Description => "Only perform decision static analysis.",
Internal => True),
Cmd_Check_SCOs => Create
(Name => "check-scos",
Description => "Parse and load SCOs files to check them.",
Internal => True),
Cmd_Dump_Trace => Create
(Name => "dump-trace",
Pattern => "[TRACE_FILEs]",
Description => "Display of trace files, slided if necessary.",
Internal => True),
Cmd_Dump_Trace_Raw => Create
(Name => "dump-trace-raw",
Pattern => "[TRACE_FILEs]",
Description => "Raw display of trace files.",
Internal => True),
Cmd_Dump_Trace_Base => Create
(Name => "dump-trace-base",
Pattern => "[TRACE_FILEs]",
Description => "",
Internal => True),
Cmd_Dump_Trace_Asm => Create
(Name => "dump-trace-asm",
Pattern => "[EXE] [TRACE_FILEs]",
Description => ("Display of trace files with assembly code for each"
& " trace."),
Internal => True),
Cmd_Dump_Src_Trace => Create
(Name => "dump-src-trace",
Pattern => "[TRACE_FILEs]",
Description => "Dump the content of a source trace file in a human"
& "-readable text form.",
Internal => True),
Cmd_Dump_Sections => Create
(Name => "dump-sections",
Pattern => "[EXEs]",
Description => "Dump sections from executable files.",
Internal => True),
Cmd_Dump_Symbols => Create
(Name => "dump-symbols",
Pattern => "[EXEs]",
Description => "Dump symbols from executable files.",
Internal => True),
Cmd_Dump_Compile_Units => Create
(Name => "dump-compile-units",
Pattern => "[EXEs]",
Description => ("Dump the name of DW_TAG_compile_unit from the"
& " debugging information in executable files."),
Internal => True),
Cmd_Dump_Subprograms => Create
(Name => "dump-subprograms",
Description => "Dump subprograms from executable files.",
Internal => True),
Cmd_Dump_Inlined_Subprograms => Create
(Name => "dump-inlined-subprograms",
Description => "Dump inlined subprograms from executable files.",
Internal => True),
Cmd_Dump_Lines => Create
(Name => "dump-lines",
Pattern => "[EXEs]",
Description => "Dump source line information from executable files.",
Internal => True),
Cmd_Dump_CFG => Create
(Name => "dump-cfg",
Pattern => "[OPTIONS] [EXE] [SELECTORs]",
Description => ("Display object code from EXE as a graph. SELECTORs"
& " must be a non-empty list of patterns, which is"
& " used to match code to draw. The patterns can be:"
& ASCII.LF & ASCII.LF
& "file:line1:col1-line2:col2" & ASCII.LF
& " Match code included in a source location range."
& ASCII.LF & ASCII.LF
& "@0xADDRESS" & ASCII.LF
& " Match all code under the symbol an address"
& " belongs to."
& ASCII.LF & ASCII.LF
& "0xADDRESS..0xADDRESS" & ASCII.LF
& " Match code included in an address range."
& ASCII.LF & ASCII.LF
& "SYMBOL_NAME" & ASCII.LF
& " Match all code under a symbol."
& ASCII.LF & ASCII.LF
& "The object code included if the graph must belong"
& " to at least one provided pattern."),
Internal => True),
Cmd_Disassemble_Insn_Properties => Create
(Name => "disassemble-insn-properties",
Pattern => "[EXE] [SELECTORs]",
Description => ("Disassemble instructions in the executable matching"
& " SELECTORs. The output is a JSON document that"
& " describes sections, instruction disassembly"
& " tokens and instruction properties. See SELECTORs"
& " in the dump-cfg command for details."),
Internal => True),
Cmd_Dump_Pragmas => Create
(Name => "dump-pragmas",
Pattern => "",
Description => "Dump the list of names for Ada pragmas that gnatcov"
& " knows, or that GNAT knows (through gnat_util) if"
& " --gnat-pragmas is passed.",
Internal => True),
Cmd_Disassemble_Raw => Create
(Name => "disassemble-raw",
Pattern => "[EXEs]",
Description => "Disassemble executables.",
Internal => True),
Cmd_Disassemble => Create
(Name => "disassemble",
Pattern => "[EXEs]",
Description => "Disassemble executables.",
Internal => True),
Cmd_Scan_Objects => Create
(Name => "scan-objects",
Pattern => "[FILEs]",
Description => ("Scan object FILEs for empty symbols or orphan"
& " regions."),
Internal => True),
Cmd_Setup => Create
(Name => "setup",
Description => "Build and install the runtime for source"
& " instrumentation and set up default arguments"
& " for future ""gnatcov instrument"" invocations.",
Internal => False),
Cmd_Instrument_Project => Create
(Name => "instrument",
Description => ("Instrument the given project and produce the"
& " associated Source Instrumentation Data files."),
Internal => False),
Cmd_Instrument_Source => Create
(Name => "instrument-source",
Description => "Instrument the given files, all belonging to the"
& " same unit.",
Pattern => "[FILES]",
Internal => True),
Cmd_Instrument_Main => Create
(Name => "instrument-main",
Description => "Insert dump trigger code in the the given main file,"
& " dumping coverage buffers of all of the specified"
& " files (through the --files switch).",
Pattern => "--files=<files_of_interest> [MAIN]",
Internal => True),
Cmd_Setup_Integration => Create
(Name => "setup-integration",
Description =>
"Generate the adequate configuration to use gnatcov in integrated"
& " instrumentation mode. The files of interest must be passed"
& " through the --files switch, the compiler driver in used through"
& " the --compilers switch, and the configuration and compiler"
& " driver wrappers are generated in the subdirectory pointed by"
& " the --output-dir switch.",
Pattern =>
"--files=<files_of_interest> --compilers=<compiler>"
& " [--output-dir=<dir>]",
Internal => False),
Cmd_Gcc_Wrapper => Create
(Name => "gcc-wrapper",
Description =>
"Implementation of the GCC wrapper for integrated instrumentation.",
Pattern => "[JSON-CONFIG-FILE]",
Internal => True),
Cmd_Add_Annotation => Create
(Name => "add-annotation",
Description =>
"Add an annotation tied to the specified source locations, to"
& " influence the instrumentation of source files or the coverage"
& " analysis. All annotations passed through --external-annotations"
& " are consolidated and written to OUTPUT_FILENAME."
& ASCII.LF & ASCII.LF
& "The relevant switches depend on the annotation KIND:"
& Annot_Kind_Relevant_Switches,
Pattern =>
"--kind=KIND [--external-annotations=FILENAME] --output="
& "OUTPUT_FILENAME [OPTIONS] FILENAME",
Internal => False),
Cmd_Delete_Annotation => Create
(Name => "delete-annotation",
Description =>
"Delete the annotation with identifier IDENTIFIER from those stored"
& " in EXT_FILENAMEs, and write back the remaining annotations to"
& " OUTPUT_FILENAME.",
Pattern =>
"--annotation-id=IDENTIFIER --external-annotations=EXT_FILENAME"
& "--output=OUTPUT_FILENAME",
Internal => False),
Cmd_Show_Annotations => Create
(Name => "show-annotations",
Description =>
"Show the annotations stored in EXT_FILENAME that apply to FILES,"
& " if present or to the project sources. Optionally filter the"
& " kind of annotations to show with --kind.",
Pattern =>
"--external-annotations=EXT_FILENAME [--kind=KIND] [OPTIONS]"
& " [FILENAME]",
Internal => False));
Bool_Infos : constant Bool_Option_Info_Array :=
(Opt_Verbose => Create
(Long_Name => "--verbose", Short_Name => "-v",
Help => "Print lots of debugging information.",
Internal => True),
Opt_Quiet => Create
(Long_Name => "--quiet", Short_Name => "-q",
Help => "Print nothing but errors/warnings.",
Internal => False),
Opt_Recursive => Create
(Long_Name => "--recursive",
Help => "DEPRECATED: In addition to those designated by"
& " -P/--projects, consider units from any"
& " transitively imported project.",
Commands => (Cmd_Run
| Cmd_Coverage
| Cmd_Instrument_Project
| Cmd_Dump_CFG => True,
others => False),
Internal => False),
Opt_No_Subprojects => Create
(Long_Name => "--no-subprojects",
Help => "Consider only units designated by the project"
& " designated by -P/--projects. Units from any"
& " transitively imported projects are not considered.",
Commands => (Cmd_Run
| Cmd_Coverage
| Cmd_Instrument_Project
| Cmd_Dump_CFG => True,
others => False),
Internal => False),
Opt_All_Decisions => Create
(Long_Name => "--all-decisions",
Help => "Perform decision coverage in stmt+decision mode even"
& " for decisions outside of control structures.",
-- TODO??? Is this really supposed to be internal?
Internal => True),
Opt_All_Messages => Create
(Long_Name => "--all-messages",
Help => "When performing source coverage analysis, also include"
& " in the report messages other than violations of a"
& " source coverage obligation.",
Internal => True),
Opt_Include => Create
(Long_Name => "--include",
Help => "Include the symbols from the next object file on"
& " the command line to the list of routines.",
Commands => (Cmd_Disp_Routines => True, others => False),
Internal => False),
Opt_Exclude => Create
(Long_Name => "--exclude",
Help => "Exclude the symbols from the next object file on"
& " the command line to the list of routines",
Commands => (Cmd_Disp_Routines => True, others => False),
Internal => False),
Opt_Excluded_SCOs => Create
(Long_Name => "--non-coverable",
Help => "Report SCOs whose coverage cannot be established due to"
& " absence of executable code.",
Commands => (Cmd_Coverage => True, others => False),
Internal => False),
Opt_Keep_Edges => Create
(Short_Name => "-k",
Help => "Do not strip edges that are supposed to be uncoverable"
& " due to exceptions.",
Commands => (Cmd_Dump_CFG => True, others => False),
Internal => True),
Opt_Pretty_Print => Create
(Long_Name => "--pretty-print",
Help => "For the disassemble-insn-properties command, output a"
& " pretty-printed JSON to ease debugging. For the"
& " instrument command, run gnatpp on the generated"
& " sources.",
Commands => (Cmd_Disassemble_Insn_Properties
| Cmd_Instrument => True,
others => False),
Internal => True),
Opt_Keep_Reading_Traces => Create
(Long_Name => "--keep-reading-traces",
Help => "When an error occurs while reading a trace file,"
& " skip it and keep reading other trace files until a"
& " coverage report can be produced. Note that this"
& " makes gnatcov exit with an error status.",
Commands => (Cmd_Coverage => True, others => False),
Internal => False),
Opt_Externally_Built_Projects => Create
(Long_Name => "--externally-built-projects",
Help => "Look into projects marked as externally built when"
& " computing the list of units of interest (they are"
& " ignored by default). For the ""instrument"" command,"
& " this only influences the instrumentation of mains.",
Commands => (Cmd_Run
| Cmd_Instrument
| Cmd_Coverage
| Cmd_Dump_CFG => True,
others => False),
Internal => False),
Opt_GNAT_Pragmas => Create
(Long_Name => "--gnat-pragmas",
Help => "Dump the list of GNAT pragmas, from gnat_util.",
Commands => (Cmd_Dump_Pragmas => True, others => False),
Internal => True),
Opt_Show_MCDC_Vectors => Create
(Long_Name => "--show-mcdc-vectors",
Help => "DEPRECATED: If set, show MCDC evaluation vectors"
& " encountered for decisions where there is at least a"
& " MCDC violation on one of the conditions. Prefer"
& " using --show-condition-vectors.",
Commands => (Cmd_Coverage => True, others => False),
Internal => False),
Opt_Show_Condition_Vectors => Create
(Long_Name => "--show-condition-vectors",
Help => "If set, show MCDC and ATCC evaluation vectors"
& " encountered for decisions where there is at least a"
& " MCDC or ATCC violation on one of the conditions.",
Commands => (Cmd_Coverage => True, others => False),
Internal => False),
Opt_Dump_Filename_Simple => Create
(Long_Name => "--dump-filename-simple",
Help => "Valid only when --dump-channel=bin-file. Create simple"
& " filenames for source trace files (no PID/timestamp"
& " variations).",
Commands => (Cmd_Setup
| Cmd_Instrument_Project
| Cmd_Setup_Integration
| Cmd_Instrument_Main => True,
others => False),
Internal => False),
Opt_Allow_Mix_Trace_Kind => Create
(Long_Name => "--mix-trace-kind",
Help => "Allow mixing binary and source traces. A warning will"
& " still be emitted.",
Commands => (Cmd_Coverage => True, others => False),
Internal => True),
Opt_Boolean_Short_Circuit_And_Or => Create
(Long_Name => "--short-circuit-and-or",
Help => "For Ada sources, consider that boolean operators"
& " ""and"" and ""or"" have short-circuit semantics and"
& " instrument them accordingly. This does not modify"
& " the actual semantics of the operators, which needs"
& " to be done with the Short_Circuit_And_Or pragma.",
Commands => (Cmd_Instrument => True, others => False),
Internal => True),
Opt_Cancel_Annotate => Create
(Long_Name => "--cancel-annotate",
Help => "Prevent gnatcov from generating a coverage report if"
& " one was requested by --annotate. This option"
& " requires --save-checkpoint to also be specified on"
& " the command line.",
Commands => (Cmd_Coverage => True, others => False),
Internal => True),
Opt_All_Warnings => Create
(Long_Name => "--all-warnings",
Help => "Print low warnings in addition to warnings and errors.",
Internal => True),
Opt_Save_Temps => Create
(Long_Name => "--save-temps",
Help => "Do not remove temporary files and directories.",
Internal => True),
Opt_SPARK_Compat => Create
(Long_Name => "--spark-compat",
Help => "Enable the SPARK compatibility mode. This ensures"
& " instrumented code will be ghost compliant.",
Commands => (Cmd_Instrument => True, others => False),
Internal => False),
Opt_Full_Slugs => Create
(Long_Name => "--full-slugs",
Help => "Use full unit slugs instead of hashes for buffer units",
Commands => (Cmd_Instrument => True, others => False),
Internal => True),
Opt_Relocate_Build_Tree => Create
(Long_Name => "--relocate-build-tree",
Help => "Relocate object, library and exec directories in the"
& " current directory.",
Commands => (Cmd_All_Setups | Cmd_Print_GPR_Registry => False,
others => True),
Internal => False),
Opt_Warnings_As_Errors => Create
(Long_Name => "--warnings-as-errors",
Short_Name => "-W",
Help => "Treat warnings as errors, i.e. exit with a non-zero"
& " status code if a warning is emitted.",
Commands => (others => True),
Internal => True),
Opt_Instrument_Block => Create
(Long_Name => "--instrument-block",
Help => "Instrument the statements as blocks, i.e. insert a"
& " single instrumentation counter incrementation for a"
& " statement block.",
Commands => (Cmd_Instrument => True, others => False),
Internal => False),
Opt_Force => Create
(Long_Name => "--force",
Short_Name => "-f",
Help =>
"Overwrite preexisting annotations with the same kind matching the"
& " same location, or any preexisting annotation with the same"
& " identifier as the one specified on the command line.",
Commands => (Cmd_Add_Annotation | Cmd_Delete_Annotation => True,
others => False),
Internal => False),
Opt_Annotate_After => Create
(Long_Name => "--annotate-after",
Help =>
"Add the annotation after the statement designated by the"
& " --location switch, as opposed to the default behavior which"
& " inserts the annotation before the designated statement.",
Commands => (Cmd_Add_Annotation => True, others => False),
Internal => False),
Opt_No_Stdlib => Create
(Long_Name => "--no-stdlib",
Help =>
"Setup the coverage runtime in a way that is compatible with the"
& " -nostdlib builder switch. This requires that the output"
& " function for the coverage runtime must be provided by the user,"
& " see section ""Coverage runtime setup for configurations with no"
& " Ada runtime"" of the User's Guide for more details.",
Commands => (Cmd_Setup => True, others => False),
Internal => False));
String_Infos : constant String_Option_Info_Array :=
(Opt_Project => Create
(Short_Name => "-P",
Pattern => "[GPR]",
Help => "Use GPR as root project to locate SCOs, select"
& " units to analyze and find default options.",
Commands => (Cmd_Print_GPR_Registry
| Cmd_Setup
| Cmd_Setup_Integration
| Cmd_Instrument_Source
| Cmd_Instrument_Main => False,
others => True),
At_Most_Once => True,
Internal => False),
Opt_Root_Dir => Create
(Long_Name => "--root-dir",
Pattern => "[DIR]",
Help => "When --relocate-build-tree is active, this"
& " designates the topmost directory of the tree of"
& " projects. By default the root project's directory"
& " is used.",
Commands => (Cmd_Print_GPR_Registry
| Cmd_All_Setups => False,
others => True),
At_Most_Once => True,
Internal => False),
Opt_Subdirs => Create
(Long_Name => "--subdirs",
Pattern => "[SUBDIR]",
Help => "When using project files, look for ALI/SID files in"
& " the provided SUBDIR of the projects' build"
& " directory.",
Commands => (Cmd_Print_GPR_Registry
| Cmd_All_Setups => False,
others => True),
At_Most_Once => False,
Internal => False),
Opt_Target => Create
(Long_Name => "--target",
Short_Name => "-t",
Pattern => "[TARGET]",
Help => "State the target toolchain configuration used to"
& " build the analyzed programs, as provided to"
& " gprbuild. For cross or 32bit native"
& " configurations, this switch, together with its"
& " possible --RTS companion, is required for all"
& " commands using project files unless the root"
& " project provides the information with"
& " ""Target""/""Runtime"" attributes. It is also"
& " needed for ""run"" commands without a project"
& " file.",
Commands => (Cmd_Print_GPR_Registry
| Cmd_Setup_Integration => False,
others => True),
At_Most_Once => True,
Internal => False),
Opt_Runtime => Create
(Long_Name => "--RTS",
Pattern => "[RUNTIME]",
Help => "When using projects files, state the runtime used"
& " to build the analyzed programs. If project files"
& " don't already set the runtime, this is required"
& " for correct project files processing.",
Commands => (Cmd_Print_GPR_Registry
| Cmd_Setup_Integration => False,
others => True),
At_Most_Once => True,
Internal => False),
Opt_Config => Create
(Long_Name => "--config",
Pattern => "[CONFIG-FILE]",
Help => "Specify a configuration project file name. If"
& " passed, this file must exist and neither --target"
& " nor --RTS must be present.",
Commands => (Cmd_Print_GPR_Registry => False, others => True),
At_Most_Once => True,
Internal => False),
Opt_Output => Create
(Long_Name => "--output",
Short_Name => "-o",
Pattern => "[FILE]",
Help =>
"Put the report/asm output/trace file/external annotations into"
& " FILE.",
Commands => (Cmd_Run
| Cmd_Coverage
| Cmd_Convert
| Cmd_Dump_CFG
| Cmd_Add_Annotation
| Cmd_Delete_Annotation => True,
others => False),
At_Most_Once => False,
Internal => False),
Opt_Output_Directory => Create
(Long_Name => "--output-dir",
Pattern => "[SUBDIR]",
Help => "Place the output files into SUBDIR.",
Commands => (Cmd_Coverage
| Cmd_Instrument_Source
| Cmd_Instrument_Main
| Cmd_Setup_Integration => True, others => False),
At_Most_Once => False,
Internal => False),
Opt_Tag => Create
(Long_Name => "--tag",
Short_Name => "-T",
Pattern => "[TAG]",
Help => "Tag to put into trace file.",
Commands => (Cmd_Run | Cmd_Convert => True, others => False),
At_Most_Once => False,
Internal => False),
Opt_Kernel => Create
(Long_Name => "--kernel",
Pattern => "[KERNEL]",
Help => "Specify which kernel to use.",
Commands => (Cmd_Run => True, others => False),
At_Most_Once => False,
Internal => False),
Opt_Coverage_Level => Create
(Long_Name => "--level",
Short_Name => "-c",
Pattern => "[LEVEL]",
Help =>
("Specify coverage levels to assess."
& ASCII.LF
& "For all commands except ""instrument"", LEVEL is one of:"
& ASCII.LF
& " " & Object_Level_Options (Separator => ", ")
& " (object coverage)"
& ASCII.LF
& " " & Source_Level_Options
& " (source coverage)"
& ASCII.LF
& "For the ""instrument"" command, "
& "a source coverage level is required."
& ASCII.LF
& "ATC and ATCC are experimental features."
),
Commands => (Cmd_Run
| Cmd_Coverage
| Cmd_Convert
| Cmd_Instrument_With_Setup => True,
others => False),
At_Most_Once => False,
Internal => False),
Opt_Text_Start => Create
(Long_Name => "--text-start",
Pattern => "[HEX_ADDR]",
Help => "??? This option was likely introduced for a feature"
& " that is not completely implemented.",
At_Most_Once => False,
Internal => True),
Opt_Exec_Prefix => Create
(Long_Name => "--exec-prefix",
Pattern => "[PREFIX]",
Help => "In cases where we cannot find executable files, look"
& " for them in the PREFIX directory.",
At_Most_Once => False,
Internal => True),
Opt_HW_Trigger_Traces => Create
(Long_Name => "--hw-trigger-traces",
Pattern => "[START_ID],[START_ADDR],[STOP_ID]",
Help => "Identity of start and stop triggers, and address for"
& " start.",
Commands => (Cmd_Convert => True, others => False),
At_Most_Once => False,
Internal => False),
Opt_Input => Create
(Long_Name => "--input",
Pattern => "[INPUT_TRACE]",
Help => "File containing trace data to be converted.",
Commands => (Cmd_Convert => True, others => False),
At_Most_Once => False,
Internal => False),
Opt_Separate => Create
(Short_Name => "-S",
Pattern => "[TAG]",
Help => "Perform separate source coverage analysis.",
Commands => (Cmd_Coverage | Cmd_Instrument => True,
others => False),
At_Most_Once => False,
Internal => False),
Opt_Output_Format => Create
(Short_Name => "-f",
Pattern => "[FORMAT]",
Help => "If given, call dot(1) to produce the actual output"
& " (SVG, PDF, DOT, ...).",
Commands => (Cmd_Dump_CFG => True, others => False),
At_Most_Once => False,
Internal => True),
Opt_Trace_Source => Create
(Long_Name => "--trace-source",
Pattern => "[SOURCE]",
Help => "Specify a trace source.",
Commands => (Cmd_Convert => True, others => False),
At_Most_Once => False,
Internal => False),
Opt_Save_Checkpoint => Create
(Long_Name => "--save-checkpoint",
Pattern => "CHECKPOINT",
Help => "Save source coverage checkpoint to named file.",
Commands => (Cmd_Coverage => True, others => False),
At_Most_Once => True,
Internal => False),
Opt_Report_Title => Create
(Long_Name => "--report-title",
Pattern => "TITLE LABEL",
Help => "Override the default title for HTML coverage"
& " reports.",
Commands => (Cmd_Coverage => True, others => False),
At_Most_Once => False,
Internal => False),
-- --dump-trigger is a special case: It used to only accept a single
-- value, but it now should also accept a comma separated list of
-- filenames for the manual case. In order not to break compatibility
-- with the previous behavior (last --dump-trigger switch present was
-- the one used), we'll need to split the option string manually.
Opt_Dump_Trigger => Create
(Long_Name => "--dump-trigger",
Help => "Select a trigger to dump coverage buffers in the"
& " instrumented program."
& ASCII.LF & ASCII.LF
& """manual"" searches for user-written dump"
& " indication in all the project sources (the search"
& " is restricted to FILES if specified) and replaces"
& " such indications with a call to the subprogram"
& " responsible for dumping the coverage buffers. A"
& " warning is emitted if no dump indications were"
& " found. See the user manual for more information."
& ASCII.LF & ASCII.LF
& """atexit"" uses the libc's atexit() routine to"
& " schedule the dump."
& ASCII.LF & ASCII.LF
& """main-end"" instructs to append a call to the"
& " dump routine at the end of the main subprogram."
& ASCII.LF & ASCII.LF
& """ravenscar-task-termination"" uses the Ravenscar"
& "-specific Ada.Task_Termination to schedule the"
& " dump on task termination."
& ASCII.LF & ASCII.LF
& "Except for ""manual"", these methods inject code"
& " in all mains in the project closure to dump"
& " coverage buffers for all units of interest in the"
& " main closure. The --dump-channel option"
& " determines the dump procedure."
& ASCII.LF & ASCII.LF & "Only the last occurrence of"
& " the switch is taken into account.",
Commands => (Cmd_Setup | Cmd_Instrument => True, others => False),
At_Most_Once => False,
Pattern => "manual[,FILES]|atexit|main-end",
Internal => False),
Opt_Dump_Channel => Create
(Long_Name => "--dump-channel",
Help => "Select a channel to dump coverage buffers in the"
& " instrumented program. Note that this option"
& " matters only when --dump-trigger is not"
& " ""manual""."
& ASCII.LF & ASCII.LF
& """bin-file"" (the default) uses the"
& " GNATcov_RTS.Traces.Output.Write_Trace_File"
& " subprogram, from the gnatcov_rts_full.gpr project"
& " in order to create a binary trace file. This is"
& " the preferred channel for native programs."
& ASCII.LF & ASCII.LF
& """base64-stdout"" uses the GNATcov_RTS.Traces"
& ".Generic_Output.Write_Trace_File_Base64 procedure"
& " to dump a base64 trace on the standard output"
& " using Ada.Text_IO. This is the preferred channel"
& " for non-native programs.",
Commands => (Cmd_Setup
| Cmd_Instrument_Project
| Cmd_Setup_Integration
| Cmd_Instrument_Main => True,
others => False),
At_Most_Once => False,
Internal => False,
Pattern => "bin-file|base64-stdout"),
Opt_Dump_Filename_Env_Var => Create