aboutsummaryrefslogtreecommitdiff
path: root/gprofng/src/Settings.h
blob: 6f2983eb2c71de097000e8d705d32e3d3bf0ad19 (plain)
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
/* Copyright (C) 2021-2024 Free Software Foundation, Inc.
   Contributed by Oracle.

   This file is part of GNU Binutils.

   This program is free software; you can redistribute it and/or modify
   it under the 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 program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY 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
   along with this program; if not, write to the Free Software
   Foundation, 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */

#ifndef _SETTINGS_H
#define _SETTINGS_H

#include <stdio.h>
#include <regex.h>

#include "gp-defs.h"
#include "Histable.h"
#include "MemorySpace.h"
#include "Metric.h"
#include "dbe_types.h"
#include "dbe_structs.h"
#include "enums.h"
#include "vec.h"

class Emsgqueue;
class Application;

struct DispTab;

// Settings object

class Settings
{
public:
  friend class DbeView;
  friend class DbeSession;

  Settings (Application *_app);
  Settings (Settings *_settings);
  virtual ~Settings ();
  void read_rc (bool ipc_or_rdt_mode);  // read all rc files
  char *read_rc (char *path);           // read rc file
  void buildMasterTabList ();       // build list of Tabs that can be invoked
  void updateTabAvailability ();    // update for datamode, leaklist
  Cmd_status set_name_format (char *str); // from a string

  Vector<DispTab*> *
  get_TabList ()        // Get the list of tabs for this view
  {
    return tab_list;
  }

  Vector<bool> *
  get_MemTabState ()    // Get the list and order of memory tabs for this view
  {
    return mem_tab_state;
  }

  Vector<int> *
  get_MemTabOrder ()
  {
    return mem_tab_order;
  }

  // Set the list of memory tabs for this view
  void set_MemTabState (Vector<bool>*sel);

  // add a newly-defined memory object tab
  void mobj_define (MemObjType_t *, bool state);

  // add a newly-defined index object tab
  void indxobj_define (int type, bool state);

  Vector<bool> *
  get_IndxTabState ()   // Get the list and order of index tabs for this view
  {
    return indx_tab_state;
  }

  Vector<int> *
  get_IndxTabOrder ()
  {
    return indx_tab_order;
  }

  // Set the list of index tabs for this view
  void set_IndxTabState (Vector<bool>*sel);

  void
  set_name_format (int fname_fmt, bool soname_fmt)
  {
    name_format = Histable::make_fmt (fname_fmt, soname_fmt);
  }

  Histable::NameFormat
  get_name_format ()
  {
    return name_format;
  }

  // public methods for setting and accessing the settings
  Cmd_status set_view_mode (char *str, bool rc); // from a string

  void
  set_view_mode (VMode mode)
  {
    view_mode = mode;
  }

  VMode
  get_view_mode ()
  {
    return view_mode;
  }

  // set the en_desc expression/on/off
  Cmd_status set_en_desc (char *str, bool rc); // from a string
  // check if the lineage or the target name matches the en_desc expression
  bool check_en_desc (const char *lineage, const char *targname);

  char *set_limit (char *str, bool rc); // from a string

  char *
  set_limit (int _limit)
  {
    limit = _limit;
    return NULL;
  }

  int
  get_limit ()
  {
    return limit;
  }

  char *set_printmode (char *_pmode);

  // processing compiler commentary visibility bits
  Cmd_status proc_compcom (const char *cmd, bool isSrc, bool rc);

  // return any error string from processing visibility settings
  char *get_compcom_errstr (Cmd_status status, const char *cmd);

  // methods for setting and getting strings, and individual settings

  char *
  get_str_scompcom ()
  {
    return str_scompcom;
  }

  char *
  get_str_dcompcom ()
  {
    return str_dcompcom;
  }

  int
  get_src_compcom ()
  {
    return src_compcom;
  }

  int
  get_dis_compcom ()
  {
    return dis_compcom;
  }

  void
  set_cmpline_visible (bool v)
  {
    cmpline_visible = v;
  }

  void
  set_funcline_visible (bool v)
  {
    funcline_visible = v;
  }

  void
  set_src_visible (int v)
  {
    src_visible = v;
  }

  int
  get_src_visible ()
  {
    return src_visible;
  }

  void
  set_srcmetric_visible (bool v)
  {
    srcmetric_visible = v;
  }

  bool
  get_srcmetric_visible ()
  {
    return srcmetric_visible;
  }

  void
  set_hex_visible (bool v)
  {
    hex_visible = v;
  }

  bool
  get_hex_visible ()
  {
    return hex_visible;
  }

  // processing and accessing the threshold settings
  Cmd_status proc_thresh (char *cmd, bool isSrc, bool rc);

  int
  get_thresh_src ()
  {
    return threshold_src;
  }

  int
  get_thresh_dis ()
  {
    return threshold_dis;
  }

  // process a tlmode setting
  Cmd_status proc_tlmode (char *cmd, bool rc);

  void
  set_tlmode (int _tlmode)
  {
    tlmode = _tlmode;
  }

  int
  get_tlmode ()
  {
    return tlmode;
  }

  void
  set_stack_align (int _stack_align)
  {
    stack_align = _stack_align;
  }

  int
  get_stack_align ()
  {
    return stack_align;
  }

  void
  set_stack_depth (int _stack_depth)
  {
    stack_depth = _stack_depth;
  }

  int
  get_stack_depth ()
  {
    return stack_depth;
  }

  // process a tabs setting: called when the tab list is requested
  Cmd_status proc_tabs (bool _rdtMode);

  Cmd_status proc_tldata (const char *cmd, bool rc); // process a tldata setting
  void set_tldata (const char* tldata_string);
  char *get_tldata ();

  char *
  get_default_metrics ()
  {
    return str_dmetrics;
  }

  char *
  get_default_sort ()
  {
    return str_dsort;
  }

  void
  set_ignore_no_xhwcprof (bool v)   // ignore no xhwcprof errors for dataspace
  {
    ignore_no_xhwcprof = v;
  }

  bool
  get_ignore_no_xhwcprof ()
  {
    return ignore_no_xhwcprof;
  }

  void
  set_ignore_fs_warn (bool v)   // ignore filesystem warnings in experiments
  {
    ignore_fs_warn = v;
  }

  bool
  get_ignore_fs_warn ()
  {
    return ignore_fs_warn;
  }

  // add a pathmap
  static char *add_pathmap (Vector<pathmap_t*> *v, const char *from, const char *to);
  void set_pathmaps (Vector<pathmap_t*> *newPathMap);

  // add a LoadObject expansion setting
  bool set_libexpand (char *, enum LibExpand, bool);
  enum LibExpand get_lo_setting (char *);

  // set LoadObject expansion defaults back to .rc specifications
  bool set_libdefaults ();

  void
  set_compare_mode (int mode)
  {
    compare_mode = mode;
  }

  int
  get_compare_mode ()
  {
    return compare_mode;
  }

  char *
  get_machinemodel ()
  {
    return dbe_strdup (machinemodel);
  }

  char *preload_libdirs;

protected: // data
  Application *app;

  // default strings from .rc file
  char *str_vmode;
  char *str_en_desc;
  char *str_datamode;
  char *str_scompcom;
  char *str_sthresh;
  char *str_dcompcom;
  char *str_dthresh;
  char *str_dmetrics;
  char *str_dsort;
  char *str_tlmode;
  char *str_tldata;
  char *str_tabs;
  char *str_rtabs;
  char *str_search_path;
  char *str_name_format;
  char *str_limit;
  char *str_printmode;
  char *str_compare;

  bool tabs_processed;

  // Processed settings
  bool en_desc;             // controls for reading descendant processes
  char * en_desc_usr;       // selective descendants: user specificaton
  regex_t * en_desc_cmp;    // selective descendants: compiled specification
  Histable::NameFormat name_format; // long/short/mangled naming for C++/Java
  VMode view_mode;          // Java mode
  int src_compcom;          // compiler commentary visibility for anno-src
  int dis_compcom;          // compiler commentary visibility for anno-dis
  int threshold_src;        // threshold for anno-src
  int threshold_dis;        // threshold for anno-dis
  int cmpline_visible;      // show compile-line flags
  int funcline_visible;     // show compile-line flags
  int src_visible;          // show source in disasm
  bool srcmetric_visible;   // show metrics for source in disasm
  bool hex_visible;         // show hex code in disasm
  char* tldata;             // timeline data type string
  int tlmode;               // timeline mode for bars
  int stack_align;          // timeline stack alignment
  int stack_depth;          // timeline stack depth
  int limit;                // print limit
  enum PrintMode print_mode;// print mode
  char print_delim;         // the delimiter, if print mode = PM_DELIM_SEP_LIST
  int compare_mode;         // compare mode

  char *machinemodel; // machine model for Memory Objects

  bool ignore_no_xhwcprof; // ignore no -xhwcprof data in dataspace
  bool ignore_fs_warn; // ignore file-system recording warning

  void set_rc (const char *path, bool msg, Emsgqueue *commentq,
	       bool override, bool ipc_or_rdt_mode = false);

  Vector<DispTab*> *tab_list;
  Vector<pathmap_t*> *pathmaps;
  Vector<lo_expand_t*> *lo_expands;
  enum LibExpand lo_expand_default;
  bool is_loexpand_default;
  Vector<bool> *mem_tab_state;
  Vector<int> *mem_tab_order;
  Vector<bool> *indx_tab_state;
  Vector<int> *indx_tab_order;
};

#endif /* ! _SETTINGS_H */