Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 301720 - [Mac] Threads are not updated while debugging
Summary: [Mac] Threads are not updated while debugging
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 6.0   Edit
Hardware: All Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 7.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-03 12:27 EST by Marc-André Laperle CLA
Modified: 2010-02-09 12:18 EST (History)
1 user (show)

See Also:
pawel.1.piech: review+


Attachments
DSF threads patch (3.54 KB, patch)
2010-02-03 12:27 EST, Marc-André Laperle CLA
no flags Details | Diff
Improved fix (4.21 KB, patch)
2010-02-04 21:56 EST, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2010-02-03 12:27:54 EST
Created attachment 158069 [details]
DSF threads patch

If I set a breakpoint before the second thread is created and then break into the second thread, it will only show one thread in the debug session unless I press the refresh button. So, it looks like Apple's GDB doesn't notify about the new thread and it shows up when refresh is pressed because -thread-list-ids is sent.

The problem is that -thread-list-ids is cached so it always returns the same
result unless the cache is flushed. So, the patch adds a listener for suspend
events and flushes the cache.
Comment 1 Marc Khouzam CLA 2010-02-04 14:40:42 EST
This bug is a DSF-GDB specific instance of bug 269838
Comment 2 Marc Khouzam CLA 2010-02-04 21:56:49 EST
Created attachment 158253 [details]
Improved fix

First let me say that I'm very impressed with Marc-Andre's patch.  Isolating the problem with the cache was quite an achievement as the caching stuff of DSF is not obvious at all.

I've modified the patch a little with things that are important when using DSF but that are not obvious.  Also, this patch will require a change in DSF, which I will open a bug for soon.

The changes are about:

1- every service has a base method getServicesTracker(), but you need to have super.initialize be called to get the tracker ready.  That is why it's better to use an initialize method instead of using the constructor

2- It is good to register() a new version of a service to add it's name as a way to find it using the DsfServicesTracker.  This is not essential and I realize we haven't done this for the other new MacOS services. Doing so allows you to call tracker.getService(MacOSGDBProcesses.class) if you need to call a method that is only defined in that class.

3- when calling addServiceEventListener() in a service, you should also call removeServiceEventListener() when shutting down the service.  You do this in an overridden shutdown() method.

4- whenever you create a new DsfServicesTracker, you must dispose() it eventually.

5- using flushCache(null) will flush the entire cache.  This is more consistent with the clearing of the cache that we do in GDBProcesses.java.  Also, it is probably the right thing to clear the entire cache because an ISuspendedEvent could occur for a single thread (not on Mac though), and that should clear the cache for the container not just the specific thread (they are both execution contexts)

6- eventDispatched() is marked as @nooverride which is an API tooling tag (for some reason, I didn't get a warning though...).  So, after debating about it, I feel it is more future-proof to have the MacOS eventDispatched() method not override the base one (by simply changing its name) and letting the base one be called automatically by DsfSession.  I believe this would allow everything to keep working even if we decided to remove eventDispatched() from the base class.

Finally, you should add -ea (which I often forget) to the VM arguments when doing your Eclipse launch.  This will allow for more checks to be done by DSF code.  In fact, if you try it with this patch, things will break :-)  That is why I need to change something in DSF.

Marc-Andre, can you confirm that this patch fixes your problem? (don't use -ea)

Thanks
Comment 3 Marc Khouzam CLA 2010-02-04 22:11:37 EST
I've opened Bug 301913 about the DSF assertion problem.
Comment 4 Marc-André Laperle CLA 2010-02-04 23:28:00 EST
Thanks for the explanations :) I can confirm that the patch fixes the problem. I also tried the patch from Bug 301913 and used -ea and it worked too.
Comment 5 Marc Khouzam CLA 2010-02-05 10:44:42 EST
(In reply to comment #4)
> Thanks for the explanations :) 

I'm trying keep you involved :-)  You're doing a great job.

> I can confirm that the patch fixes the problem.

Committed to HEAD.

Pawel can you review?
Comment 6 Pawel Piech CLA 2010-02-09 12:18:15 EST
Makes sense to me.