Skip to content

Commit

Permalink
8346082: Output JVMTI agent information in hserr files
Browse files Browse the repository at this point in the history
Reviewed-by: mdoerr, dholmes, stuefe
  • Loading branch information
MBaesken committed Dec 16, 2024
1 parent 51662c2 commit c75b1d4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/jvmtiAgentList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class JvmtiAgentList : AllStatic {
private:
static JvmtiAgent* _list;

static Iterator all();
static void initialize();
static void convert_xrun_agents();

Expand All @@ -82,6 +81,7 @@ class JvmtiAgentList : AllStatic {

static JvmtiAgent* lookup(JvmtiEnv* env, void* f_ptr);

static Iterator all();
static Iterator agents() NOT_JVMTI({ Iterator it; return it; });
static Iterator java_agents();
static Iterator native_agents();
Expand Down
26 changes: 26 additions & 0 deletions src/hotspot/share/runtime/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "oops/oop.inline.hpp"
#include "prims/jvm_misc.hpp"
#include "prims/jvmtiAgent.hpp"
#include "prims/jvmtiAgentList.hpp"
#include "runtime/arguments.hpp"
#include "runtime/atomic.hpp"
#include "runtime/frame.inline.hpp"
Expand Down Expand Up @@ -1121,6 +1122,31 @@ void os::print_environment_variables(outputStream* st, const char** env_list) {
}
}

void os::print_jvmti_agent_info(outputStream* st) {
#if INCLUDE_JVMTI
const JvmtiAgentList::Iterator it = JvmtiAgentList::all();
if (it.has_next()) {
st->print_cr("JVMTI agents:");
} else {
st->print_cr("JVMTI agents: none");
}
while (it.has_next()) {
const JvmtiAgent* agent = it.next();
if (agent != nullptr) {
const char* dyninfo = agent->is_dynamic() ? "dynamic " : "";
const char* instrumentinfo = agent->is_instrument_lib() ? "instrumentlib " : "";
const char* loadinfo = agent->is_loaded() ? "loaded" : "not loaded";
const char* initinfo = agent->is_initialized() ? "initialized" : "not initialized";
const char* optionsinfo = agent->options();
const char* pathinfo = agent->os_lib_path();
if (optionsinfo == nullptr) optionsinfo = "none";
if (pathinfo == nullptr) pathinfo = "none";
st->print_cr("%s path:%s, %s, %s, %s%soptions:%s", agent->name(), pathinfo, loadinfo, initinfo, dyninfo, instrumentinfo, optionsinfo);
}
}
#endif
}

void os::print_register_info(outputStream* st, const void* context) {
int continuation = 0;
print_register_info(st, context, continuation);
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/runtime/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ class os: AllStatic {
static void print_summary_info(outputStream* st, char* buf, size_t buflen);
static void print_memory_info(outputStream* st);
static void print_dll_info(outputStream* st);
static void print_jvmti_agent_info(outputStream* st);
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);
Expand Down
11 changes: 11 additions & 0 deletions src/hotspot/share/utilities/vmError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,12 @@ void VMError::report(outputStream* st, bool _verbose) {
os::print_dll_info(st);
st->cr();

#if INCLUDE_JVMTI
STEP_IF("printing jvmti agent info", _verbose)
os::print_jvmti_agent_info(st);
st->cr();
#endif

STEP_IF("printing native decoder state", _verbose)
Decoder::print_state_on(st);
st->cr();
Expand Down Expand Up @@ -1385,6 +1391,11 @@ void VMError::print_vm_info(outputStream* st) {
os::print_dll_info(st);
st->cr();

#if INCLUDE_JVMTI
os::print_jvmti_agent_info(st);
st->cr();
#endif

// STEP("printing VM options")

// VM options
Expand Down

1 comment on commit c75b1d4

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