mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[225996] Sort the output of -thread-list-ids must sort strings as integers, to make sure a thread with id "10" will follow thread "9" and not thread "1"
This commit is contained in:
parent
1908d66ca6
commit
dc066c0195
1 changed files with 23 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.dsf.mi.service.command.output;
|
package org.eclipse.cdt.dsf.mi.service.command.output;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GDB/MI thread list parsing.
|
* GDB/MI thread list parsing.
|
||||||
|
@ -50,7 +51,28 @@ public class MIThreadListIdsInfo extends MIInfo {
|
||||||
if (strThreadIds == null) {
|
if (strThreadIds == null) {
|
||||||
parse();
|
parse();
|
||||||
// Make sure the threads are in order for the debug view
|
// Make sure the threads are in order for the debug view
|
||||||
Arrays.sort(strThreadIds);
|
// We need our own comparator to treat these strings as integers.
|
||||||
|
Arrays.sort(strThreadIds,
|
||||||
|
new Comparator<String>() {
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
int threadInt1;
|
||||||
|
int threadInt2;
|
||||||
|
|
||||||
|
try {
|
||||||
|
threadInt1 = Integer.parseInt(o1);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
threadInt2 = Integer.parseInt(o2);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return threadInt1 - threadInt2;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return strThreadIds;
|
return strThreadIds;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue