Subversion Repositories HelenOS

Rev

Rev 3454 | Rev 3470 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3454 Rev 3455
1
/*
1
/*
2
 * Copyright (c) 2008 Jiri Svoboda
2
 * Copyright (c) 2008 Jiri Svoboda
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup trace
29
/** @addtogroup trace
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <stdio.h>
35
#include <stdio.h>
36
#include <stdlib.h>
36
#include <stdlib.h>
37
#include <unistd.h>
37
#include <unistd.h>
38
#include <syscall.h>
38
#include <syscall.h>
39
#include <ipc/ipc.h>
39
#include <ipc/ipc.h>
40
#include <fibril.h>
40
#include <fibril.h>
41
#include <errno.h>
41
#include <errno.h>
42
#include <udebug.h>
42
#include <udebug.h>
43
#include <async.h>
43
#include <async.h>
44
#include <task.h>
44
#include <task.h>
45
 
45
 
46
// Temporary: service and method names
46
// Temporary: service and method names
47
#include "proto.h"
47
#include "proto.h"
48
#include <ipc/services.h>
48
#include <ipc/services.h>
49
#include "../../srv/vfs/vfs.h"
49
#include "../../srv/vfs/vfs.h"
50
#include "../../srv/console/console.h"
50
#include "../../srv/console/console.h"
51
 
51
 
52
#include "syscalls.h"
52
#include "syscalls.h"
53
#include "ipcp.h"
53
#include "ipcp.h"
54
#include "errors.h"
54
#include "errors.h"
55
#include "trace.h"
55
#include "trace.h"
56
 
56
 
57
#define THBUF_SIZE 64
57
#define THBUF_SIZE 64
58
uintptr_t thread_hash_buf[THBUF_SIZE];
58
uintptr_t thread_hash_buf[THBUF_SIZE];
59
int n_threads;
59
int n_threads;
60
 
60
 
61
int next_thread_id;
61
int next_thread_id;
62
 
62
 
63
int phoneid;
63
int phoneid;
64
int abort_trace;
64
int abort_trace;
65
 
65
 
66
uintptr_t thash;
66
uintptr_t thash;
67
volatile int paused;
67
volatile int paused;
68
 
68
 
69
void thread_trace_start(uintptr_t thread_hash);
69
void thread_trace_start(uintptr_t thread_hash);
70
 
70
 
71
static proto_t *proto_console;
71
static proto_t *proto_console;
72
static task_id_t task_id;
72
static task_id_t task_id;
73
 
73
 
74
/** Combination of events/data to print. */
74
/** Combination of events/data to print. */
75
display_mask_t display_mask;
75
display_mask_t display_mask;
76
 
76
 
77
static int task_connect(task_id_t task_id)
77
static int task_connect(task_id_t task_id)
78
{
78
{
79
    int rc;
79
    int rc;
80
 
80
 
81
    rc = ipc_connect_kbox(task_id);
81
    rc = ipc_connect_kbox(task_id);
82
 
82
 
83
    if (rc == ENOTSUP) {
83
    if (rc == ENOTSUP) {
84
        printf("You do not have userspace debugging support "
84
        printf("You do not have userspace debugging support "
85
            "compiled in the kernel.\n");
85
            "compiled in the kernel.\n");
86
        printf("Compile kernel with 'Support for userspace debuggers' "
86
        printf("Compile kernel with 'Support for userspace debuggers' "
87
            "(CONFIG_UDEBUG) enabled.\n");
87
            "(CONFIG_UDEBUG) enabled.\n");
88
        return rc;
88
        return rc;
89
    }
89
    }
90
 
90
 
91
    if (rc < 0) {
91
    if (rc < 0) {
92
        printf("Error connecting\n");
92
        printf("Error connecting\n");
93
        printf("ipc_connect_task(%lld) -> %d ", task_id, rc);
93
        printf("ipc_connect_task(%lld) -> %d ", task_id, rc);
94
        return rc;
94
        return rc;
95
    }
95
    }
96
 
96
 
97
    phoneid = rc;
97
    phoneid = rc;
98
 
98
 
99
    rc = udebug_begin(phoneid);
99
    rc = udebug_begin(phoneid);
100
    if (rc < 0) {
100
    if (rc < 0) {
101
        printf("udebug_begin() -> %d\n", rc);
101
        printf("udebug_begin() -> %d\n", rc);
102
        return rc;
102
        return rc;
103
    }
103
    }
104
 
104
 
105
    rc = udebug_set_evmask(phoneid, UDEBUG_EM_ALL);
105
    rc = udebug_set_evmask(phoneid, UDEBUG_EM_ALL);
106
    if (rc < 0) {
106
    if (rc < 0) {
107
        printf("udebug_set_evmask(0x%x) -> %d\n ", UDEBUG_EM_ALL, rc);
107
        printf("udebug_set_evmask(0x%x) -> %d\n ", UDEBUG_EM_ALL, rc);
108
        return rc;
108
        return rc;
109
    }
109
    }
110
 
110
 
111
    return 0;
111
    return 0;
112
}
112
}
113
 
113
 
114
static int get_thread_list(void)
114
static int get_thread_list(void)
115
{
115
{
116
    int rc;
116
    int rc;
117
    size_t tb_copied;
117
    size_t tb_copied;
118
    size_t tb_needed;
118
    size_t tb_needed;
119
    int i;
119
    int i;
120
 
120
 
121
    rc = udebug_thread_read(phoneid, thread_hash_buf,
121
    rc = udebug_thread_read(phoneid, thread_hash_buf,
122
        THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed);
122
        THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed);
123
    if (rc < 0) {
123
    if (rc < 0) {
124
        printf("udebug_thread_read() -> %d\n", rc);
124
        printf("udebug_thread_read() -> %d\n", rc);
125
        return rc;
125
        return rc;
126
    }
126
    }
127
 
127
 
128
    n_threads = tb_copied / sizeof(uintptr_t);
128
    n_threads = tb_copied / sizeof(uintptr_t);
129
 
129
 
130
    printf("Threads:");
130
    printf("Threads:");
131
    for (i = 0; i < n_threads; i++) {
131
    for (i = 0; i < n_threads; i++) {
132
        printf(" [%d] (hash 0x%lx)", 1+i, thread_hash_buf[i]);
132
        printf(" [%d] (hash 0x%lx)", 1+i, thread_hash_buf[i]);
133
    }
133
    }
134
    printf("\ntotal of %u threads\n", tb_needed / sizeof(uintptr_t));
134
    printf("\ntotal of %u threads\n", tb_needed / sizeof(uintptr_t));
135
 
135
 
136
    return 0;
136
    return 0;
137
}
137
}
138
 
138
 
139
void val_print(int val, val_type_t v_type)
139
void val_print(sysarg_t val, val_type_t v_type)
140
{
140
{
141
    switch (v_type) {
141
    switch (v_type) {
142
    case V_VOID:
142
    case V_VOID:
143
        printf("<void>");
143
        printf("<void>");
144
        break;
144
        break;
145
 
145
 
146
    case V_INTEGER:
146
    case V_INTEGER:
147
        printf("%d", val);
147
        printf("%ld", val);
148
        break;
148
        break;
149
 
149
 
150
    case V_HASH:
150
    case V_HASH:
151
        printf("0x%08x", val);
151
        printf("0x%08lx", val);
152
        break;
152
        break;
153
 
153
 
154
    case V_ERRNO:
154
    case V_ERRNO:
155
        if (val >= -15 && val <= 0) {
155
        if (val >= -15 && val <= 0) {
156
            printf("%d %s (%s)", val,
156
            printf("%ld %s (%s)", val,
157
                err_desc[-val].name,
157
                err_desc[-val].name,
158
                err_desc[-val].desc);
158
                err_desc[-val].desc);
159
        } else {
159
        } else {
160
            printf("%d", val);
160
            printf("%ld", val);
161
        }
161
        }
162
        break;
162
        break;
163
    case V_INT_ERRNO:
163
    case V_INT_ERRNO:
164
        if (val >= -15 && val < 0) {
164
        if (val >= -15 && val < 0) {
165
            printf("%d %s (%s)", val,
165
            printf("%ld %s (%s)", val,
166
                err_desc[-val].name,
166
                err_desc[-val].name,
167
                err_desc[-val].desc);
167
                err_desc[-val].desc);
168
        } else {
168
        } else {
169
            printf("%d", val);
169
            printf("%ld", val);
170
        }
170
        }
171
        break;
171
        break;
172
 
172
 
173
    case V_CHAR:
173
    case V_CHAR:
174
        if (val >= 0x20 && val < 0x7f) {
174
        if (val >= 0x20 && val < 0x7f) {
175
            printf("'%c'", val);
175
            printf("'%c'", val);
176
        } else {
176
        } else {
177
            switch (val) {
177
            switch (val) {
178
            case '\a': printf("'\\a'"); break;
178
            case '\a': printf("'\\a'"); break;
179
            case '\b': printf("'\\b'"); break;
179
            case '\b': printf("'\\b'"); break;
180
            case '\n': printf("'\\n'"); break;
180
            case '\n': printf("'\\n'"); break;
181
            case '\r': printf("'\\r'"); break;
181
            case '\r': printf("'\\r'"); break;
182
            case '\t': printf("'\\t'"); break;
182
            case '\t': printf("'\\t'"); break;
183
            case '\\': printf("'\\\\'"); break;
183
            case '\\': printf("'\\\\'"); break;
184
            default: printf("'\\x%X'"); break;
184
            default: printf("'\\x%02lX'", val); break;
185
            }
185
            }
186
        }
186
        }
187
        break;
187
        break;
188
    }
188
    }
189
}
189
}
190
 
190
 
191
 
191
 
192
static void print_sc_retval(int retval, val_type_t val_type)
192
static void print_sc_retval(sysarg_t retval, val_type_t val_type)
193
{
193
{
194
    printf(" -> ");
194
    printf(" -> ");
195
    val_print(retval, val_type);
195
    val_print(retval, val_type);
196
    putchar('\n');
196
    putchar('\n');
197
}
197
}
198
 
198
 
199
static void print_sc_args(sysarg_t *sc_args, int n)
199
static void print_sc_args(sysarg_t *sc_args, int n)
200
{
200
{
201
    int i;
201
    int i;
202
 
202
 
203
    putchar('(');
203
    putchar('(');
204
    if (n > 0) printf("%ld", sc_args[0]);
204
    if (n > 0) printf("%ld", sc_args[0]);
205
    for (i = 1; i < n; i++) {
205
    for (i = 1; i < n; i++) {
206
        printf(", %ld", sc_args[i]);
206
        printf(", %ld", sc_args[i]);
207
    }
207
    }
208
    putchar(')');
208
    putchar(')');
209
}
209
}
210
 
210
 
211
static void sc_ipc_call_async_fast(sysarg_t *sc_args, sysarg_t sc_rc)
211
static void sc_ipc_call_async_fast(sysarg_t *sc_args, sysarg_t sc_rc)
212
{
212
{
213
    ipc_call_t call;
213
    ipc_call_t call;
214
    ipcarg_t phoneid;
214
    ipcarg_t phoneid;
215
   
215
   
216
    if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY)
216
    if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY)
217
        return;
217
        return;
218
 
218
 
219
    phoneid = sc_args[0];
219
    phoneid = sc_args[0];
220
 
220
 
221
    IPC_SET_METHOD(call, sc_args[1]);
221
    IPC_SET_METHOD(call, sc_args[1]);
222
    IPC_SET_ARG1(call, sc_args[2]);
222
    IPC_SET_ARG1(call, sc_args[2]);
223
    IPC_SET_ARG2(call, sc_args[3]);
223
    IPC_SET_ARG2(call, sc_args[3]);
224
    IPC_SET_ARG3(call, sc_args[4]);
224
    IPC_SET_ARG3(call, sc_args[4]);
225
    IPC_SET_ARG4(call, sc_args[5]);
225
    IPC_SET_ARG4(call, sc_args[5]);
226
    IPC_SET_ARG5(call, 0);
226
    IPC_SET_ARG5(call, 0);
227
 
227
 
228
    ipcp_call_out(phoneid, &call, sc_rc);
228
    ipcp_call_out(phoneid, &call, sc_rc);
229
}
229
}
230
 
230
 
231
static void sc_ipc_call_async_slow(sysarg_t *sc_args, sysarg_t sc_rc)
231
static void sc_ipc_call_async_slow(sysarg_t *sc_args, sysarg_t sc_rc)
232
{
232
{
233
    ipc_call_t call;
233
    ipc_call_t call;
234
    int rc;
234
    int rc;
235
 
235
 
236
    if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY)
236
    if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY)
237
        return;
237
        return;
238
 
238
 
239
    memset(&call, 0, sizeof(call));
239
    memset(&call, 0, sizeof(call));
240
    rc = udebug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args));
240
    rc = udebug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args));
241
 
241
 
242
    if (rc >= 0) {
242
    if (rc >= 0) {
243
        ipcp_call_out(sc_args[0], &call, sc_rc);
243
        ipcp_call_out(sc_args[0], &call, sc_rc);
244
    }
244
    }
245
}
245
}
246
 
246
 
247
static void sc_ipc_call_sync_fast(sysarg_t *sc_args)
247
static void sc_ipc_call_sync_fast(sysarg_t *sc_args)
248
{
248
{
249
    ipc_call_t question, reply;
249
    ipc_call_t question, reply;
250
    int rc;
250
    int rc;
251
    int phoneidx;
251
    int phoneidx;
252
 
252
 
253
//  printf("sc_ipc_call_sync_fast()\n");
253
//  printf("sc_ipc_call_sync_fast()\n");
254
    phoneidx = sc_args[0];
254
    phoneidx = sc_args[0];
255
 
255
 
256
    IPC_SET_METHOD(question, sc_args[1]);
256
    IPC_SET_METHOD(question, sc_args[1]);
257
    IPC_SET_ARG1(question, sc_args[2]);
257
    IPC_SET_ARG1(question, sc_args[2]);
258
    IPC_SET_ARG2(question, sc_args[3]);
258
    IPC_SET_ARG2(question, sc_args[3]);
259
    IPC_SET_ARG3(question, sc_args[4]);
259
    IPC_SET_ARG3(question, sc_args[4]);
260
    IPC_SET_ARG4(question, 0);
260
    IPC_SET_ARG4(question, 0);
261
    IPC_SET_ARG5(question, 0);
261
    IPC_SET_ARG5(question, 0);
262
 
262
 
263
//  printf("memset\n");
263
//  printf("memset\n");
264
    memset(&reply, 0, sizeof(reply));
264
    memset(&reply, 0, sizeof(reply));
265
//  printf("udebug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n",
265
//  printf("udebug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n",
266
//      phoneid, &reply.args, sc_args[5], sizeof(reply.args));
266
//      phoneid, &reply.args, sc_args[5], sizeof(reply.args));
267
    rc = udebug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args));
267
    rc = udebug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args));
268
//  printf("dmr->%d\n", rc);
268
//  printf("dmr->%d\n", rc);
269
    if (rc < 0) return;
269
    if (rc < 0) return;
270
 
270
 
271
//  printf("call ipc_call_sync\n");
271
//  printf("call ipc_call_sync\n");
272
    ipcp_call_sync(phoneidx, &question, &reply);
272
    ipcp_call_sync(phoneidx, &question, &reply);
273
}
273
}
274
 
274
 
275
static void sc_ipc_call_sync_slow(sysarg_t *sc_args)
275
static void sc_ipc_call_sync_slow(sysarg_t *sc_args)
276
{
276
{
277
    ipc_call_t question, reply;
277
    ipc_call_t question, reply;
278
    int rc;
278
    int rc;
279
 
279
 
280
    memset(&question, 0, sizeof(question));
280
    memset(&question, 0, sizeof(question));
281
    rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args));
281
    rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args));
282
    printf("dmr->%d\n", rc);
282
    printf("dmr->%d\n", rc);
283
    if (rc < 0) return;
283
    if (rc < 0) return;
284
 
284
 
285
    memset(&reply, 0, sizeof(reply));
285
    memset(&reply, 0, sizeof(reply));
286
    rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args));
286
    rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args));
287
    printf("dmr->%d\n", rc);
287
    printf("dmr->%d\n", rc);
288
    if (rc < 0) return;
288
    if (rc < 0) return;
289
 
289
 
290
    ipcp_call_sync(sc_args[0], &question, &reply);
290
    ipcp_call_sync(sc_args[0], &question, &reply);
291
}
291
}
292
 
292
 
293
static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc)
293
static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc)
294
{
294
{
295
    ipc_call_t call;
295
    ipc_call_t call;
296
    int rc;
296
    int rc;
297
 
297
 
298
    if (sc_rc == 0) return;
298
    if (sc_rc == 0) return;
299
 
299
 
300
    memset(&call, 0, sizeof(call));
300
    memset(&call, 0, sizeof(call));
301
    rc = udebug_mem_read(phoneid, &call, sc_args[0], sizeof(call));
301
    rc = udebug_mem_read(phoneid, &call, sc_args[0], sizeof(call));
302
//  printf("udebug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n",
302
//  printf("udebug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n",
303
//      phoneid, (int)&call, sc_args[0], sizeof(call), rc);
303
//      phoneid, (int)&call, sc_args[0], sizeof(call), rc);
304
 
304
 
305
    if (rc >= 0) {
305
    if (rc >= 0) {
306
        ipcp_call_in(&call, sc_rc);
306
        ipcp_call_in(&call, sc_rc);
307
    }
307
    }
308
}
308
}
309
 
309
 
310
static void event_syscall_b(unsigned thread_id, uintptr_t thread_hash,
310
static void event_syscall_b(unsigned thread_id, uintptr_t thread_hash,
311
    unsigned sc_id, sysarg_t sc_rc)
311
    unsigned sc_id, sysarg_t sc_rc)
312
{
312
{
313
    sysarg_t sc_args[6];
313
    sysarg_t sc_args[6];
314
    int rc;
314
    int rc;
315
 
315
 
316
    /* Read syscall arguments */
316
    /* Read syscall arguments */
317
    rc = udebug_args_read(phoneid, thread_hash, sc_args);
317
    rc = udebug_args_read(phoneid, thread_hash, sc_args);
318
 
318
 
319
    async_serialize_start();
319
    async_serialize_start();
320
 
320
 
321
//  printf("[%d] ", thread_id);
321
//  printf("[%d] ", thread_id);
322
 
322
 
323
    if (rc < 0) {
323
    if (rc < 0) {
324
        printf("error\n");
324
        printf("error\n");
325
        async_serialize_end();
325
        async_serialize_end();
326
        return;
326
        return;
327
    }
327
    }
328
 
328
 
329
    if ((display_mask & DM_SYSCALL) != 0) {
329
    if ((display_mask & DM_SYSCALL) != 0) {
330
        /* Print syscall name and arguments */
330
        /* Print syscall name and arguments */
331
        printf("%s", syscall_desc[sc_id].name);
331
        printf("%s", syscall_desc[sc_id].name);
332
        print_sc_args(sc_args, syscall_desc[sc_id].n_args);
332
        print_sc_args(sc_args, syscall_desc[sc_id].n_args);
333
    }
333
    }
334
 
334
 
335
    async_serialize_end();
335
    async_serialize_end();
336
}
336
}
337
 
337
 
338
static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash,
338
static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash,
339
    unsigned sc_id, sysarg_t sc_rc)
339
    unsigned sc_id, sysarg_t sc_rc)
340
{
340
{
341
    sysarg_t sc_args[6];
341
    sysarg_t sc_args[6];
342
    int rv_type;
342
    int rv_type;
343
    int rc;
343
    int rc;
344
 
344
 
345
    /* Read syscall arguments */
345
    /* Read syscall arguments */
346
    rc = udebug_args_read(phoneid, thread_hash, sc_args);
346
    rc = udebug_args_read(phoneid, thread_hash, sc_args);
347
 
347
 
348
    async_serialize_start();
348
    async_serialize_start();
349
 
349
 
350
//  printf("[%d] ", thread_id);
350
//  printf("[%d] ", thread_id);
351
 
351
 
352
    if (rc < 0) {
352
    if (rc < 0) {
353
        printf("error\n");
353
        printf("error\n");
354
        async_serialize_end();
354
        async_serialize_end();
355
        return;
355
        return;
356
    }
356
    }
357
 
357
 
358
    if ((display_mask & DM_SYSCALL) != 0) {
358
    if ((display_mask & DM_SYSCALL) != 0) {
359
        /* Print syscall return value */
359
        /* Print syscall return value */
360
        rv_type = syscall_desc[sc_id].rv_type;
360
        rv_type = syscall_desc[sc_id].rv_type;
361
        print_sc_retval(sc_rc, rv_type);
361
        print_sc_retval(sc_rc, rv_type);
362
    }
362
    }
363
 
363
 
364
    switch (sc_id) {
364
    switch (sc_id) {
365
    case SYS_IPC_CALL_ASYNC_FAST:
365
    case SYS_IPC_CALL_ASYNC_FAST:
366
        sc_ipc_call_async_fast(sc_args, sc_rc);
366
        sc_ipc_call_async_fast(sc_args, sc_rc);
367
        break;
367
        break;
368
    case SYS_IPC_CALL_ASYNC_SLOW:
368
    case SYS_IPC_CALL_ASYNC_SLOW:
369
        sc_ipc_call_async_slow(sc_args, sc_rc);
369
        sc_ipc_call_async_slow(sc_args, sc_rc);
370
        break;
370
        break;
371
    case SYS_IPC_CALL_SYNC_FAST:
371
    case SYS_IPC_CALL_SYNC_FAST:
372
        sc_ipc_call_sync_fast(sc_args);
372
        sc_ipc_call_sync_fast(sc_args);
373
        break;
373
        break;
374
    case SYS_IPC_CALL_SYNC_SLOW:
374
    case SYS_IPC_CALL_SYNC_SLOW:
375
        sc_ipc_call_sync_slow(sc_args);
375
        sc_ipc_call_sync_slow(sc_args);
376
        break;
376
        break;
377
    case SYS_IPC_WAIT:
377
    case SYS_IPC_WAIT:
378
        sc_ipc_wait(sc_args, sc_rc);
378
        sc_ipc_wait(sc_args, sc_rc);
379
        break;
379
        break;
380
    default:
380
    default:
381
        break;
381
        break;
382
    }
382
    }
383
 
383
 
384
    async_serialize_end();
384
    async_serialize_end();
385
}
385
}
386
 
386
 
387
static void event_thread_b(uintptr_t hash)
387
static void event_thread_b(uintptr_t hash)
388
{
388
{
389
    async_serialize_start();
389
    async_serialize_start();
390
    printf("New thread, hash 0x%lx\n", hash);
390
    printf("New thread, hash 0x%lx\n", hash);
391
    async_serialize_end();
391
    async_serialize_end();
392
 
392
 
393
    thread_trace_start(hash);
393
    thread_trace_start(hash);
394
}
394
}
395
 
395
 
396
static int trace_loop(void *thread_hash_arg)
396
static int trace_loop(void *thread_hash_arg)
397
{
397
{
398
    int rc;
398
    int rc;
399
    unsigned ev_type;
399
    unsigned ev_type;
400
    uintptr_t thread_hash;
400
    uintptr_t thread_hash;
401
    unsigned thread_id;
401
    unsigned thread_id;
402
    sysarg_t val0, val1;
402
    sysarg_t val0, val1;
403
 
403
 
404
    thread_hash = (uintptr_t)thread_hash_arg;
404
    thread_hash = (uintptr_t)thread_hash_arg;
405
    thread_id = next_thread_id++;
405
    thread_id = next_thread_id++;
406
 
406
 
407
    printf("Start tracing thread [%d] (hash 0x%lx)\n", thread_id, thread_hash);
407
    printf("Start tracing thread [%d] (hash 0x%lx)\n", thread_id, thread_hash);
408
 
408
 
409
    while (!abort_trace) {
409
    while (!abort_trace) {
410
 
410
 
411
        /* Run thread until an event occurs */
411
        /* Run thread until an event occurs */
412
        rc = udebug_go(phoneid, thread_hash,
412
        rc = udebug_go(phoneid, thread_hash,
413
            &ev_type, &val0, &val1);
413
            &ev_type, &val0, &val1);
414
 
414
 
415
//      printf("rc = %d, ev_type=%d\n", rc, ev_type);
415
//      printf("rc = %d, ev_type=%d\n", rc, ev_type);
416
        if (ev_type == UDEBUG_EVENT_FINISHED) {
416
        if (ev_type == UDEBUG_EVENT_FINISHED) {
417
            /* Done tracing this thread */
417
            /* Done tracing this thread */
418
            break;
418
            break;
419
        }
419
        }
420
 
420
 
421
        if (rc >= 0) {
421
        if (rc >= 0) {
422
            switch (ev_type) {
422
            switch (ev_type) {
423
            case UDEBUG_EVENT_SYSCALL_B:
423
            case UDEBUG_EVENT_SYSCALL_B:
424
                event_syscall_b(thread_id, thread_hash, val0, (int)val1);
424
                event_syscall_b(thread_id, thread_hash, val0, (int)val1);
425
                break;
425
                break;
426
            case UDEBUG_EVENT_SYSCALL_E:
426
            case UDEBUG_EVENT_SYSCALL_E:
427
                event_syscall_e(thread_id, thread_hash, val0, (int)val1);
427
                event_syscall_e(thread_id, thread_hash, val0, (int)val1);
428
                break;
428
                break;
429
            case UDEBUG_EVENT_STOP:
429
            case UDEBUG_EVENT_STOP:
430
                printf("Stop event\n");
430
                printf("Stop event\n");
431
                printf("Waiting for resume\n");
431
                printf("Waiting for resume\n");
432
                while (paused) {
432
                while (paused) {
433
                    usleep(1000000);
433
                    usleep(1000000);
434
                    fibril_yield();
434
                    fibril_yield();
435
                    printf(".");
435
                    printf(".");
436
                }
436
                }
437
                printf("Resumed\n");
437
                printf("Resumed\n");
438
                break;
438
                break;
439
            case UDEBUG_EVENT_THREAD_B:
439
            case UDEBUG_EVENT_THREAD_B:
440
                event_thread_b(val0);
440
                event_thread_b(val0);
441
                break;
441
                break;
442
            case UDEBUG_EVENT_THREAD_E:
442
            case UDEBUG_EVENT_THREAD_E:
443
                printf("Thread 0x%lx exited\n", val0);
443
                printf("Thread 0x%lx exited\n", val0);
444
                abort_trace = 1;
444
                abort_trace = 1;
445
                break;
445
                break;
446
            default:
446
            default:
447
                printf("Unknown event type %d\n", ev_type);
447
                printf("Unknown event type %d\n", ev_type);
448
                break;
448
                break;
449
            }
449
            }
450
        }
450
        }
451
 
451
 
452
    }
452
    }
453
 
453
 
454
    printf("Finished tracing thread [%d]\n", thread_id);
454
    printf("Finished tracing thread [%d]\n", thread_id);
455
    return 0;
455
    return 0;
456
}
456
}
457
 
457
 
458
void thread_trace_start(uintptr_t thread_hash)
458
void thread_trace_start(uintptr_t thread_hash)
459
{
459
{
460
    fid_t fid;
460
    fid_t fid;
461
 
461
 
462
    thash = thread_hash;
462
    thash = thread_hash;
463
 
463
 
464
    fid = fibril_create(trace_loop, (void *)thread_hash);
464
    fid = fibril_create(trace_loop, (void *)thread_hash);
465
    if (fid == 0) {
465
    if (fid == 0) {
466
        printf("Warning: Failed creating fibril\n");
466
        printf("Warning: Failed creating fibril\n");
467
    }
467
    }
468
    fibril_add_ready(fid);
468
    fibril_add_ready(fid);
469
}
469
}
470
 
470
 
471
static void trace_active_task(task_id_t task_id)
471
static void trace_active_task(task_id_t task_id)
472
{
472
{
473
    int i;
473
    int i;
474
    int rc;
474
    int rc;
475
    int c;
475
    int c;
476
 
476
 
477
    rc = task_connect(task_id);
477
    rc = task_connect(task_id);
478
    if (rc < 0) {
478
    if (rc < 0) {
479
        printf("Failed to connect to task %lld\n", task_id);
479
        printf("Failed to connect to task %lld\n", task_id);
480
        return;
480
        return;
481
    }
481
    }
482
 
482
 
483
    printf("Connected to task %lld\n", task_id);
483
    printf("Connected to task %lld\n", task_id);
484
 
484
 
485
    ipcp_init();
485
    ipcp_init();
486
 
486
 
487
    /*
487
    /*
488
     * User apps now typically have console on phone 3.
488
     * User apps now typically have console on phone 3.
489
     * (Phones 1 and 2 are used by the loader).
489
     * (Phones 1 and 2 are used by the loader).
490
     */
490
     */
491
    ipcp_connection_set(3, 0, proto_console);
491
    ipcp_connection_set(3, 0, proto_console);
492
 
492
 
493
    rc = get_thread_list();
493
    rc = get_thread_list();
494
    if (rc < 0) {
494
    if (rc < 0) {
495
        printf("Failed to get thread list (error %d)\n", rc);
495
        printf("Failed to get thread list (error %d)\n", rc);
496
        return;
496
        return;
497
    }
497
    }
498
 
498
 
499
    abort_trace = 0;
499
    abort_trace = 0;
500
 
500
 
501
    for (i = 0; i < n_threads; i++) {
501
    for (i = 0; i < n_threads; i++) {
502
        thread_trace_start(thread_hash_buf[i]);
502
        thread_trace_start(thread_hash_buf[i]);
503
    }
503
    }
504
 
504
 
505
    while(1) {
505
    while(1) {
506
        c = getchar();
506
        c = getchar();
507
        if (c == 'q') break;
507
        if (c == 'q') break;
508
        if (c == 'p') {
508
        if (c == 'p') {
509
            paused = 1;
509
            paused = 1;
510
            rc = udebug_stop(phoneid, thash);
510
            rc = udebug_stop(phoneid, thash);
511
            printf("stop -> %d\n", rc);
511
            printf("stop -> %d\n", rc);
512
        }
512
        }
513
        if (c == 'r') {
513
        if (c == 'r') {
514
            paused = 0;
514
            paused = 0;
515
        }
515
        }
516
    }
516
    }
517
 
517
 
518
    printf("\nTerminate debugging session...\n");
518
    printf("\nTerminate debugging session...\n");
519
    abort_trace = 1;
519
    abort_trace = 1;
520
    udebug_end(phoneid);
520
    udebug_end(phoneid);
521
    ipc_hangup(phoneid);
521
    ipc_hangup(phoneid);
522
 
522
 
523
    ipcp_cleanup();
523
    ipcp_cleanup();
524
 
524
 
525
    printf("Done\n");
525
    printf("Done\n");
526
    return;
526
    return;
527
}
527
}
528
 
528
 
529
static void main_init(void)
529
static void main_init(void)
530
{
530
{
531
    proto_t *p;
531
    proto_t *p;
532
    oper_t *o;
532
    oper_t *o;
533
 
533
 
534
    val_type_t arg_def[OPER_MAX_ARGS] = {
534
    val_type_t arg_def[OPER_MAX_ARGS] = {
535
        V_INTEGER,
535
        V_INTEGER,
536
        V_INTEGER,
536
        V_INTEGER,
537
        V_INTEGER,
537
        V_INTEGER,
538
        V_INTEGER,
538
        V_INTEGER,
539
        V_INTEGER      
539
        V_INTEGER      
540
    };
540
    };
541
 
541
 
542
    val_type_t resp_def[OPER_MAX_ARGS] = {
542
    val_type_t resp_def[OPER_MAX_ARGS] = {
543
        V_INTEGER,
543
        V_INTEGER,
544
        V_INTEGER,
544
        V_INTEGER,
545
        V_INTEGER,
545
        V_INTEGER,
546
        V_INTEGER,
546
        V_INTEGER,
547
        V_INTEGER      
547
        V_INTEGER      
548
    };
548
    };
549
 
549
 
550
    next_thread_id = 1;
550
    next_thread_id = 1;
551
    paused = 0;
551
    paused = 0;
552
 
552
 
553
    proto_init();
553
    proto_init();
554
 
554
 
555
    p = proto_new("vfs");
555
    p = proto_new("vfs");
556
    o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def);
556
    o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def);
557
    proto_add_oper(p, VFS_READ, o);
557
    proto_add_oper(p, VFS_READ, o);
558
    o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def);
558
    o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def);
559
    proto_add_oper(p, VFS_WRITE, o);
559
    proto_add_oper(p, VFS_WRITE, o);
560
    o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def);
560
    o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def);
561
    proto_add_oper(p, VFS_TRUNCATE, o);
561
    proto_add_oper(p, VFS_TRUNCATE, o);
562
    o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def);
562
    o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def);
563
    proto_add_oper(p, VFS_MOUNT, o);
563
    proto_add_oper(p, VFS_MOUNT, o);
564
/*  o = oper_new("unmount", 0, arg_def);
564
/*  o = oper_new("unmount", 0, arg_def);
565
    proto_add_oper(p, VFS_UNMOUNT, o);*/
565
    proto_add_oper(p, VFS_UNMOUNT, o);*/
566
 
566
 
567
    proto_register(SERVICE_VFS, p);
567
    proto_register(SERVICE_VFS, p);
568
 
568
 
569
    p = proto_new("console");
569
    p = proto_new("console");
570
    resp_def[0] = V_CHAR;
570
    resp_def[0] = V_CHAR;
571
    o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def);
571
    o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def);
572
    proto_add_oper(p, CONSOLE_GETCHAR, o);
572
    proto_add_oper(p, CONSOLE_GETCHAR, o);
573
 
573
 
574
    arg_def[0] = V_CHAR;
574
    arg_def[0] = V_CHAR;
575
    o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def);
575
    o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def);
576
    proto_add_oper(p, CONSOLE_PUTCHAR, o);
576
    proto_add_oper(p, CONSOLE_PUTCHAR, o);
577
    o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def);
577
    o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def);
578
    proto_add_oper(p, CONSOLE_CLEAR, o);
578
    proto_add_oper(p, CONSOLE_CLEAR, o);
579
 
579
 
580
    arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
580
    arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
581
    o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def);
581
    o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def);
582
    proto_add_oper(p, CONSOLE_GOTO, o);
582
    proto_add_oper(p, CONSOLE_GOTO, o);
583
 
583
 
584
    resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER;
584
    resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER;
585
    o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def);
585
    o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def);
586
    proto_add_oper(p, CONSOLE_GETSIZE, o);
586
    proto_add_oper(p, CONSOLE_GETSIZE, o);
587
    o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def);
587
    o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def);
588
    proto_add_oper(p, CONSOLE_FLUSH, o);
588
    proto_add_oper(p, CONSOLE_FLUSH, o);
589
 
589
 
590
    arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
590
    arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
591
    o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def);
591
    o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def);
592
    proto_add_oper(p, CONSOLE_SET_STYLE, o);
592
    proto_add_oper(p, CONSOLE_SET_STYLE, o);
593
    o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def);
593
    o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def);
594
    proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o);
594
    proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o);
595
 
595
 
596
    proto_console = p;
596
    proto_console = p;
597
    proto_register(SERVICE_CONSOLE, p);
597
    proto_register(SERVICE_CONSOLE, p);
598
}
598
}
599
 
599
 
600
static void print_syntax()
600
static void print_syntax()
601
{
601
{
602
    printf("Syntax:\n");
602
    printf("Syntax:\n");
603
    printf("\ttrace [+<events>] <executable> [<arg1> [...]]\n");
603
    printf("\ttrace [+<events>] <executable> [<arg1> [...]]\n");
604
    printf("or\ttrace [+<events>] -t <task_id>\n");
604
    printf("or\ttrace [+<events>] -t <task_id>\n");
605
    printf("Events: (default is +tp)\n");
605
    printf("Events: (default is +tp)\n");
606
    printf("\n");
606
    printf("\n");
607
    printf("\tt ... Thread creation and termination\n");
607
    printf("\tt ... Thread creation and termination\n");
608
    printf("\ts ... System calls\n");
608
    printf("\ts ... System calls\n");
609
    printf("\ti ... Low-level IPC\n");
609
    printf("\ti ... Low-level IPC\n");
610
    printf("\tp ... Protocol level\n");
610
    printf("\tp ... Protocol level\n");
611
    printf("\n");
611
    printf("\n");
612
    printf("Examples:\n");
612
    printf("Examples:\n");
613
    printf("\ttrace +s /app/tetris\n");
613
    printf("\ttrace +s /app/tetris\n");
614
    printf("\ttrace +tsip -t 12\n");
614
    printf("\ttrace +tsip -t 12\n");
615
}
615
}
616
 
616
 
617
static display_mask_t parse_display_mask(char *text)
617
static display_mask_t parse_display_mask(char *text)
618
{
618
{
619
    display_mask_t dm;
619
    display_mask_t dm;
620
    char *c;
620
    char *c;
621
 
621
 
622
    c = text;
622
    c = text;
623
 
623
 
624
    while (*c) {
624
    while (*c) {
625
        switch (*c) {
625
        switch (*c) {
626
        case 't': dm = dm | DM_THREAD; break;
626
        case 't': dm = dm | DM_THREAD; break;
627
        case 's': dm = dm | DM_SYSCALL; break;
627
        case 's': dm = dm | DM_SYSCALL; break;
628
        case 'i': dm = dm | DM_IPC; break;
628
        case 'i': dm = dm | DM_IPC; break;
629
        case 'p': dm = dm | DM_SYSTEM | DM_USER; break;
629
        case 'p': dm = dm | DM_SYSTEM | DM_USER; break;
630
        default:
630
        default:
631
            printf("Unexpected event type '%c'\n", *c);
631
            printf("Unexpected event type '%c'\n", *c);
632
            exit(1);
632
            exit(1);
633
        }
633
        }
634
 
634
 
635
        ++c;
635
        ++c;
636
    }
636
    }
637
 
637
 
638
    return dm;
638
    return dm;
639
}
639
}
640
 
640
 
641
static int parse_args(int argc, char *argv[])
641
static int parse_args(int argc, char *argv[])
642
{
642
{
643
    char *arg;
643
    char *arg;
644
    char *err_p;
644
    char *err_p;
645
 
645
 
646
    task_id = 0;
646
    task_id = 0;
647
 
647
 
648
    --argc; ++argv;
648
    --argc; ++argv;
649
 
649
 
650
    while (argc > 0) {
650
    while (argc > 0) {
651
        arg = *argv;
651
        arg = *argv;
652
        if (arg[0] == '+') {
652
        if (arg[0] == '+') {
653
            display_mask = parse_display_mask(&arg[1]);
653
            display_mask = parse_display_mask(&arg[1]);
654
        } else if (arg[0] == '-') {
654
        } else if (arg[0] == '-') {
655
            if (arg[1] == 't') {
655
            if (arg[1] == 't') {
656
                /* Trace an already running task */
656
                /* Trace an already running task */
657
                --argc; ++argv;
657
                --argc; ++argv;
658
                task_id = strtol(*argv, &err_p, 10);
658
                task_id = strtol(*argv, &err_p, 10);
659
                if (*err_p) {
659
                if (*err_p) {
660
                    printf("Task ID syntax error\n");
660
                    printf("Task ID syntax error\n");
661
                    print_syntax();
661
                    print_syntax();
662
                    return -1;
662
                    return -1;
663
                }
663
                }
664
            } else {
664
            } else {
665
                printf("Uknown option '%s'\n", arg[0]);
665
                printf("Uknown option '%s'\n", arg[0]);
666
                print_syntax();
666
                print_syntax();
667
                return -1;
667
                return -1;
668
            }
668
            }
669
        } else {
669
        } else {
670
            break;
670
            break;
671
        }
671
        }
672
 
672
 
673
        --argc; ++argv;
673
        --argc; ++argv;
674
    }
674
    }
675
 
675
 
676
    if (task_id != 0) {
676
    if (task_id != 0) {
677
        if (argc == 0) return 0;
677
        if (argc == 0) return 0;
678
        printf("Extra arguments\n");
678
        printf("Extra arguments\n");
679
        print_syntax();
679
        print_syntax();
680
        return -1;
680
        return -1;
681
    }
681
    }
682
 
682
 
683
    if (argc < 1) {
683
    if (argc < 1) {
684
        printf("Missing argument\n");
684
        printf("Missing argument\n");
685
        print_syntax();
685
        print_syntax();
686
        return -1;
686
        return -1;
687
    }
687
    }
688
 
688
 
689
    /* Execute the specified command and trace the new task. */
689
    /* Execute the specified command and trace the new task. */
690
    printf("Spawning '%s' with arguments:\n", *argv);
690
    printf("Spawning '%s' with arguments:\n", *argv);
691
    {
691
    {
692
        char **cp = argv;
692
        char **cp = argv;
693
        while (*cp) printf("'%s'\n", *cp++);
693
        while (*cp) printf("'%s'\n", *cp++);
694
    }
694
    }
695
    task_id = task_spawn(*argv, argv);
695
    task_id = task_spawn(*argv, argv);
696
 
696
 
697
    return 0;
697
    return 0;
698
}
698
}
699
 
699
 
700
int main(int argc, char *argv[])
700
int main(int argc, char *argv[])
701
{
701
{
702
    printf("System Call / IPC Tracer\n");
702
    printf("System Call / IPC Tracer\n");
703
 
703
 
704
    display_mask = DM_THREAD | DM_SYSTEM | DM_USER;
704
    display_mask = DM_THREAD | DM_SYSTEM | DM_USER;
705
 
705
 
706
    if (parse_args(argc, argv) < 0)
706
    if (parse_args(argc, argv) < 0)
707
        return 1;
707
        return 1;
708
 
708
 
709
    main_init();
709
    main_init();
710
    trace_active_task(task_id);
710
    trace_active_task(task_id);
711
 
711
 
712
    return 0;
712
    return 0;
713
}
713
}
714
 
714
 
715
/** @}
715
/** @}
716
 */
716
 */
717
 
717