Skip to content

Commit 660a388

Browse files
committed
8368787: Error reporting: hs_err files should print instructions when referencing code in nemthods
1 parent aa6ff45 commit 660a388

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/hotspot/share/code/codeBlob.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,24 @@ void CodeBlob::dump_for_addr(address addr, outputStream* st, bool verbose) const
910910
nm->print_nmethod(true);
911911
} else {
912912
nm->print_on(st);
913+
if (nm->entry_point() <= addr && addr < nm->code_end()) {
914+
// Pointing into an nmethod. Try to disassemble some instructions around addr.
915+
address start = (addr < nm->verified_entry_point()) ? nm->entry_point() : nm->verified_entry_point();
916+
address end = nm->code_end();
917+
// Try using relocations to find known instruction start and end points.
918+
// (Some platforms have variable length instructions and can only
919+
// disassemble correctly at instruction start addresses.)
920+
RelocIterator iter(nm, start);
921+
while (iter.next() && iter.addr() < addr) { // find relocation before addr
922+
start = iter.addr();
923+
}
924+
if (iter.has_current()) {
925+
if (iter.addr() == addr) iter.next(); // find relocation after addr
926+
if (iter.has_current()) end = iter.addr();
927+
}
928+
929+
Disassembler::decode(start, end, st);
930+
}
913931
}
914932
return;
915933
}

0 commit comments

Comments
 (0)