Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5498cdd0e40244d0dae04ff68bec4a4e3d559544 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Target Communication Framework Services - Disassembly</title>
</head>

<body lang='EN-US'>

<h1>Target Communication Framework Services - Disassembly</h1>

<ul>
    <li><a href='#VersionHistory'>Version History</a>
    <li><a href='#Overview'>Overview</a>
    <li><a href='#Cmds'>Commands</a>
    <ul>
        <li><a href='#CmdGetCapabilities'>Get Capabilities</a>
        <li><a href='#CmdDisassemble'>Disassemble</a>
    </ul>
    <li><a href='#API'>API</a>
</ul>

<h1>Disassembly Service</h1>

<h2><a name='VersionHistory'>Version History</a></h2>

<table border=1 cellpadding=8>
    <tr>
        <th>Version
        <th>Date
        <th>Change
    <tr>
        <td>0.1
        <td>2011-02-18
        <td>Initial contribution
</table>

<h2><a name='Overview'>Overview</a></h2>

<p>Disassembly is the translation of machine language (or memory bytes), into human readable assembly language.  The readable assembly language is produced from a specified Instruction Set Architecture (or ISA).</p>

<p>While disassembly is dependent upon a specific processor architecture, the memory from which it is derived is not.  So for a given memory context, or buffer, the specified ISA used to disassemble the memory bytes is subjective to the Tool or user.</p>

<p>The service uses standard format for error reports,
see <a href='TCF Services.html#ErrorFormat'>Error Report Format</a>.</p>

<h2><a name='Cmds'>Commands</a></h2>

<h3><a name='CmdDisassemble'>Disassemble</a></h3>

<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Disassembly &bull; disassemble &bull; <i>&lt;string: context-id&gt;</i> &bull; <i>&lt;int: start location&gt;</i> &bull; <i>&lt;int: size&gt;</i> &bull; <i>&lt;object: disassembly parameters&gt;</i> &bull;</font></b></pre>

<p> The command disassembles instruction code from a specified range of memory, in a specified context.<p>

<p>Where context-id is the memory context in which to process the command.</p>

<p>Predefined properties are:</p>
<ul>
    <li><code><b><font face="Courier New" size=2 color=#333399><a name='propISA'>"ISA"</a> : <i>&lt;string&gt;</i></font></b></code>
    - The name of the instruction set architecture.
    <li><code><b><font face="Courier New" size=2 color=#333399><a name='propSimplified'>"Simplified"</a> : <i>&lt;boolean&gt;</i></font></b></code>
    - If true, simplified mnemonics are specified.
    <li><code><b><font face="Courier New" size=2 color=#333399><a name='propPseudoInst'>"PseudoInstructions"</a> : <i>&lt;boolean&gt;</i></font></b></code>
    - If true, pseudo-instructions are requested.
    <li><code><b><font face="Courier New" size=2 color=#333399><a name='propOpcodeValue'>"OpcodeValue"</a> : <i>&lt;boolean&gt;</i></font></b></code>
    - If true, the instruction code byte values are returned.
</ul>

<p>Reply:</p>

<pre><b><font face="Courier New" size=2 color=#333399>
R &bull; <i>&lt;token&gt;</i> &bull; <i>&lt;error report&gt;</i> &bull; <i>&lt;array: disassembly output&gt;</i> &bull;

<i>&lt;array: disassembly output&gt;</i>
    &rArr; <i>&lt;null&gt;</i>
    &rArr; [ ]
    &rArr; [ <i>&lt;disassembly line list&gt;</i> ]

<i>&lt;disassembly line list&gt;</i>
    &rArr; <i>&lt;object: disassembly line&gt;</i>
    &rArr; <i>&lt;disassembly line list&gt;</i>, <i>&lt;object: disassembly line&gt;</i>
</font></b></pre>

<pre><b><font face="Courier New" size=2 color=#333399>
<i>&lt;object: disassembly line&gt;</i>
</font></b></pre>

<p>Disassembly line is an object containing properties. Predefined properties are:</p>

<ul>
    <li><code><b><font face="Courier New" size=2 color=#333399>"ISA" : <i>&lt;string&gt;</i></font></b></code>
    - Instruction Set Architecture of the disassembly line
    <li><code><b><font face="Courier New" size=2 color=#333399>"Address" : <i>&lt;int&gt;</i></font></b></code>
    - Address of the instruction
    <li><code><b><font face="Courier New" size=2 color=#333399>"Size" : <i>&lt;int&gt;</i></font></b></code>
    - Size of the instruction in bytes
    <li><code><b><font face="Courier New" size=2 color=#333399>"Instruction" : <i>&lt;array&gt;</i></font></b></code>
    - Array of the intruction fields
    <li><code><b><font face="Courier New" size=2 color=#333399>"OpcodeValue" : <i>&lt;string&gt;</i></font></b></code>
    - Encoded byte array of the instruction binary representation
</ul>

<pre><b><font face="Courier New" size=2 color=#333399>
<i>&lt;object: Instruction field&gt;</i>
</font></b></pre>

<p>Instruction field is an object containing properties.  Predefined properties are:</p>

<ul>
    <li><code><b><font face="Courier New" size=2 color=#333399>"Type" : <i>&lt;string&gt;</i></font></b></code>
    - The predefined type of the instruction field.  Predefined types are:
    <ul>
        <li>"String"
        <li>"Register"
        <li>"Address"
        <li>"Displacement"
        <li>"Immediate"
    </ul>
    <li><code><b><font face="Courier New" size=2 color=#333399>"Text" : <i>&lt;string&gt;</i></font></b></code>
    - Value of the field for "String" and "Register" types.
    <li><code><b><font face="Courier New" size=2 color=#333399>"Value" : <i>&lt;number&gt;</i></font></b></code>
    - Value of the field for "Address," "Displacement," or "Immediate" types.
    <li><code><b><font face="Courier New" size=2 color=#333399>"AddressSpace" : <i>&lt;context-id&gt;</i></font></b></code>
    - Context-ID of the address space used with the "Address" type.
</ul>


<p><b>Examples:</b></p>

<p>The following command requests disassembly at address <code>0x1000</code>, for 8 bytes, in memory context "mc1", using a generic PowerPC ISA, and requesting instruction code bytes:</p>

<pre><b><font face="Courier New" size=2 color=#333399>
C <i>&lt;token&gt;</i> Disassembly <i>disassemble "mc1" 0x1000 8 {ISA:PPC,OpcodeValue:true}</i>
</font></b></pre>

<h3><a name='CmdGetCapabilities'>Get Capabilities</a></h3>

<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Disassembly &bull; getCapabilities &bull; <i>&lt;string: context ID&gt;</i> &bull;
</font></b></pre>

<p>The command reports disassembly service capabilities to clients so they
can adjust to different implementations of the service.
The exact definition of context depends on the target agent and provided topology.</p>

<p>Reply:</p>

<pre><b><font face="Courier New" size=2 color=#333399>
R &bull; <i>&lt;token&gt;</i> &bull; <i>&lt;error report&gt;</i> &bull; <i>&lt;service capabilities&gt;</i> &bull;

<i>&lt;service capabilities&gt;</i>
    &rArr; <i>&lt;null&gt;</i>
    &rArr; <i>&lt;array: capabilities list&gt;</i>
</font></b></pre>

<p>Service capabilities consist of an array of lists of properties. All properties are optional.
Tools and targets can define additional properties. Predefined properties are:</p>

<ul>
    <li><code><b><font face="Courier New" size=2 color=#333399>"ISA" : <i>&lt;string&gt;</i></font></b></code>
    - The name of the supported instruction set architecture
    <li><code><b><font face="Courier New" size=2 color=#333399>"Simplified" : <i>&lt;boolean&gt;</i></font></b></code>
    - If true, simplified mnemonics are supported.  These are typical 1:1 correlation of architecture instruction to simplified mnemonic.
    <li><code><b><font face="Courier New" size=2 color=#333399>"PseudoInstruction" : <i>&lt;boolean&gt;</i></font></b></code>
    - If true, pseudo-instructions are supported.  These are typically macros, which correlate multiple architecture instructions to one pseudo-instruction.
    <li><code><b><font face="Courier New" size=2 color=#333399>"OpcodeValue" : <i>&lt;boolean&gt;</i></font></b></code>
    - If true, the decoded instruction code bytes are retrievable with the OpcodeValue parameter.
</ul>

<h2><a name='API'>API</a></h2>

<pre>
<font color=#3F5FBF>/**
 * TCF Disassembly service interface.
 */</font>
<font color=#7F0055>public interface</font> IDisassembly <font color=#7F0055>extends</font> IService {

    <font color=#3F5FBF>/**
     * Service name.
     */</font>
    <font color=#7F0055>static final</font> String NAME = "Disassembly";

    <font color=#7F0055>static final</font> String
        <font color=#3F5FBF>/** The name of the instruction set architecture, String */</font>
        CAPABILITY_ISA = "ISA",

        <font color=#3F5FBF>/** If true, simplified mnemonics are supported or requested, Boolean */</font>
        CAPABILITY_SIMPLIFIED = "Simplified",

        <font color=#3F5FBF>/** If true, pseudo-instructions are supported or requested, Boolean */</font>
        CAPABILITY_PSEUDO = "Pseudo",

        <font color=#3F5FBF>/** If true, instruction code bytes are supported or requested, Boolean */</font>
        CAPABILITY_OPCODE = "OpcodeValue";

    <font color=#3F5FBF>/**
     * 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.
     */</font>
    IToken getCapabilities(String context_id, DoneGetCapabilities done);

    <font color=#3F5FBF>/**
     * Call back interface for 'getCapabilities' command.
     */</font>
    <font color=#7F0055>interface</font> DoneGetCapabilities {
        <font color=#3F5FBF>/**
         * 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.
         */</font>
        <font color=#7F0055>void</font> doneGetCapabilities(IToken token, Throwable error, Map&lt;String,Object&gt;[] capabilities);
    }

    <font color=#3F5FBF>/**
     * 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.
     */</font>

    IToken disassemble(String context_id, Number addr, int size, Map&lt;String,Object&gt; params, DoneDisassemble done);

    <font color=#3F5FBF>/**
     * Call back interface for 'disassemble' command.
     */</font>
    <font color=#7F0055>interface</font> DoneDisassemble {
        <font color=#3F5FBF>/**
         * Called when disassembling is done.
         * @param token - command handle.
         * @param error - error object or null.
         * @param disassembly - array of disassembly lines.
         */</font>
        <font color=#7F0055>void</font> doneDisassemble(IToken token, Throwable error, IDisassemblyLine[] disassembly);
    }

    <font color=#3F5FBF>/**
     * Interface to represent a single disassembly line.
     */</font>
    <font color=#7F0055>interface</font> IDisassemblyLine {

        <font color=#3F5FBF>/**
         * @return instruction address.
         */</font>
        Number getAddress();

        <font color=#3F5FBF>/**
         * @return instruction size in bytes.
         */</font>
        <font color=#7F0055>int</font> getSize();

        <font color=#3F5FBF>/**
         * @return instruction binary representation.
         */</font>
        <font color=#7F0055>byte</font>[] getOpcodeValue();

        <font color=#3F5FBF>/**
         * @return array of instruction fields, each field is a collection of field properties, see FIELD_*.
         */</font>
        Map&lt;String,Object&gt;[] getInstruction();
    }

    <font color=#3F5FBF>/** Instruction field properties */</font>
    <font color=#7F0055>static final</font> String
        <font color=#3F5FBF>/** The type of the instruction field. See FTYPE_*, String. */</font>
        FIELD_TYPE = "Type",

        <font color=#3F5FBF>/** Value of the field for “String” and “Register” types, String. */</font>
        FIELD_TEXT = "Text",

        <font color=#3F5FBF>/** Value of the field for “Address,” “Displacement,” or “Immediate” types, Number. */</font>
        FIELD_VALUE = "Value",

        <font color=#3F5FBF>/** Context ID of the address space used with “Address” types, String. */</font>
        FIELD_ADDRESS_SPACE = "AddressSpace";

    <font color=#3F5FBF>/** Instruction field types */</font>
    <font color=#7F0055>static final</font> String
        FTYPE_STRING = "String",
        FTYPE_REGISTER = "Register",
        FTYPE_ADDRESS = "Address",
        FTYPE_DISPLACEMENT = "Displacement",
        FTYPE_IMMEDIATE = "Immediate";
}
</pre>

</body>
</html>

Back to the top