Skip to content

Commit aea530a

Browse files
committed
fix : Can now extract a stack starting at any point
1 parent 5b638de commit aea530a

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

src/main/java/org/jdiextractor/core/AbstractExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ protected void createTracePopulator() {
111111
* @return the thread where the execution to extract takes place
112112
*/
113113
protected ThreadReference getThread() {
114-
// WARNING: We assume the thread name matches 'entryMethod' (usually "main")
115-
return this.getThreadNamed(config.getEntrypoint().getMethodName());
114+
// WARNING: We assume the thread name matches "main"
115+
return this.getThreadNamed("main");
116116
}
117117

118118
/**

src/main/java/org/jdiextractor/core/CallStackSnapshotExtractor.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@
1818
*/
1919
public class CallStackSnapshotExtractor extends AbstractExtractor<CallStackSnapshotExtractorConfig> {
2020

21-
2221
public CallStackSnapshotExtractor() {
2322
super(false);
2423
}
2524

2625
@Override
2726
protected void executeExtraction() {
2827
try {
29-
// wait for the breakpoint
30-
this.waitForBreakpoint();
28+
this.processEventsUntil(config.getEntrypoint());
29+
int startFrame = this.getThread().frameCount();
30+
31+
this.processEventsUntil(config.getEndpoint());
3132

3233
// Extract all frames
3334
List<StackFrame> frames = this.getThread().frames();
34-
for (int i = frames.size() - 1; i >= 0; i--) {
35+
for (int i = frames.size() - startFrame - 1; i >= 0; i--) {
3536
StackFrame next = frames.get(i);
3637
this.createMethodWith(next);
3738
}
@@ -44,12 +45,6 @@ protected void executeExtraction() {
4445
}
4546
}
4647

47-
48-
49-
private void waitForBreakpoint() throws IncompatibleThreadStateException {
50-
this.processEventsUntil(config.getEndpoint());
51-
}
52-
5348
@Override
5449
protected void reactToStepEvent(StepEvent event) {
5550
// Nothing, should not happen in this scenario
@@ -60,5 +55,4 @@ protected void reactToMethodEntryEvent(MethodEntryEvent event) {
6055
// Nothing, should not happen in this scenario
6156
}
6257

63-
6458
}

0 commit comments

Comments
 (0)