Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337460

Summary: [memory][non-stop] Memory not shown in some cases for non-stop multi-threaded programs
Product: [Tools] CDT Reporter: Marc Khouzam <marc.khouzam>
Component: cdt-debug-dsf-gdbAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: cdtdoug, pawel.1.piech
Version: 8.0Flags: marc.khouzam: review? (pawel.1.piech)
Target Milestone: 8.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed fix
marc.khouzam: iplog-
Fixed including writing case marc.khouzam: iplog-

Description Marc Khouzam CLA 2011-02-17 11:27:56 EST
When running non-stop, if the first thread is running, we are unable to show the memory for other threads, even if they are stopped.

The reason is that GDBMemory_7_0#readMemoryBlock() arbitrarily chooses the first
thread of the program for all memory requests, so if that thread is running, GDB cannot fetch the memory.

The solution will probably be the same as Bug 337452.
Comment 1 Marc Khouzam CLA 2011-02-17 14:00:07 EST
Created attachment 189214 [details]
Proposed fix


The reason GDBMemory_7_0#readMemoryBlock() chooses a thread before fetching memory is because before GDB 7.2, there was no way to specify which process we want to point to in an MI command (see Bug 241317 comment #1).  To work around that, we need to specify a particular thread for that process.

The current bug is that we don't take into account that GDB cannot read memory when pointing to a thread that is running.  For non-stop mode we can have some threads running with others stopped, so we need to choose a thread that is actually stopped to be able to read any memory for that process.

The attached patch chooses the first thread that is stopped.  If all threads are running, then the MI command will fail with a target unavailable, as was correctly done before.
Comment 2 Marc Khouzam CLA 2011-02-17 14:54:31 EST
Created attachment 189221 [details]
Fixed including writing case

I forgot to fix the same issue for the writing of memory.
Comment 3 CDT Genie CLA 2011-02-17 20:23:05 EST
*** cdt cvs genie on behalf of mkhouzam ***
Bug 337460: Memory not shown in some cases for non-stop multi-threaded programs

[*] GDBMemory_7_0.java 1.4 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_0.java?root=Tools_Project&r1=1.3&r2=1.4
Comment 4 Marc Khouzam CLA 2011-02-17 20:31:08 EST
Committed to HEAD and 7_0.  I realize I missed CDT 7.0.2 but I still want the fix the branch for my own use.

Pawel can you review this small fix?
Comment 5 CDT Genie CLA 2011-02-17 21:23:04 EST
*** cdt cvs genie on behalf of mkhouzam ***
Bug 337460: Memory not shown in some cases for non-stop multi-threaded programs.

[*] GDBMemory_7_0.java 1.3.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBMemory_7_0.java?root=Tools_Project&r1=1.3&r2=1.3.2.1