Skip to content

Commit ae47d99

Browse files
committed
8346082: Output JVMTI agent information in hserr files
Backport-of: c75b1d4
1 parent b942b5e commit ae47d99

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

src/hotspot/share/prims/jvmtiAgentList.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class JvmtiAgentList : AllStatic {
6161
private:
6262
static JvmtiAgent* _list;
6363

64-
static Iterator all();
6564
static void initialize();
6665
static void convert_xrun_agents();
6766

@@ -81,6 +80,7 @@ class JvmtiAgentList : AllStatic {
8180

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

83+
static Iterator all();
8484
static Iterator agents() NOT_JVMTI({ Iterator it; return it; });
8585
static Iterator java_agents();
8686
static Iterator native_agents();

src/hotspot/share/runtime/os.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "oops/compressedOops.inline.hpp"
4343
#include "oops/oop.inline.hpp"
4444
#include "prims/jvmtiAgent.hpp"
45+
#include "prims/jvmtiAgentList.hpp"
4546
#include "prims/jvm_misc.hpp"
4647
#include "runtime/arguments.hpp"
4748
#include "runtime/atomic.hpp"
@@ -1076,6 +1077,31 @@ void os::print_environment_variables(outputStream* st, const char** env_list) {
10761077
}
10771078
}
10781079

1080+
void os::print_jvmti_agent_info(outputStream* st) {
1081+
#if INCLUDE_JVMTI
1082+
const JvmtiAgentList::Iterator it = JvmtiAgentList::all();
1083+
if (it.has_next()) {
1084+
st->print_cr("JVMTI agents:");
1085+
} else {
1086+
st->print_cr("JVMTI agents: none");
1087+
}
1088+
while (it.has_next()) {
1089+
const JvmtiAgent* agent = it.next();
1090+
if (agent != nullptr) {
1091+
const char* dyninfo = agent->is_dynamic() ? "dynamic " : "";
1092+
const char* instrumentinfo = agent->is_instrument_lib() ? "instrumentlib " : "";
1093+
const char* loadinfo = agent->is_loaded() ? "loaded" : "not loaded";
1094+
const char* initinfo = agent->is_initialized() ? "initialized" : "not initialized";
1095+
const char* optionsinfo = agent->options();
1096+
const char* pathinfo = agent->os_lib_path();
1097+
if (optionsinfo == nullptr) optionsinfo = "none";
1098+
if (pathinfo == nullptr) pathinfo = "none";
1099+
st->print_cr("%s path:%s, %s, %s, %s%soptions:%s", agent->name(), pathinfo, loadinfo, initinfo, dyninfo, instrumentinfo, optionsinfo);
1100+
}
1101+
}
1102+
#endif
1103+
}
1104+
10791105
void os::print_register_info(outputStream* st, const void* context) {
10801106
int continuation = 0;
10811107
print_register_info(st, context, continuation);

src/hotspot/share/runtime/os.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ class os: AllStatic {
775775
static void print_summary_info(outputStream* st, char* buf, size_t buflen);
776776
static void print_memory_info(outputStream* st);
777777
static void print_dll_info(outputStream* st);
778+
static void print_jvmti_agent_info(outputStream* st);
778779
static void print_environment_variables(outputStream* st, const char** env_list);
779780
static void print_context(outputStream* st, const void* context);
780781
static void print_tos_pc(outputStream* st, const void* context);

src/hotspot/share/utilities/vmError.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,12 @@ void VMError::report(outputStream* st, bool _verbose) {
12591259
os::print_dll_info(st);
12601260
st->cr();
12611261

1262+
#if INCLUDE_JVMTI
1263+
STEP_IF("printing jvmti agent info", _verbose)
1264+
os::print_jvmti_agent_info(st);
1265+
st->cr();
1266+
#endif
1267+
12621268
STEP_IF("printing native decoder state", _verbose)
12631269
Decoder::print_state_on(st);
12641270
st->cr();
@@ -1437,6 +1443,11 @@ void VMError::print_vm_info(outputStream* st) {
14371443
os::print_dll_info(st);
14381444
st->cr();
14391445

1446+
#if INCLUDE_JVMTI
1447+
os::print_jvmti_agent_info(st);
1448+
st->cr();
1449+
#endif
1450+
14401451
// STEP("printing VM options")
14411452

14421453
// VM options

0 commit comments

Comments
 (0)