diff options
author | eutarass | 2010-09-15 18:36:33 +0000 |
---|---|---|
committer | eutarass | 2010-09-15 18:36:33 +0000 |
commit | 2a3db3cd89a256db4c71cbdd6f6c62d74bfbe931 (patch) | |
tree | 21b13de8749d3c07dfde7f247812013c680f8c95 | |
parent | 69593e807c8dc0dc300648cf7d4a6921dca9648e (diff) | |
download | org.eclipse.tcf-2a3db3cd89a256db4c71cbdd6f6c62d74bfbe931.tar.gz org.eclipse.tcf-2a3db3cd89a256db4c71cbdd6f6c62d74bfbe931.tar.xz org.eclipse.tcf-2a3db3cd89a256db4c71cbdd6f6c62d74bfbe931.zip |
Created interfaces for TCF Disassembly service.
2 files changed, 233 insertions, 0 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DisassemblyProxy.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DisassemblyProxy.java new file mode 100644 index 000000000..fcd8dbba3 --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/DisassemblyProxy.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2010 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.tcf.services.remote; + +import java.util.Collection; +import java.util.Map; + +import org.eclipse.tm.tcf.core.Command; +import org.eclipse.tm.tcf.protocol.IChannel; +import org.eclipse.tm.tcf.protocol.IToken; +import org.eclipse.tm.tcf.services.IDisassembly; + +public class DisassemblyProxy implements IDisassembly { + + private final IChannel channel; + + private static class DisassemblyLine implements IDisassemblyLine { + + final Number addr; + final int size; + final Map<String,Object>[] instruction; + + @SuppressWarnings("unchecked") + DisassemblyLine(Map<String,Object> m) { + addr = (Number)m.get("Address"); + Number size = (Number)m.get("Size"); + this.size = size != null ? size.intValue() : 0; + Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)m.get("Instruction"); + instruction = c.toArray(new Map[c.size()]); + } + + public Number getAddress() { + return addr; + } + + public int getSize() { + return size; + } + + public Map<String,Object>[] getInstruction() { + return instruction; + } + } + + public DisassemblyProxy(IChannel channel) { + this.channel = channel; + } + + public String getName() { + return NAME; + } + + public IToken getCapabilities(String context_id, final DoneGetCapabilities done) { + return new Command(channel, this, "getCapabilities", new Object[]{ context_id }) { + @Override + public void done(Exception error, Object[] args) { + Map<String,Object>[] arr = null; + if (error == null) { + assert args.length == 2; + error = toError(args[0]); + arr = toCapabilitiesArray(args[1]); + } + done.doneGetCapabilities(token, error, arr); + } + }.token; + } + + public IToken disassemble(String context_id, Number addr, int size, Map<String, Object> params, final DoneDisassemble done) { + return new Command(channel, this, "disassemble", new Object[]{ context_id, addr, size, params }) { + @Override + public void done(Exception error, Object[] args) { + IDisassemblyLine[] arr = null; + if (error == null) { + assert args.length == 2; + error = toError(args[0]); + arr = toDisassemblyArray(args[1]); + } + done.doneDisassemble(token, error, arr); + } + }.token; + } + + @SuppressWarnings("unchecked") + private static Map<String,Object>[] toCapabilitiesArray(Object o) { + if (o == null) return null; + Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o; + return (Map<String,Object>[])c.toArray(new Map[c.size()]); + } + + @SuppressWarnings("unchecked") + private static IDisassemblyLine[] toDisassemblyArray(Object o) { + if (o == null) return null; + Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o; + IDisassemblyLine[] arr = new IDisassemblyLine[c.size()]; + int i = 0; + for (Map<String,Object> m : c) { + arr[i++] = new DisassemblyLine(m); + } + return arr; + } +} diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDisassembly.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDisassembly.java new file mode 100644 index 000000000..3e195140a --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IDisassembly.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2010 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.tcf.services; + +import java.util.Map; + +import org.eclipse.tm.tcf.protocol.IService; +import org.eclipse.tm.tcf.protocol.IToken; + +/** + * TCF Disassembly service interface. + */ + +public interface IDisassembly extends IService { + + static final String NAME = "Disassembly"; + + static final String + /** The name of the instruction set architecture, String */ + CAPABILITY_ISA = "ISA", + + /** If true, simplified mnemonics are supported or requested, Boolean */ + CAPABILITY_SIMPLIFIED = "Simplified", + + /** If true, pseudo-instructions are supported or requested, Boolean */ + CAPABILITY_PSEUDO = "Pseudo"; + + /** + * Retrieve disassembly service capabilities a given context-id. + * @param context_id - a context ID, usually one returned by Run Control or Memory services. + * @param done - command result call back object. + * @return - pending command handle. + */ + IToken getCapabilities(String context_id, DoneGetCapabilities done); + + /** + * Call back interface for 'getCapabilities' command. + */ + interface DoneGetCapabilities { + /** + * Called when capabilities retrieval is done. + * @param token - command handle. + * @param error - error object or null. + * @param capabilities - array of capabilities, see CAPABILITY_* for contents of each array element. + */ + void doneGetCapabilities(IToken token, Throwable error, Map<String,Object>[] capabilities); + } + + /** + * Disassemble instruction code from a specified range of memory addresses, in a specified context. + * @param context_id - a context ID, usually one returned by Run Control or Memory services. + * @param addr - address of first instruction to disassemble. + * @param size - size in bytes of the address range. + * @param params - properties to control the disassembly output, an element of capabilities array, see getCapabilities. + * @param done - command result call back object. + * @return - pending command handle. + */ + IToken disassemble(String context_id, Number addr, int size, Map<String,Object> params, DoneDisassemble done); + + /** + * Call back interface for 'disassemble' command. + */ + interface DoneDisassemble { + /** + * Called when disassembling is done. + * @param token - command handle. + * @param error - error object or null. + * @param disassembly - array of disassembly lines. + */ + void doneDisassemble(IToken token, Throwable error, IDisassemblyLine[] disassembly); + } + + /** + * Interface to represent a single disassembly line. + */ + interface IDisassemblyLine { + + /** + * @return instruction address. + */ + Number getAddress(); + + /** + * @return instruction size in bytes. + */ + int getSize(); + + /** + * @return array of instruction fields, each field is a collection of field properties, see FIELD_*. + */ + Map<String,Object>[] getInstruction(); + } + + /** Instruction field properties */ + static final String + /** The type of the instruction field. See FTYPE_*, String. */ + FIELD_TYPE = "Type", + + /** Value of the field for “String” and “Register” types, String. */ + FIELD_TEXT = "Text", + + /** Value of the field for “Address,” “Displacement,” or “Immediate” types, Number. */ + FIELD_VALUE = "Value", + + /** Context ID of the address space used with “Address” types, String. */ + FIELD_ADDRESS_SPACE = "AddressSpace"; + + /** Instruction field types */ + static final String + FTYPE_STRING = "String", + FTYPE_Register = "Register", + FTYPE_ADDRESS = "Address", + FTYPE_DISPLACEMENT = "Displacement", + FTYPE_IMMEDIATE = "Immediate"; + +} |