mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bugxilla 280607.
This commit is contained in:
parent
35a8ff9f89
commit
5cdc9c1c05
1 changed files with 43 additions and 6 deletions
|
@ -77,19 +77,56 @@ public class CLIInfoThreadsInfo extends MIInfo {
|
|||
}
|
||||
|
||||
protected void parseThreadInfo(String str, List<ThreadInfo> info) {
|
||||
// Fetch the OS ThreadId & Find the current thread
|
||||
if(str.length() > 0 ){
|
||||
Pattern pattern = Pattern.compile("(^\\*?\\s*\\d+)(\\s*Thread\\s*)(0x[0-9a-fA-F]+|-?\\d+)(\\s*\\(LWP\\s*)(\\d*)", Pattern.MULTILINE); //$NON-NLS-1$
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
boolean isCurrentThread = false;
|
||||
// Fetch the OS ThreadId & Find the current thread
|
||||
// Here is an example output from GDB which shows normal threads as well as
|
||||
// LWP process threads
|
||||
//
|
||||
// (gdb) info threads
|
||||
// 7 Thread 0x941c00 (sleeping) 0x0000000806c6d0df in pthread_mutexattr_init () from /usr/lib/libpthread.so.2
|
||||
// 6 Thread 0x953000 (sleeping) 0x0000000806c6d0df in pthread_mutexattr_init () from /usr/lib/libpthread.so.2
|
||||
// 5 Thread 0x953400 (sleeping) 0x0000000806c6d0df in pthread_mutexattr_init () from /usr/lib/libpthread.so.2
|
||||
// 4 Thread 0x953800 (sleeping) 0x0000000806c6d0df in pthread_mutexattr_init () from /usr/lib/libpthread.so.2
|
||||
// * 3 Thread 0x510400 (LWP 100132) 0x0000000806c7489c in pthread_testcancel () from /usr/lib/libpthread.so.2
|
||||
// 2 Thread 0x510000 (runnable) 0x0000000806e468ec in read () from /lib/libc.so.6
|
||||
//
|
||||
// Here is other output which will be handled
|
||||
//
|
||||
// (gdb) info threads
|
||||
// 6 Thread 1286 (tid 38473, running) 0x00000000 in ?? ()
|
||||
// 5 Thread 1029 (tid 34369, running) 0x00000000 in ?? ()
|
||||
// 4 Thread 772 (tid 39483, running) 0xd037eb94 in clock_gettime ()
|
||||
// * 3 Thread 515 (tid 39741, running) 0x00000000 in ?? ()
|
||||
//
|
||||
// It also turns out that GDB for Windows ( at least the one shipped with Wascana ) returns lower
|
||||
// case "thread" , so the code needs to be case-insensitive. Also since the original code wanted
|
||||
// to favor the LWP info, we will leave this in. Only if it does not come up with a match will we
|
||||
// default to the more general algorithm.
|
||||
|
||||
if(str.length() > 0 ){
|
||||
Pattern pattern = Pattern.compile("(^\\*?\\s*\\d+)(\\s*[Tt][Hh][Rr][Ee][Aa][Dd]\\s*)(0x[0-9a-fA-F]+|-?\\d+)(\\s*\\([Ll][Ww][Pp]\\s*)(\\d*)", Pattern.MULTILINE); //$NON-NLS-1$
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
boolean isCurrentThread = false;
|
||||
if (matcher.find()) {
|
||||
String id = matcher.group(1).trim();
|
||||
if (id.charAt(0) == '*') {
|
||||
isCurrentThread = true;
|
||||
id = id.substring(1).trim();
|
||||
}
|
||||
info.add(new ThreadInfo(id, matcher.group(5), "", isCurrentThread)); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
pattern = Pattern.compile("(^\\*?\\s*\\d+)(\\s*[Tt][Hh][Rr][Ee][Aa][Dd]\\s*)(\\S+(\\s*\\(.*?\\))?)", Pattern.MULTILINE); //$NON-NLS-1$
|
||||
matcher = pattern.matcher(str);
|
||||
if (matcher.find()) {
|
||||
String id = matcher.group(1).trim();
|
||||
if (id.charAt(0) == '*') {
|
||||
isCurrentThread = true;
|
||||
id = id.substring(1).trim();
|
||||
}
|
||||
info.add(new ThreadInfo(id, matcher.group(5), "", isCurrentThread)); //$NON-NLS-1$
|
||||
info.add(new ThreadInfo(id, matcher.group(3), "", isCurrentThread)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue