(root)/
binutils-2.41/
gprofng/
src/
Settings.h
       1  /* Copyright (C) 2021-2023 Free Software Foundation, Inc.
       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 _SETTINGS_H
      22  #define _SETTINGS_H
      23  
      24  #include <stdio.h>
      25  #include <regex.h>
      26  
      27  #include "gp-defs.h"
      28  #include "Histable.h"
      29  #include "MemorySpace.h"
      30  #include "Metric.h"
      31  #include "dbe_types.h"
      32  #include "dbe_structs.h"
      33  #include "enums.h"
      34  #include "vec.h"
      35  
      36  class Emsgqueue;
      37  class Application;
      38  
      39  struct DispTab;
      40  
      41  // Settings object
      42  
      43  class Settings
      44  {
      45  public:
      46    friend class DbeView;
      47    friend class DbeSession;
      48  
      49    Settings (Application *_app);
      50    Settings (Settings *_settings);
      51    virtual ~Settings ();
      52    void read_rc (bool ipc_or_rdt_mode);  // read all rc files
      53    char *read_rc (char *path);           // read rc file
      54    void buildMasterTabList ();       // build list of Tabs that can be invoked
      55    void updateTabAvailability ();    // update for datamode, leaklist
      56    Cmd_status set_name_format (char *str); // from a string
      57  
      58    Vector<DispTab*> *
      59    get_TabList ()        // Get the list of tabs for this view
      60    {
      61      return tab_list;
      62    }
      63  
      64    Vector<bool> *
      65    get_MemTabState ()    // Get the list and order of memory tabs for this view
      66    {
      67      return mem_tab_state;
      68    }
      69  
      70    Vector<int> *
      71    get_MemTabOrder ()
      72    {
      73      return mem_tab_order;
      74    }
      75  
      76    // Set the list of memory tabs for this view
      77    void set_MemTabState (Vector<bool>*sel);
      78  
      79    // add a newly-defined memory object tab
      80    void mobj_define (MemObjType_t *, bool state);
      81  
      82    // add a newly-defined index object tab
      83    void indxobj_define (int type, bool state);
      84  
      85    Vector<bool> *
      86    get_IndxTabState ()   // Get the list and order of index tabs for this view
      87    {
      88      return indx_tab_state;
      89    }
      90  
      91    Vector<int> *
      92    get_IndxTabOrder ()
      93    {
      94      return indx_tab_order;
      95    }
      96  
      97    // Set the list of index tabs for this view
      98    void set_IndxTabState (Vector<bool>*sel);
      99  
     100    void
     101    set_name_format (int fname_fmt, bool soname_fmt)
     102    {
     103      name_format = Histable::make_fmt (fname_fmt, soname_fmt);
     104    }
     105  
     106    Histable::NameFormat
     107    get_name_format ()
     108    {
     109      return name_format;
     110    }
     111  
     112    // public methods for setting and accessing the settings
     113    Cmd_status set_view_mode (char *str, bool rc); // from a string
     114  
     115    void
     116    set_view_mode (VMode mode)
     117    {
     118      view_mode = mode;
     119    }
     120  
     121    VMode
     122    get_view_mode ()
     123    {
     124      return view_mode;
     125    }
     126  
     127    // set the en_desc expression/on/off
     128    Cmd_status set_en_desc (char *str, bool rc); // from a string
     129    // check if the lineage or the target name matches the en_desc expression
     130    bool check_en_desc (const char *lineage, const char *targname);
     131  
     132    char *set_limit (char *str, bool rc); // from a string
     133  
     134    char *
     135    set_limit (int _limit)
     136    {
     137      limit = _limit;
     138      return NULL;
     139    }
     140  
     141    int
     142    get_limit ()
     143    {
     144      return limit;
     145    }
     146  
     147    char *set_printmode (char *_pmode);
     148  
     149    // processing compiler commentary visibility bits
     150    Cmd_status proc_compcom (const char *cmd, bool isSrc, bool rc);
     151  
     152    // return any error string from processing visibility settings
     153    char *get_compcom_errstr (Cmd_status status, const char *cmd);
     154  
     155    // methods for setting and getting strings, and individual settings
     156  
     157    char *
     158    get_str_scompcom ()
     159    {
     160      return str_scompcom;
     161    }
     162  
     163    char *
     164    get_str_dcompcom ()
     165    {
     166      return str_dcompcom;
     167    }
     168  
     169    int
     170    get_src_compcom ()
     171    {
     172      return src_compcom;
     173    }
     174  
     175    int
     176    get_dis_compcom ()
     177    {
     178      return dis_compcom;
     179    }
     180  
     181    void
     182    set_cmpline_visible (bool v)
     183    {
     184      cmpline_visible = v;
     185    }
     186  
     187    void
     188    set_funcline_visible (bool v)
     189    {
     190      funcline_visible = v;
     191    }
     192  
     193    void
     194    set_src_visible (int v)
     195    {
     196      src_visible = v;
     197    }
     198  
     199    int
     200    get_src_visible ()
     201    {
     202      return src_visible;
     203    }
     204  
     205    void
     206    set_srcmetric_visible (bool v)
     207    {
     208      srcmetric_visible = v;
     209    }
     210  
     211    bool
     212    get_srcmetric_visible ()
     213    {
     214      return srcmetric_visible;
     215    }
     216  
     217    void
     218    set_hex_visible (bool v)
     219    {
     220      hex_visible = v;
     221    }
     222  
     223    bool
     224    get_hex_visible ()
     225    {
     226      return hex_visible;
     227    }
     228  
     229    // processing and accessing the threshold settings
     230    Cmd_status proc_thresh (char *cmd, bool isSrc, bool rc);
     231  
     232    int
     233    get_thresh_src ()
     234    {
     235      return threshold_src;
     236    }
     237  
     238    int
     239    get_thresh_dis ()
     240    {
     241      return threshold_dis;
     242    }
     243  
     244    // process a tlmode setting
     245    Cmd_status proc_tlmode (char *cmd, bool rc);
     246  
     247    void
     248    set_tlmode (int _tlmode)
     249    {
     250      tlmode = _tlmode;
     251    }
     252  
     253    int
     254    get_tlmode ()
     255    {
     256      return tlmode;
     257    }
     258  
     259    void
     260    set_stack_align (int _stack_align)
     261    {
     262      stack_align = _stack_align;
     263    }
     264  
     265    int
     266    get_stack_align ()
     267    {
     268      return stack_align;
     269    }
     270  
     271    void
     272    set_stack_depth (int _stack_depth)
     273    {
     274      stack_depth = _stack_depth;
     275    }
     276  
     277    int
     278    get_stack_depth ()
     279    {
     280      return stack_depth;
     281    }
     282  
     283    // process a tabs setting: called when the tab list is requested
     284    Cmd_status proc_tabs (bool _rdtMode);
     285  
     286    Cmd_status proc_tldata (const char *cmd, bool rc); // process a tldata setting
     287    void set_tldata (const char* tldata_string);
     288    char *get_tldata ();
     289  
     290    char *
     291    get_default_metrics ()
     292    {
     293      return str_dmetrics;
     294    }
     295  
     296    char *
     297    get_default_sort ()
     298    {
     299      return str_dsort;
     300    }
     301  
     302    void
     303    set_ignore_no_xhwcprof (bool v)   // ignore no xhwcprof errors for dataspace
     304    {
     305      ignore_no_xhwcprof = v;
     306    }
     307  
     308    bool
     309    get_ignore_no_xhwcprof ()
     310    {
     311      return ignore_no_xhwcprof;
     312    }
     313  
     314    void
     315    set_ignore_fs_warn (bool v)   // ignore filesystem warnings in experiments
     316    {
     317      ignore_fs_warn = v;
     318    }
     319  
     320    bool
     321    get_ignore_fs_warn ()
     322    {
     323      return ignore_fs_warn;
     324    }
     325  
     326    // add a pathmap
     327    static char *add_pathmap (Vector<pathmap_t*> *v, const char *from, const char *to);
     328    void set_pathmaps (Vector<pathmap_t*> *newPathMap);
     329  
     330    // add a LoadObject expansion setting
     331    bool set_libexpand (char *, enum LibExpand, bool);
     332    enum LibExpand get_lo_setting (char *);
     333  
     334    // set LoadObject expansion defaults back to .rc specifications
     335    bool set_libdefaults ();
     336  
     337    void
     338    set_compare_mode (int mode)
     339    {
     340      compare_mode = mode;
     341    }
     342  
     343    int
     344    get_compare_mode ()
     345    {
     346      return compare_mode;
     347    }
     348  
     349    char *
     350    get_machinemodel ()
     351    {
     352      return dbe_strdup (machinemodel);
     353    }
     354  
     355    char *preload_libdirs;
     356  
     357  protected: // data
     358    Application *app;
     359  
     360    // default strings from .rc file
     361    char *str_vmode;
     362    char *str_en_desc;
     363    char *str_datamode;
     364    char *str_scompcom;
     365    char *str_sthresh;
     366    char *str_dcompcom;
     367    char *str_dthresh;
     368    char *str_dmetrics;
     369    char *str_dsort;
     370    char *str_tlmode;
     371    char *str_tldata;
     372    char *str_tabs;
     373    char *str_rtabs;
     374    char *str_search_path;
     375    char *str_name_format;
     376    char *str_limit;
     377    char *str_printmode;
     378    char *str_compare;
     379  
     380    bool tabs_processed;
     381  
     382    // Processed settings
     383    bool en_desc;             // controls for reading descendant processes
     384    char * en_desc_usr;       // selective descendants: user specificaton
     385    regex_t * en_desc_cmp;    // selective descendants: compiled specification
     386    Histable::NameFormat name_format; // long/short/mangled naming for C++/Java
     387    VMode view_mode;          // Java mode
     388    int src_compcom;          // compiler commentary visibility for anno-src
     389    int dis_compcom;          // compiler commentary visibility for anno-dis
     390    int threshold_src;        // threshold for anno-src
     391    int threshold_dis;        // threshold for anno-dis
     392    int cmpline_visible;      // show compile-line flags
     393    int funcline_visible;     // show compile-line flags
     394    int src_visible;          // show source in disasm
     395    bool srcmetric_visible;   // show metrics for source in disasm
     396    bool hex_visible;         // show hex code in disasm
     397    char* tldata;             // timeline data type string
     398    int tlmode;               // timeline mode for bars
     399    int stack_align;          // timeline stack alignment
     400    int stack_depth;          // timeline stack depth
     401    int limit;                // print limit
     402    enum PrintMode print_mode;// print mode
     403    char print_delim;         // the delimiter, if print mode = PM_DELIM_SEP_LIST
     404    int compare_mode;         // compare mode
     405  
     406    char *machinemodel; // machine model for Memory Objects
     407  
     408    bool ignore_no_xhwcprof; // ignore no -xhwcprof data in dataspace
     409    bool ignore_fs_warn; // ignore file-system recording warning
     410  
     411    void set_rc (const char *path, bool msg, Emsgqueue *commentq,
     412  	       bool override, bool ipc_or_rdt_mode = false);
     413  
     414    Vector<DispTab*> *tab_list;
     415    Vector<pathmap_t*> *pathmaps;
     416    Vector<lo_expand_t*> *lo_expands;
     417    enum LibExpand lo_expand_default;
     418    bool is_loexpand_default;
     419    Vector<bool> *mem_tab_state;
     420    Vector<int> *mem_tab_order;
     421    Vector<bool> *indx_tab_state;
     422    Vector<int> *indx_tab_order;
     423  };
     424  
     425  #endif /* ! _SETTINGS_H */