Debian Codegraph @

org/gprofng/mpmt/timeline/events/RaceEvent.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.AnAddress;
19 import org.gprofng.mpmt.AnInteger;
20 import org.gprofng.mpmt.AnLocale;
21 import org.gprofng.mpmt.statecolors.StackState;
22 import java.util.List;
23
24 public final class RaceEvent extends ExtendedEvent {
25 private static final int WRITE_RACE = 0;
26 private static final int WRITE_RACE_RED = 1;
27 private static final int READ_RACE = 2;
28 private static final int READ_RACE_RED = 3;
29
30 private static final String[] TYPES = {
31 AnLocale.getString("Write"), // NOI18N
32 AnLocale.getString("Write Red"), // NOI18N
33 AnLocale.getString("Read"), // NOI18N
34 AnLocale.getString("Read Red") // NOI18N
35 };
36
37 private static final String TYPE = AnLocale.getString("Type:"); // NOI18N
38 private static final String RACE_ID = AnLocale.getString("Race ID:"); // NOI18N
39 private static final String ADDRESS = AnLocale.getString("Address:"); // NOI18N
40
41 private static final String[] GENERIC_RACE_LABELS = {TYPE, ADDRESS, RACE_ID};
42
43 private final int type;
44 private final int race_id;
45 private final long vaddr;
46
47 public RaceEvent(
48 final int lwpid,
49 final int thrid,
50 final int cpuid,
51 final long ts,
52 final long stack,
53 final long func,
54 List<StackState> stackStates,
55 final int type,
56 final int race_id,
57 final long vaddr,
58 long time_adjust) {
59 super(lwpid, thrid, cpuid, ts, stack, func, time_adjust, stackStates);
60 this.type = type;
61 this.race_id = race_id;
62 this.vaddr = vaddr;
63 }
64
65 public String[] getEventSpecificInfo() {
66 // fixme what about redundancy flag bit?
67 switch (type) {
68 case WRITE_RACE:
69 case WRITE_RACE_RED:
70 case READ_RACE:
71 case READ_RACE_RED:
72 return new String[] {
73 TYPES[type], AnAddress.toHexString(vaddr), new AnInteger(race_id).toString()
74 };
75 }
76
77 return null;
78 }
79
80 public String[] getEventSpecificLabels() {
81 switch (type) {
82 case WRITE_RACE:
83 case WRITE_RACE_RED:
84 case READ_RACE:
85 case READ_RACE_RED:
86 return GENERIC_RACE_LABELS;
87 }
88
89 return null;
90 }
91 }