Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class XCTraceTableHandler extends DefaultHandler {
static final String SAMPLE_RATE = "sample-rate-micro-seconds";
static final String FRAME = "frame";
static final String BACKTRACE = "backtrace";
static final String TAGGED_BACKTRACE = "tagged-backtrace";
static final String TEXT_ADDRESSES = "text-addresses";
static final String BINARY = "binary";
static final String SAMPLE_TIME = "sample-time";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ private <T extends TraceElement> T peek() {
return res;
}

private <T extends TraceElement> T tryPeek() {
if (entriesStack.isEmpty()) {
return null;
}
return peek();
}

private LongHolder popAndUpdateLongHolder() {
LongHolder value = pop();
if (isNeedToParseCharacters()) {
Expand Down Expand Up @@ -212,6 +219,9 @@ public void startElement(String uri, String localName, String qName, Attributes
return holder;
});
break;
case XCTraceTableHandler.TAGGED_BACKTRACE:
pushCachedOrNew(attributes, id -> new ValueHolder<Frame>(id));
break;
case XCTraceTableHandler.BINARY:
pushCachedOrNew(attributes, id -> new ValueHolder<>(id, parseName(attributes)));
break;
Expand Down Expand Up @@ -253,10 +263,25 @@ public void endElement(String uri, String localName, String qName) {
LongHolder value = popAndUpdateLongHolder();
currentSample.setWeight(value.getValue());
break;
case XCTraceTableHandler.BACKTRACE:
case XCTraceTableHandler.BACKTRACE: {
Frame topFrame = this.<ValueHolder<Frame>>pop().getValue();
// Backtrace may be wrapped into a tagged-backtrace element.
// And it's the only case when something will be on the elements stack.
ValueHolder<Frame> taggedBacktrace = tryPeek();
if (taggedBacktrace != null) {
// Let's put the top frame into the tagged backtrace and let the next case clause handle it.
taggedBacktrace.setValue(topFrame);
} else {
// There's no tagged backtrace, so let's update the sample here.
currentSample.setTopFrame(topFrame.getAddress(), topFrame.getName(), topFrame.getBinary());
}
break;
}
case XCTraceTableHandler.TAGGED_BACKTRACE: {
Frame topFrame = this.<ValueHolder<Frame>>pop().getValue();
currentSample.setTopFrame(topFrame.getAddress(), topFrame.getName(), topFrame.getBinary());
break;
}
case XCTraceTableHandler.BINARY:
ValueHolder<String> bin = pop();
this.<Frame>peek().setBinary(bin.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void parseCpuProfileXcode14_0_1() throws Exception {
verifyProfile(XCTraceTableHandler.ProfilingTableType.CPU_PROFILE, "cpu-profile.xcode14.0.1", false);
}

@Test
public void parseCpuProfileXcode26_4_1() throws Exception {
verifyProfile(XCTraceTableHandler.ProfilingTableType.CPU_PROFILE, "cpu-profile.xcode26.4.1", true);
}

@Test
public void unsupportedSchema() throws Exception {
XCTraceTableProfileHandler handler = new XCTraceTableProfileHandler(XCTraceTableHandler.ProfilingTableType.CPU_PROFILE, sample -> fail("Expected no samples"));
Expand All @@ -66,6 +71,11 @@ public void parseCountersProfile() throws Exception {
verifyProfile(XCTraceTableHandler.ProfilingTableType.COUNTERS_PROFILE, "counters-profile", true);
}

@Test
public void parseCountersProfileXcode26_4_1() throws Exception {
verifyProfile(XCTraceTableHandler.ProfilingTableType.COUNTERS_PROFILE, "counters-profile.xcode26.4.1", true);
}

@Test
public void parseCountersTimeProfile() throws Exception {
verifyProfile(XCTraceTableHandler.ProfilingTableType.COUNTERS_PROFILE, "counters-time-profile", true);
Expand All @@ -81,6 +91,11 @@ public void parseTimeProfileXcode12_5() throws Exception {
verifyProfile(XCTraceTableHandler.ProfilingTableType.TIME_PROFILE, "time-profile.xcode12.5", false);
}

@Test
public void parseTimeProfileXcode26_4_1() throws Exception {
verifyProfile(XCTraceTableHandler.ProfilingTableType.TIME_PROFILE, "time-profile.xcode26.4.1", true);
}

private void verifyProfile(XCTraceTableHandler.ProfilingTableType tableType, String profileName,
boolean fixAddress) throws Exception {
List<XCTraceTableProfileHandler.XCTraceSample> samples = new ArrayList<>();
Expand Down
Loading