Skip to content

Commit

Permalink
8293851: hs_err should print more stack in hex dump
Browse files Browse the repository at this point in the history
Backport-of: cbd0688b321ff88a405be4f7929d6862e543ab50
  • Loading branch information
shipilev committed Aug 23, 2023
1 parent 3f8e995 commit d35a896
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 34 deletions.
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp
Expand Up @@ -454,9 +454,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Aix::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp
Expand Up @@ -472,9 +472,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp);
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp
Expand Up @@ -852,9 +852,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp);
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp
Expand Up @@ -346,9 +346,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
Expand Up @@ -453,9 +453,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", p2i(sp));
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp
Expand Up @@ -467,9 +467,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp
Expand Up @@ -358,9 +358,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *frame_sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(frame_sp));
print_hex_dump(st, (address)frame_sp, (address)(frame_sp + 64), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp
Expand Up @@ -440,9 +440,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
Expand Up @@ -584,9 +584,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
print_hex_dump(st, (address)sp, (address)(sp + 8), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp
Expand Up @@ -211,9 +211,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)uc->Sp;
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
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
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp
Expand Up @@ -455,9 +455,8 @@ void os::print_tos_pc(outputStream *st, const void *context) {

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

intptr_t *sp = (intptr_t *)uc->REG_SP;
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
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
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/runtime/os.cpp
Expand Up @@ -963,6 +963,11 @@ void os::print_dhm(outputStream* st, const char* startStr, long sec) {
st->print_cr("%s %ld days %ld:%02ld hours", startStr, days, hours, minutes);
}

void os::print_tos(outputStream* st, address sp) {
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
print_hex_dump(st, sp, sp + 512, sizeof(intptr_t));
}

void os::print_instructions(outputStream* st, address pc, int unitsize) {
st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc));
print_hex_dump(st, pc - 256, pc + 256, unitsize);
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/runtime/os.hpp
Expand Up @@ -694,12 +694,13 @@ class os: AllStatic {
static void print_environment_variables(outputStream* st, const char** env_list);
static void print_context(outputStream* st, const void* context);
static void print_tos_pc(outputStream* st, const void* context);
static void print_tos(outputStream* st, address sp);
static void print_instructions(outputStream* st, address pc, int unitsize);
static void print_register_info(outputStream* st, const void* context);
static bool signal_sent_by_kill(const void* siginfo);
static void print_siginfo(outputStream* st, const void* siginfo);
static void print_signal_handlers(outputStream* st, char* buf, size_t buflen);
static void print_date_and_time(outputStream* st, char* buf, size_t buflen);
static void print_instructions(outputStream* st, address pc, int unitsize);

// helper for output of seconds in days , hours and months
static void print_dhm(outputStream* st, const char* startStr, long sec);
Expand Down

1 comment on commit d35a896

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.