Skip to content

Commit 4c67304

Browse files
committed
Fix the annotation region format parsing on JDK 24/25
1 parent 05a10a5 commit 4c67304

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

dd-java-agent/agent-profiling/profiling-controller-openjdk/src/main/java/com/datadog/profiling/controller/openjdk/events/SmapEntryCache.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ static AnnotatedRegion fromAnnotatedEntry(String line, int javaVersion) {
9797
long startAddress = -1;
9898
int dashIndex = line.indexOf('-');
9999
if (dashIndex > 0) {
100-
startAddress = isVsyscall ? -0x1000 - 1 : Long.decode(line.substring(0, dashIndex - 1));
100+
if (line.charAt(dashIndex - 1) == ' ') {
101+
dashIndex--; // skip space before dash
102+
}
103+
startAddress = isVsyscall ? -0x1000 - 1 : Long.decode(line.substring(0, dashIndex));
101104
String description = extractElement(line, descIndex, dashIndex + 1);
102105
if (description == null || description.isEmpty()) {
103106
return new AnnotatedRegion(startAddress, "UNDEFINED");

dd-java-agent/agent-profiling/profiling-controller-openjdk/src/test/java/com/datadog/profiling/controller/openjdk/events/SmapEntryFactoryTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ void testAnnotatedRegionsSanity(int javaVersion) throws Exception {
2525
Objects.requireNonNull(
2626
SmapEntryFactory.class.getResourceAsStream(
2727
"/smap/annotated_regions_" + javaVersion + ".txt"))))) {
28+
29+
long sentinel = 0x1000000420000000L;
2830
String line = null;
2931
Set<String> descs = new HashSet<>();
32+
boolean sentinelFound = false;
33+
3034
while ((line = br.readLine()) != null) {
3135
SmapEntryCache.AnnotatedRegion region =
3236
SmapEntryCache.fromAnnotatedEntry(line, javaVersion);
3337
if (line.startsWith("0x")) {
3438
assertNotNull(region);
3539
descs.add(region.description);
40+
sentinelFound |= region.startAddress == sentinel;
3641
}
3742
}
43+
assertTrue(sentinelFound, "Sentinel address not found");
3844
assertTrue(descs.contains("JAVAHEAP"), "JAVAHEAP not found");
3945
assertTrue(descs.contains("GC"), "GC not found");
4046
assertTrue(descs.contains("META"), "META not found");

dd-java-agent/agent-profiling/profiling-controller-openjdk/src/test/resources/smap/annotated_regions_23.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Memory mappings:
1616
(*) - Mapping contains data from multiple regions
1717

1818
size prot offset What
19-
0x0000000420000000 - 0x000000043b000000 452984832 rw-p 00000000 JAVAHEAP
19+
0x1000000420000000 - 0x100000043b000000 452984832 rw-p 00000000 JAVAHEAP
20+
0x0000000420000000 - 0x000000043b000000 452984832 rw-p 00000000 JAVAHEAP
2021
0x000000043b000000 - 0x000000045b000000 536870912 ---p 00000000 JAVAHEAP
2122
0x000000045b000000 - 0x0000000491000000 905969664 rw-p 00000000 JAVAHEAP
2223
0x0000000491000000 - 0x00000004c9000000 939524096 ---p 00000000 JAVAHEAP

dd-java-agent/agent-profiling/profiling-controller-openjdk/src/test/resources/smap/annotated_regions_24.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ file: file mapped, if mapping is not anonymous
3030

3131
from to vsize prot rss hugetlb pgsz notes info file
3232
========================================================================================================================================================================
33+
0x1000000420000000-0x100000043b000000 452984832 rw-p 00000000 0 4K com JAVAHEAP
3334
0x0000000448800000-0x000000049d800000 1426063360 rw-p 1425514496 0 4K com JAVAHEAP -
3435
0x000000049d800000-0x0000000800000000 14537457664 ---p 0 0 4K - JAVAHEAP -
3536
0x0000561c39706000-0x0000561c39707000 4096 r--p 4096 0 4K com - /home/bits/.sdkman/candidates/java/24.0.2-librca/bin/java

0 commit comments

Comments
 (0)