Changes in uspace/app/taskdump/taskdump.c [1d6dd2a:9af1c61] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskdump/taskdump.c
r1d6dd2a r9af1c61 48 48 #include <macros.h> 49 49 #include <assert.h> 50 #include <str.h>51 50 52 51 #include <symtab.h> … … 64 63 static symtab_t *app_symtab; 65 64 66 static errno_t connect_task(task_id_t task_id);65 static int connect_task(task_id_t task_id); 67 66 static int parse_args(int argc, char *argv[]); 68 67 static void print_syntax(void); 69 static errno_t threads_dump(void);70 static errno_t thread_dump(uintptr_t thash);71 static errno_t areas_dump(void);72 static errno_t td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);68 static int threads_dump(void); 69 static int thread_dump(uintptr_t thash); 70 static int areas_dump(void); 71 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value); 73 72 74 73 static void autoload_syms(void); … … 84 83 int main(int argc, char *argv[]) 85 84 { 86 errno_t rc;85 int rc; 87 86 88 87 printf("Task Dump Utility\n"); … … 93 92 94 93 rc = connect_task(task_id); 95 if (rc != EOK) {94 if (rc < 0) { 96 95 printf("Failed connecting to task %" PRIu64 ".\n", task_id); 97 96 return 1; … … 106 105 107 106 rc = threads_dump(); 108 if (rc != EOK)107 if (rc < 0) 109 108 printf("Failed dumping threads.\n"); 110 109 111 110 rc = areas_dump(); 112 if (rc != EOK)111 if (rc < 0) 113 112 printf("Failed dumping address space areas.\n"); 114 113 115 114 rc = fibrils_dump(app_symtab, sess); 116 if (rc != EOK)115 if (rc < 0) 117 116 printf("Failed dumping fibrils.\n"); 118 117 … … 123 122 } 124 123 125 static errno_t connect_task(task_id_t task_id)124 static int connect_task(task_id_t task_id) 126 125 { 127 126 async_sess_t *ksess = async_connect_kbox(task_id); … … 141 140 } 142 141 143 errno_t rc = udebug_begin(ksess);144 if (rc != EOK) {145 printf("udebug_begin() -> % s\n", str_error_name(rc));142 int rc = udebug_begin(ksess); 143 if (rc < 0) { 144 printf("udebug_begin() -> %d\n", rc); 146 145 return rc; 147 146 } … … 211 210 } 212 211 213 static errno_t threads_dump(void)212 static int threads_dump(void) 214 213 { 215 214 uintptr_t *thash_buf; … … 220 219 size_t needed; 221 220 size_t i; 222 errno_t rc;221 int rc; 223 222 224 223 /* TODO: See why NULL does not work. */ 225 224 rc = udebug_thread_read(sess, &dummy_buf, 0, &copied, &needed); 226 if (rc != EOK) {227 printf("udebug_thread_read() -> % s\n", str_error_name(rc));225 if (rc < 0) { 226 printf("udebug_thread_read() -> %d\n", rc); 228 227 return rc; 229 228 } … … 238 237 239 238 rc = udebug_thread_read(sess, thash_buf, buf_size, &copied, &needed); 240 if (rc != EOK) {241 printf("udebug_thread_read() -> % s\n", str_error_name(rc));239 if (rc < 0) { 240 printf("udebug_thread_read() -> %d\n", rc); 242 241 return rc; 243 242 } … … 261 260 } 262 261 263 static errno_t areas_dump(void)262 static int areas_dump(void) 264 263 { 265 264 as_area_info_t *ainfo_buf; … … 270 269 size_t needed; 271 270 size_t i; 272 errno_t rc;271 int rc; 273 272 274 273 rc = udebug_areas_read(sess, &dummy_buf, 0, &copied, &needed); 275 if (rc != EOK) {276 printf("udebug_areas_read() -> % s\n", str_error_name(rc));274 if (rc < 0) { 275 printf("udebug_areas_read() -> %d\n", rc); 277 276 return rc; 278 277 } … … 282 281 283 282 rc = udebug_areas_read(sess, ainfo_buf, buf_size, &copied, &needed); 284 if (rc != EOK) {285 printf("udebug_areas_read() -> % s\n", str_error_name(rc));283 if (rc < 0) { 284 printf("udebug_areas_read() -> %d\n", rc); 286 285 return rc; 287 286 } … … 321 320 } 322 321 323 errno_t td_stacktrace(uintptr_t fp, uintptr_t pc)322 int td_stacktrace(uintptr_t fp, uintptr_t pc) 324 323 { 325 324 uintptr_t nfp; 326 325 stacktrace_t st; 327 326 char *sym_pc; 328 errno_t rc;327 int rc; 329 328 330 329 st.op_arg = NULL; … … 350 349 } 351 350 352 static errno_t thread_dump(uintptr_t thash)351 static int thread_dump(uintptr_t thash) 353 352 { 354 353 istate_t istate; 355 354 uintptr_t pc, fp; 356 355 char *sym_pc; 357 errno_t rc;356 int rc; 358 357 359 358 rc = udebug_regs_read(sess, thash, &istate); 360 if (rc != EOK) {361 printf("Failed reading registers : %s.\n", str_error_name(rc));359 if (rc < 0) { 360 printf("Failed reading registers (%d).\n", rc); 362 361 return EIO; 363 362 } … … 379 378 } 380 379 381 static errno_t td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value)380 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value) 382 381 { 383 382 uintptr_t data; 384 errno_t rc;383 int rc; 385 384 386 385 (void) arg; 387 386 388 387 rc = udebug_mem_read(sess, &data, addr, sizeof(data)); 389 if (rc != EOK) {388 if (rc < 0) { 390 389 printf("Warning: udebug_mem_read() failed.\n"); 391 390 return rc; … … 400 399 { 401 400 char *file_name; 402 errno_t rc; 403 int ret; 401 int rc; 404 402 405 403 assert(app_name != NULL); 406 404 assert(app_symtab == NULL); 407 405 408 r et= asprintf(&file_name, "/app/%s", app_name);409 if (r et< 0) {406 rc = asprintf(&file_name, "/app/%s", app_name); 407 if (rc < 0) { 410 408 printf("Memory allocation failure.\n"); 411 409 exit(1); … … 421 419 free(file_name); 422 420 423 r et= asprintf(&file_name, "/srv/%s", app_name);424 if (r et< 0) {421 rc = asprintf(&file_name, "/srv/%s", app_name); 422 if (rc < 0) { 425 423 printf("Memory allocation failure.\n"); 426 424 exit(1); … … 434 432 } 435 433 436 r et= asprintf(&file_name, "/drv/%s/%s", app_name, app_name);437 if (r et< 0) {434 rc = asprintf(&file_name, "/drv/%s/%s", app_name, app_name); 435 if (rc < 0) { 438 436 printf("Memory allocation failure.\n"); 439 437 exit(1); … … 456 454 size_t copied, needed, name_size; 457 455 char *name; 458 errno_t rc;456 int rc; 459 457 460 458 rc = udebug_name_read(sess, &dummy_buf, 0, &copied, &needed); 461 if (rc != EOK)459 if (rc < 0) 462 460 return NULL; 463 461 … … 465 463 name = malloc(name_size + 1); 466 464 rc = udebug_name_read(sess, name, name_size, &copied, &needed); 467 if (rc != EOK) {465 if (rc < 0) { 468 466 free(name); 469 467 return NULL; … … 489 487 char *name; 490 488 size_t offs; 491 errno_t rc; 492 int ret; 489 int rc; 493 490 char *str; 494 491 … … 500 497 501 498 if (rc == EOK) { 502 r et= asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs);499 rc = asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs); 503 500 } else { 504 r et= asprintf(&str, "%p", (void *) addr);505 } 506 507 if (r et< 0) {501 rc = asprintf(&str, "%p", (void *) addr); 502 } 503 504 if (rc < 0) { 508 505 printf("Memory allocation error.\n"); 509 506 exit(1);
Note:
See TracChangeset
for help on using the changeset viewer.