Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3b64c284337cb4878704fe28fdb52c1a1517020a (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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Target Communication Framework Services - Processes</title>
</head>

<body lang='EN-US'>
  
<h1>Target Communication Framework Services - Processes</h1>
 
<ul>
    <li><a href='#Cmds'>Commands</a>
    <ul>
        <li><a href='#CmdGetContext'>Get Context</a>
        <li><a href='#CmdGetChildren'>Get Children</a>
        <li><a href='#CmdAttach'>Attach</a>
        <li><a href='#CmdDetach'>Detach</a>
        <li><a href='#CmdTerminate'>Terminate</a>
        <li><a href='#CmdSignal'>Signal</a>
        <li><a href='#CmdStart'>Start</a>
    </ul>
    <li><a href='#Events'>Events</a>
    <li><a href='#API'>API</a>
</ul>

<h1>Processes Service</h1>

<p>Processes service provides access to the target OS's process 
information, allows to start and terminate a process, and allows
to attach and detach a process for debugging. Debug services,
like Memory and Run Control, require a process to be attached
before they can access it.</p>

<p>Command and event parameters are encoded
as zero terminated <a href='TCF Specification.html#JSON'>JSON</a> strings.</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='CmdGetContext'>Get Context</a></h3>
 
<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Processes &bull; getContext &bull; <i>&lt;string: context ID&gt;</i> &bull;
</font></b></pre>

<p>The command retrieves context info for given context ID.
A context corresponds to an execution thread, process, address space, etc.
Context IDs are valid across TCF services, so it is allowed to issue 'Processes.getContext'
command with a context that was obtained, for example, from Memory service.
However, 'Processes.getContext' is supposed to return only process specific data.
If the ID is not a process ID, 'Processes.getContext' may not return any
useful information.
</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;context data&gt;</i> &bull;

<i>&lt;context data&gt;</i>
    &rArr; null
    &rArr; <i>&lt;object&gt;</i>
</font></b></pre>

<p>Context data object should, at least, contain member
<b><font face="Courier New" size=2 color=#333399>"ID" : <i>&lt;string&gt;.</i></font></b>
</p>

<p>Predefined process context properties are:</p>
<ul>
    <li><code><b><font face="Courier New" size=2 color=#333399>"ID" : <i>&lt;string&gt;</i></font></b></code>
    - ID of the context, same as getContext command argument.

    <li><code><b><font face="Courier New" size=2 color=#333399>"ParentID" : <i>&lt;string&gt;</i></font></b></code>
    - parent context ID.
        
    <li><code><b><font face="Courier New" size=2 color=#333399>"Name" : <i>&lt;string&gt;</i></font></b></code>
    - process name. Client UI can show this name to a user.

    <li><code><b><font face="Courier New" size=2 color=#333399>"Attached" : <i>&lt;boolean&gt;</i></font></b></code>
    - true if the context is attached to debugger.
        
    <li><code><b><font face="Courier New" size=2 color=#333399>"CanTerminate" : <i>&lt;boolean&gt;</i></font></b></code>
    - true if the service can terminate the process.
</ul>

<h3><a name='CmdGetChildren'>Get Children</a></h3>
 
<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Processes &bull; getChildren &bull; <i>&lt;string: parent context ID&gt;</i> &bull;
</font></b></pre>

<p>The command requests a list of contexts available for process control commands.</p>
 
<p>Parent context ID can be null &ndash; to retrieve top level of the hierarchy, can be one
of context IDs retrieved by previous getChildren commands, or it can be obtained from another service.
Contexts hierarchy can be simple plain list or it can form a tree. It is up to target agent developers to
choose layout that is most descriptive for a given target.</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;array of context IDs&gt;</i> &bull;

<i>&lt;array of context IDs&gt;</i>
    &rArr; null
    &rArr; [ ]
    &rArr; [ <i>&lt;context ID list&gt;</i> ]
  
<i>&lt;context ID list&gt;</i>
    &rArr; <i>&lt;string: context ID&gt;</i>
    &rArr; <i>&lt;context ID list&gt;</i> , <i>&lt;string: context ID&gt;</i>
</font></b></pre>

<h3><a name='CmdAttach'>Attach</a></h3>
 
<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Processes &bull; attach &bull; <i>&lt;string: context ID&gt;</i> &bull;
</font></b></pre>

<p>The command attaches debugger to a process.
Services like Run Control, Memory, Breakpoints work only with attached processes.</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;
</font></b></pre>

<h3><a name='CmdDetach'>Detach</a></h3>
 
<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Processes &bull; detach &bull; <i>&lt;string: context ID&gt;</i> &bull;
</font></b></pre>

<p>The command detaches debugger from a process.</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;
</font></b></pre>

<h3><a name='CmdTerminate'>Terminate</a></h3>
 
<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Processes &bull; terminate &bull; <i>&lt;string: context ID&gt;</i> &bull;
</font></b></pre>

<p>The command terminates a process.</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;
</font></b></pre>

<h3><a name='CmdSignal'>Signal</a></h3>
 
<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Processes &bull; signal &bull; <i>&lt;string: context ID&gt;</i> &bull; <i>&lt;int: signal&gt;</i> &bull;
</font></b></pre>

<p>The command sends a signal to a process.</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;
</font></b></pre>

<h3><a name='CmdStart'>Start</a></h3>
 
<pre><b><font face="Courier New" size=2 color=#333399>
C &bull; <i>&lt;token&gt;</i> &bull; Processes &bull; start &bull; <i>&lt;string: working directory&gt;</i> &bull; <i>&lt;string: program image file&gt;</i> &bull;
    <i>&lt;string array: command line&gt;</i> &bull; <i>&lt;string array: environment variables&gt;</i> &bull; <i>&lt;boolean: attach&gt;</i> &bull;

<i>&lt;string array&gt;</i>
    &rArr; null
    &rArr; [ ]
    &rArr; [ <i>&lt;string list&gt;</i> ]
  
<i>&lt;string list&gt;</i>
    &rArr; <i>&lt;string&gt;</i>
    &rArr; <i>&lt;string list&gt;</i> , <i>&lt;string&gt;</i>
</font></b></pre>

<p>The command starts a new process on remote machine.
<i>&lt;string: working directory&gt;</i> - initial value of working directory for the process.
<i>&lt;string: program image file&gt;</i> - image file to start process with.
<i>&lt;string array: command line&gt;</i> - command line arguments for the process.
<i>&lt;string array: environment variables&gt;</i> - list of environment variables for the process,
they will be added to default process environment. 
<i>&lt;boolean: attach&gt;</i> - if true debugger should be attached to the process.</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;context data&gt;</i> &bull;
</font></b></pre>

<p>On success the command returns context data for created process. Context data has same format as Get Context result.</p>

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

<p>No events are currently defined for Processes service.</p>

<h2><a name='API'>API</a></h2>
 
<pre>
<font color=#7F0055>public interface</font> IProcesses <font color=#7F0055>extends</font> IService {

    <font color=#7F0055>static final</font> String NAME = "Processes";
    
    <font color=#3F5FBF>/**
     * Retrieve context info for given context ID.
     * A context corresponds to an execution thread, process, address space, etc.
     * Context IDs are valid across TCF services, so it is allowed to issue
     * 'IProcesses.getContext' command with a context that was obtained,
     * for example, from Memory service.
     * However, 'Processes.getContext' is supposed to return only process specific data,
     * If the ID is not a process ID, 'IProcesses.getContext' may not return any
     * useful information
     *    
     * <font color=#7F9FBF><font color=#7F9FBF>@param</font></font> id &ndash; context ID. 
     * <font color=#7F9FBF><font color=#7F9FBF>@param</font></font> done - call back interface called when operation is completed.
     */</font>
    IToken getContext(String id, DoneGetContext done);

    <font color=#3F5FBF>/**
     * Client call back interface for getContext().
     */</font>
    <font color=#7F0055>interface</font> DoneGetContext {
        <font color=#3F5FBF>/**
         * Called when contexts data retrieval is done.
         * <font color=#7F9FBF>@param</font> error &ndash; error description if operation failed, null if succeeded.
         * <font color=#7F9FBF>@param</font> context &ndash; context data.
         */</font>
        <font color=#7F0055>void</font> doneGetContext(IToken token, Exception error, ProcessContext context);
    }

    <font color=#3F5FBF>/**
     * Retrieve children of given context.
     *   
     * <font color=#7F9FBF>@param</font> parent_context_id &ndash; parent context ID. Can be null &ndash;
     * to retrieve top level of the hierarchy, or one of context IDs retrieved
     * by previous getContext or getChildren commands. 
     * <font color=#7F9FBF>@param</font> done - call back interface called when operation is completed.
     */</font>
    IToken getChildren(String parent_context_id, <font color=#7F0055>boolean</font> attached_only, DoneGetChildren done);

    <font color=#3F5FBF>/**
     * Client call back interface for getChildren().
     */</font>
    <font color=#7F0055>interface</font> DoneGetChildren {
        <font color=#3F5FBF>/**
         * Called when contexts data retrieval is done.
         * <font color=#7F9FBF>@param</font> error &ndash; error description if operation failed, null if succeeded.
         * <font color=#7F9FBF>@param</font> context_ids &ndash; array of available context IDs.
         */</font>
        <font color=#7F0055>void</font> doneGetChildren(IToken token, Exception error, String[] context_ids);
    }
    
    <font color=#3F5FBF>/**
     * Context property names.
     */</font>
    <font color=#7F0055>static final</font> String
        <font color=#3F5FBF>/** The TCF context ID */</font>
        PROP_ID = "ID",
        
        <font color=#3F5FBF>/** The TCF parent context ID */</font>
        PROP_PARENTID = "ParentID",
        
        <font color=#3F5FBF>/** Is the context attached */</font>
        PROP_ATTACHED = "Attached",
        
        <font color=#3F5FBF>/** Can terminate the context */</font>
        PROP_CAN_TERMINATE = "CanTerminate",
        
        <font color=#3F5FBF>/** Process name. Client UI can show this name to a user */</font>
        PROP_NAME = "Name";
    
    <font color=#7F0055>interface</font> ProcessContext {
        
        <font color=#3F5FBF>/** 
         * Get context ID.
         * Same as getProperties().get(&ldquo;ID&rdquo;)
         */</font>
        String getID();

        <font color=#3F5FBF>/**
         * Get parent context ID.
         * Same as getProperties().get(&ldquo;ParentID&rdquo;)
         */</font>
        String getParentID();

        <font color=#3F5FBF>/**
         * Get process name.
         * Client UI can show this name to a user.
         * Same as getProperties().get(&ldquo;Name&rdquo;)
         */</font>
        String getName();

        <font color=#3F5FBF>/**
         * Utility method to read context property PROP_ATTACHED.
         * Services like IRunControl, IMemory, IBreakpoints work only with attached processes.
         * <font color=#7F9FBF><font color=#7F9FBF>@return</font></font> value of PROP_ATTACHED.
         */</font>
        <font color=#7F0055>boolean</font> isAttached();

        <font color=#3F5FBF>/**
         * Utility method to read context property PROP_CAN_TERMINATE.
         * <font color=#7F9FBF><font color=#7F9FBF>@return</font></font> value of PROP_CAN_TERMINATE.
         */</font>
        <font color=#7F0055>boolean</font> canTerminate();

        <font color=#3F5FBF>/**
         * Get all available context properties.
         * <font color=#7F9FBF>@return</font> Map 'property name' -> 'property value'
         */</font>
        Map&lt;String, Object&gt; getProperties();
        
        <font color=#3F5FBF>/**
         * Attach debugger to a process.
         * Services like IRunControl, IMemory, IBreakpoints work only with attached processes.
         * <font color=#7F9FBF>@param</font> done - call back interface called when operation is completed.
         * <font color=#7F9FBF>@return</font> pending command handle, can be used to cancel the command.
         */</font>
        IToken attach(DoneCommand done);

        <font color=#3F5FBF>/**
         * Detach debugger from a process.
         * Process execution will continue without debugger supervision.
         * <font color=#7F9FBF>@param</font> done - call back interface called when operation is completed.
         * <font color=#7F9FBF>@return</font> pending command handle, can be used to cancel the command.
         */</font>
        IToken detach(DoneCommand done);
        
        <font color=#3F5FBF>/**
         * Terminate a process. 
         * <font color=#7F9FBF>@param</font> done - call back interface called when operation is completed.
         * <font color=#7F9FBF>@return</font> pending command handle, can be used to cancel the command.
         */</font>
        IToken terminate(DoneCommand done);
    
        <font color=#3F5FBF>/**
         * Send a signal to a process.
         * <font color=#7F9FBF>@param</font> signal - signal ID.
         * <font color=#7F9FBF>@param</font> done - call back interface called when operation is completed.
         * <font color=#7F9FBF>@return</font> pending command handle, can be used to cancel the command.
         */</font>
        IToken signal(<font color=#7F0055>int</font> signal, DoneCommand done);
    }
    
    <font color=#7F0055>interface</font> DoneCommand {
        <font color=#7F0055>void</font> doneCommand(IToken token, Exception error);
    }

    <font color=#3F5FBF>/**
     * Start a new process on remote machine.
     * <font color=#7F9FBF>@param</font> directory - initial value of working directory for the process.
     * <font color=#7F9FBF>@param</font> file - process image file.
     * <font color=#7F9FBF>@param</font> command_line - command line arguments for the process.
     * <font color=#7F9FBF>@param</font> environment - list of environment variables for the process. 
     * <font color=#7F9FBF>@param</font> attach - if true debugger should be attached to the process.
     * <font color=#7F9FBF>@param</font> done - call back interface called when operation is completed.
     * <font color=#7F9FBF>@return</font> pending command handle, can be used to cancel the command.
     */</font>
    IToken start(String directory, String file,
            String[] command_line, String[] environment, <font color=#7F0055>boolean</font> attach, DoneStart done);
    
    <font color=#7F0055>interface</font> DoneStart {
        <font color=#7F0055>void</font> doneStart(IToken token, Exception error, ProcessContext process);
    }
}
</pre>

</body>
</html>

Back to the top