RFR (S) 8217879: hs_err should print more instructions in hex dump
Thomas Stüfe
thomas.stuefe at gmail.com
Tue Jan 29 16:34:56 UTC 2019
On Tue, Jan 29, 2019 at 4:27 PM Aleksey Shipilev <shade at redhat.com> wrote:
> On 1/29/19 2:20 PM, Thomas Stüfe wrote:
> > Or, start at the pc and work your way downward byte for byte (or word
> for word since SafeFetch
> > aligns to word size anyway), squirreling the bytes away temporarily,
> until -256 or first fault. Then
> > print those bytes. You only have to do this on the first leg, on the
> second you work upward, the
> > same direction you print, so no need to temporarily store the bytes.
>
> Actually, we can use this idea for linear probing here as well. This
> allows to dispense the
> exponential steps, because we only fail twice in worst case, and it
> simplifies reliance on page
> sizes. Like this:
>
> void os::print_instructions(outputStream* st, address pc, int unitsize) {
> st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc));
>
> // Probe the memory around the PC for readability.
> const int max_delta = 256;
> int delta;
> address low = pc, high = pc;
>
> delta = 0;
> while (delta <= max_delta && is_readable_pointer(pc - delta)) {
> low = pc - delta;
> delta++;
> }
>
> delta = 0;
> while (delta <= max_delta && is_readable_pointer(pc + delta)) {
> high = pc + delta;
> delta++;
> }
>
> if (low < high) {
> print_hex_dump(st, low, high, unitsize);
> } else {
> st->print_cr("Memory is not readable");
> }
> }
>
> WDYT?
>
Even better. No need to store those bytes on the first leg.
Note that your approach assumes that the readable addresses stay readable,
and since we are in error handling all bets are open, someone may unmap the
pages concurrently right after we probed them and before printing.
But well, this is error handling and we have secondary crash handling and
there is a thing like too much paranoia :)
..thomas
>
> -Aleksey
>
>
More information about the hotspot-dev
mailing list