forked from mirror/BlueMap
Add ThreadDump to debug-dump-command
This commit is contained in:
parent
b4832fd237
commit
b06ef68d99
@ -34,18 +34,19 @@
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@DebugDump
|
||||
public class WorldRegionRenderTask implements RenderTask {
|
||||
|
||||
@DebugDump private final BmMap map;
|
||||
@DebugDump private final Vector2i worldRegion;
|
||||
@DebugDump private final boolean force;
|
||||
private final BmMap map;
|
||||
private final Vector2i worldRegion;
|
||||
private final boolean force;
|
||||
|
||||
private Deque<Vector2i> tiles;
|
||||
@DebugDump private int tileCount;
|
||||
@DebugDump private long startTime;
|
||||
private int tileCount;
|
||||
private long startTime;
|
||||
|
||||
@DebugDump private volatile int atWork;
|
||||
@DebugDump private volatile boolean cancelled;
|
||||
private volatile int atWork;
|
||||
private volatile boolean cancelled;
|
||||
|
||||
public WorldRegionRenderTask(BmMap map, Vector2i worldRegion) {
|
||||
this(map, worldRegion, false);
|
||||
@ -151,11 +152,13 @@ private void complete() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@DebugDump
|
||||
public synchronized boolean hasMoreWork() {
|
||||
return !cancelled && (tiles == null || !tiles.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
@DebugDump
|
||||
public double estimateProgress() {
|
||||
if (tiles == null) return 0;
|
||||
if (tileCount == 0) return 1;
|
||||
|
@ -54,6 +54,15 @@ public void dump(Path file) throws IOException {
|
||||
|
||||
Set<Object> alreadyDumped = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
|
||||
try {
|
||||
ConfigurationNode threadDump = node.node("threads");
|
||||
for (Thread thread : Thread.getAllStackTraces().keySet()) {
|
||||
dumpInstance(thread, loader.defaultOptions(), threadDump.appendListNode(), alreadyDumped);
|
||||
}
|
||||
} catch (SecurityException ex){
|
||||
node.node("threads").set(ex.toString());
|
||||
}
|
||||
|
||||
ConfigurationNode dump = node.node("dump");
|
||||
for (Object instance : instances) {
|
||||
Class<?> type = instance.getClass();
|
||||
@ -138,6 +147,20 @@ private void dumpInstance(Object instance, ConfigurationOptions options, Configu
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Thread) {
|
||||
Thread t = (Thread) instance;
|
||||
node.node("name").set(t.getName());
|
||||
node.node("state").set(t.getState().toString());
|
||||
node.node("priority").set(t.getPriority());
|
||||
node.node("alive").set(t.isAlive());
|
||||
node.node("id").set(t.getId());
|
||||
node.node("deamon").set(t.isDaemon());
|
||||
node.node("interrupted").set(t.isInterrupted());
|
||||
|
||||
dumpInstance(t.getStackTrace(), options, node.node("stackTrace"), alreadyDumped);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean allFields = type.isAnnotationPresent(DebugDump.class);
|
||||
|
||||
boolean foundSomething = false;
|
||||
|
Loading…
Reference in New Issue
Block a user