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

Bug 344298

Summary: [multi-process][disassembly] The disassembly window shows wrong code when debugging multiple processes.
Product: [Tools] CDT Reporter: Nicolas Blanc <nicolas.blanc>
Component: cdt-debug-dsf-gdbAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: aleherb+eclipse, cdtdoug, john.cortell, pawel.1.piech
Version: 8.0Flags: aleherb+eclipse: review+
marc.khouzam: review? (john.cortell)
Target Milestone: 8.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Proposed fix
marc.khouzam: iplog-
Fix for JUnit tests only
marc.khouzam: iplog-
Proposed fix (no Junit) marc.khouzam: iplog-

Description Nicolas Blanc CLA 2011-04-29 11:22:43 EDT
Build Identifier: I20101208-1300

When attaching several processes using GDB 7.2 and GDB's DSF plugin the disassembly window is not aware that there are several processes.

The thread ID of the user-selected thread is not specified in the MI command to disassemble code. Consequenlty, if several processes are debugged altogether the disassembly window might display the code for the wrong process.

Example of a typical diassembly command issued by Eclipse:

83-data-disassemble -s 247506561616 -e 247506561696 -- 0

To avoid this problem, GDB 7.2's thread option should be added:

83-data-disassemble --thread 2 -s 247506561616 -e 247506561696 -- 0

Note that other windows such as the variable window and the memory window already use this option. 

Example: 85-var-create --thread 4 --frame 2 - * i



Reproducible: Always

Steps to Reproduce:
1.Create a new debug configuration "C/C++ Attach to Application" using the DSF laucher.
2. Use gdb v7.2 as the debugger.
3. Attach two different applications using the same debug session.
4. Switch among the two processes and inspect the content of the disassembly window. The disassembly window does not switch its content correctly.
Comment 1 Marc Khouzam CLA 2011-04-29 12:00:24 EDT
Thanks for reporting this.  It is a big deal.

The reason is that the IDisassemblyDMContext is still implemented by GDBControlDMContext which represents GDB, instead of being implemented by MIContainerDMC.  We have to move that interface is the same fashion as for
bug 335324 and bug 335325.
Comment 2 Marc Khouzam CLA 2011-05-01 21:42:39 EDT
Created attachment 194458 [details]
Proposed fix

This simple patch moves the IDisassemblyDMContext to MIContainerDMC.

Things seem to work better and the JUnit tests for Disassembly pass.
But then I ran into Bug 344408 which prevents from properly showing the source code in the disassembly view, which affects the second process we add to the multi-process session.

This patch is still an improvement and I think it is ok even before we fix Bug 344408.  I'll try to get others that know Disassembly better than myself to review the patch fast since we are so close to the M7 build.
Comment 3 Marc Khouzam CLA 2011-05-01 21:44:08 EDT
Toni, this patch is very simple but makes a serious change.  I was hoping to get your opinion on it
Comment 4 Marc Khouzam CLA 2011-05-01 21:45:00 EDT
John, your opinion would be valuable as well.
Comment 5 Marc Khouzam CLA 2011-05-01 21:54:11 EDT
A note on the API changes.

The fix still works even if we don't remove IDisassemblyDMContext from GDBControlDMContext.  So, if you guys feel that part of the change impacts API too much, we could leave GDBControlDMContext as is (with a comment).
Comment 6 Marc Khouzam CLA 2011-05-01 22:04:04 EDT
Created attachment 194459 [details]
Fix for JUnit tests only

I committed the fix for the JUnit tests only, which works with or without the full fix.
Comment 7 Marc Khouzam CLA 2011-05-01 22:06:45 EDT
Created attachment 194460 [details]
Proposed fix (no Junit)

This is the fix itself, without the JUnit change.  3-line change.
Comment 8 CDT Genie CLA 2011-05-01 22:23:04 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 344298: JUnit support for Disassembly in case of multi-process.

[*] MIDisassemblyTest.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIDisassemblyTest.java?root=Tools_Project&r1=1.4&r2=1.5
Comment 9 Anton Leherbauer CLA 2011-05-02 04:08:24 EDT
Makes sense, +1 for the API change.  I don't think this would break existing code.
Comment 10 Marc Khouzam CLA 2011-05-02 09:59:39 EDT
(In reply to comment #9)
> Makes sense, +1 for the API change.  I don't think this would break existing
> code.

Thanks Toni!

Committed to HEAD.
Comment 11 Marc Khouzam CLA 2011-05-02 10:00:51 EDT
I think I messed up the review flags by re-using an already-open webpage.  Toni, if you can try to re-mark it as approved, that would be nice.  Thanks.
Comment 13 Marc Khouzam CLA 2011-05-02 11:13:09 EDT
Bug 344408 has been fixed, but it was not sufficient for the multi-process case.  I opened Bug 344471 for the multi-process case.