Skip to content

Commit c75b1d4

Browse files
committed
8346082: Output JVMTI agent information in hserr files
Reviewed-by: mdoerr, dholmes, stuefe
1 parent 51662c2 commit c75b1d4

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

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

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

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

src/hotspot/share/runtime/os.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "oops/oop.inline.hpp"
5050
#include "prims/jvm_misc.hpp"
5151
#include "prims/jvmtiAgent.hpp"
52+
#include "prims/jvmtiAgentList.hpp"
5253
#include "runtime/arguments.hpp"
5354
#include "runtime/atomic.hpp"
5455
#include "runtime/frame.inline.hpp"
@@ -1121,6 +1122,31 @@ void os::print_environment_variables(outputStream* st, const char** env_list) {
11211122
}
11221123
}
11231124

1125+
void os::print_jvmti_agent_info(outputStream* st) {
1126+
#if INCLUDE_JVMTI
1127+
const JvmtiAgentList::Iterator it = JvmtiAgentList::all();
1128+
if (it.has_next()) {
1129+
st->print_cr("JVMTI agents:");
1130+
} else {
1131+
st->print_cr("JVMTI agents: none");
1132+
}
1133+
while (it.has_next()) {
1134+
const JvmtiAgent* agent = it.next();
1135+
if (agent != nullptr) {
1136+
const char* dyninfo = agent->is_dynamic() ? "dynamic " : "";
1137+
const char* instrumentinfo = agent->is_instrument_lib() ? "instrumentlib " : "";
1138+
const char* loadinfo = agent->is_loaded() ? "loaded" : "not loaded";
1139+
const char* initinfo = agent->is_initialized() ? "initialized" : "not initialized";
1140+
const char* optionsinfo = agent->options();
1141+
const char* pathinfo = agent->os_lib_path();
1142+
if (optionsinfo == nullptr) optionsinfo = "none";
1143+
if (pathinfo == nullptr) pathinfo = "none";
1144+
st->print_cr("%s path:%s, %s, %s, %s%soptions:%s", agent->name(), pathinfo, loadinfo, initinfo, dyninfo, instrumentinfo, optionsinfo);
1145+
}
1146+
}
1147+
#endif
1148+
}
1149+
11241150
void os::print_register_info(outputStream* st, const void* context) {
11251151
int continuation = 0;
11261152
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
@@ -813,6 +813,7 @@ class os: AllStatic {
813813
static void print_summary_info(outputStream* st, char* buf, size_t buflen);
814814
static void print_memory_info(outputStream* st);
815815
static void print_dll_info(outputStream* st);
816+
static void print_jvmti_agent_info(outputStream* st);
816817
static void print_environment_variables(outputStream* st, const char** env_list);
817818
static void print_context(outputStream* st, const void* context);
818819
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
@@ -1207,6 +1207,12 @@ void VMError::report(outputStream* st, bool _verbose) {
12071207
os::print_dll_info(st);
12081208
st->cr();
12091209

1210+
#if INCLUDE_JVMTI
1211+
STEP_IF("printing jvmti agent info", _verbose)
1212+
os::print_jvmti_agent_info(st);
1213+
st->cr();
1214+
#endif
1215+
12101216
STEP_IF("printing native decoder state", _verbose)
12111217
Decoder::print_state_on(st);
12121218
st->cr();
@@ -1385,6 +1391,11 @@ void VMError::print_vm_info(outputStream* st) {
13851391
os::print_dll_info(st);
13861392
st->cr();
13871393

1394+
#if INCLUDE_JVMTI
1395+
os::print_jvmti_agent_info(st);
1396+
st->cr();
1397+
#endif
1398+
13881399
// STEP("printing VM options")
13891400

13901401
// VM options

0 commit comments

Comments
 (0)