@@ -3998,13 +3998,25 @@ void nmethod::print_value_on_impl(outputStream* st) const {
39983998void 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