1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
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)
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.
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. */
28 #include "dbe_types.h"
30 #include "Hist_data.h"
32 #include "Stats_data.h"
34 #include "Exp_Layout.h"
35 #include "DefaultMap.h"
40 const char nl[] = "\n";
41 const char tab[] = "\t";
44 enum Print_destination
61 Print_destination dest; // printer or file
62 char *name; // of printer or file
63 int ncopies; // # of copies
64 bool header; // print header first
65 FILE *openfile; // if destination is DEST_OPEN_FILE
76 class er_print_common_display
79 er_print_common_display ()
82 pr_params.header = false;
85 virtual ~er_print_common_display () { }
87 // Open the file/printer to write to
88 int open (Print_params *);
91 set_out_file (FILE *o)
94 pr_params.dest = DEST_FILE;
97 // Print the final output data. This function calls
98 // data_dump() to actually do the dumping of data.
101 // Print the output in the appropriate format.
102 virtual void data_dump () = 0;
104 void header_dump (int exp_idx);
106 // Return the report. If the report size is greater than max, return truncated report
107 // Allocates memory, so the caller should free this memory.
108 char *get_output (int max);
113 Print_params pr_params;
115 int exp_idx1, exp_idx2;
120 class er_print_histogram : public er_print_common_display
123 er_print_histogram (DbeView *dbv, Hist_data *data, MetricList *metrics_list,
124 Print_mode disp_type, int limit, char *sort_name,
125 Histable *sobj, bool show_load, bool show_header);
129 void dump_list (int limit);
130 void dump_detail (int limit);
131 void get_gprof_width (Metric::HistMetric *hist_metric, int limit);
132 void dump_gprof (int limit);
133 void dump_annotated_dataobjects (Vector<int> *marks, int threshold);
134 void dump_annotated ();
136 Stack_coverage *stack_cov;
137 Hist_data *hist_data;
145 class er_print_ctree : public er_print_common_display
148 er_print_ctree (DbeView *dbv, Vector<Histable*> *cstack, Histable *sobj,
151 void print_children (Hist_data *data, int index, Histable *obj, char *prefix,
152 Hist_data::HistItem *total);
155 Vector<Histable*> *cstack;
158 Metric::HistMetric *hist_metric;
163 class er_print_gprof : public er_print_common_display
166 er_print_gprof (DbeView *dbv, Vector<Histable*> *cstack);
169 Vector<Histable*> *cstack;
172 class er_print_leaklist : public er_print_common_display
175 er_print_leaklist (DbeView *dbv, bool show_leak,
176 bool show_alloca, int limit);
185 class er_print_heapactivity : public er_print_common_display
188 er_print_heapactivity (DbeView *_dbev, Histable::Type _type,
189 bool _printStat, int _limit);
193 void printStatistics (Hist_data *hist_data);
194 void printCallStacks (Hist_data *hist_data);
201 class er_print_ioactivity : public er_print_common_display
204 er_print_ioactivity (DbeView *_dbev, Histable::Type _type,
205 bool _printStat, int _limit);
209 void printStatistics (Hist_data *hist_data);
210 void printCallStacks (Hist_data *hist_data);
217 class er_print_experiment : public er_print_common_display
220 er_print_experiment (DbeView *me, int bgn_idx, int end_idx, bool show_load,
221 bool show_header, bool show_stat, bool show_over, bool show_odetail);
225 int max_len1, max_len2, max_len3;
226 void overview_sum (int &maxlen);
227 void overview_dump (int exp_idx, int &maxlen);
228 void overview_summary (Ovw_data *ovw_data, int &maxlen);
229 void overview_item (Ovw_data::Ovw_item *ovw_item,
230 Ovw_data::Ovw_item *ovw_item_labels);
231 void overview_value (Value *value, ValueTag value_tag, double total_value);
232 void statistics_sum (int &maxlen);
233 void statistics_dump (int exp_idx, int &maxlen);
234 void statistics_item (Stats_data *stats_data);
241 // Print the header. Experiment name and the sample
242 // selection, along with the percentage.
243 char *pr_load_objects (Vector<LoadObject*> *loadobjects, char *lead);
244 char *pr_samples (Experiment *exp);
245 char *pr_mesgs (Emsg *msg, const char *null_str, const char *lead);
246 void print_load_object (FILE *out_file);
247 void print_header (Experiment *exp, FILE *out_file);
249 // Print Function metrics
250 int print_label (FILE *out_file, MetricList *metrics_list,
251 Metric::HistMetric *hist_metric, int space);
252 void print_anno_file (char *name, const char *sel, const char *srcFile,
253 bool isDisasm, FILE *dis_file, FILE *inp_file,
254 FILE *out_file, DbeView *dbev, bool xdefault);
255 void print_html_title (FILE *out_file, char *title);
256 void print_html_label (FILE *out_file, MetricList *metrics_list);
257 void print_html_content (FILE *out_file, Hist_data *d, MetricList *metrics_list,
258 int limit, Histable::NameFormat nfmt);
259 void print_html_one (FILE *out_file, Hist_data *data, Hist_data::HistItem *item,
260 MetricList *metrics_list, Histable::NameFormat nfmt);
261 void print_html_trailer (FILE* out_file);
262 char *html_ize_name (char *name);
263 void print_delim_label (FILE *out_file, MetricList *metrics_list, char delim);
264 void print_delim_content (FILE *out_file, Hist_data *data,
265 MetricList *metrics_list, int limit,
266 Histable::NameFormat nfmt, char delim);
267 void print_delim_one (FILE *out_file, Hist_data *data, Hist_data::HistItem *item,
268 MetricList *metrics_list, Histable::NameFormat nfmt, char delim);
269 void print_delim_trailer (FILE* out_file, char delim);
270 char *csv_ize_name (char *name, char delim);
271 char *split_metric_name (char *name);