Skip to content

Commit 112bcb7

Browse files
committed
Accommodate MinGW GDB thread IDs
1 parent ffe4ab0 commit 112bcb7

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.tests;singleton:=true
55
Bundle-Vendor: %providerName
6-
Bundle-Version: 1.0.0.qualifier
6+
Bundle-Version: 1.0.100.qualifier
77
Fragment-Host: org.eclipse.cdt.dsf.gdb
88
Bundle-RequiredExecutionEnvironment: JavaSE-17
99
Require-Bundle: org.junit;bundle-version="[4.13.2,5)"

dsf-gdb/org.eclipse.cdt.dsf.gdb.tests/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThreadTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2014 Freescale and others.
2+
* Copyright (c) 2011, 2026 Freescale and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
1111
* Contributors:
1212
* Freescale - Initial API and Implementation
1313
* Alvaro Sanchez-Leon (Ericsson) - Moved from cdt.tests.dsf.gdb (Bug 437562)
14+
* John Dallaway - Accommodate decimal parent ID with hex OS ID (#1421)
1415
*******************************************************************************/
1516
package org.eclipse.cdt.dsf.mi.service.command.output;
1617

@@ -23,6 +24,7 @@ public class MIThreadTests {
2324
public void testOsIdParsing() {
2425
assertEquals("7010", MIThread.parseOsId("Thread 0xb7c8ab90 (LWP 7010)"));
2526
assertEquals("32942", MIThread.parseOsId("Thread 162.32942"));
27+
assertEquals("0x80ae", MIThread.parseOsId("Thread 162.0x80ae")); // for MinGW gdb
2628
assertEquals("abc123", MIThread.parseOsId("Thread abc123"));
2729
assertEquals("abc123", MIThread.parseOsId("thread abc123"));
2830
assertEquals("abc123", MIThread.parseOsId("THREAD abc123"));
@@ -32,5 +34,6 @@ public void testOsIdParsing() {
3234
@Test
3335
public void testParentIdParsing() {
3436
assertEquals("162", MIThread.parseParentId("Thread 162.32942"));
37+
assertEquals("162", MIThread.parseParentId("Thread 162.0x80ae")); // for MinGW gdb
3538
}
3639
}

dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThread.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2008, 2014 Ericsson and others.
2+
* Copyright (c) 2008, 2026 Ericsson and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,6 +15,7 @@
1515
* Xavier Raynaud (Kalray) - MIThread can be overridden (Bug 429124)
1616
* Alvaro Sanchez-Leon - Bug 451396 - Improve extensibility to process MI "-thread-info" results
1717
* Simon Marchi (Ericsson) - Bug 378154 - Have MIThread provide thread name
18+
* John Dallaway - Accommodate decimal parent ID with hex OS ID (#1421)
1819
*******************************************************************************/
1920
package org.eclipse.cdt.dsf.mi.service.command.output;
2021

@@ -166,7 +167,8 @@ public static MIThread parse(MITuple tuple) {
166167
// Note that windows gdbs returns lower case "thread" , so the matcher needs to be case-insensitive.
167168
private static Pattern fgOsIdPattern1 = Pattern
168169
.compile("([Tt][Hh][Rr][Ee][Aa][Dd]\\s*)(0x[0-9a-fA-F]+|-?\\d+)(\\s*\\([Ll][Ww][Pp]\\s*)(\\d*)", 0); //$NON-NLS-1$
169-
private static Pattern fgOsIdPattern2 = Pattern.compile("[Tt][Hh][Rr][Ee][Aa][Dd]\\s*\\d+\\.(\\d+)", 0); //$NON-NLS-1$
170+
private static Pattern fgOsIdPattern2 = Pattern.compile("[Tt][Hh][Rr][Ee][Aa][Dd]\\s*\\d+\\.(0x[0-9a-fA-F]+|\\d+)", //$NON-NLS-1$
171+
0);
170172
private static Pattern fgOsIdPattern3 = Pattern.compile("[Tt][Hh][Rr][Ee][Aa][Dd]\\s*(\\S+)", 0); //$NON-NLS-1$
171173
private static Pattern fgOsIdPattern4 = Pattern.compile("[Pp][Rr][Oo][Cc][Ee][Ss][Ss]\\s*(\\S+)", 0); //$NON-NLS-1$
172174

@@ -177,7 +179,7 @@ protected static String parseOsId(String str) {
177179
// General format:
178180
// "Thread 0xb7c8ab90 (LWP 7010)"
179181
// ^^^^
180-
// "Thread 162.32942"
182+
// "Thread 162.32942" => an integer in decimal or 0x hex notation
181183
// ^^^^^
182184
// "thread abc123"
183185
//
@@ -208,7 +210,8 @@ protected static String parseOsId(String str) {
208210
return null;
209211
}
210212

211-
private static Pattern fgIdPattern = Pattern.compile("[Tt][Hh][Rr][Ee][Aa][Dd]\\s*(\\d+)\\.\\d+", 0); //$NON-NLS-1$
213+
private static Pattern fgIdPattern = Pattern.compile("[Tt][Hh][Rr][Ee][Aa][Dd]\\s*(\\d+)\\.(0x[0-9a-fA-F]+|\\d+)", //$NON-NLS-1$
214+
0);
212215

213216
/**
214217
* This is used to parse the same ID fed to {@link #parseOsId(String)}. The

0 commit comments

Comments
 (0)