]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gprofng/src/Command.h
Update year range in gprofng copyright notices
[thirdparty/binutils-gdb.git] / gprofng / src / Command.h
CommitLineData
76bdc726 1/* Copyright (C) 2021-2023 Free Software Foundation, Inc.
bb368aad
VM
2 Contributed by Oracle.
3
4 This file is part of GNU Binutils.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
20
21#ifndef _COMMAND_H
22#define _COMMAND_H
23
24
25#include <stdio.h>
26#include <sys/types.h>
27
28#include "Metric.h"
29#include "Hist_data.h"
30#include "dbe_types.h"
31#include "vec.h"
32#include "enums.h"
33
34// This enum lists all the commands parsed by er_print
35// The ordering here is not important, but LAST_CMD must
36// be defined as the last command for which a help line will exist
37// Command.cc has a matching list, and the ordering in
38// that list determines what shows up under the help and xhelp commands.
39// In particular, the entry for HELP is the last one printed
40// for the help command, and the entry for HHELP is the last
41// one printed for xhelp.
42
43enum CmdType
44{
45 // Pathtree-related commands
46 FUNCS = 0,
47 HOTPCS,
48 HOTLINES,
49 FDETAIL,
50 OBJECTS,
51 LDETAIL,
52 PDETAIL,
53 SOURCE,
54 DISASM,
55 METRIC_LIST,
56 METRICS,
57 SORT,
58 GPROF,
59 GMETRIC_LIST,
60 FSINGLE,
61 CSINGLE,
62 CPREPEND,
63 CAPPEND,
64 CRMFIRST,
65 CRMLAST,
66 CALLTREE,
67 CALLFLAME,
68
69 // Source/disassembly control commands
70 SCOMPCOM,
71 STHRESH,
72 DCOMPCOM,
73 COMPCOM,
74 DTHRESH,
75
76 // Heap trace-related commands
77 LEAKS,
78 ALLOCS,
79 HEAP,
80 HEAPSTAT,
81
82 // I/O trace-related commands
83 IOACTIVITY,
84 IOVFD,
85 IOCALLSTACK,
86 IOSTAT,
87
88 // Race detection related commands
89 RACE_EVNTS,
90 RACE_SUM,
91
92 // Deadlock detection commands
93 DEADLOCK_EVNTS,
94 DEADLOCK_SUM,
95
96 // DataSpace commands
97 DOBJECTS,
98 DO_SINGLE,
99 DO_LAYOUT,
100 DO_METRIC_LIST,
101
102 // MemorySpace commands
103 MEMOBJ,
104 MEMOBJLIST,
105 MEMOBJDEF,
106 MEMOBJDROP,
107 MACHINEMODEL,
108
109 // Custom tab commands
110 INDXOBJDEF,
111 INDXOBJLIST,
112 INDXOBJ,
113 INDX_METRIC_LIST,
114
115 // Old-style filtering commands
116 OBJECT_LIST,
117 OBJECT_SELECT,
118 SAMPLE_LIST,
119 SAMPLE_SELECT,
120 THREAD_LIST,
121 THREAD_SELECT,
122 LWP_LIST,
123 LWP_SELECT,
124 CPU_LIST,
125 CPU_SELECT,
126
127 // Shared Object display commands
128 OBJECT_SHOW,
129 OBJECT_HIDE,
130 OBJECT_API,
131 OBJECTS_DEFAULT,
132
133 // the new filtering commands
134 FILTERS,
135
136 // Miscellaneous commands
137 COMPARE,
138 PRINTMODE,
139 HEADER,
140 OVERVIEW_NEW,
141 SAMPLE_DETAIL,
142 STATISTICS,
143 EXP_LIST,
144 DESCRIBE,
145 OUTFILE,
146 APPENDFILE,
147 LIMIT,
148 NAMEFMT,
149 VIEWMODE,
150 EN_DESC,
151 SETPATH,
152 ADDPATH,
153 PATHMAP,
154 LIBDIRS,
155 SCRIPT,
156 VERSION_cmd,
157 QUIT,
158 PROCSTATS,
159
160 // Experiments handling commands
161 ADD_EXP,
162 DROP_EXP,
163 OPEN_EXP,
164
165 // .rc-only Commands
166 DMETRICS,
167 DSORT,
168 TLMODE,
169 TLDATA,
170 TABS,
171 TIMELINE,
172 MPI_TIMELINE,
173 MPI_CHART,
174 TIMELINE_CLASSIC_TBR,
175 SOURCE_V2,
176 DISASM_V2,
177 RTABS,
178 DUALSOURCE,
179 SOURCEDISAM,
180
181 HELP, // this is the last of the commands listed with "help"
182 IFREQ,
183 DUMPNODES,
184 DUMPSTACKS,
185 DUMPUNK,
186 DUMPFUNC,
187 DUMPDOBJS,
188 DUMPMAP,
189 DUMPENTITIES,
190 DUMP_PROFILE,
191 DUMP_SYNC,
192 DUMP_HWC,
193 DUMP_HEAP,
194 DUMP_IOTRACE,
195 RACE_ACCS,
196 DMPI_FUNCS,
197 DMPI_MSGS,
198 DMPI_EVENTS,
199 DMEM,
200 DUMP_GC,
201 DKILL,
202 IGNORE_NO_XHWCPROF,
203 IGNORE_FS_WARN,
204 QQUIT,
205 HHELP, // this is the last command listed with "xhelp"
206 NO_CMD, // Dummy command, used for headers in help
207 DUMMY_CMD, // Dummy command, used for help
208
209 // unused commands
210 LOADOBJECT,
211 LOADOBJECT_LIST,
212 LOADOBJECT_SELECT,
213
214 // Internal-only Commands
215 LAST_CMD, // No more commands for which a help line is possible
216 STDIN,
217 COMMENT,
218 WHOAMI,
219
220 // Error return "commands"
221 AMBIGUOUS_CMD,
222 UNKNOWN_CMD
223};
224
225typedef struct
226{
227 const CmdType token; // command key
228 const char *str; // command string
229 const char *alt; // alternate command string
230 const char *arg; // argument string for help
231 const int arg_count; // no. of arguments
232 char **desc; // description for help
233} Cmdtable;
234
235// Command class: never instantiated, completely static
236class Command
237{
238public:
239
240 // look up a string in the command table, return type, set number of args
241 static CmdType get_command (char *cmd, int &arg_count, int &param);
242 static const char *get_cmd_str (CmdType type);
243 static void print_help (char *prog_name, bool cmd_line, bool usermode, FILE *outf);
244 static char *get_err_string (Cmd_status err);
245
246 static const char *DEFAULT_METRICS; // default if no .rc files read
247 static const char *DEFAULT_SORT; // default if no .rc files read
248 static const char *DEFAULT_CMD; // token for default
249 static const char *ALL_CMD; // token for all
250 static const char *ANY_CMD; // token for any
251 static const char *NONE_CMD; // token for none
252 static const char *HWC_CMD; // token for all HWC
253 static const char *BIT_CMD; // token for any bit-derived metric
254
255private:
256 static const int user_no; // the last user command
257 static const int hidden_no; // the last hidden command
258 static const int command_no; // the last parsable command
259
260 static void init_desc ();
261 static char *fmt_help (int nc, char head);
262};
263
264// Analyzer display tabs
265struct DispTab
266{
267 DispTab (int ntype, int num, bool vis, CmdType token)
268 {
269 type = ntype;
270 order = num;
271 visible = vis;
272 available = true;
273 cmdtoken = token;
274 }
275
276 void setAvailability (bool val) { available = val; }
277
278 int type; // Display type
279 int order; // Order in which tabs should appear in GUI
280 bool visible; // Is Tab visible
281 bool available; // Is tab available for this experiment
282 CmdType cmdtoken; // command token
283 int param; // command parameter (used for memory space)
284};
285
286#endif /* ! _COMMAND_H */