Skip to content

Commit 81dd1c8

Browse files
committed
Use frame_complete_offset for better start address computation. Improve comments.
1 parent 4a05d40 commit 81dd1c8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/hotspot/share/code/nmethod.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,13 +3998,25 @@ void nmethod::print_value_on_impl(outputStream* st) const {
39983998
void nmethod::print_code_snippet(outputStream* st, address addr) const {
39993999
if (entry_point() <= addr && addr < code_end()) {
40004000
// Pointing into the nmethod's code. Try to disassemble some instructions around addr.
4001-
address start = (addr < verified_entry_point()) ? entry_point() : verified_entry_point();
4001+
// Determine conservative start and end points.
4002+
address start;
4003+
if (frame_complete_offset() != CodeOffsets::frame_never_safe &&
4004+
addr >= code_begin() + frame_complete_offset()) {
4005+
start = code_begin() + frame_complete_offset();
4006+
} else {
4007+
start = (addr < verified_entry_point()) ? entry_point() : verified_entry_point();
4008+
}
40024009
address end = code_end();
4003-
// Try using relocations to find known instruction start and end points.
4010+
4011+
// Try using relocations to find closer instruction start and end points.
40044012
// (Some platforms have variable length instructions and can only
40054013
// disassemble correctly at instruction start addresses.)
40064014
RelocIterator iter((nmethod*)this, start);
40074015
while (iter.next() && iter.addr() < addr) { // find relocation before addr
4016+
// Note: There's a relocation which doesn't point to an instruction start:
4017+
// ZBarrierRelocationFormatStoreGoodAfterMov with ZGC on x86_64
4018+
// We could detect and skip it, but hex dump is still usable when
4019+
// disassembler produces garbage in such a very rare case.
40084020
start = iter.addr();
40094021
}
40104022
if (iter.has_current()) {

0 commit comments

Comments
 (0)