Skip to content

Commit 1ef3092

Browse files
committed
fixed address range parsing
1 parent 2325a53 commit 1ef3092

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

tda/src/main/java/de/grimmfrost/tda/parser/SunJDKParser.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,15 +1046,13 @@ public String[] getThreadTokens(String name) {
10461046
tokens[4] = nidToken;
10471047
}
10481048

1049-
if (strippedToken.indexOf('[') > 0) {
1049+
if (strippedToken.lastIndexOf('[') > strippedToken.indexOf("nid=")) {
10501050
if (strippedToken.indexOf("lwp_id=") > 0) {
1051-
tokens[5] = strippedToken.substring(strippedToken.indexOf(" ", strippedToken.indexOf("lwp_id=")) + 1, strippedToken.indexOf('[',
1052-
strippedToken.indexOf("lwp_id=")) - 1);
1051+
tokens[5] = strippedToken.substring(strippedToken.indexOf(" ", strippedToken.indexOf("lwp_id=")) + 1, strippedToken.lastIndexOf('[') - 1);
10531052
} else {
1054-
tokens[5] = strippedToken.substring(strippedToken.indexOf(" ", strippedToken.indexOf("nid=")) + 1, strippedToken.indexOf('[',
1055-
strippedToken.indexOf("nid=")) - 1);
1053+
tokens[5] = strippedToken.substring(strippedToken.indexOf(" ", strippedToken.indexOf("nid=")) + 1, strippedToken.lastIndexOf('[') - 1);
10561054
}
1057-
tokens[6] = strippedToken.substring(strippedToken.indexOf('['));
1055+
tokens[6] = strippedToken.substring(strippedToken.lastIndexOf('['));
10581056
} else {
10591057
tokens[5] = strippedToken.substring(strippedToken.indexOf(" ", strippedToken.indexOf("nid=")) + 1);
10601058
}

tda/src/main/resources/de/grimmfrost/tda/doc/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ TDA - Thread Dump Analyzer -- Version 2.7
66
Note: This is the 2.7 release of the software, for an usage overview see Help/Overview.
77

88
Changes from 2.6 are:
9+
* Introduced logging for easier debugging in MCP mode, added red dot in UI mode if error
10+
occurred with tooltip to check logfile.
11+
* Fixed address range parsing in thread titles for newer JVMs.
912
* Fixed missing protocolVersion in MCP, which broke the Cursor Integration.
1013
* Experimental support for JSON based jmap thread dumps.
1114
* Support for SMR parsing in thread dumps (Java 11+)

tda/src/test/java/de/grimmfrost/tda/parser/SunJDKParserTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,4 +503,23 @@ public void testLongRunningDetectionWithVariableFields() throws IOException {
503503
}
504504
}
505505
}
506+
@Test
507+
public void testGetThreadTokensWithThreadTypeNumber() {
508+
Map<String, Map<String, String>> threadStore = new HashMap<>();
509+
SunJDKParser parser = new SunJDKParser(new BufferedReader(new StringReader("")), threadStore, 0, false, 0, new DateMatcher());
510+
511+
// Line from carrier_stuck.log
512+
String line = "\"ForkJoinPool-1-worker-1\" #11 daemon [11] prio=5 os_prio=0 cpu=5678.90ms elapsed=58230.14s tid=0x00007f8b2c158000 nid=0x1ac7 runnable [0x00007f8b234f5000]";
513+
514+
String[] tokens = parser.getThreadTokens(line);
515+
516+
// tokens: 0: name, 1: type, 2: prio, 3: tid, 4: nid, 5: state, 6: address
517+
assertEquals("ForkJoinPool-1-worker-1", tokens[0], "Thread Name");
518+
assertEquals("Daemon", tokens[1], "Thread Type");
519+
assertEquals("5", tokens[2], "Priority");
520+
assertEquals(String.valueOf(Long.parseLong("00007f8b2c158000", 16)), tokens[3], "TID");
521+
assertEquals(String.valueOf(Long.parseLong("1ac7", 16)), tokens[4], "NID");
522+
assertEquals("runnable", tokens[5].trim(), "State");
523+
assertEquals("[0x00007f8b234f5000]", tokens[6], "Address Range");
524+
}
506525
}

0 commit comments

Comments
 (0)