Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 280607 - [debug view][commands][cdi] CLIInfoThreadsInfo parsing tied to LWP
Summary: [debug view][commands][cdi] CLIInfoThreadsInfo parsing tied to LWP
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 6.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 7.0   Edit
Assignee: Randy Rohrbach CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-17 08:35 EDT by Peter Saunders CLA
Modified: 2010-03-08 12:39 EST (History)
3 users (show)

See Also:
pawel.1.piech: review+


Attachments
CLIInfoThreadsInfo.java.patch (1.32 KB, patch)
2009-06-17 08:35 EDT, Peter Saunders CLA
no flags Details | Diff
better parsing of the command line information (3.72 KB, patch)
2010-02-25 15:50 EST, Randy Rohrbach CLA
no flags Details | Diff
Fix accidental regression in last commit. Also, enhanced documentation (4.64 KB, patch)
2010-03-03 17:57 EST, John Cortell CLA
john.cortell: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Saunders CLA 2009-06-17 08:35:09 EDT
Created attachment 139418 [details]
CLIInfoThreadsInfo.java.patch

Build ID: v200905220803

Steps To Reproduce:

1. Use DSF GDB for non-LWP multi-threaded debugging
2. Observe detailed thread info provided by GDB is not presented in Debug view

More information:

The pattern matcher in CLIInfoThreadsInfo#parseThreadInfo() will only match "info threads" substrings of the form:

  <x> Thread <y> (LWP <z>)

DSF GDB currently extracts <z> for use as the pid but this is not a general solution. When debugging non-LWP multi-threaded systems, valuable information provided by GDB inside the parentheses is lost.

Given thread info of the form:

  <x> Thread <y> (<text>)

the attached patch makes DSF GDB treat "<y> (<text>)" as the pid. A more elegant solution would extract <text> into a separate ThreadInfo member variable.

Note that <y> is not always numeric and the "(<text>)" part is optional.
Comment 1 Marc Khouzam CLA 2009-06-17 09:12:04 EDT
(In reply to comment #0)
> 1. Use DSF GDB for non-LWP multi-threaded debugging

Can you tell me how to do that?
What I tried was to compile without -lpthread.  What happened was that 'info thread' did not give any output (note that debugging worked properly).

> Given thread info of the form:
> 
>   <x> Thread <y> (<text>)

Can you post some example of this?
Comment 2 Peter Saunders CLA 2009-06-17 09:59:12 EDT
(In reply to comment #1)

> > 1. Use DSF GDB for non-LWP multi-threaded debugging
> 
> Can you tell me how to do that?

Consider the scenario where DSF GDB is attaching to a remote target which is running a non-POSIX operating system. The GDB server on the remote target will determine the precise format of the "info threads" output.

> > Given thread info of the form:
> > 
> >   <x> Thread <y> (<text>)
> 
> Can you post some example of this?

Here are two examples of "info threads" output containing useful information in the parentheses:

http://groups.google.com/group/gnu.gdb.bug/browse_thread/thread/fe0cc7f7092ef090
http://mail.kde.org/pipermail/kdepim-bugs/2007-August/002774.html
Comment 3 Marc Khouzam CLA 2009-06-17 11:51:38 EDT
I've also noticed this problem with GDB 6.8 using gdbserver on Linux.

926,397 18info threads
926,408 &"info threads\n"
926,408 ~"* 1 Thread 14994  main () at ../testapp.cc:504\n"

Comment 4 Peter Saunders CLA 2009-06-17 13:08:25 EDT
(In reply to comment #3)

> I've also noticed this problem with GDB 6.8 using gdbserver on Linux.
> 
> 926,397 18info threads
> 926,408 &"info threads\n"
> 926,408 ~"* 1 Thread 14994  main () at ../testapp.cc:504\n"

Yes. The thread information in parentheses is optional. My patch accommodates the above case.
Comment 5 Randy Rohrbach CLA 2010-02-08 15:20:46 EST
I'll sign up for this one. I looked at the patch and I think it needs to be
a little more flexible. But it was a pretty fast look and I could have misread it.
Anyway, I'll find out when I test it.

Randy
Comment 6 Randy Rohrbach CLA 2010-02-25 15:50:41 EST
Created attachment 160240 [details]
better parsing of the command line information

This is a melding of the patch supplied by the submitter and the original.
Basically I changed it to try the first original algorithm, based on the assumption that the LWP number was originally important. If it fails to find
that then it defaults to the parsing algorithm supplied by the submitter.

It also is a little more forgiving with respect to the case of the informatio
returned.

Randy
Comment 7 Randy Rohrbach CLA 2010-02-25 15:53:21 EST
Pawel

   I checked in the attached patch to HEAD. Please take a look at it.

Randy
Comment 8 Pawel Piech CLA 2010-03-01 17:24:15 EST
Looks fine to me.  I only extracted the Patterns into static variables so they don't have to be created every time.
Comment 9 John Cortell CLA 2010-03-03 16:49:13 EST
(In reply to comment #8)
> Looks fine to me.  I only extracted the Patterns into static variables so they
> don't have to be created every time.

Pawel, looks like your tweak rendered the fix a non-fix :-) A simple copy-n-paste bug. You never use 'RESULT_PATTERN' (instead you accidentally use the LWP variant twice).

I'm in the code now, fixing the case for cygwin/mingw, which uses yet another format. Oh joy. So, I'll take care of this, too.
Comment 10 Pawel Piech CLA 2010-03-03 16:52:20 EST
(In reply to comment #9)
> Pawel, looks like your tweak rendered the fix a non-fix :-) A simple
> copy-n-paste bug. You never use 'RESULT_PATTERN' (instead you accidentally use
> the LWP variant twice).
wow that's bad... thanks for catching it
Comment 11 John Cortell CLA 2010-03-03 17:57:55 EST
Created attachment 160872 [details]
Fix accidental regression in last commit. Also, enhanced documentation
Comment 12 Peter Saunders CLA 2010-03-08 12:39:02 EST
Note also bug 280631. Without the patch in 280631, new non-LWP threads may never be seen in the Debug view.