#1676: Make dwarf stack walking mode an alias for vm

Co-authored-by: Bara' Hasheesh <bara.hasheesh@gmail.com>
This commit is contained in:
Andrei Pangin
2026-04-13 21:51:25 +01:00
committed by GitHub
parent 4d5441f2cd
commit 2df2733d1d
4 changed files with 20 additions and 17 deletions

View File

@@ -255,6 +255,7 @@ Error Arguments::parse(const char* args) {
if (value != NULL) {
if (strstr(value, "stats")) _features.stats = 1;
if (strstr(value, "jnienv")) _features.jnienv = 1;
if (strstr(value, "agct")) _features.agct = 1;
if (strstr(value, "mixed")) _features.mixed = 1;
if (strstr(value, "vtable")) _features.vtable_target = 1;
if (strstr(value, "comptask")) _features.comp_task = 1;

View File

@@ -105,13 +105,14 @@ enum EventMask {
constexpr int EVENT_MASK_SIZE = 7;
struct StackWalkFeatures {
unsigned short stats : 1; // collect stack walking duration statistics
unsigned short jnienv : 1; // verify JNIEnv* obtained using VMStructs
unsigned short mixed : 1; // mixed stack traces with Java and native frames interleaved
unsigned short vtable_target : 1; // show receiver classes of vtable/itable stubs
unsigned short comp_task : 1; // display current compilation task for JIT threads
unsigned short pc_addr : 1; // record exact PC address for each sample
unsigned short _padding : 10; // pad structure to 16 bits
unsigned short stats : 1; // collect stack walking duration statistics
unsigned short jnienv : 1; // verify JNIEnv* obtained using VMStructs
unsigned short agct : 1; // force usage of AsyncGetCallTrace instead of VMStructs
unsigned short mixed : 1; // mixed stack traces with Java and native frames interleaved
unsigned short vtable_target : 1; // show receiver classes of vtable/itable stubs
unsigned short comp_task : 1; // display current compilation task for JIT threads
unsigned short pc_addr : 1; // record exact PC address for each sample
unsigned short _padding : 9; // pad structure to 16 bits
};

View File

@@ -540,9 +540,10 @@ class Recording {
}
static const char* getFeaturesString(char* str, size_t size, StackWalkFeatures f) {
int chars = snprintf(str, size, "%s%s%s%s%s%s",
int chars = snprintf(str, size, "%s%s%s%s%s%s%s",
f.stats ? ",stats" : "",
f.jnienv ? ",jnienv" : "",
f.agct ? ",agct" : "",
f.mixed ? ",mixed" : "",
f.vtable_target ? ",vtable" : "",
f.comp_task ? ",comptask" : "",

View File

@@ -943,17 +943,17 @@ Error Profiler::start(Arguments& args, bool reset) {
return Error("VMStructs stack walking is not supported on this JVM/platform");
}
if (_cstack == CSTACK_DEFAULT) {
if (VMStructs::hasStackStructs()) {
// Use VMStructs by default when possible
_cstack = args._cstack = CSTACK_VM;
} else if (VM::isOpenJ9() && DWARF_SUPPORTED) {
// OpenJ9 libs are compiled with frame pointers omitted
_cstack = args._cstack = CSTACK_DWARF;
}
if ((_cstack == CSTACK_DEFAULT || _cstack == CSTACK_DWARF) && VMStructs::hasStackStructs() && !_features.agct) {
// Use VMStructs by default when possible
_cstack = args._cstack = CSTACK_VM;
} else if (_cstack == CSTACK_DEFAULT && VM::isOpenJ9() && DWARF_SUPPORTED) {
// OpenJ9 libs are compiled with frame pointers omitted
_cstack = args._cstack = CSTACK_DWARF;
}
if (_cstack != CSTACK_VM && _features.mixed) {
if (_cstack == CSTACK_VM && _features.agct) {
return Error("agct feature is incompatible with cstack=vm");
} else if (_cstack != CSTACK_VM && _features.mixed) {
return Error("mixed feature is only allowed with VMStructs stack walking");
}