Skip to content

Commit

Permalink
8343343: Misc crash dump improvements on more platforms after JDK-829…
Browse files Browse the repository at this point in the history
…4160
  • Loading branch information
TheRealMDoerr committed Oct 31, 2024
1 parent c40bb76 commit 4d6bee5
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 213 deletions.
29 changes: 6 additions & 23 deletions src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
// Avoid crash during crash if pc broken.
if (epc) {
frame fr(sp, epc, frame::kind::unknown);
return fr;
if (epc == nullptr || !is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
frame fr(sp);
return fr;
return frame(sp, epc, frame::kind::unknown);
}

frame os::fetch_compiled_frame_from_context(const void* ucVoid) {
Expand Down Expand Up @@ -447,23 +447,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Aix::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = 32 /* r0-r32 */ + 3 /* pc, lr, sp */;
int n = continuation;
Expand Down
23 changes: 6 additions & 17 deletions src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, fp, epc);
}

Expand Down Expand Up @@ -442,23 +448,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Bsd::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = 29 /* x0-x28 */ + 3 /* fp, lr, sp */;
int n = continuation;
Expand Down
23 changes: 6 additions & 17 deletions src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, fp, epc);
}

Expand Down Expand Up @@ -836,23 +842,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Bsd::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = AMD64_ONLY(16) NOT_AMD64(8);
int n = continuation;
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ void os::print_context(outputStream* st, const void* context) {
ShouldNotCallThis();
}

void os::print_tos_pc(outputStream *st, const void *context) {
ShouldNotCallThis();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
ShouldNotCallThis();
}
Expand Down
17 changes: 0 additions & 17 deletions src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Linux::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::fetch_frame_from_context(uc).pc();
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = 32 /* r0-r31 */;
int n = continuation;
Expand Down
23 changes: 6 additions & 17 deletions src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, fp, epc);
}

Expand Down Expand Up @@ -474,23 +480,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Linux::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = ARM_REGS_IN_CONTEXT;
int n = continuation;
Expand Down
23 changes: 6 additions & 17 deletions src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, epc, frame::kind::unknown);
}

Expand Down Expand Up @@ -461,23 +467,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Linux::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = 32 /* r0-r32 */ + 3 /* pc, lr, ctr */;
int n = continuation;
Expand Down
17 changes: 0 additions & 17 deletions src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Linux::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::fetch_frame_from_context(uc).pc();
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = 32;
int n = continuation;
Expand Down
23 changes: 6 additions & 17 deletions src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, epc);
}

Expand Down Expand Up @@ -442,23 +448,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Linux::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = 16 /* r0-r15 */ + 1 /* pc */;
int n = continuation;
Expand Down
17 changes: 0 additions & 17 deletions src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,23 +578,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const ucontext_t* uc = (const ucontext_t*)context;

address sp = (address)os::Linux::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::fetch_frame_from_context(uc).pc();
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = AMD64_ONLY(16) NOT_AMD64(8);
int n = continuation;
Expand Down
15 changes: 0 additions & 15 deletions src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,21 +376,6 @@ void os::print_context(outputStream* st, const void* ucVoid) {
st->print_cr("No context information.");
}

void os::print_tos_pc(outputStream *st, const void* ucVoid) {
const ucontext_t* uc = (const ucontext_t*)ucVoid;

address sp = (address)os::Linux::ucontext_get_sp(uc);
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::Posix::ucontext_get_pc(uc);
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
st->print_cr("No register info.");
}
Expand Down
24 changes: 6 additions & 18 deletions src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
intptr_t* sp;
intptr_t* fp;
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
if (!is_readable_pointer(epc)) {
// Try to recover from calling into bad memory
// Assume new frame has not been set up, the same as
// compiled frame stack bang
return fetch_compiled_frame_from_context(ucVoid);
}
return frame(sp, fp, epc);
}

Expand Down Expand Up @@ -205,24 +211,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const CONTEXT* uc = (const CONTEXT*)context;

address sp = (address)uc->Sp;
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = (address)uc->Pc;
st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
print_hex_dump(st, pc - 32, pc + 32, sizeof(char), /* print_ascii=*/false);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = 29 /* X0-X28 */;
int n = continuation;
Expand Down
17 changes: 0 additions & 17 deletions src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,23 +464,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr();
}

void os::print_tos_pc(outputStream *st, const void *context) {
if (context == nullptr) return;

const CONTEXT* uc = (const CONTEXT*)context;

address sp = (address)uc->REG_SP;
print_tos(st, sp);
st->cr();

// Note: it may be unsafe to inspect memory near pc. For example, pc may
// point to garbage if entry point in an nmethod is corrupted. Leave
// this at the end, and hope for the best.
address pc = os::fetch_frame_from_context(uc).pc();
print_instructions(st, pc);
st->cr();
}

void os::print_register_info(outputStream *st, const void *context, int& continuation) {
const int register_count = AMD64_ONLY(16) NOT_AMD64(8);
int n = continuation;
Expand Down
Loading

0 comments on commit 4d6bee5

Please sign in to comment.