From 4c8aa90cffa28e69d54bc9a7d2d8047cb4e7c004 Mon Sep 17 00:00:00 2001
From: Benshuai5D <benshuai5d@163.com>
Date: Mon, 11 May 2026 11:48:49 +0800
Subject: [PATCH 06/26] AbortVMOnException option support matching multiple
exception
src/hotspot/share/utilities/exceptions.cpp | 50 +++++++++++++++++++---
1 file changed, 43 insertions(+), 7 deletions(-)
@@ -538,16 +538,52 @@ ExceptionMark::~ExceptionMark() {
// caller frees value_string if necessary
void Exceptions::debug_check_abort(const char *value_string, const char* message) {
- if (AbortVMOnException != nullptr && value_string != nullptr &&
- strstr(AbortVMOnException, value_string)) {
- if (AbortVMOnExceptionMessage == nullptr || (message != nullptr &&
- strstr(message, AbortVMOnExceptionMessage))) {
- if (message == nullptr) {
- fatal("Saw %s, aborting", value_string);
+ if (value_string == nullptr || AbortVMOnException == nullptr) {
+ return;
+ }
+
+ bool should_abort = false;
+
+ // Check if contains commas to determine matching mode
+ if (strchr(AbortVMOnException, ',') != nullptr) {
+ // Multi-exception mode: exact matching
+ const char* start = AbortVMOnException;
+ const char* end;
+
+ while (*start) {
+ end = strchr(start, ',');
+ if (end == nullptr) {
+ end = start + strlen(start);
+ }
+ size_t len = end - start;
+
+ // Remove trailing spaces
+ while (len > 0 && start[len - 1] == ' ') { len--; }
+
+ // Exact match
+ if (len == strlen(value_string) && strncmp(start, value_string, len) == 0) {
+ should_abort = true;
+ break;
+ }
+
+ if (*end == ',') {
+ start = end + 1;
} else {
- fatal("Saw %s: %s, aborting", value_string, message);
+ break;
}
}
+ } else {
+ // Single exception mode: keep original logic
+ should_abort = (strstr(value_string, AbortVMOnException) != nullptr);
+ }
+
+ if (should_abort && (AbortVMOnExceptionMessage == nullptr ||
+ (message != nullptr && strstr(message, AbortVMOnExceptionMessage)))) {
+ if (message == nullptr) {
+ fatal("Saw %s, aborting", value_string);
+ } else {
+ fatal("Saw %s: %s, aborting", value_string, message);
+ }
}
}
--
2.17.1