| 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 DeadlockEvent extends ExtendedEvent { |
| 25 |
private static final String[] TYPES = { |
| 26 |
AnLocale.getString("Lock Held"), // NOI18N |
| 27 |
AnLocale.getString("Lock Requested"), // NOI18N |
| 28 |
AnLocale.getString("<Unknown>"), // NOI18N |
| 29 |
}; |
| 30 |
private static final String[] DLTYPES = { |
| 31 |
AnLocale.getString("Potential Deadlock"), // NOI18N |
| 32 |
AnLocale.getString("Actual Deadlock"), // NOI18N |
| 33 |
AnLocale.getString("<Unknown>"), // NOI18N |
| 34 |
}; |
| 35 |
|
| 36 |
private static final String TYPE = AnLocale.getString("Lock Event:"); // NOI18N |
| 37 |
private static final String DLTYPE = AnLocale.getString("Deadlock Type:"); // NOI18N |
| 38 |
private static final String DEADLOCK_ID = AnLocale.getString("Deadlock ID:"); // NOI18N |
| 39 |
private static final String ADDRESS = AnLocale.getString("Address:"); // NOI18N |
| 40 |
|
| 41 |
private static final String[] GENERIC_RACE_LABELS = {TYPE, DLTYPE, ADDRESS, DEADLOCK_ID}; |
| 42 |
|
| 43 |
private final int type; |
| 44 |
private final int dltype; |
| 45 |
private final int deadlock_id; |
| 46 |
private final long vaddr; |
| 47 |
|
| 48 |
public DeadlockEvent( |
| 49 |
final int lwpid, |
| 50 |
final int thrid, |
| 51 |
final int cpuid, |
| 52 |
final long ts, |
| 53 |
final long stack, |
| 54 |
final long func, |
| 55 |
List<StackState> stackStates, |
| 56 |
final int type, |
| 57 |
final int dltype, |
| 58 |
final int deadlock_id, |
| 59 |
final long vaddr, |
| 60 |
long time_adjust) { |
| 61 |
super(lwpid, thrid, cpuid, ts, stack, func, time_adjust, stackStates); |
| 62 |
this.type = (type >= 0 && type < TYPES.length) ? type : TYPES.length - 1; |
| 63 |
this.dltype = (dltype >= 0 && dltype < DLTYPES.length) ? dltype : DLTYPES.length - 1; |
| 64 |
this.deadlock_id = deadlock_id; |
| 65 |
this.vaddr = vaddr; |
| 66 |
} |
| 67 |
|
| 68 |
public String[] getEventSpecificInfo() { |
| 69 |
return new String[] { |
| 70 |
TYPES[type], |
| 71 |
DLTYPES[dltype], |
| 72 |
AnAddress.toHexString(vaddr), |
| 73 |
new AnInteger(deadlock_id).toString() |
| 74 |
}; |
| 75 |
} |
| 76 |
|
| 77 |
public String[] getEventSpecificLabels() { |
| 78 |
return GENERIC_RACE_LABELS; |
| 79 |
} |
| 80 |
} |