mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 357270 - Show opcodes in the disassembly view
Change-Id: Ia88fa4032483cf70f41714bddd688d754bb5451b Signed-off-by: William Riley <william.riley@renesas.com> Reviewed-on: https://git.eclipse.org/r/22972 Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
6b32a922ba
commit
f54cf7280e
11 changed files with 492 additions and 51 deletions
|
@ -0,0 +1,159 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2014 Ericsson and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Ericsson - initial API and implementation
|
||||
* William Riley (Renesas) - Bug 357270
|
||||
*****************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.cdt.dsf.debug.service.IDisassembly;
|
||||
import org.eclipse.cdt.dsf.debug.service.IDisassembly2;
|
||||
import org.eclipse.cdt.dsf.debug.service.IDisassembly3;
|
||||
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
||||
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||
import org.eclipse.cdt.dsf.mi.service.MIDisassembly;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIDataDisassemble;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
/**
|
||||
* @since 4.4
|
||||
*/
|
||||
public class GDBDisassembly_7_3 extends MIDisassembly implements IDisassembly3 {
|
||||
|
||||
public GDBDisassembly_7_3(DsfSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.dsf.service.AbstractDsfService#initialize(org.eclipse
|
||||
* .cdt.dsf.concurrent.RequestMonitor)
|
||||
*/
|
||||
@Override
|
||||
public void initialize(final RequestMonitor rm) {
|
||||
super.initialize(new ImmediateRequestMonitor(rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
doInitialize(rm);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doInitialize(final RequestMonitor rm) {
|
||||
register(new String[] { IDisassembly.class.getName(),
|
||||
IDisassembly2.class.getName(),
|
||||
IDisassembly3.class.getName(),
|
||||
MIDisassembly.class.getName(),
|
||||
GDBDisassembly_7_3.class.getName() },
|
||||
new Hashtable<String, String>());
|
||||
|
||||
rm.done();
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// IDisassembly3
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
@Override
|
||||
public void getInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress,
|
||||
DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
// Ask for opCodes by default
|
||||
getInstructions(context, startAddress, endAddress, true, drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInstructions(IDisassemblyDMContext context, String filename,
|
||||
int linenum, int lines,
|
||||
DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
// Ask for opCodes by default
|
||||
getInstructions(context, filename, linenum, lines, true, drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMixedInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress,
|
||||
DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
// Ask for opCodes by default
|
||||
getMixedInstructions(context, startAddress, endAddress, true, drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMixedInstructions(IDisassemblyDMContext context,
|
||||
String filename, int linenum, int lines,
|
||||
DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
// Ask for opCodes by default
|
||||
getMixedInstructions(context, filename, linenum, lines, true, drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress, boolean opCodes,
|
||||
DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
getInstructions(context, startAddress, endAddress,
|
||||
opCodes ? MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY_OPCODES :
|
||||
MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY,
|
||||
drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInstructions(IDisassemblyDMContext context, String filename,
|
||||
int linenum, int lines, boolean opCodes,
|
||||
DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
getInstructions(context, filename, linenum, lines,
|
||||
opCodes ? MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY_OPCODES :
|
||||
MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY,
|
||||
drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMixedInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress, boolean opCodes,
|
||||
DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
getMixedInstructions(context, startAddress, endAddress,
|
||||
opCodes ? MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED_OPCODES :
|
||||
MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED,
|
||||
drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMixedInstructions(IDisassemblyDMContext context,
|
||||
String filename, int linenum, int lines, boolean opCodes,
|
||||
DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
getMixedInstructions(context, filename, linenum, lines,
|
||||
opCodes ? MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED_OPCODES :
|
||||
MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED,
|
||||
drm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void alignOpCodeAddress(IDisassemblyDMContext context,
|
||||
BigInteger address, DataRequestMonitor<BigInteger> drm)
|
||||
{
|
||||
drm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID,
|
||||
NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2013 Ericsson and others.
|
||||
* Copyright (c) 2008, 2014 Ericsson and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -14,6 +14,7 @@
|
|||
* Vladimir Prus (Mentor Graphics) - Support for OS resources.
|
||||
* Marc Khouzam (Ericsson) - Support for GDB 7.6 memory service
|
||||
* Marc Khouzam (Ericsson) - Support for GDB 7.4 trace control service
|
||||
* William Riley (Renesas) - Support for GDB 7.3 disassembly service (Bug 357270)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.service;
|
||||
|
||||
|
@ -163,6 +164,9 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
|||
|
||||
@Override
|
||||
protected IDisassembly createDisassemblyService(DsfSession session) {
|
||||
if (GDB_7_3_VERSION.compareTo(fVersion) <= 0) {
|
||||
return new GDBDisassembly_7_3(session);
|
||||
}
|
||||
return new MIDisassembly(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
|
|||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.commands.MIDataDisassemble;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIDataDisassembleInfo;
|
||||
import org.eclipse.cdt.dsf.service.AbstractDsfService;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
|
@ -66,7 +67,6 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly {
|
|||
fConnection = getServicesTracker().getService(ICommandControl.class);
|
||||
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
|
||||
|
||||
// getSession().addServiceEventListener(this, null);
|
||||
register(new String[] { IDisassembly.class.getName(), MIDisassembly.class.getName() },
|
||||
new Hashtable<String, String>());
|
||||
rm.done();
|
||||
|
@ -78,7 +78,6 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly {
|
|||
@Override
|
||||
public void shutdown(RequestMonitor rm) {
|
||||
unregister();
|
||||
// getSession().removeServiceEventListener(this);
|
||||
super.shutdown(rm);
|
||||
}
|
||||
|
||||
|
@ -97,22 +96,36 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.dsf.debug.service.IDisassembly#getInstructions(org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext, java.math.BigInteger, java.math.BigInteger, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public void getInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress,
|
||||
DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
getInstructions(context, startAddress, endAddress, MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY, drm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to allow getting disassembly instructions not in mixed mode.
|
||||
* @since 4.4
|
||||
*/
|
||||
protected void getInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress, int mode,
|
||||
final DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
// Validate the context
|
||||
// Checking what we don't support instead of what we do support allows
|
||||
// others to extend the 'mode' field with new values.
|
||||
assert mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED ||
|
||||
mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED_OPCODES;
|
||||
|
||||
if (context == null) {
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$);
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$
|
||||
drm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Go for it
|
||||
String start = (startAddress != null) ? startAddress.toString() : "$pc"; //$NON-NLS-1$
|
||||
String end = (endAddress != null) ? endAddress.toString() : "$pc + 100"; //$NON-NLS-1$
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, start, end, false),
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, start, end, mode),
|
||||
new DataRequestMonitor<MIDataDisassembleInfo>(getExecutor(), drm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
|
@ -128,17 +141,30 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly {
|
|||
*/
|
||||
@Override
|
||||
public void getInstructions(IDisassemblyDMContext context, String filename,
|
||||
int linenum, int lines, final DataRequestMonitor<IInstruction[]> drm)
|
||||
int linenum, int lines, DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
// Validate the context
|
||||
getInstructions(context, filename, linenum, lines, MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY, drm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to allow getting disassembly instructions not in mixed mode.
|
||||
* @since 4.4
|
||||
*/
|
||||
protected void getInstructions(IDisassemblyDMContext context, String filename,
|
||||
int linenum, int lines, int mode, final DataRequestMonitor<IInstruction[]> drm)
|
||||
{
|
||||
// Checking what we don't support instead of what we do support allows
|
||||
// others to extend the 'mode' field with new values.
|
||||
assert mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED ||
|
||||
mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED_OPCODES;
|
||||
|
||||
if (context == null) {
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$);
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$
|
||||
drm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Go for it
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, filename, linenum, lines, false),
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, filename, linenum, lines, mode),
|
||||
new DataRequestMonitor<MIDataDisassembleInfo>(getExecutor(), drm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
|
@ -157,17 +183,31 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly {
|
|||
BigInteger startAddress, BigInteger endAddress,
|
||||
final DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
// Validate the context
|
||||
if (context == null) {
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$);
|
||||
getMixedInstructions(context, startAddress, endAddress, MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED, drm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to allow getting disassembly instructions in mixed mode.
|
||||
* @since 4.4
|
||||
*/
|
||||
protected void getMixedInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress, int mode,
|
||||
final DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
// Checking what we don't support instead of what we do support allows
|
||||
// others to extend the 'mode' field with new values.
|
||||
assert mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY ||
|
||||
mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY_OPCODES;
|
||||
|
||||
if (context == null) {
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$
|
||||
drm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Go for it
|
||||
String start = (startAddress != null) ? startAddress.toString() : "$pc"; //$NON-NLS-1$
|
||||
String end = (endAddress != null) ? endAddress.toString() : "$pc + 100"; //$NON-NLS-1$
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, start, end, true),
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, start, end, mode),
|
||||
new DataRequestMonitor<MIDataDisassembleInfo>(getExecutor(), drm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
|
@ -186,15 +226,29 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly {
|
|||
String filename, int linenum, int lines,
|
||||
final DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
// Validate the context
|
||||
getMixedInstructions(context, filename, linenum, lines, MIDataDisassemble.DATA_DISASSEMBLE_MODE_MIXED, drm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to allow getting disassembly instructions in mixed mode.
|
||||
* @since 4.4
|
||||
*/
|
||||
protected void getMixedInstructions(IDisassemblyDMContext context,
|
||||
String filename, int linenum, int lines, int mode,
|
||||
final DataRequestMonitor<IMixedInstruction[]> drm)
|
||||
{
|
||||
// Checking what we don't support instead of what we do support allows
|
||||
// others to extend the 'mode' field with new values.
|
||||
assert mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY ||
|
||||
mode != MIDataDisassemble.DATA_DISASSEMBLE_MODE_DISASSEMBLY_OPCODES;
|
||||
|
||||
if (context == null) {
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$);
|
||||
drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Unknown context type", null)); //$NON-NLS-1$
|
||||
drm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Go for it
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, filename, linenum, lines, true),
|
||||
fConnection.queueCommand(fCommandFactory.createMIDataDisassemble(context, filename, linenum, lines, mode),
|
||||
new DataRequestMonitor<MIDataDisassembleInfo>(getExecutor(), drm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
|
@ -204,5 +258,4 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,19 +49,31 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
|
|||
* '-- MODE'
|
||||
* - 0 disassembly
|
||||
* - 1 mixed source and disassembly
|
||||
* - 2 disassembly with raw opcodes
|
||||
* - 3 mixed source and disassembly with raw opcodes
|
||||
* Note: Modes 2 and 3 are only available starting with GDB 7.3
|
||||
* - 2 disassembly with raw opcodes
|
||||
* - 3 mixed source and disassembly with raw opcodes
|
||||
* Note: Modes 2 and 3 are only available starting with GDB 7.3
|
||||
*/
|
||||
|
||||
public class MIDataDisassemble extends MICommand<MIDataDisassembleInfo> {
|
||||
|
||||
private static final int MIN_MODE = 0;
|
||||
|
||||
/** @since 4.4 */
|
||||
public static final int DATA_DISASSEMBLE_MODE_DISASSEMBLY = 0;
|
||||
/** @since 4.4 */
|
||||
public static final int DATA_DISASSEMBLE_MODE_MIXED = 1;
|
||||
/** @since 4.4 */
|
||||
public static final int DATA_DISASSEMBLE_MODE_DISASSEMBLY_OPCODES = 2;
|
||||
/** @since 4.4 */
|
||||
public static final int DATA_DISASSEMBLE_MODE_MIXED_OPCODES = 3;
|
||||
|
||||
private static final int MAX_MODE = 3;
|
||||
|
||||
|
||||
private static final String MODE_OUT_OF_RANGE = "Mode out of range: "; //$NON-NLS-1$
|
||||
|
||||
public MIDataDisassemble(IDisassemblyDMContext ctx, String start, String end, boolean mode) {
|
||||
this(ctx, start, end, mode ? 1 : 0);
|
||||
this(ctx, start, end, mode ? DATA_DISASSEMBLE_MODE_MIXED : DATA_DISASSEMBLE_MODE_DISASSEMBLY);
|
||||
}
|
||||
|
||||
/** @since 4.1 */
|
||||
|
@ -77,7 +89,7 @@ public class MIDataDisassemble extends MICommand<MIDataDisassembleInfo> {
|
|||
}
|
||||
|
||||
public MIDataDisassemble(IDisassemblyDMContext ctx, String file, int linenum, int lines, boolean mode) {
|
||||
this(ctx, file, linenum, lines, mode ? 1 : 0);
|
||||
this(ctx, file, linenum, lines, mode ? DATA_DISASSEMBLE_MODE_MIXED : DATA_DISASSEMBLE_MODE_DISASSEMBLY);
|
||||
}
|
||||
|
||||
/** @since 4.1 */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2014 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* QNX Software Systems - Initial API and implementation
|
||||
* Ericsson - Adapted for DSF
|
||||
* Dmitry Kozlov (Mentor Graphics) - Add tab symbols parsing (Bug 391115)
|
||||
* William Riley (Renesas) - Add raw Opcode parsing (Bug 357270)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.mi.service.command.output;
|
||||
|
@ -21,10 +22,11 @@ public class MIInstruction extends AbstractInstruction {
|
|||
|
||||
// The parsed information
|
||||
BigInteger address;
|
||||
String function = ""; //$NON-NLS-1$
|
||||
String function = ""; //$NON-NLS-1$
|
||||
long offset;
|
||||
String opcode = ""; //$NON-NLS-1$
|
||||
String args = ""; //$NON-NLS-1$
|
||||
String opcode = ""; //$NON-NLS-1$
|
||||
String args = ""; //$NON-NLS-1$
|
||||
BigInteger rawOpcodes = null;
|
||||
|
||||
public MIInstruction(MITuple tuple) {
|
||||
parse(tuple);
|
||||
|
@ -59,6 +61,11 @@ public class MIInstruction extends AbstractInstruction {
|
|||
public String getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getRawOpcodes() {
|
||||
return rawOpcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the assembly instruction result. Each instruction has the following
|
||||
|
@ -73,6 +80,13 @@ public class MIInstruction extends AbstractInstruction {
|
|||
* ...,
|
||||
* {address="0x00010820",func-name="main",offset="100",inst="restore "}
|
||||
*
|
||||
* An instruction may also contain:
|
||||
* - Opcode bytes
|
||||
*
|
||||
* {address="0x004016b9",func-name="main",offset="9",opcodes="e8 a2 05 00 00",
|
||||
* inst="call 0x401c60 <__main>"},
|
||||
* ...,
|
||||
*
|
||||
* In addition, the opcode and arguments are extracted form the assembly instruction.
|
||||
*/
|
||||
private void parse(MITuple tuple) {
|
||||
|
@ -82,7 +96,7 @@ public class MIInstruction extends AbstractInstruction {
|
|||
MIValue value = results[i].getMIValue();
|
||||
String str = ""; //$NON-NLS-1$
|
||||
|
||||
if (value != null && value instanceof MIConst) {
|
||||
if (value instanceof MIConst) {
|
||||
str = ((MIConst)value).getCString();
|
||||
}
|
||||
|
||||
|
@ -111,7 +125,9 @@ public class MIInstruction extends AbstractInstruction {
|
|||
/* for the instruction, we do not want the C string but the
|
||||
translated string since the only thing we are doing is
|
||||
displaying it. */
|
||||
str = ((MIConst) value).getString();
|
||||
if (value instanceof MIConst) {
|
||||
str = ((MIConst) value).getString();
|
||||
}
|
||||
/* to avoid improper displaying of instructions we need to translate tabs */
|
||||
str = str.replace("\\t", "\t"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
@ -131,6 +147,16 @@ public class MIInstruction extends AbstractInstruction {
|
|||
// guard no argument
|
||||
if( index < chars.length )
|
||||
args = str.substring( index );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (var.equals("opcodes")) { //$NON-NLS-1$
|
||||
try {
|
||||
rawOpcodes = decodeOpcodes(str);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,5 +176,17 @@ public class MIInstruction extends AbstractInstruction {
|
|||
}
|
||||
return new BigInteger(string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decode given string representation of a space separated hex encoded byte
|
||||
* array
|
||||
*
|
||||
* @param string
|
||||
* space separated hexadecimal byte array
|
||||
* @return opcode bytes as <code>BigInteger</code>
|
||||
*/
|
||||
private static BigInteger decodeOpcodes(String string) {
|
||||
// Removing space separation and parse as single big integer
|
||||
return new BigInteger(string.replace(" ", ""), 16); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2013 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2010, 2014 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -13,6 +13,7 @@
|
|||
* Patrick Chuong (Texas Instruments) - Bug 328168
|
||||
* Patrick Chuong (Texas Instruments) - Bug 353351
|
||||
* Patrick Chuong (Texas Instruments) - Bug 337851
|
||||
* William Riley (Renesas) - Bug 357270
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
|
||||
|
||||
|
@ -30,10 +31,12 @@ import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
|
|||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyUtils;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.ErrorPosition;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback;
|
||||
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
|
@ -48,6 +51,7 @@ import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
|||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
||||
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
||||
import org.eclipse.cdt.dsf.debug.service.IInstructionWithRawOpcodes;
|
||||
import org.eclipse.cdt.dsf.debug.service.IInstructionWithSize;
|
||||
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
||||
|
@ -729,15 +733,21 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
|
|||
break;
|
||||
}
|
||||
}
|
||||
final String opCode;
|
||||
final String functionOffset; // Renamed from opCode to avoid confusion
|
||||
// insert function name+offset instead of opcode bytes
|
||||
if (functionName != null && functionName.length() > 0) {
|
||||
opCode= functionName + '+' + instruction.getOffset();
|
||||
functionOffset= functionName + '+' + instruction.getOffset();
|
||||
} else {
|
||||
opCode= ""; //$NON-NLS-1$
|
||||
functionOffset= ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
BigInteger opCodes = null;
|
||||
// Get raw Opcodes if available
|
||||
if(instruction instanceof IInstructionWithRawOpcodes){
|
||||
opCodes = ((IInstructionWithRawOpcodes)instruction).getRawOpcodes();
|
||||
}
|
||||
|
||||
p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), opCode, instruction.getInstruction(), compilationPath, -1);
|
||||
p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), functionOffset, opCodes, instruction.getInstruction(), compilationPath, -1);
|
||||
if (p == null) {
|
||||
break;
|
||||
}
|
||||
|
@ -863,14 +873,20 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
|
|||
break;
|
||||
}
|
||||
}
|
||||
final String opCode;
|
||||
final String funcOffset;
|
||||
// insert function name+offset instead of opcode bytes
|
||||
if (functionName != null && functionName.length() > 0) {
|
||||
opCode= functionName + '+' + instruction.getOffset();
|
||||
funcOffset= functionName + '+' + instruction.getOffset();
|
||||
} else {
|
||||
opCode= ""; //$NON-NLS-1$
|
||||
funcOffset= ""; //$NON-NLS-1$
|
||||
}
|
||||
p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), opCode, instruction.getInstruction(), file, lineNumber);
|
||||
|
||||
BigInteger opCodes = null;
|
||||
if(instruction instanceof IInstructionWithRawOpcodes){
|
||||
opCodes = ((IInstructionWithRawOpcodes)instruction).getRawOpcodes();
|
||||
}
|
||||
|
||||
p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), funcOffset, opCodes, instruction.getInstruction(), file, lineNumber);
|
||||
if (p == null) {
|
||||
break;
|
||||
}
|
||||
|
@ -1162,6 +1178,7 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
|
|||
* @param addr the address
|
||||
* @param rm the data request monitor
|
||||
*/
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
void alignOpCodeAddress(final BigInteger addr, final DataRequestMonitor<BigInteger> rm) {
|
||||
IDisassembly2 disassembly = getService(IDisassembly2.class);
|
||||
if (disassembly == null) {
|
||||
|
@ -1170,9 +1187,8 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
|
|||
return;
|
||||
}
|
||||
|
||||
final DsfExecutor executor= DsfSession.getSession(fDsfSessionId).getExecutor();
|
||||
final IDisassemblyDMContext context = DMContexts.getAncestorOfType(fTargetContext, IDisassemblyDMContext.class);
|
||||
disassembly.alignOpCodeAddress(context, addr, new DataRequestMonitor<BigInteger>(executor, rm) {
|
||||
disassembly.alignOpCodeAddress(context, addr, new ImmediateDataRequestMonitor<BigInteger>(rm) {
|
||||
@Override
|
||||
protected void handleFailure() {
|
||||
rm.setData(addr);
|
||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
|
||||
Bundle-Version: 2.4.0.qualifier
|
||||
Bundle-Version: 2.5.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>2.4.0-SNAPSHOT</version>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.dsf</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2010, 2014 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,22 +7,34 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
* William Riley (Renesas) - Add raw Opcodes parsing (Bug 357270)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Implementers of {@link IInstruction} should extend this abstract class
|
||||
* instead of implementing the interface directly.
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
public abstract class AbstractInstruction implements IInstructionWithSize {
|
||||
public abstract class AbstractInstruction implements IInstructionWithSize, IInstructionWithRawOpcodes {
|
||||
/*
|
||||
* @see org.eclipse.cdt.dsf.debug.service.IInstructionWithSize#getSize()
|
||||
*/
|
||||
@Override
|
||||
public Integer getSize() {
|
||||
// unkown size
|
||||
// unknown size
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
*/
|
||||
@Override
|
||||
public BigInteger getRawOpcodes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/*****************************************************************
|
||||
* Copyright (c) 2014 Renesas Electronics and others
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* William Riley (Renesas) - Bug 357270
|
||||
*****************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
|
||||
/**
|
||||
* This interface extends the disassembly service with support for raw opcodes
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
*/
|
||||
public interface IDisassembly3 extends IDisassembly2 {
|
||||
|
||||
/**
|
||||
* Gets a block of disassembled code given an address range.
|
||||
*
|
||||
* @param context
|
||||
* Context of the disassembly code
|
||||
* @param startAddress
|
||||
* Beginning address, inclusive. If null, disassemble from the
|
||||
* instruction pointer.
|
||||
* @param endAddress
|
||||
* End address, exclusive. If null, implementation should attempt
|
||||
* to disassemble some reasonable, default number of
|
||||
* instructions. That default is implementation specific.
|
||||
* @param opCodes
|
||||
* If raw opcodes should be retrieved
|
||||
* @param drm
|
||||
* Disassembled code
|
||||
*/
|
||||
public void getInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress, boolean opCodes,
|
||||
DataRequestMonitor<IInstruction[]> drm);
|
||||
|
||||
/**
|
||||
* Gets a block of disassembled code given a filename, line number, and line
|
||||
* count.
|
||||
*
|
||||
* @param context
|
||||
* Context of the disassembly code
|
||||
* @param filename
|
||||
* File to disassemble
|
||||
* @param linenum
|
||||
* Starting point. 1-based line number within the file. If the
|
||||
* line does not represent compiled code, disassembly will start
|
||||
* at the first subsequent line that does.
|
||||
* @param instructionCount
|
||||
* Number of instructions to disassemble. -1 means all available
|
||||
* instructions (starting at [linenum])
|
||||
* @param opCodes
|
||||
* If raw opcodes should be retrieved
|
||||
*
|
||||
* @param drm
|
||||
* Disassembled code
|
||||
*/
|
||||
public void getInstructions(IDisassemblyDMContext context, String filename,
|
||||
int linenum, int instructionCount, boolean opCodes,
|
||||
DataRequestMonitor<IInstruction[]> drm);
|
||||
|
||||
/**
|
||||
* Gets a block of mixed disassembled code given an address range.
|
||||
*
|
||||
* @param context
|
||||
* Context of the disassembly code
|
||||
* @param startAddress
|
||||
* Beginning address, inclusive. If null, disassemble from the
|
||||
* instruction pointer.
|
||||
* @param endAddress
|
||||
* End address, exclusive.
|
||||
* @param opCodes
|
||||
* If opcodes should be retrieved
|
||||
* @param drm
|
||||
* Disassembled code
|
||||
*/
|
||||
public void getMixedInstructions(IDisassemblyDMContext context,
|
||||
BigInteger startAddress, BigInteger endAddress, boolean opCodes,
|
||||
DataRequestMonitor<IMixedInstruction[]> drm);
|
||||
|
||||
/**
|
||||
* Gets a block of mixed disassembled code given a filename, line number,
|
||||
* and line count.
|
||||
*
|
||||
* @param context
|
||||
* Context of the disassembly code
|
||||
* @param filename
|
||||
* File to disassemble
|
||||
* @param linenum
|
||||
* Starting point. 1-based line number within the file. If the
|
||||
* line does not represent compiled code, disassembly will start
|
||||
* at the first subsequent line that does.
|
||||
* @param instructionCount
|
||||
* Number of instructions to disassemble. -1 means all available
|
||||
* instructions (starting at [linenum])
|
||||
* @param opCodes
|
||||
* If opcodes should be retrieved
|
||||
* @param drm
|
||||
* Disassembled code
|
||||
*/
|
||||
public void getMixedInstructions(IDisassemblyDMContext context,
|
||||
String filename, int linenum, int instructionCount,
|
||||
boolean opCodes, DataRequestMonitor<IMixedInstruction[]> drm);
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Renesas Electronics and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* William Riley (Renesas) - Bug 357270
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Extension interface for instructions with raw Opcodes
|
||||
* <p>
|
||||
* Implementers must extend {@link AbstractInstruction} instead of implementing
|
||||
* this interface directly.
|
||||
* </p>
|
||||
*
|
||||
* @since 2.5
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
*/
|
||||
public interface IInstructionWithRawOpcodes extends IInstruction {
|
||||
|
||||
/**
|
||||
* @return The raw Opcodes of the Instruction or <code>null</code> if
|
||||
* unknown
|
||||
*/
|
||||
BigInteger getRawOpcodes();
|
||||
}
|
Loading…
Add table
Reference in a new issue