[9a1b20c] | 1 | /*
|
---|
| 2 | * Copyright (c) 2008 Jiri Svoboda
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 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
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 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
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 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
|
---|
| 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
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup trace
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | #include <stdio.h>
|
---|
| 36 | #include <stdlib.h>
|
---|
| 37 | #include <unistd.h>
|
---|
| 38 | #include <fibril.h>
|
---|
| 39 | #include <errno.h>
|
---|
| 40 | #include <udebug.h>
|
---|
| 41 | #include <async.h>
|
---|
[47e0a05b] | 42 | #include <task.h>
|
---|
[3bf907a] | 43 | #include <mem.h>
|
---|
[19f857a] | 44 | #include <str.h>
|
---|
[3e6a98c5] | 45 | #include <stdbool.h>
|
---|
[4470e26] | 46 | #include <loader/loader.h>
|
---|
[9d8a1ed] | 47 | #include <io/console.h>
|
---|
| 48 | #include <io/keycode.h>
|
---|
[1e4cada] | 49 | #include <fibril_synch.h>
|
---|
[1ccafee] | 50 | #include <sys/types.h>
|
---|
| 51 | #include <sys/typefmt.h>
|
---|
[df02460] | 52 | #include <vfs/vfs.h>
|
---|
[9a1b20c] | 53 |
|
---|
[f2ef7fd] | 54 | #include <libc.h>
|
---|
| 55 |
|
---|
[28a3e74] | 56 | /* Temporary: service and method names */
|
---|
[9a1b20c] | 57 | #include "proto.h"
|
---|
| 58 | #include <ipc/services.h>
|
---|
| 59 | #include "../../srv/vfs/vfs.h"
|
---|
[d3e6935] | 60 | #include <ipc/console.h>
|
---|
[9a1b20c] | 61 |
|
---|
| 62 | #include "syscalls.h"
|
---|
| 63 | #include "ipcp.h"
|
---|
| 64 | #include "errors.h"
|
---|
[1643855] | 65 | #include "trace.h"
|
---|
[9a1b20c] | 66 |
|
---|
| 67 | #define THBUF_SIZE 64
|
---|
[a5c3f73] | 68 | uintptr_t thread_hash_buf[THBUF_SIZE];
|
---|
| 69 | int n_threads;
|
---|
[9a1b20c] | 70 |
|
---|
| 71 | int next_thread_id;
|
---|
| 72 |
|
---|
[c8404d4] | 73 | ipc_call_t thread_ipc_req[THBUF_SIZE];
|
---|
| 74 |
|
---|
[79ae36dd] | 75 | async_sess_t *sess;
|
---|
[9ad5b5cc] | 76 | bool abort_trace;
|
---|
[9a1b20c] | 77 |
|
---|
[a5c3f73] | 78 | uintptr_t thash;
|
---|
[9ad5b5cc] | 79 | static bool paused;
|
---|
| 80 | static fibril_condvar_t state_cv;
|
---|
| 81 | static fibril_mutex_t state_lock;
|
---|
[84683fdc] | 82 |
|
---|
[9ad5b5cc] | 83 | static bool cev_valid;
|
---|
[79ae36dd] | 84 | static kbd_event_t cev;
|
---|
[9a1b20c] | 85 |
|
---|
[a5c3f73] | 86 | void thread_trace_start(uintptr_t thread_hash);
|
---|
[9a1b20c] | 87 |
|
---|
[1643855] | 88 | static task_id_t task_id;
|
---|
[4470e26] | 89 | static loader_t *task_ldr;
|
---|
[9ad5b5cc] | 90 | static bool task_wait_for;
|
---|
[1643855] | 91 |
|
---|
| 92 | /** Combination of events/data to print. */
|
---|
| 93 | display_mask_t display_mask;
|
---|
[9a1b20c] | 94 |
|
---|
[4470e26] | 95 | static int program_run_fibril(void *arg);
|
---|
[84683fdc] | 96 | static int cev_fibril(void *arg);
|
---|
[4470e26] | 97 |
|
---|
| 98 | static void program_run(void)
|
---|
| 99 | {
|
---|
| 100 | fid_t fid;
|
---|
| 101 |
|
---|
| 102 | fid = fibril_create(program_run_fibril, NULL);
|
---|
| 103 | if (fid == 0) {
|
---|
| 104 | printf("Error creating fibril\n");
|
---|
| 105 | exit(1);
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | fibril_add_ready(fid);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[84683fdc] | 111 | static void cev_fibril_start(void)
|
---|
| 112 | {
|
---|
| 113 | fid_t fid;
|
---|
| 114 |
|
---|
| 115 | fid = fibril_create(cev_fibril, NULL);
|
---|
| 116 | if (fid == 0) {
|
---|
| 117 | printf("Error creating fibril\n");
|
---|
| 118 | exit(1);
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | fibril_add_ready(fid);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[4470e26] | 124 | static int program_run_fibril(void *arg)
|
---|
| 125 | {
|
---|
| 126 | int rc;
|
---|
| 127 |
|
---|
| 128 | /*
|
---|
| 129 | * This must be done in background as it will block until
|
---|
| 130 | * we let the task reply to this call.
|
---|
| 131 | */
|
---|
| 132 | rc = loader_run(task_ldr);
|
---|
| 133 | if (rc != 0) {
|
---|
| 134 | printf("Error running program\n");
|
---|
| 135 | exit(1);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | free(task_ldr);
|
---|
| 139 | task_ldr = NULL;
|
---|
| 140 |
|
---|
| 141 | printf("program_run_fibril exiting\n");
|
---|
| 142 | return 0;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | static int connect_task(task_id_t task_id)
|
---|
[9a1b20c] | 147 | {
|
---|
[79ae36dd] | 148 | async_sess_t *ksess = async_connect_kbox(task_id);
|
---|
| 149 |
|
---|
| 150 | if (!ksess) {
|
---|
| 151 | if (errno == ENOTSUP) {
|
---|
| 152 | printf("You do not have userspace debugging support "
|
---|
| 153 | "compiled in the kernel.\n");
|
---|
| 154 | printf("Compile kernel with 'Support for userspace debuggers' "
|
---|
| 155 | "(CONFIG_UDEBUG) enabled.\n");
|
---|
| 156 | return errno;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
[c9a29d6] | 159 | printf("Error connecting\n");
|
---|
[79ae36dd] | 160 | printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, errno);
|
---|
| 161 | return errno;
|
---|
[fb9b0b0] | 162 | }
|
---|
[79ae36dd] | 163 |
|
---|
| 164 | int rc = udebug_begin(ksess);
|
---|
[c9a29d6] | 165 | if (rc < 0) {
|
---|
| 166 | printf("udebug_begin() -> %d\n", rc);
|
---|
| 167 | return rc;
|
---|
| 168 | }
|
---|
[79ae36dd] | 169 |
|
---|
| 170 | rc = udebug_set_evmask(ksess, UDEBUG_EM_ALL);
|
---|
[c9a29d6] | 171 | if (rc < 0) {
|
---|
| 172 | printf("udebug_set_evmask(0x%x) -> %d\n ", UDEBUG_EM_ALL, rc);
|
---|
| 173 | return rc;
|
---|
| 174 | }
|
---|
[79ae36dd] | 175 |
|
---|
| 176 | sess = ksess;
|
---|
[9a1b20c] | 177 | return 0;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | static int get_thread_list(void)
|
---|
| 181 | {
|
---|
| 182 | int rc;
|
---|
| 183 | size_t tb_copied;
|
---|
| 184 | size_t tb_needed;
|
---|
| 185 | int i;
|
---|
| 186 |
|
---|
[79ae36dd] | 187 | rc = udebug_thread_read(sess, thread_hash_buf,
|
---|
[9a1b20c] | 188 | THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed);
|
---|
[c9a29d6] | 189 | if (rc < 0) {
|
---|
| 190 | printf("udebug_thread_read() -> %d\n", rc);
|
---|
| 191 | return rc;
|
---|
| 192 | }
|
---|
[9a1b20c] | 193 |
|
---|
[a5c3f73] | 194 | n_threads = tb_copied / sizeof(uintptr_t);
|
---|
[9a1b20c] | 195 |
|
---|
[c9a29d6] | 196 | printf("Threads:");
|
---|
| 197 | for (i = 0; i < n_threads; i++) {
|
---|
[7e752b2] | 198 | printf(" [%d] (hash %p)", 1 + i, (void *) thread_hash_buf[i]);
|
---|
[9a1b20c] | 199 | }
|
---|
[7e752b2] | 200 | printf("\ntotal of %zu threads\n", tb_needed / sizeof(uintptr_t));
|
---|
[9a1b20c] | 201 |
|
---|
| 202 | return 0;
|
---|
| 203 | }
|
---|
| 204 |
|
---|
[356acd0] | 205 | void val_print(sysarg_t val, val_type_t v_type)
|
---|
[9a1b20c] | 206 | {
|
---|
[f019cc07] | 207 | long sval;
|
---|
| 208 |
|
---|
| 209 | sval = (long) val;
|
---|
| 210 |
|
---|
[abf3564] | 211 | switch (v_type) {
|
---|
| 212 | case V_VOID:
|
---|
| 213 | printf("<void>");
|
---|
| 214 | break;
|
---|
| 215 |
|
---|
| 216 | case V_INTEGER:
|
---|
[f019cc07] | 217 | printf("%ld", sval);
|
---|
[abf3564] | 218 | break;
|
---|
| 219 |
|
---|
| 220 | case V_HASH:
|
---|
[4470e26] | 221 | case V_PTR:
|
---|
[7e752b2] | 222 | printf("%p", (void *) val);
|
---|
[abf3564] | 223 | break;
|
---|
| 224 |
|
---|
| 225 | case V_ERRNO:
|
---|
[f019cc07] | 226 | if (sval >= -15 && sval <= 0) {
|
---|
| 227 | printf("%ld %s (%s)", sval,
|
---|
| 228 | err_desc[-sval].name,
|
---|
| 229 | err_desc[-sval].desc);
|
---|
[9a1b20c] | 230 | } else {
|
---|
[f019cc07] | 231 | printf("%ld", sval);
|
---|
[9a1b20c] | 232 | }
|
---|
[abf3564] | 233 | break;
|
---|
| 234 | case V_INT_ERRNO:
|
---|
[f019cc07] | 235 | if (sval >= -15 && sval < 0) {
|
---|
| 236 | printf("%ld %s (%s)", sval,
|
---|
| 237 | err_desc[-sval].name,
|
---|
| 238 | err_desc[-sval].desc);
|
---|
[abf3564] | 239 | } else {
|
---|
[f019cc07] | 240 | printf("%ld", sval);
|
---|
[abf3564] | 241 | }
|
---|
| 242 | break;
|
---|
| 243 |
|
---|
| 244 | case V_CHAR:
|
---|
[f019cc07] | 245 | if (sval >= 0x20 && sval < 0x7f) {
|
---|
[7e752b2] | 246 | printf("'%c'", (char) sval);
|
---|
[9a1b20c] | 247 | } else {
|
---|
[f019cc07] | 248 | switch (sval) {
|
---|
[abf3564] | 249 | case '\a': printf("'\\a'"); break;
|
---|
| 250 | case '\b': printf("'\\b'"); break;
|
---|
| 251 | case '\n': printf("'\\n'"); break;
|
---|
| 252 | case '\r': printf("'\\r'"); break;
|
---|
| 253 | case '\t': printf("'\\t'"); break;
|
---|
| 254 | case '\\': printf("'\\\\'"); break;
|
---|
[7e752b2] | 255 | default: printf("'\\x%02" PRIxn "'", val); break;
|
---|
[abf3564] | 256 | }
|
---|
[9a1b20c] | 257 | }
|
---|
[abf3564] | 258 | break;
|
---|
[9a1b20c] | 259 | }
|
---|
[abf3564] | 260 | }
|
---|
| 261 |
|
---|
| 262 |
|
---|
[356acd0] | 263 | static void print_sc_retval(sysarg_t retval, val_type_t val_type)
|
---|
[abf3564] | 264 | {
|
---|
| 265 | printf(" -> ");
|
---|
| 266 | val_print(retval, val_type);
|
---|
[9a1b20c] | 267 | putchar('\n');
|
---|
| 268 | }
|
---|
| 269 |
|
---|
[a5c3f73] | 270 | static void print_sc_args(sysarg_t *sc_args, int n)
|
---|
[9a1b20c] | 271 | {
|
---|
| 272 | int i;
|
---|
| 273 |
|
---|
| 274 | putchar('(');
|
---|
[7e752b2] | 275 | if (n > 0) printf("%" PRIun, sc_args[0]);
|
---|
[abf3564] | 276 | for (i = 1; i < n; i++) {
|
---|
[7e752b2] | 277 | printf(", %" PRIun, sc_args[i]);
|
---|
[9a1b20c] | 278 | }
|
---|
| 279 | putchar(')');
|
---|
| 280 | }
|
---|
| 281 |
|
---|
[a5c3f73] | 282 | static void sc_ipc_call_async_fast(sysarg_t *sc_args, sysarg_t sc_rc)
|
---|
[9a1b20c] | 283 | {
|
---|
| 284 | ipc_call_t call;
|
---|
[96b02eb9] | 285 | sysarg_t phoneid;
|
---|
[9a1b20c] | 286 |
|
---|
[f019cc07] | 287 | if (sc_rc == (sysarg_t) IPC_CALLRET_FATAL ||
|
---|
| 288 | sc_rc == (sysarg_t) IPC_CALLRET_TEMPORARY)
|
---|
[9a1b20c] | 289 | return;
|
---|
| 290 |
|
---|
| 291 | phoneid = sc_args[0];
|
---|
| 292 |
|
---|
[228e490] | 293 | IPC_SET_IMETHOD(call, sc_args[1]);
|
---|
[9a1b20c] | 294 | IPC_SET_ARG1(call, sc_args[2]);
|
---|
| 295 | IPC_SET_ARG2(call, sc_args[3]);
|
---|
| 296 | IPC_SET_ARG3(call, sc_args[4]);
|
---|
| 297 | IPC_SET_ARG4(call, sc_args[5]);
|
---|
| 298 | IPC_SET_ARG5(call, 0);
|
---|
| 299 |
|
---|
| 300 | ipcp_call_out(phoneid, &call, sc_rc);
|
---|
| 301 | }
|
---|
| 302 |
|
---|
[a5c3f73] | 303 | static void sc_ipc_call_async_slow(sysarg_t *sc_args, sysarg_t sc_rc)
|
---|
[9a1b20c] | 304 | {
|
---|
| 305 | ipc_call_t call;
|
---|
| 306 | int rc;
|
---|
| 307 |
|
---|
[f019cc07] | 308 | if (sc_rc == (sysarg_t) IPC_CALLRET_FATAL ||
|
---|
| 309 | sc_rc == (sysarg_t) IPC_CALLRET_TEMPORARY)
|
---|
[9a1b20c] | 310 | return;
|
---|
| 311 |
|
---|
| 312 | memset(&call, 0, sizeof(call));
|
---|
[79ae36dd] | 313 | rc = udebug_mem_read(sess, &call.args, sc_args[1], sizeof(call.args));
|
---|
[9a1b20c] | 314 |
|
---|
| 315 | if (rc >= 0) {
|
---|
| 316 | ipcp_call_out(sc_args[0], &call, sc_rc);
|
---|
| 317 | }
|
---|
| 318 | }
|
---|
| 319 |
|
---|
[a5c3f73] | 320 | static void sc_ipc_wait(sysarg_t *sc_args, int sc_rc)
|
---|
[9a1b20c] | 321 | {
|
---|
| 322 | ipc_call_t call;
|
---|
| 323 | int rc;
|
---|
| 324 |
|
---|
| 325 | if (sc_rc == 0) return;
|
---|
| 326 |
|
---|
| 327 | memset(&call, 0, sizeof(call));
|
---|
[79ae36dd] | 328 | rc = udebug_mem_read(sess, &call, sc_args[0], sizeof(call));
|
---|
| 329 |
|
---|
| 330 | if (rc >= 0)
|
---|
[9a1b20c] | 331 | ipcp_call_in(&call, sc_rc);
|
---|
| 332 | }
|
---|
| 333 |
|
---|
[a5c3f73] | 334 | static void event_syscall_b(unsigned thread_id, uintptr_t thread_hash,
|
---|
| 335 | unsigned sc_id, sysarg_t sc_rc)
|
---|
[9a1b20c] | 336 | {
|
---|
[a5c3f73] | 337 | sysarg_t sc_args[6];
|
---|
[9a1b20c] | 338 | int rc;
|
---|
| 339 |
|
---|
| 340 | /* Read syscall arguments */
|
---|
[79ae36dd] | 341 | rc = udebug_args_read(sess, thread_hash, sc_args);
|
---|
[9a1b20c] | 342 |
|
---|
| 343 | if (rc < 0) {
|
---|
| 344 | printf("error\n");
|
---|
| 345 | return;
|
---|
| 346 | }
|
---|
| 347 |
|
---|
[1643855] | 348 | if ((display_mask & DM_SYSCALL) != 0) {
|
---|
| 349 | /* Print syscall name and arguments */
|
---|
| 350 | printf("%s", syscall_desc[sc_id].name);
|
---|
| 351 | print_sc_args(sc_args, syscall_desc[sc_id].n_args);
|
---|
| 352 | }
|
---|
[9a1b20c] | 353 | }
|
---|
| 354 |
|
---|
[a5c3f73] | 355 | static void event_syscall_e(unsigned thread_id, uintptr_t thread_hash,
|
---|
| 356 | unsigned sc_id, sysarg_t sc_rc)
|
---|
[9a1b20c] | 357 | {
|
---|
[a5c3f73] | 358 | sysarg_t sc_args[6];
|
---|
[9a1b20c] | 359 | int rv_type;
|
---|
| 360 | int rc;
|
---|
| 361 |
|
---|
| 362 | /* Read syscall arguments */
|
---|
[79ae36dd] | 363 | rc = udebug_args_read(sess, thread_hash, sc_args);
|
---|
[9a1b20c] | 364 |
|
---|
| 365 | // printf("[%d] ", thread_id);
|
---|
| 366 |
|
---|
| 367 | if (rc < 0) {
|
---|
| 368 | printf("error\n");
|
---|
| 369 | return;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
[1643855] | 372 | if ((display_mask & DM_SYSCALL) != 0) {
|
---|
| 373 | /* Print syscall return value */
|
---|
| 374 | rv_type = syscall_desc[sc_id].rv_type;
|
---|
| 375 | print_sc_retval(sc_rc, rv_type);
|
---|
| 376 | }
|
---|
[9a1b20c] | 377 |
|
---|
| 378 | switch (sc_id) {
|
---|
| 379 | case SYS_IPC_CALL_ASYNC_FAST:
|
---|
| 380 | sc_ipc_call_async_fast(sc_args, sc_rc);
|
---|
| 381 | break;
|
---|
| 382 | case SYS_IPC_CALL_ASYNC_SLOW:
|
---|
| 383 | sc_ipc_call_async_slow(sc_args, sc_rc);
|
---|
| 384 | break;
|
---|
| 385 | case SYS_IPC_WAIT:
|
---|
| 386 | sc_ipc_wait(sc_args, sc_rc);
|
---|
| 387 | break;
|
---|
| 388 | default:
|
---|
| 389 | break;
|
---|
| 390 | }
|
---|
| 391 | }
|
---|
| 392 |
|
---|
[a5c3f73] | 393 | static void event_thread_b(uintptr_t hash)
|
---|
[9a1b20c] | 394 | {
|
---|
[7e752b2] | 395 | printf("New thread, hash %p\n", (void *) hash);
|
---|
[9a1b20c] | 396 | thread_trace_start(hash);
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 | static int trace_loop(void *thread_hash_arg)
|
---|
| 400 | {
|
---|
| 401 | int rc;
|
---|
| 402 | unsigned ev_type;
|
---|
[a5c3f73] | 403 | uintptr_t thread_hash;
|
---|
[9a1b20c] | 404 | unsigned thread_id;
|
---|
[a5c3f73] | 405 | sysarg_t val0, val1;
|
---|
[9a1b20c] | 406 |
|
---|
[a5c3f73] | 407 | thread_hash = (uintptr_t)thread_hash_arg;
|
---|
[9a1b20c] | 408 | thread_id = next_thread_id++;
|
---|
[c8404d4] | 409 | if (thread_id >= THBUF_SIZE) {
|
---|
| 410 | printf("Too many threads.\n");
|
---|
| 411 | return ELIMIT;
|
---|
| 412 | }
|
---|
[9a1b20c] | 413 |
|
---|
[7e752b2] | 414 | printf("Start tracing thread [%u] (hash %p).\n",
|
---|
| 415 | thread_id, (void *) thread_hash);
|
---|
[9a1b20c] | 416 |
|
---|
| 417 | while (!abort_trace) {
|
---|
| 418 |
|
---|
[84683fdc] | 419 | fibril_mutex_lock(&state_lock);
|
---|
[741fd16] | 420 | if (paused) {
|
---|
[7e752b2] | 421 | printf("Thread [%u] paused. Press R to resume.\n",
|
---|
[654a30a] | 422 | thread_id);
|
---|
| 423 |
|
---|
| 424 | while (paused)
|
---|
[84683fdc] | 425 | fibril_condvar_wait(&state_cv, &state_lock);
|
---|
[654a30a] | 426 |
|
---|
[7e752b2] | 427 | printf("Thread [%u] resumed.\n", thread_id);
|
---|
[741fd16] | 428 | }
|
---|
[84683fdc] | 429 | fibril_mutex_unlock(&state_lock);
|
---|
[741fd16] | 430 |
|
---|
[9a1b20c] | 431 | /* Run thread until an event occurs */
|
---|
[79ae36dd] | 432 | rc = udebug_go(sess, thread_hash,
|
---|
[9a1b20c] | 433 | &ev_type, &val0, &val1);
|
---|
| 434 |
|
---|
| 435 | // printf("rc = %d, ev_type=%d\n", rc, ev_type);
|
---|
| 436 | if (ev_type == UDEBUG_EVENT_FINISHED) {
|
---|
[c9a29d6] | 437 | /* Done tracing this thread */
|
---|
[9a1b20c] | 438 | break;
|
---|
| 439 | }
|
---|
| 440 |
|
---|
| 441 | if (rc >= 0) {
|
---|
| 442 | switch (ev_type) {
|
---|
| 443 | case UDEBUG_EVENT_SYSCALL_B:
|
---|
| 444 | event_syscall_b(thread_id, thread_hash, val0, (int)val1);
|
---|
| 445 | break;
|
---|
| 446 | case UDEBUG_EVENT_SYSCALL_E:
|
---|
| 447 | event_syscall_e(thread_id, thread_hash, val0, (int)val1);
|
---|
| 448 | break;
|
---|
| 449 | case UDEBUG_EVENT_STOP:
|
---|
[c9a29d6] | 450 | printf("Stop event\n");
|
---|
[84683fdc] | 451 | fibril_mutex_lock(&state_lock);
|
---|
[9ad5b5cc] | 452 | paused = true;
|
---|
[84683fdc] | 453 | fibril_mutex_unlock(&state_lock);
|
---|
[9a1b20c] | 454 | break;
|
---|
| 455 | case UDEBUG_EVENT_THREAD_B:
|
---|
| 456 | event_thread_b(val0);
|
---|
| 457 | break;
|
---|
| 458 | case UDEBUG_EVENT_THREAD_E:
|
---|
[7e752b2] | 459 | printf("Thread %" PRIun " exited.\n", val0);
|
---|
[84683fdc] | 460 | fibril_mutex_lock(&state_lock);
|
---|
[9ad5b5cc] | 461 | abort_trace = true;
|
---|
[84683fdc] | 462 | fibril_condvar_broadcast(&state_cv);
|
---|
| 463 | fibril_mutex_unlock(&state_lock);
|
---|
[9a1b20c] | 464 | break;
|
---|
| 465 | default:
|
---|
[ef687799] | 466 | printf("Unknown event type %d.\n", ev_type);
|
---|
[9a1b20c] | 467 | break;
|
---|
| 468 | }
|
---|
| 469 | }
|
---|
| 470 |
|
---|
| 471 | }
|
---|
| 472 |
|
---|
[ef687799] | 473 | printf("Finished tracing thread [%d].\n", thread_id);
|
---|
[9a1b20c] | 474 | return 0;
|
---|
| 475 | }
|
---|
| 476 |
|
---|
[a5c3f73] | 477 | void thread_trace_start(uintptr_t thread_hash)
|
---|
[9a1b20c] | 478 | {
|
---|
| 479 | fid_t fid;
|
---|
| 480 |
|
---|
| 481 | thash = thread_hash;
|
---|
| 482 |
|
---|
| 483 | fid = fibril_create(trace_loop, (void *)thread_hash);
|
---|
| 484 | if (fid == 0) {
|
---|
| 485 | printf("Warning: Failed creating fibril\n");
|
---|
| 486 | }
|
---|
| 487 | fibril_add_ready(fid);
|
---|
| 488 | }
|
---|
| 489 |
|
---|
[a000878c] | 490 | static loader_t *preload_task(const char *path, char **argv,
|
---|
[4470e26] | 491 | task_id_t *task_id)
|
---|
[9a1b20c] | 492 | {
|
---|
[4470e26] | 493 | loader_t *ldr;
|
---|
[9a1b20c] | 494 | int rc;
|
---|
| 495 |
|
---|
[a000878c] | 496 | /* Spawn a program loader */
|
---|
[08b777e] | 497 | ldr = loader_connect();
|
---|
[4470e26] | 498 | if (ldr == NULL)
|
---|
| 499 | return 0;
|
---|
| 500 |
|
---|
| 501 | /* Get task ID. */
|
---|
| 502 | rc = loader_get_task_id(ldr, task_id);
|
---|
| 503 | if (rc != EOK)
|
---|
| 504 | goto error;
|
---|
| 505 |
|
---|
| 506 | /* Send program pathname */
|
---|
| 507 | rc = loader_set_pathname(ldr, path);
|
---|
| 508 | if (rc != EOK)
|
---|
| 509 | goto error;
|
---|
| 510 |
|
---|
| 511 | /* Send arguments */
|
---|
[a000878c] | 512 | rc = loader_set_args(ldr, (const char **) argv);
|
---|
[4470e26] | 513 | if (rc != EOK)
|
---|
| 514 | goto error;
|
---|
| 515 |
|
---|
[8e1dc00] | 516 | /* Send default files */
|
---|
[7171760] | 517 | int *files[4];
|
---|
| 518 | int fd_stdin;
|
---|
| 519 | int fd_stdout;
|
---|
| 520 | int fd_stderr;
|
---|
[8e1dc00] | 521 |
|
---|
[7171760] | 522 | if ((stdin != NULL) && (fhandle(stdin, &fd_stdin) == EOK))
|
---|
| 523 | files[0] = &fd_stdin;
|
---|
[8e1dc00] | 524 | else
|
---|
| 525 | files[0] = NULL;
|
---|
| 526 |
|
---|
[7171760] | 527 | if ((stdout != NULL) && (fhandle(stdout, &fd_stdout) == EOK))
|
---|
| 528 | files[1] = &fd_stdout;
|
---|
[8e1dc00] | 529 | else
|
---|
| 530 | files[1] = NULL;
|
---|
| 531 |
|
---|
[7171760] | 532 | if ((stderr != NULL) && (fhandle(stderr, &fd_stderr) == EOK))
|
---|
| 533 | files[2] = &fd_stderr;
|
---|
[8e1dc00] | 534 | else
|
---|
| 535 | files[2] = NULL;
|
---|
| 536 |
|
---|
| 537 | files[3] = NULL;
|
---|
| 538 |
|
---|
| 539 | rc = loader_set_files(ldr, files);
|
---|
| 540 | if (rc != EOK)
|
---|
| 541 | goto error;
|
---|
| 542 |
|
---|
[4470e26] | 543 | /* Load the program. */
|
---|
| 544 | rc = loader_load_program(ldr);
|
---|
| 545 | if (rc != EOK)
|
---|
| 546 | goto error;
|
---|
| 547 |
|
---|
| 548 | /* Success */
|
---|
| 549 | return ldr;
|
---|
| 550 |
|
---|
| 551 | /* Error exit */
|
---|
| 552 | error:
|
---|
| 553 | loader_abort(ldr);
|
---|
| 554 | return NULL;
|
---|
| 555 | }
|
---|
[9a1b20c] | 556 |
|
---|
[84683fdc] | 557 | static int cev_fibril(void *arg)
|
---|
| 558 | {
|
---|
| 559 | (void) arg;
|
---|
[79ae36dd] | 560 |
|
---|
| 561 | console_ctrl_t *console = console_init(stdin, stdout);
|
---|
| 562 |
|
---|
[84683fdc] | 563 | while (true) {
|
---|
| 564 | fibril_mutex_lock(&state_lock);
|
---|
| 565 | while (cev_valid)
|
---|
| 566 | fibril_condvar_wait(&state_cv, &state_lock);
|
---|
| 567 | fibril_mutex_unlock(&state_lock);
|
---|
[79ae36dd] | 568 |
|
---|
| 569 | if (!console_get_kbd_event(console, &cev))
|
---|
[84683fdc] | 570 | return -1;
|
---|
[79ae36dd] | 571 |
|
---|
[84683fdc] | 572 | fibril_mutex_lock(&state_lock);
|
---|
[9ad5b5cc] | 573 | cev_valid = true;
|
---|
[84683fdc] | 574 | fibril_condvar_broadcast(&state_cv);
|
---|
[79ae36dd] | 575 | fibril_mutex_unlock(&state_lock);
|
---|
[84683fdc] | 576 | }
|
---|
| 577 | }
|
---|
| 578 |
|
---|
[4470e26] | 579 | static void trace_task(task_id_t task_id)
|
---|
| 580 | {
|
---|
[79ae36dd] | 581 | kbd_event_t ev;
|
---|
[9d8a1ed] | 582 | bool done;
|
---|
[4470e26] | 583 | int i;
|
---|
| 584 | int rc;
|
---|
[9a1b20c] | 585 |
|
---|
| 586 | ipcp_init();
|
---|
[c9a29d6] | 587 |
|
---|
[9a1b20c] | 588 | rc = get_thread_list();
|
---|
| 589 | if (rc < 0) {
|
---|
| 590 | printf("Failed to get thread list (error %d)\n", rc);
|
---|
| 591 | return;
|
---|
| 592 | }
|
---|
| 593 |
|
---|
[9ad5b5cc] | 594 | abort_trace = false;
|
---|
[9a1b20c] | 595 |
|
---|
| 596 | for (i = 0; i < n_threads; i++) {
|
---|
| 597 | thread_trace_start(thread_hash_buf[i]);
|
---|
| 598 | }
|
---|
| 599 |
|
---|
[9d8a1ed] | 600 | done = false;
|
---|
| 601 |
|
---|
| 602 | while (!done) {
|
---|
[84683fdc] | 603 | fibril_mutex_lock(&state_lock);
|
---|
| 604 | while (!cev_valid && !abort_trace)
|
---|
| 605 | fibril_condvar_wait(&state_cv, &state_lock);
|
---|
| 606 | fibril_mutex_unlock(&state_lock);
|
---|
| 607 |
|
---|
| 608 | ev = cev;
|
---|
| 609 |
|
---|
| 610 | fibril_mutex_lock(&state_lock);
|
---|
| 611 | cev_valid = false;
|
---|
| 612 | fibril_condvar_broadcast(&state_cv);
|
---|
| 613 | fibril_mutex_unlock(&state_lock);
|
---|
| 614 |
|
---|
| 615 | if (abort_trace)
|
---|
| 616 | break;
|
---|
[9d8a1ed] | 617 |
|
---|
| 618 | if (ev.type != KEY_PRESS)
|
---|
| 619 | continue;
|
---|
| 620 |
|
---|
| 621 | switch (ev.key) {
|
---|
| 622 | case KC_Q:
|
---|
| 623 | done = true;
|
---|
| 624 | break;
|
---|
| 625 | case KC_P:
|
---|
[741fd16] | 626 | printf("Pause...\n");
|
---|
[79ae36dd] | 627 | rc = udebug_stop(sess, thash);
|
---|
[654a30a] | 628 | if (rc != EOK)
|
---|
| 629 | printf("Error: stop -> %d\n", rc);
|
---|
[9d8a1ed] | 630 | break;
|
---|
| 631 | case KC_R:
|
---|
[84683fdc] | 632 | fibril_mutex_lock(&state_lock);
|
---|
[9ad5b5cc] | 633 | paused = false;
|
---|
[84683fdc] | 634 | fibril_condvar_broadcast(&state_cv);
|
---|
| 635 | fibril_mutex_unlock(&state_lock);
|
---|
[741fd16] | 636 | printf("Resume...\n");
|
---|
[9d8a1ed] | 637 | break;
|
---|
[7c014d1] | 638 | default:
|
---|
| 639 | break;
|
---|
[9a1b20c] | 640 | }
|
---|
| 641 | }
|
---|
| 642 |
|
---|
[c9a29d6] | 643 | printf("\nTerminate debugging session...\n");
|
---|
[9ad5b5cc] | 644 | abort_trace = true;
|
---|
[79ae36dd] | 645 | udebug_end(sess);
|
---|
| 646 | async_hangup(sess);
|
---|
[9a1b20c] | 647 |
|
---|
| 648 | ipcp_cleanup();
|
---|
| 649 |
|
---|
[c9a29d6] | 650 | printf("Done\n");
|
---|
[9a1b20c] | 651 | return;
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | static void main_init(void)
|
---|
| 655 | {
|
---|
| 656 | proto_t *p;
|
---|
| 657 | oper_t *o;
|
---|
| 658 |
|
---|
[abf3564] | 659 | val_type_t arg_def[OPER_MAX_ARGS] = {
|
---|
| 660 | V_INTEGER,
|
---|
| 661 | V_INTEGER,
|
---|
| 662 | V_INTEGER,
|
---|
| 663 | V_INTEGER,
|
---|
| 664 | V_INTEGER
|
---|
| 665 | };
|
---|
| 666 |
|
---|
| 667 | val_type_t resp_def[OPER_MAX_ARGS] = {
|
---|
| 668 | V_INTEGER,
|
---|
| 669 | V_INTEGER,
|
---|
| 670 | V_INTEGER,
|
---|
| 671 | V_INTEGER,
|
---|
[fa09449] | 672 | V_INTEGER
|
---|
[abf3564] | 673 | };
|
---|
| 674 |
|
---|
[9a1b20c] | 675 | next_thread_id = 1;
|
---|
[9ad5b5cc] | 676 | paused = false;
|
---|
| 677 | cev_valid = false;
|
---|
[84683fdc] | 678 |
|
---|
| 679 | fibril_mutex_initialize(&state_lock);
|
---|
| 680 | fibril_condvar_initialize(&state_cv);
|
---|
[9a1b20c] | 681 |
|
---|
| 682 | proto_init();
|
---|
| 683 |
|
---|
| 684 | p = proto_new("vfs");
|
---|
[a5facfb] | 685 | o = oper_new("open", 2, arg_def, V_INT_ERRNO, 0, resp_def);
|
---|
| 686 | proto_add_oper(p, VFS_IN_OPEN, o);
|
---|
[abf3564] | 687 | o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def);
|
---|
[4198f9c3] | 688 | proto_add_oper(p, VFS_IN_READ, o);
|
---|
[abf3564] | 689 | o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def);
|
---|
[4198f9c3] | 690 | proto_add_oper(p, VFS_IN_WRITE, o);
|
---|
[a5facfb] | 691 | o = oper_new("seek", 3, arg_def, V_ERRNO, 0, resp_def);
|
---|
| 692 | proto_add_oper(p, VFS_IN_SEEK, o);
|
---|
[abf3564] | 693 | o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def);
|
---|
[4198f9c3] | 694 | proto_add_oper(p, VFS_IN_TRUNCATE, o);
|
---|
[a5facfb] | 695 | o = oper_new("fstat", 1, arg_def, V_ERRNO, 0, resp_def);
|
---|
| 696 | proto_add_oper(p, VFS_IN_FSTAT, o);
|
---|
| 697 | o = oper_new("close", 1, arg_def, V_ERRNO, 0, resp_def);
|
---|
| 698 | proto_add_oper(p, VFS_IN_CLOSE, o);
|
---|
[abf3564] | 699 | o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def);
|
---|
[4198f9c3] | 700 | proto_add_oper(p, VFS_IN_MOUNT, o);
|
---|
[abf3564] | 701 | /* o = oper_new("unmount", 0, arg_def);
|
---|
[4198f9c3] | 702 | proto_add_oper(p, VFS_IN_UNMOUNT, o);*/
|
---|
[a5facfb] | 703 | o = oper_new("sync", 1, arg_def, V_ERRNO, 0, resp_def);
|
---|
| 704 | proto_add_oper(p, VFS_IN_SYNC, o);
|
---|
[741a7af9] | 705 | o = oper_new("mkdir", 1, arg_def, V_ERRNO, 0, resp_def);
|
---|
[4198f9c3] | 706 | proto_add_oper(p, VFS_IN_MKDIR, o);
|
---|
[741a7af9] | 707 | o = oper_new("unlink", 0, arg_def, V_ERRNO, 0, resp_def);
|
---|
[4198f9c3] | 708 | proto_add_oper(p, VFS_IN_UNLINK, o);
|
---|
[741a7af9] | 709 | o = oper_new("rename", 0, arg_def, V_ERRNO, 0, resp_def);
|
---|
[4198f9c3] | 710 | proto_add_oper(p, VFS_IN_RENAME, o);
|
---|
[a5facfb] | 711 | o = oper_new("stat", 0, arg_def, V_ERRNO, 0, resp_def);
|
---|
| 712 | proto_add_oper(p, VFS_IN_STAT, o);
|
---|
[9a1b20c] | 713 |
|
---|
| 714 | proto_register(SERVICE_VFS, p);
|
---|
| 715 | }
|
---|
| 716 |
|
---|
| 717 | static void print_syntax()
|
---|
| 718 | {
|
---|
[47e0a05b] | 719 | printf("Syntax:\n");
|
---|
| 720 | printf("\ttrace [+<events>] <executable> [<arg1> [...]]\n");
|
---|
| 721 | printf("or\ttrace [+<events>] -t <task_id>\n");
|
---|
[1643855] | 722 | printf("Events: (default is +tp)\n");
|
---|
| 723 | printf("\n");
|
---|
| 724 | printf("\tt ... Thread creation and termination\n");
|
---|
| 725 | printf("\ts ... System calls\n");
|
---|
| 726 | printf("\ti ... Low-level IPC\n");
|
---|
| 727 | printf("\tp ... Protocol level\n");
|
---|
| 728 | printf("\n");
|
---|
[47e0a05b] | 729 | printf("Examples:\n");
|
---|
| 730 | printf("\ttrace +s /app/tetris\n");
|
---|
| 731 | printf("\ttrace +tsip -t 12\n");
|
---|
[9a1b20c] | 732 | }
|
---|
| 733 |
|
---|
[a000878c] | 734 | static display_mask_t parse_display_mask(const char *text)
|
---|
[9a1b20c] | 735 | {
|
---|
[f1cc9db] | 736 | display_mask_t dm = 0;
|
---|
[a000878c] | 737 | const char *c = text;
|
---|
| 738 |
|
---|
[1643855] | 739 | while (*c) {
|
---|
| 740 | switch (*c) {
|
---|
[a000878c] | 741 | case 't':
|
---|
| 742 | dm = dm | DM_THREAD;
|
---|
| 743 | break;
|
---|
| 744 | case 's':
|
---|
| 745 | dm = dm | DM_SYSCALL;
|
---|
| 746 | break;
|
---|
| 747 | case 'i':
|
---|
| 748 | dm = dm | DM_IPC;
|
---|
| 749 | break;
|
---|
| 750 | case 'p':
|
---|
| 751 | dm = dm | DM_SYSTEM | DM_USER;
|
---|
| 752 | break;
|
---|
[1643855] | 753 | default:
|
---|
[ef687799] | 754 | printf("Unexpected event type '%c'.\n", *c);
|
---|
[1643855] | 755 | exit(1);
|
---|
| 756 | }
|
---|
[a000878c] | 757 |
|
---|
[1643855] | 758 | ++c;
|
---|
| 759 | }
|
---|
[a000878c] | 760 |
|
---|
[1643855] | 761 | return dm;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | static int parse_args(int argc, char *argv[])
|
---|
| 765 | {
|
---|
[9a1b20c] | 766 | char *err_p;
|
---|
| 767 |
|
---|
[47e0a05b] | 768 | task_id = 0;
|
---|
| 769 |
|
---|
[a000878c] | 770 | --argc;
|
---|
| 771 | ++argv;
|
---|
[1643855] | 772 |
|
---|
[47e0a05b] | 773 | while (argc > 0) {
|
---|
[a000878c] | 774 | char *arg = *argv;
|
---|
[1643855] | 775 | if (arg[0] == '+') {
|
---|
| 776 | display_mask = parse_display_mask(&arg[1]);
|
---|
[47e0a05b] | 777 | } else if (arg[0] == '-') {
|
---|
| 778 | if (arg[1] == 't') {
|
---|
| 779 | /* Trace an already running task */
|
---|
[a000878c] | 780 | --argc;
|
---|
| 781 | ++argv;
|
---|
[47e0a05b] | 782 | task_id = strtol(*argv, &err_p, 10);
|
---|
[4470e26] | 783 | task_ldr = NULL;
|
---|
[9ad5b5cc] | 784 | task_wait_for = false;
|
---|
[47e0a05b] | 785 | if (*err_p) {
|
---|
| 786 | printf("Task ID syntax error\n");
|
---|
| 787 | print_syntax();
|
---|
| 788 | return -1;
|
---|
| 789 | }
|
---|
| 790 | } else {
|
---|
[7e752b2] | 791 | printf("Uknown option '%c'\n", arg[0]);
|
---|
[47e0a05b] | 792 | print_syntax();
|
---|
| 793 | return -1;
|
---|
| 794 | }
|
---|
[1643855] | 795 | } else {
|
---|
[47e0a05b] | 796 | break;
|
---|
[1643855] | 797 | }
|
---|
[a000878c] | 798 |
|
---|
| 799 | --argc;
|
---|
| 800 | ++argv;
|
---|
[1643855] | 801 | }
|
---|
| 802 |
|
---|
[47e0a05b] | 803 | if (task_id != 0) {
|
---|
[a000878c] | 804 | if (argc == 0)
|
---|
| 805 | return 0;
|
---|
[47e0a05b] | 806 | printf("Extra arguments\n");
|
---|
[9a1b20c] | 807 | print_syntax();
|
---|
[47e0a05b] | 808 | return -1;
|
---|
[9a1b20c] | 809 | }
|
---|
| 810 |
|
---|
[47e0a05b] | 811 | if (argc < 1) {
|
---|
| 812 | printf("Missing argument\n");
|
---|
[9a1b20c] | 813 | print_syntax();
|
---|
[1643855] | 814 | return -1;
|
---|
[9a1b20c] | 815 | }
|
---|
| 816 |
|
---|
[4470e26] | 817 | /* Preload the specified program file. */
|
---|
[47e0a05b] | 818 | printf("Spawning '%s' with arguments:\n", *argv);
|
---|
[a000878c] | 819 |
|
---|
| 820 | char **cp = argv;
|
---|
| 821 | while (*cp)
|
---|
| 822 | printf("'%s'\n", *cp++);
|
---|
| 823 |
|
---|
[4470e26] | 824 | task_ldr = preload_task(*argv, argv, &task_id);
|
---|
[9ad5b5cc] | 825 | task_wait_for = true;
|
---|
[47e0a05b] | 826 |
|
---|
[1643855] | 827 | return 0;
|
---|
| 828 | }
|
---|
| 829 |
|
---|
| 830 | int main(int argc, char *argv[])
|
---|
| 831 | {
|
---|
[4470e26] | 832 | int rc;
|
---|
[6e3a44a] | 833 | task_exit_t texit;
|
---|
| 834 | int retval;
|
---|
[4470e26] | 835 |
|
---|
[1643855] | 836 | printf("System Call / IPC Tracer\n");
|
---|
[ef687799] | 837 | printf("Controls: Q - Quit, P - Pause, R - Resume\n");
|
---|
[1643855] | 838 |
|
---|
| 839 | display_mask = DM_THREAD | DM_SYSTEM | DM_USER;
|
---|
| 840 |
|
---|
| 841 | if (parse_args(argc, argv) < 0)
|
---|
| 842 | return 1;
|
---|
| 843 |
|
---|
[9a1b20c] | 844 | main_init();
|
---|
[4470e26] | 845 |
|
---|
| 846 | rc = connect_task(task_id);
|
---|
| 847 | if (rc < 0) {
|
---|
[7e752b2] | 848 | printf("Failed connecting to task %" PRIu64 ".\n", task_id);
|
---|
[4470e26] | 849 | return 1;
|
---|
| 850 | }
|
---|
| 851 |
|
---|
[7e752b2] | 852 | printf("Connected to task %" PRIu64 ".\n", task_id);
|
---|
[4470e26] | 853 |
|
---|
[6e3a44a] | 854 | if (task_ldr != NULL)
|
---|
[4470e26] | 855 | program_run();
|
---|
| 856 |
|
---|
[84683fdc] | 857 | cev_fibril_start();
|
---|
[4470e26] | 858 | trace_task(task_id);
|
---|
[1643855] | 859 |
|
---|
[6e3a44a] | 860 | if (task_wait_for) {
|
---|
| 861 | printf("Waiting for task to exit.\n");
|
---|
| 862 |
|
---|
| 863 | rc = task_wait(task_id, &texit, &retval);
|
---|
| 864 | if (rc != EOK) {
|
---|
| 865 | printf("Failed waiting for task.\n");
|
---|
| 866 | return -1;
|
---|
| 867 | }
|
---|
| 868 |
|
---|
| 869 | if (texit == TASK_EXIT_NORMAL) {
|
---|
| 870 | printf("Task exited normally, return value %d.\n",
|
---|
| 871 | retval);
|
---|
| 872 | } else {
|
---|
| 873 | printf("Task exited unexpectedly.\n");
|
---|
| 874 | }
|
---|
| 875 | }
|
---|
| 876 |
|
---|
[1643855] | 877 | return 0;
|
---|
[9a1b20c] | 878 | }
|
---|
| 879 |
|
---|
| 880 | /** @}
|
---|
| 881 | */
|
---|