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

Print string contents for "this" references #20933

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

h3110n3rv3
Copy link
Contributor

The changes reflect the feature request #20878.

Print string contents for this references.
Also, print address for string arguments and returns.

Closes: #20878
Signed-off-by: Nick Kamal <[email protected]>

@h3110n3rv3
Copy link
Contributor Author

@TobiAjila Could you please take a look?
Does this need to be done for compiled and native methods as well?

@h3110n3rv3 h3110n3rv3 force-pushed the print-string-improvements branch 2 times, most recently from 34fd8b7 to ca5dd4d Compare January 17, 2025 19:25
@h3110n3rv3 h3110n3rv3 changed the title WIP: Print string contents for "this" references Print string contents for "this" references Jan 17, 2025
runtime/rastrace/mt.tdf Outdated Show resolved Hide resolved
@tajila
Copy link
Contributor

tajila commented Jan 21, 2025

@keithc-ca Please review these changes

Comment on lines 231 to 235
sprintf(outputString, "(String)<Memory allocation error>");
} else if (utf8Length > maxStringLength) {
sprintf(outputString, "(String)\"%.*s\"...", (U_32)maxStringLength, utf8String);
} else {
sprintf(outputString, "(String)\"%.*s\"", (U_32)utf8Length, utf8String);
Copy link
Contributor

Choose a reason for hiding this comment

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

These should include @%p - like lines 536-540.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 237 takes the receiver as an argument to print the address, that's why it's not added here.
Would you like me to change the format to do this way instead?

runtime/rastrace/method_trace.c Outdated Show resolved Hide resolved
runtime/rastrace/mt.tdf Outdated Show resolved Hide resolved
@h3110n3rv3 h3110n3rv3 requested a review from dsouzai as a code owner January 23, 2025 23:24
@h3110n3rv3 h3110n3rv3 force-pushed the print-string-improvements branch 4 times, most recently from fa774b7 to 6d6bb46 Compare January 24, 2025 00:13
The changes reflect the feature request eclipse-openj9#20878.

Print string contents for this references.
Also, print address for string arguments and returns.

Closes: eclipse-openj9#20878
Signed-off-by: Nick Kamal <[email protected]>
@h3110n3rv3 h3110n3rv3 force-pushed the print-string-improvements branch from 26dfab8 to ff2e56f Compare January 24, 2025 00:42
@h3110n3rv3 h3110n3rv3 requested a review from keithc-ca January 24, 2025 00:46
TraceEntry=Trc_MethodEntry Overhead=1 Level=5 Group=bytecodeMethods Template="%.*s.%.*s%.*s bytecode method, this = 0x%zx"
TraceEntry=Trc_MethodEntry Obsolete Overhead=1 Level=5 Group=bytecodeMethods Template="%.*s.%.*s%.*s bytecode method, this = 0x%zx,"

TraceEntry=Trc_MethodEntry Overhead=1 Level=5 Group=bytecodeMethods Template="%.*s.%.*s%.*s bytecode method, this = 0x%zx %.*s"
Copy link
Contributor

Choose a reason for hiding this comment

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

New tracepoints must be added at the end of files like this (and there's no need to change the template of one that is being obsoleted). See https://github.com/eclipse-openj9/openj9/blob/master/doc/diagnostics/AddingTracepoints.md.

@@ -200,12 +200,48 @@ traceMethodEnter(J9VMThread *thr, J9Method *method, void *receiverAddress, UDATA
if (modifiers & J9AccNative) {
Trc_MethodEntryN(thr, J9UTF8_LENGTH(className), J9UTF8_DATA(className), J9UTF8_LENGTH(methodName), J9UTF8_DATA(methodName), J9UTF8_LENGTH(methodSignature), J9UTF8_DATA(methodSignature), receiver);
} else {
Trc_MethodEntry(thr, J9UTF8_LENGTH(className), J9UTF8_DATA(className), J9UTF8_LENGTH(methodName), J9UTF8_DATA(methodName), J9UTF8_LENGTH(methodSignature), J9UTF8_DATA(methodSignature), receiver);
Trc_MethodEntry(thr, J9UTF8_LENGTH(className), J9UTF8_DATA(className), J9UTF8_LENGTH(methodName), J9UTF8_DATA(methodName), J9UTF8_LENGTH(methodSignature), J9UTF8_DATA(methodSignature), receiver, 0, "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just one space after each comma, please.

@@ -479,7 +515,7 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length)
const unsigned int maxStringLength = RAS_GLOBAL_FROM_JAVAVM(maxStringLength, vm);

if (clazz == J9VMJAVALANGSTRING_OR_NULL(vm)
&& (0 != maxStringLength)
&& (0 != maxStringLength)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't add a leading space here.

sprintf(outputString, "- (String)\"%.*s\"", (U_32)utf8Length, utf8String);
}

Trc_MethodEntry(thr, J9UTF8_LENGTH(className), J9UTF8_DATA(className), J9UTF8_LENGTH(methodName), J9UTF8_DATA(methodName), J9UTF8_LENGTH(methodSignature), J9UTF8_DATA(methodSignature), receiver, J9UTF8_LENGTH(outputString), outputString);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just one space after each comma, please.

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.

Improvements for Xtrace String printing feature
3 participants