mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
capture speedup - request all frames in one request
This commit is contained in:
@@ -207,6 +207,44 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
|
||||
return myFrameCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as frames(), but always force full frames refresh if not cached,
|
||||
* this is useful when you need all frames but do not plan to invoke anything
|
||||
* as only one request is sent
|
||||
*/
|
||||
@NotNull
|
||||
public List<StackFrameProxyImpl> forceFrames() throws EvaluateException {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
final ThreadReference threadRef = getThreadReference();
|
||||
try {
|
||||
//LOG.assertTrue(threadRef.isSuspended());
|
||||
checkValid();
|
||||
|
||||
if (myFrames == null) {
|
||||
try {
|
||||
List<StackFrame> frames = threadRef.frames();
|
||||
myFrameCount = frames.size();
|
||||
myFrames = new ArrayList<>(myFrameCount);
|
||||
myFramesFromBottom.clear();
|
||||
int idx = 0;
|
||||
for (StackFrame frame : frames) {
|
||||
StackFrameProxyImpl frameProxy = new StackFrameProxyImpl(this, frame, myFrameCount - idx);
|
||||
myFrames.add(frameProxy);
|
||||
myFramesFromBottom.addFirst(frameProxy);
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
catch (IncompatibleThreadStateException | InternalException e) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ObjectCollectedException ignored) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return myFrames;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<StackFrameProxyImpl> frames() throws EvaluateException {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
|
||||
@@ -74,7 +74,7 @@ public class StackFrameItem {
|
||||
ThreadReferenceProxyImpl threadReferenceProxy = suspendContext.getThread();
|
||||
if (threadReferenceProxy != null) {
|
||||
List<StackFrameItem> res = new ArrayList<>();
|
||||
for (StackFrameProxyImpl frame : threadReferenceProxy.frames()) {
|
||||
for (StackFrameProxyImpl frame : threadReferenceProxy.forceFrames()) {
|
||||
try {
|
||||
List<XNamedValue> vars = null;
|
||||
if (withVars) {
|
||||
|
||||
+17
-13
@@ -30,6 +30,7 @@ import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.jdi.DecompiledLocalVariable;
|
||||
import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
|
||||
import com.intellij.debugger.memory.utils.StackFrameItem;
|
||||
import com.intellij.debugger.settings.CapturePoint;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
@@ -104,22 +105,25 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint {
|
||||
public boolean processLocatableEvent(SuspendContextCommandImpl action, LocatableEvent event) throws EventProcessingException {
|
||||
SuspendContextImpl suspendContext = action.getSuspendContext();
|
||||
if (suspendContext != null) {
|
||||
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
|
||||
if (frameProxy != null) {
|
||||
ThreadReferenceProxyImpl thread = suspendContext.getThread();
|
||||
if (thread != null) {
|
||||
DebugProcessImpl process = suspendContext.getDebugProcess();
|
||||
try {
|
||||
Map<Object, List<StackFrameItem>> stacks = process.getUserData(CAPTURED_STACKS);
|
||||
if (stacks == null) {
|
||||
stacks = new CapturedStacksMap();
|
||||
process.putUserData(CAPTURED_STACKS, Collections.synchronizedMap(stacks));
|
||||
}
|
||||
Value key = myCaptureEvaluator.evaluate(new EvaluationContextImpl(suspendContext, frameProxy));
|
||||
if (key instanceof ObjectReference) {
|
||||
List<StackFrameItem> frames = StackFrameItem.createFrames(suspendContext, true);
|
||||
if (frames.size() > MAX_STACK_LENGTH) {
|
||||
frames = frames.subList(0, MAX_STACK_LENGTH);
|
||||
StackFrameProxyImpl frameProxy = ContainerUtil.getFirstItem(thread.forceFrames());
|
||||
if (frameProxy != null) {
|
||||
Map<Object, List<StackFrameItem>> stacks = process.getUserData(CAPTURED_STACKS);
|
||||
if (stacks == null) {
|
||||
stacks = new CapturedStacksMap();
|
||||
process.putUserData(CAPTURED_STACKS, Collections.synchronizedMap(stacks));
|
||||
}
|
||||
Value key = myCaptureEvaluator.evaluate(new EvaluationContextImpl(suspendContext, frameProxy));
|
||||
if (key instanceof ObjectReference) {
|
||||
List<StackFrameItem> frames = StackFrameItem.createFrames(suspendContext, true);
|
||||
if (frames.size() > MAX_STACK_LENGTH) {
|
||||
frames = frames.subList(0, MAX_STACK_LENGTH);
|
||||
}
|
||||
stacks.put(getKey((ObjectReference)key), frames);
|
||||
}
|
||||
stacks.put(getKey((ObjectReference)key), frames);
|
||||
}
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
|
||||
Reference in New Issue
Block a user