1/* Copyright (C) 2021 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 _OVW_DATA_H
22#define _OVW_DATA_H
23
24// An Ovw_data object is used to supply data for constructing an overview
25// display.
26
27#include "dbe_structs.h"
28
29class Sample;
30class DataView;
31
32class Ovw_data
33{
34public:
35
36  enum OVW_LMS_STORAGE
37  {// in display order, not LMS_* order
38    // Note: use same display order of LMS_* in: er.rc, TimelineVariable.java,
39    // Ovw_data.h, BaseMetricTreeNode.cc and Experiment.cc metric registration
40    OVW_LMS_USER,
41    OVW_LMS_SYSTEM,
42    OVW_LMS_TRAP,
43    OVW_LMS_USER_LOCK,
44    OVW_LMS_DFAULT,
45    OVW_LMS_TFAULT,
46    OVW_LMS_KFAULT,
47    OVW_LMS_STOPPED,
48    OVW_LMS_WAIT_CPU,
49    OVW_LMS_SLEEP,
50    OVW_NUMVALS         // must be last
51  };
52
53  // Ovw_item contains one slice of data
54  struct Ovw_item
55  {
56    Value values [OVW_NUMVALS + 1]; // Value list (value[0] is left over)
57    int states;                     // Number of non-zero states
58    Value total;                    // Total of all values
59    int size;                       // Number of values
60    timestruc_t start;              // Start time of sample
61    timestruc_t duration;           // Duration of sample
62    timestruc_t end;                // End time of sample
63    timestruc_t tlwp;               // Total LWP time
64    double nlwp;                    // Average number of LWPs
65    ValueTag type;                  // Type of value
66    int number;                     // Sample number
67    char *start_label;              // Sample start label
68    char *end_label;                // Sample end label
69  };
70
71  Ovw_data (DataView *, hrtime_t exp_start);
72  Ovw_data ();
73  ~Ovw_data ();
74  void sum (Ovw_data *data);
75  Ovw_item get_totals ();
76  Ovw_item get_labels ();
77
78  // zero out contents of Ovw_item
79  static Ovw_item *reset_item (Ovw_item *item);
80
81  int
82  size ()
83  {
84    return ovw_items->size ();
85  }
86
87  Ovw_item
88  fetch (int index)
89  {
90    return *ovw_items->fetch (index);
91  }
92
93private:
94  // Compute the values for "ovw_item" from "sample".
95  void extract_data (Ovw_item *ovw_item, Sample *sample);
96
97  Vector<Ovw_item*> *ovw_items;
98  Ovw_item *totals;             // Item to cache totals
99  DataView *packets;
100};
101
102#endif /* _OVW_DATA_H */
103