Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for -Xtrace:maxstringlength option #1497

Merged

Conversation

Sreekala-Gopakumar
Copy link
Contributor

#1466

Added the new parameter, maxstringlength.

Closes #1466
Signed-off-by: Sreekala Gopakumar [email protected]

@Sreekala-Gopakumar
Copy link
Contributor Author

Jenkins doc stage

@Sreekala-Gopakumar
Copy link
Contributor Author

Sreekala-Gopakumar commented Mar 20, 2025

@h3110n3rv3 @pshipton - I have updated the topics. Please check and confirm that the information is correct. Could you please especially check the following:

Thanks!

@pshipton
Copy link
Member

@h3110n3rv3 Pls do the initial review.

Can this be added as a new feature in the 0.50.0 release section

Yes

@Sreekala-Gopakumar
Copy link
Contributor Author

@h3110n3rv3 @pshipton - I have updated the topics. Please check and confirm that the information is correct. Could you please especially check the following:

Thanks!

@h3110n3rv3 - Could you please review and let me know if any changes are required. Thanks!

@h3110n3rv3
Copy link

h3110n3rv3 commented Mar 27, 2025

@Sreekala-Gopakumar Sorry if I wasn't clear in my previous comment.
The default now is address + 32 characters of string (i.e., if maxstringlength is not provided) - before this feature, it used to be only address printing with no way to print actual strings. This only affects tracing where addresses were printed for string arguments/return values.
maxstringlength provides a way for printing custom length of string arguments/return values.
examples:
Default behavior now:
-Xtrace:methods={java/lang/String.concat'()'},print=mt --> address + 32 string characters
12:31:00.323 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: ((String)"Lorem ipsum dolor sit amet, cons"...)
12:31:00.323 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92A80 - (String)"HelloLorem ipsum dolor sit amet,"...

maxstringlength set to 0:
-Xtrace:methods={java/lang/String.concat'()'},print=mt,maxstringlength=0 --> address only
12:35:58.213 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: (java/lang/String@00000006049B84E0)
12:35:58.213 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92AD8

maxstringlength set to custom value (max 128):
-Xtrace:methods={java/lang/String.concat'()'},print=mt,maxstringlength=80 --> prints address + 80 string characters
12:37:52.935 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: ((String)"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula "...)
12:37:52.935 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92AE0 - (String)"HelloLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo li"...

@Sreekala-Gopakumar Sreekala-Gopakumar force-pushed the 1466XtraceMaxStr branch 2 times, most recently from 186ef85 to 9dbfac9 Compare March 27, 2025 17:48
@Sreekala-Gopakumar
Copy link
Contributor Author

Jenkins doc stage

@Sreekala-Gopakumar
Copy link
Contributor Author

@h3110n3rv3 @pshipton - I have made the changes. Please check and let me know if any further changes are required. Thanks!

@h3110n3rv3
Copy link

@Sreekala-Gopakumar Most of it looks good.
Just a minor suggestion: I think we should specify that maxstringlength is to print string argument/return values of custom length since, now, by default string+addresses are printed.
You can use the maxstringlength parameter of the -Xtrace option to specify the custom length of string arguments being passed, as well as the values returned from the methods, to be printed along with the addresses in a trace output.

@Sreekala-Gopakumar
Copy link
Contributor Author

Jenkins doc stage

@Sreekala-Gopakumar
Copy link
Contributor Author

Jenkins doc stage

@Sreekala-Gopakumar
Copy link
Contributor Author

@h3110n3rv3 @pshipton - Please check and confirm. Thanks!

Use to print the string arguments sent to and the values that are returned from the methods as strings instead of addresses in a trace output. The range of the maximum string length that can be set is 0-128. If the length is not specified, 32 characters of the strings are printed by default. If `maxstringlength=0`, the string addresses are printed instead.

This parameter is used with other method tracing options, such as `-Xtrace:methods={java/lang/String.concat'()'}`. While using such method tracing options, the argument is passed to this function as a string and the value is returned as a string. Without this parameter, you cannot capture the contents of the string arguments and return values. Only the address of the string object is displayed. If you want to see the string that is passed to and returned from a method for debugging purposes, use the `maxstringlength` parameter.

Choose a reason for hiding this comment

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

@Sreekala-Gopakumar Sorry if I wasn't clear in my previous comment.
The default now is address + 32 characters of string (i.e., if maxstringlength is not provided) - before this feature, it used to be only address printing with no way to print actual strings. This only affects tracing where addresses were printed for string arguments/return values.
maxstringlength provides a way for printing custom length of string arguments/return values.
examples:
Default behavior now:
-Xtrace:methods={java/lang/String.concat'()'},print=mt --> address + 32 string characters
12:31:00.323 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: ((String)"Lorem ipsum dolor sit amet, cons"...)
12:31:00.323 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92A80 - (String)"HelloLorem ipsum dolor sit amet,"...

maxstringlength set to 0:
-Xtrace:methods={java/lang/String.concat'()'},print=mt,maxstringlength=0 --> address only
12:35:58.213 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: (java/lang/String@00000006049B84E0)
12:35:58.213 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92AD8

maxstringlength set to custom value (max 128):
-Xtrace:methods={java/lang/String.concat'()'},print=mt,maxstringlength=80 --> prints address + 80 string characters
12:37:52.935 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: ((String)"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula "...)
12:37:52.935 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92AE0 - (String)"HelloLorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo li"...

Choose a reason for hiding this comment

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

@Sreekala-Gopakumar
Copy link
Contributor Author

@pshipton - Can this be merged? Thanks!

docs/xtrace.md Outdated
| [`-Xtrace:trigger=<clause>`](#trigger) | Determines when various triggered trace actions occur, including turning trace on or off. |
| [`-Xtrace:buffers=<size>[dynamic\|nodynamic]`](#buffers) | Modifies the size of buffers that are used to store trace data |
| [`-Xtrace:exception.output=<filename>[,<size>]`](#exceptionoutput) | Redirects exceptions trace data to a file |
| [`-Xtrace:maxstringlength=[<length>]`](#maxstringlength) | Specifies the length of the string arguments and the values of the methods that are printed in addition to the string object addresses in a trace output |
Copy link
Member

Choose a reason for hiding this comment

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

return values

docs/xtrace.md Outdated

Use to specify the length of the string arguments and return values that are printed in a trace output. The range of the maximum string length that can be set is 0-128. If the length is not specified, 32 characters of the strings are printed by default along with the addresses. If `maxstringlength=0`, only the string addresses are printed instead.

This parameter is used with other method tracing options, such as `-Xtrace:methods={java/lang/String.concat'()'}` and affects only those tracing operations where addresses are printed for string arguments and return values. When using such method tracing options, the argument is passed to the function as a string and the value is returned as a string. Earlier, you could not capture the contents of the string arguments and return values. Only the address of the string object was printed. Now, both the actual strings as well as the addresses can be printed.
Copy link
Member

Choose a reason for hiding this comment

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

should it be "and return values, only the address" using a comma instead of period?

eclipse-openj9#1466

Added the new parameter, `maxstringlength`. Incorporated review feedback.

Closes eclipse-openj9#1466
Signed-off-by: Sreekala Gopakumar [email protected]
@Sreekala-Gopakumar
Copy link
Contributor Author

Jenkins doc stage

@Sreekala-Gopakumar
Copy link
Contributor Author

@pshipton - Incorporated the suggested changes. Thanks!

@pshipton pshipton merged commit c97dfda into eclipse-openj9:master Apr 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add documentation for -Xtrace:maxstringlength option
3 participants