Compare commits

...

3 Commits

Author SHA1 Message Date
Andrei Pangin
f6ca3c1ff8 dumpOtlp() should accept Counter argument (#1728) 2026-04-15 19:38:08 +01:00
Andrei Pangin
86adc1605a Updated CHANGELOG 2026-04-15 16:24:06 +01:00
Andrei Pangin
804df3ac8e #1203: Fix "Instance field not found" when using -Xcheck:jni on JDK 8 2026-04-15 16:22:31 +01:00
7 changed files with 23 additions and 10 deletions

View File

@@ -27,15 +27,18 @@
### Bug fixes
- #1727: Allocation profile has wrong units in OTLP format
- #1716: Wall-clock Heatmap does not count samples correctly
- #1715: Fix Zing crash when profiling cpu+wall together
- #1708: Another fix for correct vDSO unwinding on ARM64
- #1707: Workaround for JFR shutdown race
- #1699: Allow negative keys in JFR constant pool
- #1697: Ensure remaining buffer is sufficient for event data in JfrReader
- #1657: Re-enable workaround for a long attach on JDK 8
- #1654: Prefer perf-events engine when record-cpu or target-cpu are selected
- #1585: Scale perf counters in case of multiplexing
- #1528: Add a hard-coded limit on the maximum number of jmethodIDs
- #1203: Fix "Instance field not found" when using `-Xcheck:jni` on JDK 8
- Do not walk past virtual thread continuation barriers
## [4.3] - 2026-01-20

View File

@@ -201,7 +201,7 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
@Override
public String dumpCollapsed(Counter counter) {
try {
return execute0("collapsed," + counter.name().toLowerCase());
return execute0("collapsed," + (counter == Counter.SAMPLES ? "samples" : "total"));
} catch (IOException e) {
throw new IllegalStateException(e);
}
@@ -242,12 +242,13 @@ public class AsyncProfiler implements AsyncProfilerMXBean {
* <p>
* This API is UNSTABLE and might change or be removed in the next version of async-profiler.
*
* @param counter Which counter to use for aggregation
* @return OTLP representation of the profile
*/
@Override
public byte[] dumpOtlp() {
public byte[] dumpOtlp(Counter counter) {
try {
return execute1("otlp");
return execute1("otlp," + (counter == Counter.SAMPLES ? "samples" : "total"));
} catch (IOException e) {
throw new IllegalStateException(e);
}

View File

@@ -31,5 +31,5 @@ public interface AsyncProfilerMXBean {
String dumpCollapsed(Counter counter);
String dumpTraces(int maxTraces);
String dumpFlat(int maxMethods);
byte[] dumpOtlp();
byte[] dumpOtlp(Counter counter);
}

View File

@@ -442,7 +442,9 @@ void VMStructs::resolveOffsets() {
return;
}
if (_klass_offset_addr != NULL) {
JVMFlag* cjc = JVMFlag::find("CheckJNICalls");
if (cjc != NULL && !cjc->get() && _klass_offset_addr != NULL) {
// Create a synthetic fieldID to access VMKlass from jclass instance
_klass = (jfieldID)(uintptr_t)(*_klass_offset_addr << 2 | 2);
}
@@ -461,8 +463,7 @@ void VMStructs::resolveOffsets() {
&& (_compact_object_headers ? (_markword_klass_shift >= 0 && _markword_monitor_value == MONITOR_BIT)
: _oop_klass_offset >= 0)
&& (_symbol_length_offset >= 0 || _symbol_length_and_refcount_offset >= 0)
&& _symbol_body_offset >= 0
&& _klass != NULL;
&& _symbol_body_offset >= 0;
_has_method_structs = _jmethod_ids_offset >= 0
&& _nmethod_method_offset >= 0

View File

@@ -5,7 +5,6 @@
package test.api;
import java.nio.ByteBuffer;
import one.profiler.AsyncProfiler;
import one.profiler.Counter;
import one.profiler.Events;
@@ -22,7 +21,7 @@ public class DumpOtlp extends BusyLoops {
}
// TODO: Should we test this further?
byte[] profile = AsyncProfiler.getInstance().dumpOtlp();
byte[] profile = AsyncProfiler.getInstance().dumpOtlp(Counter.TOTAL);
System.out.println(profile.length);
}
}

View File

@@ -5,6 +5,7 @@
package test.otlp;
import one.profiler.AsyncProfiler;
import one.profiler.Counter;
import one.profiler.Events;
import io.opentelemetry.proto.profiles.v1development.*;
@@ -39,7 +40,7 @@ public class OtlpProfileTimeTest {
}
public static Profile dumpAndGetProfile(AsyncProfiler profiler) throws Exception {
byte[] dump = profiler.dumpOtlp();
byte[] dump = profiler.dumpOtlp(Counter.SAMPLES);
ProfilesData data = ProfilesData.parseFrom(dump);
return data.getResourceProfiles(0).getScopeProfiles(0).getProfiles(0);
}

View File

@@ -5,9 +5,11 @@
package test.vmstructs;
import one.profiler.test.Assert;
import one.profiler.test.Output;
import one.profiler.test.Test;
import one.profiler.test.TestProcess;
import test.alloc.Hello;
import test.smoke.Alloc;
public class VmstructsTests {
@@ -25,4 +27,10 @@ public class VmstructsTests {
Output out = p.profile("stop -o collapsed");
assert out.contains("Alloc.allocate");
}
@Test(mainClass = Hello.class, jvmArgs = "-Xcheck:jni", agentArgs = "start,event=alloc", output = true)
public void checkJni(TestProcess p) throws Exception {
p.waitForExit();
Assert.isEqual(p.exitCode(), 0);
}
}