RFR (S) 8217879: hs_err should print more instructions in hex dump

Aleksey Shipilev shade at redhat.com
Tue Jan 29 15:27:29 UTC 2019


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?

-Aleksey



More information about the hotspot-dev mailing list