Skip to content

8346082: Output JVMTI agent information in hserr files#22706

Closed
MBaesken wants to merge 6 commits intoopenjdk:masterfrom
MBaesken:JDK-8346082
Closed

8346082: Output JVMTI agent information in hserr files#22706
MBaesken wants to merge 6 commits intoopenjdk:masterfrom
MBaesken:JDK-8346082

Conversation

@MBaesken
Copy link
Member

@MBaesken MBaesken commented Dec 12, 2024

We should output more information about the JVMTI agents in the hserr file.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8346082: Output JVMTI agent information in hserr files (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22706/head:pull/22706
$ git checkout pull/22706

Update a local copy of the PR:
$ git checkout pull/22706
$ git pull https://git.openjdk.org/jdk.git pull/22706/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22706

View PR using the GUI difftool:
$ git pr show -t 22706

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22706.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 12, 2024

👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 12, 2024

@MBaesken This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8346082: Output JVMTI agent information in hserr files

Reviewed-by: mdoerr, dholmes, stuefe

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 39 new commits pushed to the master branch:

  • 45a3297: 8346248: serviceability/dcmd/vm/{SystemMapTest.java,SystemMapTest.java} failing on macos-aarch64
  • dbffe33: 8345263: Make sure that lint categories are used correctly when logging lint warnings
  • 32c8195: 8345801: C2: Clean up include statements to speed up compilation when touching type.hpp
  • 9286018: 8345322: RISC-V: Add concurrent gtests for cmpxchg variants
  • 4fc43b0: 8345770: javadoc: API documentation builds are not always reproducible
  • ee1c5ad: 8345975: Update SAP SE copyright year to 2024 where it was missed
  • 3518b4b: 8344171: Clone and initialize Assertion Predicates in order instead of in reverse-order
  • c88e081: 8346160: Fix -Wzero-as-null-pointer-constant warnings from explicit casts
  • ab1dbd4: 8346202: Correct typo in SQLPermission
  • 6b022bb: 8344453: Test jdk/jfr/event/oldobject/TestSanityDefault.java timed out
  • ... and 29 more: https://git.openjdk.org/jdk/compare/3f2556b86079fbdba848b1ac16b62a376386999b...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8346082: Output JVMTI agent information is hserr files 8346082: Output JVMTI agent information is hserr files Dec 12, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 12, 2024
@openjdk
Copy link

openjdk bot commented Dec 12, 2024

@MBaesken The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Dec 12, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 12, 2024

Webrevs

@dholmes-ora
Copy link
Member

/label add sereviceability

@dholmes-ora
Copy link
Member

/label add serviceability

@openjdk
Copy link

openjdk bot commented Dec 12, 2024

@dholmes-ora
The label sereviceability is not a valid label.
These labels are valid:

  • graal
  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Dec 12, 2024
@openjdk
Copy link

openjdk bot commented Dec 12, 2024

@dholmes-ora
The serviceability label was successfully added.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems okay. Someone from serviceability should give their opinion on the content.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 12, 2024
@larry-cable
Copy link
Contributor

I do not understand the use case that this additional information solves for, nor does the bug provide any further enlightenment, I think this ER requires more rationale to motivate its inclusion.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Dec 13, 2024
@MBaesken
Copy link
Member Author

MBaesken commented Dec 13, 2024

I do not understand the use case that this additional information solves for, nor does the bug provide any further enlightenment, I think this ER requires more rationale to motivate its inclusion.

Currently the info about the JVMTI agents in the hserr/hsinfo is not good. You might see them in the so/dll list and maybe command-line output but this is far from ideal. A little separate section gives more clarity.
Bad JVMTI agents (and even good ones) can influence what is going on at runtime so that info should be present.

@MBaesken MBaesken changed the title 8346082: Output JVMTI agent information is hserr files 8346082: Output JVMTI agent information in hserr files Dec 13, 2024
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 13, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Dec 13, 2024
Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice enhancement! Could you add an example output to the description, please?

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, two bikeshedding nits.

I approve now, up to you if you take my suggestions.

Comment on lines +1136 to +1138
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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just print these as flags, its clearer and simpler to print. E.g.

"myagent path:  mylib.so dynamic:1 loaded:1 instrument_lib:0 initialized:1 xxx options xxx"

while (it.has_next()) {
const JvmtiAgent* agent = it.next();
if (agent != nullptr) {
if (first_agent) st->print_cr("JVMTI agents:");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if no agents are loaded, I would print "JVMTI agents: none" unconditionally. Makes it more obvious than just a missing entry; that could be also an error.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 13, 2024
@MBaesken
Copy link
Member Author

Nice enhancement! Could you add an example output to the description, please?

Currently it looks like this

JVMTI agents:
asyncProfiler path:none, loaded, initialized   options:start,flat=10000,interval=50us,traces=1,event=wall,loglevel=none

(example is from a JVM started with async-profiler : images/jdk/bin/java -agentlib:asyncProfiler=start,flat=10000,interval=50us,traces=1,event=wall,loglevel=none .... )

@MBaesken
Copy link
Member Author

if no agents are loaded, I would print "JVMTI agents: none" unconditionally. Makes it more obvious than just a missing entry; >that could be also an error.

Maybe after the while loop something like this ?

  bool first_agent = true;
  while (it.has_next()) {
      ...
  }
  **if (first_agent) st->print_cr("JVMTI agents: none");**

@alexmenkov
Copy link

if no agents are loaded, I would print "JVMTI agents: none" unconditionally. Makes it more obvious than just a missing entry; >that could be also an error.

Maybe after the while loop something like this ?

  bool first_agent = true;
  while (it.has_next()) {
      ...
  }
  **if (first_agent) st->print_cr("JVMTI agents: none");**

You can do it before the loop:

if (it.has_next()) {
  st->print_cr("JVMTI agents:");
} else {
  st->print_cr("JVMTI agents: none");
}

and get rid of first_agent variable

@MBaesken
Copy link
Member Author

When printing 'JVMTI agents: none' , should I maybe better iterate JvmtiAgentList::all() to get the xrun agents as well and be sure that there are really none ?
Unfortunately JvmtiAgentList::all() is private , any objections making it public ? Otherwise we probably need to call 2 iterations (agents() and xrun_agents()).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Dec 16, 2024
Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 16, 2024
@MBaesken
Copy link
Member Author

Hi Martin, David, Thomas, thanks for the reviews !

(should we consider adding the JVMTI agent output to jcmd too as a separate command/option? (but not in this change) )

@mlbridge
Copy link

mlbridge bot commented Dec 16, 2024

Mailing list message from Laurence Cable on serviceability-dev:

again what's the use case?

On 12/16/24 6:35 AM, Matthias Baesken wrote:

@TheRealMDoerr
Copy link
Contributor

again what's the use case?

Assume a customer uses a tool like the async profiler and causes a JVM crash by doing that. A supporter looks at the hs_err file and wonders about what might have happened. Such a hint would be very helpful.

@mlbridge
Copy link

mlbridge bot commented Dec 16, 2024

Mailing list message from Laurence Cable on serviceability-dev:

On 12/16/24 8:45 AM, Martin Doerr wrote:

On Mon, 16 Dec 2024 16:28:29 GMT, Laurence Cable <larry.cable at oracle.com> wrote:

again what's the use case?
Assume a customer uses a tool like the async profiler and causes a JVM crash by doing that. A supporter looks at the hs_err file and wonders about what might have happened. Such a hint would be very helpful.

I was referring to the suggestion that there should be a jcmd to emit
agent info ... I dont see that as useful

@MBaesken
Copy link
Member Author

MBaesken commented Dec 16, 2024

jcmd to emit agent info

Okay, then let's avoid adding it to jcmd; for hserr/hsinfo adding the info is more important.

My idea was that currently we can do 'data dump' and 'load agents' with jcmd

JVMTI.agent_load
JVMTI.data_dump

So for completeness, when you offer loading agents, it might be useful to be able to show the current agents with the same tool jcmd. But on the other hand you are probably correct that this new option might not be used a lot so it is maybe not worth the effort.

@MBaesken
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Dec 16, 2024

Going to push as commit c75b1d4.
Since your change was applied there have been 48 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 16, 2024
@openjdk openjdk bot closed this Dec 16, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 16, 2024
@openjdk
Copy link

openjdk bot commented Dec 16, 2024

@MBaesken Pushed as commit c75b1d4.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@tstuefe
Copy link
Member

tstuefe commented Dec 16, 2024

jcmd to emit agent info

Okay, then let's avoid adding it to jcmd; for hserr/hsinfo adding the info is more important.

My idea was that currently we can do 'data dump' and 'load agents' with jcmd

JVMTI.agent_load
JVMTI.data_dump

So for completeness, when you offer loading agents, it might be useful to be able to show the current agents with the same tool jcmd. But on the other hand you are probably correct that this new option might not be used a lot so it is maybe not worth the effort.

Since we already have VM.info jcmd, which after your patch already shows jvmti info, a separate command would be redundant, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

6 participants