Debian Codegraph @

org/gprofng/mpmt/timeline/events/ProfileEvent.java

raw
1 /* Copyright (C) 2022-2025 Free Software Foundation
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses>. */
15
16 package org.gprofng.mpmt.timeline.events;
17
18 import org.gprofng.mpmt.AnLocale;
19 import org.gprofng.mpmt.AnLong;
20 import org.gprofng.mpmt.statecolors.StackState;
21 import org.gprofng.mpmt.timeline2.TimelineVariable;
22 import java.awt.Color;
23 import java.util.List;
24 import javax.swing.ImageIcon;
25
26 public final class ProfileEvent extends ExtendedEvent implements DurationEvent, StateEvent {
27 private final String[] LABELS = {
28 AnLocale.getString("Duration (msec.):"), // NOI18N
29 AnLocale.getString("Thread State:") // NOI18N
30 };
31
32 private final int mstate;
33 private final long interval; // in nanosec
34 private final long duration; // visual duration, in nanosec
35 private final int ompstate;
36 private final String[] eventSpecificInfo;
37
38 public ProfileEvent(
39 int lwpid,
40 int thrid,
41 int cpuid,
42 long ts,
43 long stack,
44 long func,
45 List<StackState> stackStates,
46 int mstate,
47 long interval,
48 int ompstate,
49 long duration,
50 long time_adjust) {
51 super(lwpid, thrid, cpuid, ts, stack, func, time_adjust, stackStates);
52
53 this.mstate = mstate;
54 this.ompstate = ompstate; // YXXX unused for now
55 this.interval = interval;
56 this.duration = duration;
57 this.eventSpecificInfo = initEventSpecificInfo();
58 }
59
60 public String[] getEventSpecificInfo() {
61 String[] rc = this.eventSpecificInfo.clone();
62 return rc;
63 }
64
65 private String[] initEventSpecificInfo() {
66 String state = TimelineVariable.mstate_info.getNameByRawIdx(mstate);
67 return new String[] {
68 new AnLong(interval).toTime(0.000001), state,
69 };
70 }
71
72 public String[] getEventSpecificLabels() {
73 return LABELS;
74 }
75
76 public ImageIcon[] getEventSpecificIcons() {
77 Color color = TimelineVariable.mstate_info.getColorByRawIdx(mstate);
78 ImageIcon icon = new ImageIcon(StackState.createIcon(color));
79 return new ImageIcon[] {
80 null, icon,
81 };
82 }
83
84 public long getDuration() {
85 return duration;
86 }
87
88 public int getState() {
89 return mstate;
90 }
91 }