8284273: Early crashes in os::print_context on AArch64

Reviewed-by: stefank, stuefe
This commit is contained in:
Gerard Ziemski 2022-05-19 16:19:36 +00:00
parent fd36f3730e
commit 83cec4b6cc
15 changed files with 113 additions and 29 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021 SAP SE. All rights reserved. * Copyright (c) 2012, 2021 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -447,6 +447,12 @@ void os::print_context(outputStream *st, const void *context) {
} }
st->cr(); st->cr();
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Aix::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Aix::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved.
* Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@ -420,6 +420,7 @@ void os::print_context(outputStream *st, const void *context) {
if (context == NULL) return; if (context == NULL) return;
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
st->print_cr("Registers:"); st->print_cr("Registers:");
st->print( " x0=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 0]); st->print( " x0=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 0]);
st->print(" x1=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 1]); st->print(" x1=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 1]);
@ -464,6 +465,12 @@ void os::print_context(outputStream *st, const void *context) {
st->print( "pc=" INTPTR_FORMAT, (intptr_t)uc->context_pc); st->print( "pc=" INTPTR_FORMAT, (intptr_t)uc->context_pc);
st->print(" cpsr=" INTPTR_FORMAT, (intptr_t)uc->context_cpsr); st->print(" cpsr=" INTPTR_FORMAT, (intptr_t)uc->context_cpsr);
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp); st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -801,6 +801,7 @@ void os::print_context(outputStream *st, const void *context) {
if (context == NULL) return; if (context == NULL) return;
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
st->print_cr("Registers:"); st->print_cr("Registers:");
#ifdef AMD64 #ifdef AMD64
st->print( "RAX=" INTPTR_FORMAT, (intptr_t)uc->context_rax); st->print( "RAX=" INTPTR_FORMAT, (intptr_t)uc->context_rax);
@ -844,6 +845,12 @@ void os::print_context(outputStream *st, const void *context) {
#endif // AMD64 #endif // AMD64
st->cr(); st->cr();
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp); st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -247,6 +247,10 @@ void os::print_context(outputStream* st, const void* context) {
ShouldNotCallThis(); ShouldNotCallThis();
} }
void os::print_tos_pc(outputStream *st, const void *context) {
ShouldNotCallThis();
}
void os::print_register_info(outputStream *st, const void *context) { void os::print_register_info(outputStream *st, const void *context) {
ShouldNotCallThis(); ShouldNotCallThis();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -327,12 +327,18 @@ void os::print_context(outputStream *st, const void *context) {
if (context == NULL) return; if (context == NULL) return;
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
st->print_cr("Registers:"); st->print_cr("Registers:");
for (int r = 0; r < 31; r++) { for (int r = 0; r < 31; r++) {
st->print("R%-2d=", r); st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]);
print_location(st, uc->uc_mcontext.regs[r]);
} }
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
@ -361,8 +367,10 @@ void os::print_register_info(outputStream *st, const void *context) {
// this is only for the "general purpose" registers // this is only for the "general purpose" registers
for (int r = 0; r < 31; r++) for (int r = 0; r < 31; r++) {
st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); st->print("R%-2d=", r);
print_location(st, uc->uc_mcontext.regs[r]);
}
st->cr(); st->cr();
} }

View File

@ -434,6 +434,7 @@ size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
void os::print_context(outputStream *st, const void *context) { void os::print_context(outputStream *st, const void *context) {
if (context == NULL) return; if (context == NULL) return;
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
st->print_cr("Registers:"); st->print_cr("Registers:");
@ -445,6 +446,12 @@ void os::print_context(outputStream *st, const void *context) {
// now print flag register // now print flag register
st->print_cr(" %-4s = 0x%08lx", "cpsr",uc->uc_mcontext.arm_cpsr); st->print_cr(" %-4s = 0x%08lx", "cpsr",uc->uc_mcontext.arm_cpsr);
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", p2i(sp)); st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", p2i(sp));
@ -463,8 +470,8 @@ void os::print_register_info(outputStream *st, const void *context) {
if (context == NULL) return; if (context == NULL) return;
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
intx* reg_area = (intx*)&uc->uc_mcontext.arm_r0;
intx* reg_area = (intx*)&uc->uc_mcontext.arm_r0;
st->print_cr("Register to memory mapping:"); st->print_cr("Register to memory mapping:");
st->cr(); st->cr();
for (int r = 0; r < ARM_REGS_IN_CONTEXT; r++) { for (int r = 0; r < ARM_REGS_IN_CONTEXT; r++) {
@ -474,8 +481,6 @@ void os::print_register_info(outputStream *st, const void *context) {
st->cr(); st->cr();
} }
typedef int64_t cmpxchg_long_func_t(int64_t, int64_t, volatile int64_t*); typedef int64_t cmpxchg_long_func_t(int64_t, int64_t, volatile int64_t*);
cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap; cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;

View File

@ -460,6 +460,12 @@ void os::print_context(outputStream *st, const void *context) {
} }
st->cr(); st->cr();
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -333,17 +333,21 @@ static const char* reg_abi_names[] = {
}; };
void os::print_context(outputStream *st, const void *context) { void os::print_context(outputStream *st, const void *context) {
if (context == NULL) { if (context == NULL) return;
return;
}
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
st->print_cr("Registers:"); st->print_cr("Registers:");
for (int r = 0; r < 32; r++) { for (int r = 0; r < 32; r++) {
st->print("%-*.*s=", 8, 8, reg_abi_names[r]); st->print_cr("%-*.*s=" INTPTR_FORMAT, 8, 8, reg_abi_names[r], (uintptr_t)uc->uc_mcontext.__gregs[r]);
print_location(st, uc->uc_mcontext.__gregs[r]);
} }
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *frame_sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); intptr_t *frame_sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(frame_sp)); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(frame_sp));
@ -359,9 +363,7 @@ void os::print_context(outputStream *st, const void *context) {
} }
void os::print_register_info(outputStream *st, const void *context) { void os::print_register_info(outputStream *st, const void *context) {
if (context == NULL) { if (context == NULL) return;
return;
}
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
@ -374,8 +376,10 @@ void os::print_register_info(outputStream *st, const void *context) {
// this is only for the "general purpose" registers // this is only for the "general purpose" registers
for (int r = 0; r < 32; r++) for (int r = 0; r < 32; r++) {
st->print_cr("%-*.*s=" INTPTR_FORMAT, 8, 8, reg_abi_names[r], (uintptr_t)uc->uc_mcontext.__gregs[r]); st->print("%-*.*s=", 8, 8, reg_abi_names[r]);
print_location(st, uc->uc_mcontext.__gregs[r]);
}
st->cr(); st->cr();
} }

View File

@ -433,6 +433,12 @@ void os::print_context(outputStream *st, const void *context) {
} }
st->cr(); st->cr();
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));

View File

@ -525,6 +525,7 @@ void os::print_context(outputStream *st, const void *context) {
if (context == NULL) return; if (context == NULL) return;
const ucontext_t *uc = (const ucontext_t*)context; const ucontext_t *uc = (const ucontext_t*)context;
st->print_cr("Registers:"); st->print_cr("Registers:");
#ifdef AMD64 #ifdef AMD64
st->print( "RAX=" INTPTR_FORMAT, (intptr_t)uc->uc_mcontext.gregs[REG_RAX]); st->print( "RAX=" INTPTR_FORMAT, (intptr_t)uc->uc_mcontext.gregs[REG_RAX]);
@ -570,6 +571,12 @@ void os::print_context(outputStream *st, const void *context) {
#endif // AMD64 #endif // AMD64
st->cr(); st->cr();
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const ucontext_t* uc = (const ucontext_t*)context;
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -290,6 +290,10 @@ void os::print_context(outputStream* st, const void* context) {
ShouldNotCallThis(); ShouldNotCallThis();
} }
void os::print_tos_pc(outputStream *st, const void *context) {
ShouldNotCallThis();
}
void os::print_register_info(outputStream *st, const void *context) { void os::print_register_info(outputStream *st, const void *context) {
ShouldNotCallThis(); ShouldNotCallThis();
} }

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2020, Microsoft Corporation. All rights reserved. * Copyright (c) 2020, Microsoft Corporation. All rights reserved.
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -203,6 +204,12 @@ void os::print_context(outputStream *st, const void *context) {
st->print(", X28=" INTPTR_FORMAT, uc->X28); st->print(", X28=" INTPTR_FORMAT, uc->X28);
st->cr(); st->cr();
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const CONTEXT* uc = (const CONTEXT*)context;
intptr_t *sp = (intptr_t *)uc->Sp; intptr_t *sp = (intptr_t *)uc->Sp;
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
@ -216,7 +223,6 @@ void os::print_context(outputStream *st, const void *context) {
st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); print_hex_dump(st, pc - 32, pc + 32, sizeof(char));
st->cr(); st->cr();
} }
void os::print_register_info(outputStream *st, const void *context) { void os::print_register_info(outputStream *st, const void *context) {

View File

@ -441,6 +441,12 @@ void os::print_context(outputStream *st, const void *context) {
#endif // AMD64 #endif // AMD64
st->cr(); st->cr();
st->cr(); st->cr();
}
void os::print_tos_pc(outputStream *st, const void *context) {
if (context == NULL) return;
const CONTEXT* uc = (const CONTEXT*)context;
intptr_t *sp = (intptr_t *)uc->REG_SP; intptr_t *sp = (intptr_t *)uc->REG_SP;
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
@ -455,7 +461,6 @@ void os::print_context(outputStream *st, const void *context) {
st->cr(); st->cr();
} }
void os::print_register_info(outputStream *st, const void *context) { void os::print_register_info(outputStream *st, const void *context) {
if (context == NULL) return; if (context == NULL) return;

View File

@ -690,6 +690,7 @@ class os: AllStatic {
static void print_dll_info(outputStream* st); static void print_dll_info(outputStream* st);
static void print_environment_variables(outputStream* st, const char** env_list); static void print_environment_variables(outputStream* st, const char** env_list);
static void print_context(outputStream* st, const void* context); static void print_context(outputStream* st, const void* context);
static void print_tos_pc(outputStream* st, const void* context);
static void print_register_info(outputStream* st, const void* context); static void print_register_info(outputStream* st, const void* context);
static bool signal_sent_by_kill(const void* siginfo); static bool signal_sent_by_kill(const void* siginfo);
static void print_siginfo(outputStream* st, const void* siginfo); static void print_siginfo(outputStream* st, const void* siginfo);

View File

@ -879,6 +879,14 @@ void VMError::report(outputStream* st, bool _verbose) {
st->cr(); st->cr();
} }
STEP("printing registers")
// printing registers
if (_verbose && _context) {
os::print_context(st, _context);
st->cr();
}
STEP("printing register info") STEP("printing register info")
// decode register contents if possible // decode register contents if possible
@ -888,11 +896,11 @@ void VMError::report(outputStream* st, bool _verbose) {
st->cr(); st->cr();
} }
STEP("printing registers, top of stack, instructions near pc") STEP("printing top of stack, instructions near pc")
// registers, top of stack, instructions near pc // printing top of stack, instructions near pc
if (_verbose && _context) { if (_verbose && _context) {
os::print_context(st, _context); os::print_tos_pc(st, _context);
st->cr(); st->cr();
} }