Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskdump/taskdump.c

    rdafa2d04 r7e752b2  
    5454#define LINE_BYTES 16
    5555
    56 #define DBUF_SIZE 4096
    57 static uint8_t data_buf[DBUF_SIZE];
    58 
    5956static int phoneid;
    6057static task_id_t task_id;
     
    7067static int thread_dump(uintptr_t thash);
    7168static int areas_dump(void);
    72 static int area_dump(as_area_info_t *area);
    73 static void hex_dump(uintptr_t addr, void *buffer, size_t size);
    7469static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);
    7570
     
    9085        rc = connect_task(task_id);
    9186        if (rc < 0) {
    92                 printf("Failed connecting to task %" PRIdTASKID ".\n", task_id);
     87                printf("Failed connecting to task %" PRIu64 ".\n", task_id);
    9388                return 1;
    9489        }
     
    9792        app_symtab = NULL;
    9893
    99         printf("Dumping task '%s' (task ID %" PRIdTASKID ").\n", app_name, task_id);
     94        printf("Dumping task '%s' (task ID %" PRIu64 ").\n", app_name, task_id);
    10095        autoload_syms();
    10196        putchar('\n');
     
    131126        if (rc < 0) {
    132127                printf("Error connecting\n");
    133                 printf("ipc_connect_task(%" PRIdTASKID ") -> %d ", task_id, rc);
     128                printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc);
    134129                return rc;
    135130        }
     
    173168                                core_file_name = *argv;
    174169                        } else {
    175                                 printf("Uknown option '%s'\n", arg[0]);
     170                                printf("Uknown option '%c'\n", arg[0]);
    176171                                print_syntax();
    177172                                return -1;
     
    245240        printf("Threads:\n");
    246241        for (i = 0; i < n_threads; i++) {
    247                 printf(" [%d] hash: %p\n", 1+i, thash_buf[i]);
     242                printf(" [%zu] hash: %p\n", 1 + i, (void *) thash_buf[i]);
    248243
    249244                thread_dump(thash_buf[i]);
     
    289284        printf("Address space areas:\n");
    290285        for (i = 0; i < n_areas; i++) {
    291                 printf(" [%d] flags: %c%c%c%c base: %p size: %p\n", 1+i,
     286                printf(" [%zu] flags: %c%c%c%c base: %p size: %zu\n", 1 + i,
    292287                    (ainfo_buf[i].flags & AS_AREA_READ) ? 'R' : '-',
    293288                    (ainfo_buf[i].flags & AS_AREA_WRITE) ? 'W' : '-',
    294289                    (ainfo_buf[i].flags & AS_AREA_EXEC) ? 'X' : '-',
    295290                    (ainfo_buf[i].flags & AS_AREA_CACHEABLE) ? 'C' : '-',
    296                     ainfo_buf[i].start_addr, ainfo_buf[i].size);
     291                    (void *) ainfo_buf[i].start_addr, ainfo_buf[i].size);
    297292        }
    298293
     
    331326
    332327        sym_pc = fmt_sym_address(pc);
    333         printf("Thread %p crashed at %s. FP = %p\n", thash, sym_pc, fp);
     328        printf("Thread %p crashed at %s. FP = %p\n", (void *) thash,
     329            sym_pc, (void *) fp);
    334330        free(sym_pc);
    335331
     
    339335        while (stacktrace_fp_valid(&st, fp)) {
    340336                sym_pc = fmt_sym_address(pc);
    341                 printf("  %p: %s\n", fp, sym_pc);
     337                printf("  %p: %s\n", (void *) fp, sym_pc);
    342338                free(sym_pc);
    343339
     
    354350
    355351        return EOK;
    356 }
    357 
    358 static int area_dump(as_area_info_t *area)
    359 {
    360         size_t to_copy;
    361         size_t total;
    362         uintptr_t addr;
    363         int rc;
    364 
    365         addr = area->start_addr;
    366         total = 0;
    367 
    368         while (total < area->size) {
    369                 to_copy = min(area->size - total, DBUF_SIZE);
    370                 rc = udebug_mem_read(phoneid, data_buf, addr, to_copy);
    371                 if (rc < 0) {
    372                         printf("udebug_mem_read() failed.\n");
    373                         return rc;
    374                 }
    375 
    376                 hex_dump(addr, data_buf, to_copy);
    377 
    378                 addr += to_copy;
    379                 total += to_copy;
    380         }
    381 
    382         return EOK;
    383 }
    384 
    385 static void hex_dump(uintptr_t addr, void *buffer, size_t size)
    386 {
    387         uint8_t *data = (uint8_t *) buffer;
    388         uint8_t b;
    389         size_t pos, i;
    390 
    391         assert(addr % LINE_BYTES == 0);
    392         assert(size % LINE_BYTES == 0);
    393 
    394         pos = 0;
    395 
    396         while (pos < size) {
    397                 printf("%08lx:", addr + pos);
    398                 for (i = 0; i < LINE_BYTES; ++i) {
    399                         if (i % 4 == 0) putchar(' ');
    400                         printf(" %02x", data[pos + i]);
    401                 }
    402                 putchar('\t');
    403 
    404                 for (i = 0; i < LINE_BYTES; ++i) {
    405                         b = data[pos + i];
    406                         if (b >= 32 && b < 127) {
    407                                 putchar(b);
    408                         } else {
    409                                 putchar(' ');
    410                         }
    411                 }
    412                 putchar('\n');
    413                 pos += LINE_BYTES;
    414         }
    415352}
    416353
     
    521458
    522459        if (rc == EOK) {
    523                 rc = asprintf(&str, "%p (%s+%p)", addr, name, offs);
     460                rc = asprintf(&str, "%p (%s+%zu)", (void *) addr, name, offs);
    524461        } else {
    525                 rc = asprintf(&str, "%p", addr);
     462                rc = asprintf(&str, "%p", (void *) addr);
    526463        }
    527464
Note: See TracChangeset for help on using the changeset viewer.