Skip to content

Commit

Permalink
Add Exception message to Xdump stack agent output
Browse files Browse the repository at this point in the history
When Xdump:stack is used to dump stack trace filtered on an exception,
this change along with the primary exception message, displays
additional detail about the exception if any. This is similar to how
javacore displays additional detail about an exception in 1TISIGINFO
tag.

Fixes: eclipse-openj9#8435
Signed-off-by: Kabir Islam <kaislam1@in.ibm.com>
  • Loading branch information
imkabir committed Sep 8, 2022
1 parent 1d9d168 commit 97db7d3
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion runtime/rasdump/trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,12 @@ omr_error_t
triggerDumpAgents(struct J9JavaVM *vm, struct J9VMThread *self, UDATA eventFlags, struct J9RASdumpEventData *eventData)
{
J9RASdumpQueue *queue;
j9object_t emessage = NULL;
char stackBuffer[256];
char* buf = stackBuffer;
UDATA len = 0;
char* subDetailedMessage = NULL;
UDATA subLength = 0;

/* we lock the dump configuration here so that the agent and setting queues can't be
* changed underneath us while we're producing the dumps
Expand Down Expand Up @@ -1004,7 +1010,32 @@ triggerDumpAgents(struct J9JavaVM *vm, struct J9VMThread *self, UDATA eventFlags
OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);
char dateStamp[64];
omrstr_ftime_ex(dateStamp, sizeof(dateStamp), "%Y/%m/%d %H:%M:%S", now, OMRSTR_FTIME_FLAG_LOCAL);
j9nls_printf(PORTLIB, J9NLS_INFO | J9NLS_STDERR | J9NLS_VITAL, J9NLS_DMP_PROCESSING_EVENT_TIME, mapDumpEvent(eventFlags), detailLength, detailData, dateStamp);

/*If there is more details about the event, print it.
* During abort event detailData is empty string - skip the abort event */
if (strcmp (detailData,"") && eventData->exceptionRef && *eventData->exceptionRef) {
emessage = J9VMJAVALANGTHROWABLE_DETAILMESSAGE(self, *eventData->exceptionRef);
if (NULL != emessage) {
subLength = strlen (detailData) + strlen ("\" \"");
subDetailedMessage = (char *)j9mem_allocate_memory(subLength+1, OMRMEM_CATEGORY_VM);
strcpy (subDetailedMessage, detailData);
strcat (subDetailedMessage,"\" \"");
buf = self->javaVM->internalVMFunctions->copyStringToUTF8WithMemAlloc(self, emessage, J9_STR_NULL_TERMINATE_RESULT, subDetailedMessage, subLength, stackBuffer, 256, &len);
if (NULL != buf) {
j9nls_printf(PORTLIB, J9NLS_INFO | J9NLS_STDERR | J9NLS_VITAL, J9NLS_DMP_PROCESSING_EVENT_TIME, mapDumpEvent(eventFlags), strlen (buf), buf, dateStamp);
}
}
if (buf != stackBuffer) {
j9mem_free_memory(buf);
}
if (NULL != subDetailedMessage) {
j9mem_free_memory(subDetailedMessage);
}
}
else {
j9nls_printf(PORTLIB, J9NLS_INFO | J9NLS_STDERR | J9NLS_VITAL, J9NLS_DMP_PROCESSING_EVENT_TIME, mapDumpEvent(eventFlags), detailLength, detailData, dateStamp);
}

printed = 1;
}
}
Expand Down

0 comments on commit 97db7d3

Please sign in to comment.