Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352410 - No thread groups shown in debug view (debugging using a GDB stub)
Summary: No thread groups shown in debug view (debugging using a GDB stub)
Status: CLOSED NOT_ECLIPSE
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-19 04:15 EDT by Raphael Zulliger CLA
Modified: 2011-07-19 09:00 EDT (History)
2 users (show)

See Also:


Attachments
patch (hot fix) (2.01 KB, patch)
2011-07-19 04:15 EDT, Raphael Zulliger CLA
no flags Details | Diff
GDB command cache traces (good case) (44.44 KB, text/plain)
2011-07-19 04:18 EDT, Raphael Zulliger CLA
no flags Details
GDB MI commands (good case) (43.66 KB, text/plain)
2011-07-19 04:18 EDT, Raphael Zulliger CLA
no flags Details
GDB command cache traces (bad case) (11.49 KB, text/plain)
2011-07-19 04:19 EDT, Raphael Zulliger CLA
no flags Details
GDB MI commands (bad case) (19.65 KB, text/plain)
2011-07-19 04:20 EDT, Raphael Zulliger CLA
no flags Details
Screenshot of the debug view (bad case) (10.21 KB, image/png)
2011-07-19 04:21 EDT, Raphael Zulliger CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Zulliger CLA 2011-07-19 04:15:13 EDT
Build Identifier: Build id: 20110615-0604

I'm trying to debug a C++ application which is running on an embedded device using (my own) GDB stub.

About every 2nd time when I launch a new debugging session CDT ends up by not showing any threads.

I started debugging this issue and finally figured out what the problem is: It's an outdated cache entry of a GDB/MI command. This issue could probably be a bug which is not just related to my GDB stub (and hardware) but may be a generic one. That's why I post my findings here.

The details: In my case, sometimes it happens that the very first GDB/MI command issued by CDT is a '-list-thread-groups'. Unfortunately, at that time, GDB does not have any thread groups and returns a '1^done,groups=[{id="i1",type="process"}]'. Obviously, this value get's stored in the GDB/MI command cache. Sometime later, GDB reports a '=thread-group-started,id="i1",pid="1"'. However, this updated information doesn't make it into the cache (why?). Instead, the cache still return the 'empty' thread group information. With my limited knowledge about CDT, it seems to me that a cache-update (or cache flush) needs to be done when a '=thread-group-started' is received, am I wrong? However, I couldn't find such piece of code. Did I miss something?

My 'hot fix' is to flush the whole cache whenever a '=thread-group-started' is received (flushCache(null)). This fixes the issue for me. I guess that this patch could be improved by not flushing the whole cache, but only the specific GDB/MI command - but I was not able to figure out what's the best way to do that (at least not within 5 minutes :-)). Maybe someone could point me to such a solution?

Finally, it would be great to have this issue fixed in CDT.

Btw: I'm using GDB version 7.2 (+ some minor patches).

Reproducible: Sometimes

Steps to Reproduce:
Reproducibility may depend on 3rd party software and hardware... thus I can't provide any instruction on how to reproduce.
Comment 1 Raphael Zulliger CLA 2011-07-19 04:15:58 EDT
Created attachment 199876 [details]
patch (hot fix)
Comment 2 Raphael Zulliger CLA 2011-07-19 04:18:25 EDT
Created attachment 199877 [details]
GDB command cache traces (good case)

The cache returns thread group information that contain a valid pid. The cached MI command was number ^11.
Comment 3 Raphael Zulliger CLA 2011-07-19 04:18:48 EDT
Created attachment 199878 [details]
GDB MI commands (good case)
Comment 4 Raphael Zulliger CLA 2011-07-19 04:19:35 EDT
Created attachment 199879 [details]
GDB command cache traces (bad case)

The cache returns thread group information that contain NO pid. The cached MI command was number ^1.
Comment 5 Raphael Zulliger CLA 2011-07-19 04:20:08 EDT
Created attachment 199880 [details]
GDB MI commands (bad case)
Comment 6 Raphael Zulliger CLA 2011-07-19 04:21:46 EDT
Created attachment 199881 [details]
Screenshot of the debug view (bad case)
Comment 7 Marc Khouzam CLA 2011-07-19 08:17:00 EDT
(In reply to comment #0)

> The details: In my case, sometimes it happens that the very first GDB/MI
> command issued by CDT is a '-list-thread-groups'. Unfortunately, at that time,
> GDB does not have any thread groups and returns a
> '1^done,groups=[{id="i1",type="process"}]'. Obviously, this value get's stored
> in the GDB/MI command cache. Sometime later, GDB reports a
> '=thread-group-started,id="i1",pid="1"'. However, this updated information
> doesn't make it into the cache (why?). 

The CommandCache, only stores commands, not events.  Event should clear the cache so that the next command can be triggered eventually and be stored in the cache.

> Instead, the cache still return the
> 'empty' thread group information. With my limited knowledge about CDT, it seems
> to me that a cache-update (or cache flush) needs to be done when a
> '=thread-group-started' is received, am I wrong? However, I couldn't find such
> piece of code. Did I miss something?

In MIRunControlEventProcessor_7_0.eventReceived(), when getting '=thread-group-started', we should be sending an MIThreadGroupCreatedEvent.  This event is received in GDBProcesses_7_0.eventDispatched(MIThreadGroupCreatedEvent e), which then sends a ContainerStartedDMEvent, which is processed in GDBProcesses_7_0.eventDispatched(IStartedDMEvent e), which clears the cache.
 
Can you check that this code is not being called for you?  Are you seeing the MIThreadGroupCreatedEvent?
Comment 8 Raphael Zulliger CLA 2011-07-19 08:55:50 EDT
(In reply to comment #7)
> In MIRunControlEventProcessor_7_0.eventReceived(), when getting
> '=thread-group-started', we should be sending an MIThreadGroupCreatedEvent. 
> This event is received in
> GDBProcesses_7_0.eventDispatched(MIThreadGroupCreatedEvent e), which then sends
> a ContainerStartedDMEvent, which is processed in
> GDBProcesses_7_0.eventDispatched(IStartedDMEvent e), which clears the cache.
> 
> Can you check that this code is not being called for you?  Are you seeing the
> MIThreadGroupCreatedEvent?

Thanks for your fast response!

No, it's not called - but thanks to your explanation, I was able to easily find the mistake (which was in my code): My class derived from GDBControl (instead of GDBControl_7_2). After I changed to GDBControl_7_2, it behaves exactly as you described it above.

I'm very sorry to have disturbed you...
Comment 9 Marc Khouzam CLA 2011-07-19 09:00:11 EDT
(In reply to comment #8)
> I'm very sorry to have disturbed you...

No problem.  A quick resolution like that is always good news :-)