Bug 357270 - [disassembly] Show opcodes in the disassembly view
Summary: [disassembly] Show opcodes in the disassembly view
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.0   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 8.4.0   Edit
Assignee: William Riley CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on: 357073 357440
Blocks:
  Show dependency tree
 
Reported: 2011-09-09 14:26 EDT by Marc Khouzam CLA
Modified: 2015-09-11 08:30 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Khouzam CLA 2011-09-09 14:26:30 EDT
With GDB 7.3, the command -data-disassemble can also return the list of opcodes matching the disassembly.

It would be nice to have an option to show those opcodes in the disassembly view.
Comment 1 Marc Khouzam CLA 2011-09-09 14:31:26 EDT
Bug 357073 will be adding the MIDataDisassemble changes to support this.
Comment 2 James Blackburn CLA 2011-09-13 04:08:50 EDT
This functionality was part of the original WR disassembly view as donated to eclipse -- which prompted us to add support to GDB ;)

I suspect fixing this should be straightforward as it certainly (used to) work in our fork of the disassembly view.
Comment 3 Marc Khouzam CLA 2011-09-13 09:33:10 EDT
(In reply to comment #2)
> This functionality was part of the original WR disassembly view as donated to
> eclipse -- which prompted us to add support to GDB ;)

Nice!

> I suspect fixing this should be straightforward as it certainly (used to) work
> in our fork of the disassembly view.

I gather it is something Broadcom is planning on doing, and was started with Bug 357073.  Looking forward to it :-)
Comment 4 Anton Leherbauer CLA 2011-09-16 06:06:30 EDT
Adding bug 357440 as a dependency. The ruler column is now available. I hope it suits your needs!
Comment 5 Axel Siebert CLA 2014-01-29 04:08:29 EST
After investigating why the opcodes display doesn't work, I found this feature request and saw that the low-level part, querying the opcodes from GDB, is already finished (Bug 357073) and the high-level part, the opcode column in the view and related preferences, as well (Bug 357440), but it seems that nobody found the time to implement the tiny middle part connecting the two ends:

http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IInstruction.java needs a small addition to store raw opcode bytes
http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInstruction.java needs a small addition to parse the opcode bytes in the GDB response
http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java needs a small addition to retrieve the opcode bytes and put them in the disassembly

Does anyone feel like doing that?
Comment 6 Marc-André Laperle CLA 2014-01-29 10:36:43 EST
(In reply to Axel Siebert from comment #5)
> Does anyone feel like doing that?

It seems you have made a lot of progress investing this already. I'm sure this would get reviewed if you pushed a patch to Gerrit and it would be a nice addition ;)

http://wiki.eclipse.org/Getting_started_with_CDT_development
http://wiki.eclipse.org/CDT/git#Using_Gerrit_for_CDT
Comment 7 William Riley CLA 2014-02-12 05:40:44 EST
In reply to Axel Siebert from comment #5)
> Does anyone feel like doing that?


(In reply to Marc-Andre Laperle from comment #6)
> (In reply to Axel Siebert from comment #5)
> > Does anyone feel like doing that?
> 
> It seems you have made a lot of progress investing this already. I'm sure
> this would get reviewed if you pushed a patch to Gerrit and it would be a
> nice addition ;)
> 
> http://wiki.eclipse.org/Getting_started_with_CDT_development
> http://wiki.eclipse.org/CDT/git#Using_Gerrit_for_CDT

If Axel does not wish to do this then we (Renesas) have an implementation we would be happy to contribute, we were planning on doing this but are still in the process of sorting out a contribution agreement.
Comment 8 William Riley CLA 2014-03-06 06:48:51 EST
Pushed to Gerrit for review (https://git.eclipse.org/r/22972), along with some explanatory comments/queries.
Comment 9 Marc Khouzam CLA 2014-03-16 14:47:56 EDT
(In reply to William Riley from comment #8)
> Pushed to Gerrit for review (https://git.eclipse.org/r/22972), along with
> some explanatory comments/queries.

Thanks William.

What is the current situation with your contribution agreement?
Comment 10 William Riley CLA 2014-03-16 19:36:22 EDT
(In reply to Marc Khouzam from comment #9)
> (In reply to William Riley from comment #8)
> > Pushed to Gerrit for review (https://git.eclipse.org/r/22972), along with
> > some explanatory comments/queries.
> 
> Thanks William.
> 
> What is the current situation with your contribution agreement?

I have signed an individual Contributor License Agreement, with approval. My understanding is that there is a company equivalent of this which we are in the process of signing (I'm not dealing with this directly). If the individual CLA is not sufficient I will chase the company agreement up more urgently.
Comment 11 Marc Khouzam CLA 2014-03-27 07:03:36 EDT
The original posted patch, even without empty lines is more than 250 lines, so I will have to open a CQ to approve it.
Comment 12 Marc Khouzam CLA 2014-03-27 15:59:17 EDT
I've filed the CQ:
https://dev.eclipse.org/ipzilla/show_bug.cgi?id=8139
(I believe only committers can login to ipzilla)
Comment 13 Marc Khouzam CLA 2014-03-31 09:26:45 EDT
(In reply to Marc Khouzam from comment #12)
> I've filed the CQ:
> https://dev.eclipse.org/ipzilla/show_bug.cgi?id=8139
> (I believe only committers can login to ipzilla)

CQ has been approved.
I'll commit soon.
Comment 14 Marc Khouzam CLA 2014-03-31 14:31:54 EDT
Committed to master.
Thanks William!

Could you add an entry to the New and Noteworthy:
http://wiki.eclipse.org/CDT/User/NewIn84
Comment 15 William Riley CLA 2014-03-31 14:37:16 EDT
(In reply to Marc Khouzam from comment #14)
> Committed to master.
> Thanks William!
> 
> Could you add an entry to the New and Noteworthy:
> http://wiki.eclipse.org/CDT/User/NewIn84

Thanks for reviewing this.

Will do.
Comment 16 Derek Morris CLA 2014-06-02 10:17:50 EDT
This patch does not work properly for architectures that have variable-size instructions (such as ARM).

The opcodes are always displayed as 32-bit values, even though (in Thumb mode) many instruction are only 16-bit.

The data-disassemble command does the correct thing (in returning an opcode as 16 or 32 bits, so it is just the display that is getting it wrong.

For example, here is the data-disassemble for a bit of code (reformatted to highlight):

{address="0x1400028a",func-name="c_entry",offset="54",
     opcodes="a3 fb 00 12",inst="umull\tr1, r2, r3, r0"},
{address="0x1400028e",func-name="c_entry",offset="58",
     opcodes="92 09",inst="lsrs\tr2, r2, #6"}

notice the first instruction is 32-bits and the 2nd is 16 bits. In the disassembly view, the opcodes display as

(address) 0xa3fb0012 ...
(address) 0x00009209 ...
Comment 17 William Riley CLA 2014-06-02 11:07:25 EDT
The ruler column (added in https://bugs.eclipse.org/bugs/show_bug.cgi?id=357440) pads all opcodes to the same length on display. 

I did briefly look into using the number of opcode bytes returned as the instruction size. However GDB does not appear to return opcodes for fixed length instructions sets correctly, meaning the number of bytes returned cannot be used as instruction size. e.g. On an instruction set with a 4 byte fixed size GDB is returning only returns 2 bytes (opcodes="00 00") for some instructions.
Comment 18 Stanislav Perepelitsa CLA 2015-09-11 08:30:35 EDT
Is it planned to fix variable-length instruction display in the way where instruction appearance relies on GDB  '-data-disassemble' command outcome?
Obviously, fixed-length display is not flexible as there are many architectures with variable-length opcodes.