Skip to content

Commit

Permalink
8260022: [ppc] os::print_function_and_library_name shall resolve func…
Browse files Browse the repository at this point in the history
…tion descriptors transparently

Reviewed-by: mdoerr, lucy
  • Loading branch information
tstuefe committed Jan 27, 2021
1 parent fa40a96 commit 3e4194c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/hotspot/cpu/ppc/assembler_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#ifndef CPU_PPC_ASSEMBLER_PPC_HPP
#define CPU_PPC_ASSEMBLER_PPC_HPP

#include "asm/assembler.hpp"
#include "asm/register.hpp"

// Address is an abstraction used to represent a memory location
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

// no precompiled headers
#include "jvm.h"
#include "assembler_ppc.hpp"
#include "asm/assembler.inline.hpp"
#include "classfile/classLoader.hpp"
#include "classfile/systemDictionary.hpp"
Expand Down Expand Up @@ -493,3 +494,8 @@ bool os::platform_print_native_stack(outputStream* st, void* context, char *buf,
AixNativeCallstack::print_callstack_for_context(st, (const ucontext_t*)context, true, buf, (size_t) buf_size);
return true;
}

// HAVE_FUNCTION_DESCRIPTORS
void* os::resolve_function_descriptor(void* p) {
return ((const FunctionDescriptor*)p)->entry();
}
9 changes: 6 additions & 3 deletions src/hotspot/os_cpu/aix_ppc/os_aix_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }

#define PLATFORM_PRINT_NATIVE_STACK 1
static bool platform_print_native_stack(outputStream* st, void* context,
char *buf, int buf_size);
#define PLATFORM_PRINT_NATIVE_STACK 1
static bool platform_print_native_stack(outputStream* st, void* context,
char *buf, int buf_size);

#define HAVE_FUNCTION_DESCRIPTORS 1
static void* resolve_function_descriptor(void* p);

#endif // OS_CPU_AIX_PPC_OS_AIX_PPC_HPP
7 changes: 7 additions & 0 deletions src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

// no precompiled headers
#include "jvm.h"
#include "assembler_ppc.hpp"
#include "asm/assembler.inline.hpp"
#include "classfile/classLoader.hpp"
#include "classfile/systemDictionary.hpp"
Expand Down Expand Up @@ -498,3 +499,9 @@ int os::extra_bang_size_in_bytes() {
// PPC does not require the additional stack bang.
return 0;
}

#ifdef HAVE_FUNCTION_DESCRIPTORS
void* os::resolve_function_descriptor(void* p) {
return ((const FunctionDescriptor*)p)->entry();
}
#endif
6 changes: 6 additions & 0 deletions src/hotspot/os_cpu/linux_ppc/os_linux_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@
// Note: Currently only used in 64 bit Windows implementations
static bool register_code_area(char *low, char *high) { return true; }

#if !defined(ABI_ELFv2)
// ppc (not ppcle) has function descriptors
#define HAVE_FUNCTION_DESCRIPTORS 1
static void* resolve_function_descriptor(void* p);
#endif

#endif // OS_CPU_LINUX_PPC_OS_LINUX_PPC_HPP
26 changes: 24 additions & 2 deletions src/hotspot/share/runtime/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,24 @@ bool os::print_function_and_library_name(outputStream* st,
buflen = O_BUFLEN;
}
int offset = 0;
const bool have_function_name = dll_address_to_function_name(addr, p, buflen,
&offset, demangle);
bool have_function_name = dll_address_to_function_name(addr, p, buflen,
&offset, demangle);
bool is_function_descriptor = false;
#ifdef HAVE_FUNCTION_DESCRIPTORS
// When we deal with a function descriptor instead of a real code pointer, try to
// resolve it. There is a small chance that a random pointer given to this function
// may just happen to look like a valid descriptor, but this is rare and worth the
// risk to see resolved function names. But we will print a little suffix to mark
// this as a function descriptor for the reader (see below).
if (!have_function_name && os::is_readable_pointer(addr)) {
address addr2 = (address)os::resolve_function_descriptor(addr);
if (have_function_name = is_function_descriptor =
dll_address_to_function_name(addr2, p, buflen, &offset, demangle)) {
addr = addr2;
}
}
#endif // HANDLE_FUNCTION_DESCRIPTORS

if (have_function_name) {
// Print function name, optionally demangled
if (demangle && strip_arguments) {
Expand Down Expand Up @@ -934,6 +950,12 @@ bool os::print_function_and_library_name(outputStream* st,
st->print("+%d", offset);
}
}

// Write a trailing marker if this was a function descriptor
if (have_function_name && is_function_descriptor) {
st->print_raw(" (FD)");
}

return have_function_name || have_library_name;
}

Expand Down

1 comment on commit 3e4194c

@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.