Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2010-03-03 23:05:47 +0000
committerJohn Cortell2010-03-03 23:05:47 +0000
commit293b055013a77cb0e35175e76e48638331aa9e8c (patch)
tree368794994a805a49219997b172a9e607b3277891 /dsf-gdb
parentcafa75507de9e90daaebc342d703aa570376f500 (diff)
downloadorg.eclipse.cdt-293b055013a77cb0e35175e76e48638331aa9e8c.tar.gz
org.eclipse.cdt-293b055013a77cb0e35175e76e48638331aa9e8c.tar.xz
org.eclipse.cdt-293b055013a77cb0e35175e76e48638331aa9e8c.zip
[280607] fixed copy-n-paste mistake in last commit. Also enhanced the documentation.
Diffstat (limited to 'dsf-gdb')
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLIInfoThreadsInfo.java54
1 files changed, 44 insertions, 10 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 f2d31500dbd..fdb6a3e0416 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
@@ -28,13 +28,39 @@ import java.util.regex.Pattern;
*/
public class CLIInfoThreadsInfo extends MIInfo {
+ /**
+ * Matcher for 'info threads' output typically returned by gdbservers
+ * running on POSIX systems. Relevant output is in the form: <br>
+ * <p>
+ * <code>
+ * &lt;x&gt; Thread &lt;y&gt; (LWP &lt;z&gt;)
+ * </code>
+ *
+ * <p>
+ * Where 'y' is a hex number with a '0x' prefix.
+ *
+ * <p>
+ * Note that the output likely includes non-LWP threads, but they are
+ * intentionally ignored
+ */
private static final Pattern RESULT_PATTERN_LWP = 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 for 'info threads' output typically returned by gdbservers running
+ * on non-POSIX systems. Output is in the more general form: <br>
+ * <p>
+ * <code>
+ * &lt;x&gt; Thread &lt;y&gt; (&lt;text&gt;)
+ * </code>
+ *
+ * <p>where 'y' is not necessarily numeric and (&lt;text&gt;) is optional
+ */
private static final Pattern RESULT_PATTERN = Pattern.compile(
"(^\\*?\\s*\\d+)(\\s*[Tt][Hh][Rr][Ee][Aa][Dd]\\s*)(\\S+(\\s*\\(.*?\\))?)", Pattern.MULTILINE); //$NON-NLS-1$
+
protected List<ThreadInfo> info;
-
+
public CLIInfoThreadsInfo(MIOutput out) {
super(out);
parse();
@@ -84,8 +110,9 @@ public class CLIInfoThreadsInfo extends MIInfo {
protected void parseThreadInfo(String str, List<ThreadInfo> info) {
// 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
+ // LWP process threads. We ignore non-LWP threads.
//
+ // [example A]
// (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
@@ -94,21 +121,28 @@ public class CLIInfoThreadsInfo extends MIInfo {
// * 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
+ // However, 'info threads' output varies, and depends on the gdbserver
//
+ // [example B, observed with FreeBSD]
// (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.
-
+ // [example C, observed with cygwin and mingw]
+ // 2 thread 5264.0x608 0x7c90eb94 in ntdll!LdrAccessResource ()
+ // from /cygdrive/c/WINDOWS/system32/ntdll.dll
+ // * 1 thread 5264.0x16f8 main (argc=1, argv=0x661f00) at MultiThread.cc:16
+ //
+ // Note that windows gdbs returns lower case "thread" , so the matcher
+ // needs to be case-insensitive.
+ //
+ // The original code favored the format in example A and so we will
+ // continue to give it precedence. The newly added support for formats
+ // B and C will have lower precedence.
if(str.length() > 0 ){
- Matcher matcher = RESULT_PATTERN_LWP.matcher(str);
+ Matcher matcher = RESULT_PATTERN_LWP.matcher(str); // example A
boolean isCurrentThread = false;
if (matcher.find()) {
String id = matcher.group(1).trim();
@@ -119,7 +153,7 @@ public class CLIInfoThreadsInfo extends MIInfo {
info.add(new ThreadInfo(id, matcher.group(5), "", isCurrentThread)); //$NON-NLS-1$
}
else {
- matcher = RESULT_PATTERN_LWP.matcher(str);
+ matcher = RESULT_PATTERN.matcher(str); // examples B and C
if (matcher.find()) {
String id = matcher.group(1).trim();
if (id.charAt(0) == '*') {

Back to the top