Skip to content

Commit c97dfda

Browse files
authored
Merge pull request #1497 from Sreekala-Gopakumar/1466XtraceMaxStr
Add documentation for -Xtrace:maxstringlength option
2 parents 1e57d25 + 9b08104 commit c97dfda

File tree

2 files changed

+69
-22
lines changed

2 files changed

+69
-22
lines changed

docs/version0.50.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
The following new features and notable changes since version 0.49.0 are included in this release:
2727

2828
- [New binaries and changes to supported environments](#binaries-and-supported-environments)
29+
- [New parameter `maxstringlength` added to the `-Xtrace` option](#new-parameter-maxstringlength-added-to-the-xtrace-option)
2930
- ![Start of content that applies to Java 24 and later](cr/java24plus.png) [New JDK 24 features](#new-jdk-24-features) ![End of content that applies to Java 24 and later](cr/java_close.png)
3031

3132
## Features and changes
@@ -38,7 +39,13 @@ OpenJDK 24 with Eclipse OpenJ9 is *not* a long term support (LTS) release.
3839

3940
To learn more about support for OpenJ9 releases, including OpenJDK levels and platform support, see [Supported environments](openj9_support.md).
4041

41-
### ### ![Start of content that applies to Java 24 and later](cr/java24plus.png) New JDK 24 features
42+
### New parameter `maxstringlength` added to the `-Xtrace` option
43+
44+
You can use the `maxstringlength` parameter of the `-Xtrace` option to specify the length of the string arguments and return values of a method that are now printed in a trace output in addition to the addresses.
45+
46+
For more information, see [`maxstringlength`](xtrace.md#maxstringlength).
47+
48+
### ![Start of content that applies to Java 24 and later](cr/java24plus.png) New JDK 24 features
4249

4350
The following features are supported by OpenJ9:
4451

docs/xtrace.md

+61-21
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,19 @@ The following parameters can be used to configure trace. (Follow links for more
5858

5959
| Command | Result |
6060
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
61-
| [`-Xtrace:properties[=<filename>]`](#properties) | Configures trace options based on a file |
62-
| [`-Xtrace:buffers=<size>[dynamic\|nodynamic]`](#buffers) | Modifies the size of buffers that are used to store trace data |
63-
| [`-Xtrace:exception.output=<filename>[,<size>]`](#exceptionoutput) | Redirects exceptions trace data to a file. |
64-
| [`-Xtrace:methods=<method_specification>`](#methods) | Traces methods |
65-
| [`-Xtrace:output=<filename>[,<size>[,<generations>]]`](#output) | Sends trace data to a file, optionally of a specific size and number of generations. |
66-
| [`-Xtrace:resume`](#resume) | Resumes tracing globally. |
67-
| [`-Xtrace:resumecount=<count>`](#resumecount) | Enables tracing at a thread level after a specified count. |
68-
| [`-Xtrace:sleeptime=<time>`](#sleeptime) | Pauses trace operations for a specified length of time. |
69-
| [`-Xtrace:stackdepth=<n>`](#stackdepth) | Limits the maximum number of stack frames reported by the jstacktrace trace trigger action. |
70-
| [`-Xtrace:suspend`](#suspend) | Suspends tracing globally. |
71-
| [`-Xtrace:suspendcount=<count>`](#suspendcount) | Suspends tracing at a thread level after a specified count. |
72-
| [`-Xtrace:trigger=<clause>`](#trigger) | Determines when various triggered trace actions occur, including turning trace on or off. |
61+
| [`-Xtrace:buffers=<size>[dynamic\|nodynamic]`](#buffers) | Modifies the size of buffers that are used to store trace data |
62+
| [`-Xtrace:exception.output=<filename>[,<size>]`](#exceptionoutput) | Redirects exceptions trace data to a file |
63+
| [`-Xtrace:maxstringlength=[<length>]`](#maxstringlength) | Specifies the length of the string arguments and the return values of the methods that are printed in addition to the string object addresses in a trace output |
64+
| [`-Xtrace:methods=<method_specification>`](#methods) | Traces methods |
65+
| [`-Xtrace:output=<filename>[,<size>[,<generations>]]`](#output) | Sends trace data to a file, optionally of a specific size and number of generations |
66+
| [`-Xtrace:properties[=<filename>]`](#properties) | Configures trace options based on a file |
67+
| [`-Xtrace:resume`](#resume) | Resumes tracing globally |
68+
| [`-Xtrace:resumecount=<count>`](#resumecount) | Enables tracing at a thread level after a specified count |
69+
| [`-Xtrace:sleeptime=<time>`](#sleeptime) | Pauses trace operations for a specified length of time |
70+
| [`-Xtrace:stackdepth=<n>`](#stackdepth) | Limits the maximum number of stack frames reported by the jstacktrace trace trigger action |
71+
| [`-Xtrace:suspend`](#suspend) | Suspends tracing globally |
72+
| [`-Xtrace:suspendcount=<count>`](#suspendcount) | Suspends tracing at a thread level after a specified count |
73+
| [`-Xtrace:trigger=<clause>`](#trigger) | Determines when various triggered trace actions occur, including turning trace on or off |
7374

7475
:fontawesome-solid-pencil:{: .note aria-hidden="true"} **Note:** If an option value contains commas, it must be enclosed in braces. For example: `methods={java/lang/*,com/ibm/*}`
7576

@@ -79,14 +80,14 @@ The following parameters can be used to control tracepoint activation. (Follow l
7980

8081
| Command | Result |
8182
|--------------------------------------------------------------------|-------------------------------------------------------------------------------------|
82-
| [`-Xtrace:maximal=<tracepoint_specification>`](#maximal-tracepoint) | Records all associated data. |
83-
| [`-Xtrace:minimal=<tracepoint_specification>`](#minimal-tracepoint) | Records only the time stamp and tracepoint identifier. |
84-
| [`-Xtrace:count=<tracepoint_specification>`](#count-tracepoint) | Counts the tracepoints that are used in a trace configuration. |
85-
| [`-Xtrace:print=<tracepoint_specification>`](#print-tracepoint) | Prints the specified tracepoints to stderr in real time. |
86-
| [`-Xtrace:iprint=<tracepoint_specification>`](#iprint-tracepoint) | Prints the specified tracepoints to stderr in real time with indentation. |
87-
| [`-Xtrace:exception=<tracepoint_specification>`](#exception-tracepoint) | Enables exception tracing. |
88-
| [`-Xtrace:external<tracepoint_specification>`](#external-tracepoint) | Routes trace data to trace listeners, which are registered by using the JVMTI APIs. |
89-
| [`-Xtrace:none[=<tracepoint_specification>]`](#none-tracepoint) | Prevents the trace engine from loading if it is the only trace option specified. |
83+
| [`-Xtrace:count=<tracepoint_specification>`](#count-tracepoint) | Counts the tracepoints that are used in a trace configuration |
84+
| [`-Xtrace:exception=<tracepoint_specification>`](#exception-tracepoint) | Enables exception tracing |
85+
| [`-Xtrace:external<tracepoint_specification>`](#external-tracepoint) | Routes trace data to trace listeners, which are registered by using the JVMTI APIs |
86+
| [`-Xtrace:iprint=<tracepoint_specification>`](#iprint-tracepoint) | Prints the specified tracepoints to stderr in real time with indentation |
87+
| [`-Xtrace:maximal=<tracepoint_specification>`](#maximal-tracepoint) | Records all associated data |
88+
| [`-Xtrace:minimal=<tracepoint_specification>`](#minimal-tracepoint) | Records only the time stamp and tracepoint identifier |
89+
| [`-Xtrace:none[=<tracepoint_specification>]`](#none-tracepoint) | Prevents the trace engine from loading if it is the only trace option specified |
90+
| [`-Xtrace:print=<tracepoint_specification>`](#print-tracepoint) | Prints the specified tracepoints to stderr in real time |
9091

9192
:fontawesome-solid-pencil:{: .note aria-hidden="true"} **Note:** These options control which individual tracepoints are activated at run time and the implicit destination of the trace data. All these properties are independent of each other and can be mixed and matched in any way that you choose. For more information, see [Tracepoint activation](#tracepoint-activation).
9293

@@ -478,7 +479,7 @@ This form of tracing is channeled through a single set of buffers, as opposed to
478479

479480
### `exception.output`
480481

481-
Use exception output to redirect exceptions trace data to a file.
482+
Use `exception.output` to redirect exceptions trace data to a file.
482483

483484
-Xtrace:exception.output=<filename>[,<size>]
484485

@@ -543,6 +544,45 @@ When specified, trace data is placed into internal trace buffers that can then b
543544

544545
`minimal` and `maximal` traces are independent from any types that follow them. For example, if the `maximal` option is specified, it does not affect a later option such as `print`.
545546

547+
### `maxstringlength`
548+
549+
(**Added in the 0.50.0 release**)
550+
551+
-Xtrace:maxstringlength=[<length>]
552+
553+
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.
554+
555+
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.
556+
557+
#### Examples
558+
559+
Default behavior - Address and 32 string characters
560+
561+
`-Xtrace:methods={java/lang/String.concat'()'},print=mt`
562+
563+
```
564+
12:31:00.323 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: ((String)"Lorem ipsum dolor sit amet, cons"...)
565+
12:31:00.323 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92A80 - (String)"HelloLorem ipsum dolor sit amet,"...
566+
```
567+
568+
`maxstringlength` set to `0` - Address only
569+
570+
`-Xtrace:methods={java/lang/String.concat'()'},print=mt,maxstringlength=0`
571+
572+
```
573+
12:35:58.213 0x25a00 mt.18 - this: java/lang/String@00000006049B84B8 method arguments: (java/lang/String@00000006049B84E0)
574+
12:35:58.213 0x25a00 mt.28 - return value: java/lang/String@00000007FFF92AD8
575+
```
576+
577+
`maxstringlength` set to a custom value - Address and custom number of string characters (`80` in this example)
578+
579+
`-Xtrace:methods={java/lang/String.concat'()'},print=mt,maxstringlength=80`
580+
581+
```
582+
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 "...)
583+
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"...
584+
```
585+
546586
### `methods`
547587

548588
Using method trace provides a complete and potentially large diagnosis of code paths inside your application and the system classes. Use wild cards and filtering to control method trace so that you can focus on the sections of code that interest you. Note that method trace is powerful but it also has a cost. Application throughput is affected by method trace.

0 commit comments

Comments
 (0)