From 5cdc9c1c059978b706ee9bd18875ff9bf8b5f58b Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Thu, 25 Feb 2010 20:51:59 +0000 Subject: [PATCH] Bugxilla 280607. --- .../command/output/CLIInfoThreadsInfo.java | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoThreadsInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoThreadsInfo.java index 16c138201de..580bb7cdfc4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoThreadsInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoThreadsInfo.java @@ -77,19 +77,56 @@ public class CLIInfoThreadsInfo extends MIInfo { } protected void parseThreadInfo(String str, List 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$ } } + } } } +