Skip to content

Commit e33b6c1

Browse files
committed
8319437: NMT should show library names in call stacks
Reviewed-by: dholmes, zgu
1 parent 2fae07f commit e33b6c1

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/hotspot/share/utilities/nativeCallStack.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,33 @@ void NativeCallStack::print_on(outputStream* out, int indent) const {
8282
char buf[1024];
8383
int offset;
8484
if (is_empty()) {
85-
for (int index = 0; index < indent; index ++) out->print(" ");
85+
out->fill_to(indent);
8686
out->print("[BOOTSTRAP]");
8787
} else {
8888
for (int frame = 0; frame < NMT_TrackingStackDepth; frame ++) {
8989
pc = get_frame(frame);
9090
if (pc == nullptr) break;
91-
// Print indent
92-
for (int index = 0; index < indent; index ++) out->print(" ");
91+
out->fill_to(indent);
92+
out->print("[" PTR_FORMAT "]", p2i(pc));
93+
// Print function and library; shorten library name to just its last component
94+
// for brevity, and omit it completely for libjvm.so
95+
bool function_printed = false;
9396
if (os::dll_address_to_function_name(pc, buf, sizeof(buf), &offset)) {
94-
out->print("[" PTR_FORMAT "] %s+0x%x", p2i(pc), buf, offset);
95-
} else {
96-
out->print("[" PTR_FORMAT "]", p2i(pc));
97+
out->print("%s+0x%x", buf, offset);
98+
function_printed = true;
99+
}
100+
if ((!function_printed || !os::address_is_in_vm(pc)) &&
101+
os::dll_address_to_library_name(pc, buf, sizeof(buf), &offset)) {
102+
const char* libname = strrchr(buf, os::file_separator()[0]);
103+
if (libname != nullptr) {
104+
libname++;
105+
} else {
106+
libname = buf;
107+
}
108+
out->print(" in %s", libname);
109+
if (!function_printed) {
110+
out->print("+0x%x", offset);
111+
}
97112
}
98113

99114
// Note: we deliberately omit printing source information here. NativeCallStack::print_on()

0 commit comments

Comments
 (0)