Wolfgang Thallergcc16 merge934c3885 months agoHistory
3126 lines · 85.4 KB · C++
RawDownload
/* Copyright (C) 2021-2026 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.  */ #include "config.h"#include "util.h"#include "Application.h"#include "DbeSession.h"#include "CallStack.h"#include "Command.h"#include "DataObject.h"#include "Experiment.h"#include "ExpGroup.h"#include "FilterExp.h"#include "FilterSet.h"#include "Function.h"#include "DbeView.h"#include "PathTree.h"#include "DataSpace.h"#include "MemorySpace.h"#include "IOActivity.h"#include "HeapActivity.h"#include "Print.h"#include "MetricList.h"#include "Module.h"#include "Filter.h"#include "LoadObject.h"#include "dbe_types.h"#include "StringBuilder.h" DbeView::DbeView (Application *_app, Settings *_settings, int _vindex){  init ();  phaseIdx = 0;  settings = new Settings (_settings);  ptree = new PathTree (this);  dspace = new DataSpace (this);  memspaces = new Vector<MemorySpace*>;  iospace = new IOActivity (this);  heapspace = new HeapActivity (this);  filters = new Vector<FilterSet*>;  lo_expands = new Vector<enum LibExpand>;  cur_filter_str = NULL;  prev_filter_str = NULL;  cur_filter_expr = NULL;  filter_active = false;  noParFilter = false;  dataViews = new Vector<Vector<DataView*>*>;  names_src[0] = NULL;  names_src[1] = NULL;  names_src[2] = NULL;  names_dis[0] = NULL;  names_dis[1] = NULL;  names_dis[2] = NULL;  marks = new Vector<int>;  marks2dsrc = new Vector<int_pair_t>;  marks2dsrc_inc = new Vector<int_pair_t>;  marks2ddis = new Vector<int_pair_t>;  marks2ddis_inc = new Vector<int_pair_t>;  app = _app;   // set the view's index  vindex = _vindex;   // clear the precomputed data  func_data = NULL;  line_data = NULL;  pc_data = NULL;  src_data = NULL;  dis_data = NULL;  fitem_data = NULL;  callers = NULL;  callees = NULL;  dobj_data = NULL;  dlay_data = NULL;  iofile_data = NULL;  iovfd_data = NULL;  iocs_data = NULL;  heapcs_data = NULL;   // and clear the selections  sel_obj = NULL;  sel_dobj = NULL;  sel_binctx = NULL;  func_scope = false;  lastSelInstr = NULL;  lastSelFunc = NULL;   // Initialize index spaces  int sz = settings->get_IndxTabState ()->size ();  indxspaces = new Vector<PathTree*>(sz);  indx_data = new Vector<Hist_data*>(sz);  sel_idxobj = new Vector<Histable*>(sz);  for (int i = 0; i < sz; i++)    {      PathTree *is = new PathTree (this, i);      indxspaces->store (i, is);      indx_data->store (i, NULL);      sel_idxobj->store (i, NULL);    }  reset ();   lobjectsNoJava = NULL;   // set lo_expands for already existing LoadObjects  int idx;  LoadObject *lo;  Vector<LoadObject*> *lobjs = dbeSession->get_text_segments ();  Vec_loop (LoadObject*, lobjs, idx, lo)  {    lo_expands->store (lo->seg_idx, LIBEX_SHOW);    set_lo_expand (lo->seg_idx, LIBEX_SHOW);  }  delete lobjs;} DbeView::DbeView (DbeView *dbev, int _vindex){  init ();  phaseIdx = 0;  settings = new Settings (dbev->settings);  ptree = new PathTree (this);  dspace = new DataSpace (this);  iospace = new IOActivity (this);  heapspace = new HeapActivity (this);  memspaces = new Vector<MemorySpace*>;  filters = new Vector<FilterSet*>;  lo_expands = new Vector<enum LibExpand>;  cur_filter_str = NULL;  prev_filter_str = NULL;  cur_filter_expr = NULL;  noParFilter = false;  dataViews = new Vector<Vector<DataView*>*>;  names_src[0] = NULL;  names_src[1] = NULL;  names_src[2] = NULL;  names_dis[0] = NULL;  names_dis[1] = NULL;  names_dis[2] = NULL;  marks = new Vector<int>;  marks2dsrc = new Vector<int_pair_t>;  marks2dsrc_inc = new Vector<int_pair_t>;  marks2ddis = new Vector<int_pair_t>;  marks2ddis_inc = new Vector<int_pair_t>;  app = dbev->app;   // set the view's index  vindex = _vindex;   // clear the precomputed data  func_data = NULL;  line_data = NULL;  pc_data = NULL;  src_data = NULL;  dis_data = NULL;  fitem_data = NULL;  callers = NULL;  callees = NULL;  dobj_data = NULL;  dlay_data = NULL;  iofile_data = NULL;  iovfd_data = NULL;  iocs_data = NULL;  heapcs_data = NULL;   // and clear the selections  sel_obj = NULL;  sel_dobj = NULL;  sel_binctx = NULL;  func_scope = false;  lastSelInstr = NULL;  lastSelFunc = NULL;   // create the vector of IndexSpaces  int sz = dbev->indxspaces->size ();  indxspaces = new Vector<PathTree*>(sz);  indx_data = new Vector<Hist_data*>(sz);  sel_idxobj = new Vector<Histable*>(sz);  for (int i = 0; i < sz; i++)    {      PathTree *is = new PathTree (this, i);      indxspaces->store (i, is);      indx_data->store (i, NULL);      sel_idxobj->store (i, NULL);    }  reset ();   // now copy the relevant information from the original view  for (int i = 0; i < dbeSession->nexps (); i++)    add_experiment (i, dbev->get_exp_enable (i));  update_advanced_filter ();  delete lo_expands;  lo_expands = dbev->lo_expands->copy ();  lobjectsNoJava = NULL;} DbeView::~DbeView (){  delete settings;  delete ptree;  delete dspace;  delete iospace;  delete heapspace;  Destroy (memspaces);  Destroy (filters);  delete lo_expands;  free (cur_filter_str);  free (prev_filter_str);  delete cur_filter_expr;  for (int exp_id = 0; exp_id < dataViews->size (); ++exp_id)    {      Vector<DataView*> *expDataViewList = dataViews->fetch (exp_id);      Destroy (expDataViewList);    }  delete dataViews;  delete reg_metrics;  metrics_lists->destroy ();  delete metrics_lists;  metrics_ref_lists->destroy ();  delete metrics_ref_lists;  delete derived_metrics;  delete marks;  delete marks2dsrc;  delete marks2dsrc_inc;  delete marks2ddis;  delete marks2ddis_inc;   // Index spaces  indxspaces->destroy ();  delete indxspaces;   indx_data->destroy ();  delete indx_data;  delete sel_idxobj;  delete lobjectsNoJava;} voidDbeView::init (){  phaseIdx = 0;  reg_metrics = new Vector<BaseMetric*>;  metrics_lists = new Vector<MetricList*>;  metrics_ref_lists = new Vector<MetricList*>;  for (int i = 0; i <= MET_HEAP; i++)    {      metrics_lists->append (NULL);      metrics_ref_lists->append (NULL);    }  derived_metrics = new DerivedMetrics;  derived_metrics->add_definition (GTXT ("CPI"), GTXT ("Cycles Per Instruction"), GTXT ("cycles/insts"));  derived_metrics->add_definition (GTXT ("IPC"), GTXT ("Instructions Per Cycle"), GTXT ("insts/cycles"));  derived_metrics->add_definition (GTXT ("K_CPI"), GTXT ("Kernel Cycles Per Instruction"), GTXT ("K_cycles/K_insts"));  derived_metrics->add_definition (GTXT ("K_IPC"), GTXT ("Kernel Instructions Per Cycle"), GTXT ("K_insts/K_cycles"));} boolDbeView::set_libexpand (char *liblist, enum LibExpand flag){  bool changed = settings->set_libexpand (liblist, flag, false);  // Show/hide performance optimization:  // No need to call update_lo_expand for every library because dbev->set_libexpand()  // is called from a loop in Dbe.cc SetLoadObjectState for every load object.  // It is sufficient to call update_lo_expand() just once at the end of the loop.  //  At all other places such as er_print.cc which calls specific set_libexpand()  //  explicitly call update_lo_expands();  return changed;} boolDbeView::set_libdefaults (){  bool changed = settings->set_libdefaults ();  if (changed == true)    update_lo_expands ();  return changed;} voidDbeView::update_lo_expands (){  int index;  LoadObject *lo;   // search all load objects  Vector<LoadObject*> *lobjs = dbeSession->get_text_segments ();  Vec_loop (LoadObject*, lobjs, index, lo)  {    // now search the settings list for this one    enum LibExpand flag = settings->get_lo_setting (lo->get_pathname ());    set_lo_expand (lo->seg_idx, flag);  }  delete lobjs;} enum LibExpandDbeView::get_lo_expand (int idx){  if (idx < lo_expands->size ())    return lo_expands->get (idx);  return LIBEX_SHOW;} boolDbeView::set_lo_expand (int idx, enum LibExpand flag){  // LIBRARY_VISIBILITY  if (flag == LIBEX_HIDE)    {      resetShowAll ();      dbeSession->set_lib_visibility_used ();    }  // if no change  if (idx < lo_expands->size () && flag == get_lo_expand (idx))    return false;  setShowHideChanged (); // this is necessary if called from er_print   // change the flag  lo_expands->store (idx, flag);   // and reset the data  fflush (stderr);  purge_events ();  reset_data (true);  return true;} voidDbeView::reset (){  phaseIdx++;   // reset all the per-experiment arrays  filters->destroy ();  lo_expands->reset ();  free (cur_filter_str);  cur_filter_str = NULL;  free (prev_filter_str);  prev_filter_str = NULL;  delete cur_filter_expr;  cur_filter_expr = NULL;  noParFilter = false;  for (int exp_id = 0; exp_id < dataViews->size (); ++exp_id)    {      Vector<DataView*> *expDataViewList = dataViews->fetch (exp_id);      if (expDataViewList)	expDataViewList->destroy ();    }  dataViews->destroy ();  reset_metrics ();   // now reset any cached data  reset_data (true);  ompDisMode = false;  showAll = true;  showHideChanged = false;  newViewMode = false;} voidDbeView::reset_data (bool all){  // clear the precomputed data  if (func_data != NULL)    {      delete func_data;      func_data = NULL;    }  if (line_data != NULL)    {      delete line_data;      line_data = NULL;    }  if (pc_data != NULL)    {      delete pc_data;      pc_data = NULL;    }  if (src_data != NULL)    {      delete src_data;      src_data = NULL;    }  if (dis_data != NULL)    {      delete dis_data;      dis_data = NULL;    }  if (fitem_data != NULL)    {      delete fitem_data;      fitem_data = NULL;    }  if (callers != NULL)    {      delete callers;      callers = NULL;    }  if (callees != NULL)    {      delete callees;      callees = NULL;    }  if (dobj_data != NULL)    {      delete dobj_data;      dobj_data = NULL;    }  if (dlay_data != NULL)    {      delete dlay_data;      dlay_data = NULL;    }  if (iofile_data != NULL)    {      delete iofile_data;      iofile_data = NULL;    }  if (iovfd_data != NULL)    {      delete iovfd_data;      iovfd_data = NULL;    }  if (iocs_data != NULL)    {      delete iocs_data;      iocs_data = NULL;    }  if (heapcs_data != NULL)    {      delete heapcs_data;      heapcs_data = NULL;    }   // and reset the selections  if (all)    {      sel_obj = NULL;      sel_dobj = NULL;      lastSelInstr = NULL;      lastSelFunc = NULL;      // Set selected object <Total> if possible      Function * ft = dbeSession->get_Total_Function ();      set_sel_obj (ft);    }  sel_binctx = NULL;   dspace->reset ();  iospace->reset ();  heapspace->reset ();   // loop over MemorySpaces, resetting each one  for (long i = 0, sz = VecSize (memspaces); i < sz; i++)    {      MemorySpace *ms = memspaces->get (i);      ms->reset ();    }   // loop over IndexSpaces, resetting cached data  indx_data->destroy ();  for (long i = 0, sz = VecSize (indxspaces); i < sz; i++)    {      indx_data->store (i, NULL);      sel_idxobj->store (i, NULL);    }} Vector<BaseMetric*> *DbeView::get_all_reg_metrics (){  Vector<BaseMetric*> *mlist = dbeSession->get_all_reg_metrics ();  return mlist;} BaseMetric *DbeView::register_metric_expr (BaseMetric::Type type, char *cmd, char *expr_spec){  BaseMetric *bm = dbeSession->register_metric_expr (type, cmd, expr_spec);  return bm;} Metric *DbeView::get_compare_metric (Metric *mtr, int groupNum){

Lines 1–500 of 3126.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t