Ignore:
File:
1 edited

Legend:

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

    rc1b979a r3e6a98c5  
    3535#include <async.h>
    3636#include <elf/elf_linux.h>
    37 #include <fibrildump.h>
    3837#include <stdio.h>
    3938#include <stdlib.h>
     
    5352#include <elf_core.h>
    5453#include <stacktrace.h>
    55 #include <taskdump.h>
    5654
    5755#define LINE_BYTES 16
     
    7876static istate_t reg_state;
    7977
    80 static stacktrace_ops_t td_stacktrace_ops = {
    81         .read_uintptr = td_read_uintptr
    82 };
    83 
    8478int main(int argc, char *argv[])
    8579{
     
    112106        if (rc < 0)
    113107                printf("Failed dumping address space areas.\n");
    114 
    115         rc = fibrils_dump(app_symtab, sess);
    116         if (rc < 0)
    117                 printf("Failed dumping fibrils.\n");
    118108
    119109        udebug_end(sess);
     
    321311}
    322312
    323 int td_stacktrace(uintptr_t fp, uintptr_t pc)
    324 {
    325         uintptr_t nfp;
     313static int thread_dump(uintptr_t thash)
     314{
     315        istate_t istate;
     316        uintptr_t pc, fp, nfp;
    326317        stacktrace_t st;
    327318        char *sym_pc;
    328319        int rc;
    329320
     321        rc = udebug_regs_read(sess, thash, &istate);
     322        if (rc < 0) {
     323                printf("Failed reading registers (%d).\n", rc);
     324                return EIO;
     325        }
     326
     327        pc = istate_get_pc(&istate);
     328        fp = istate_get_fp(&istate);
     329
     330        /* Save register state for dumping to core file later. */
     331        reg_state = istate;
     332
     333        sym_pc = fmt_sym_address(pc);
     334        printf("Thread %p: PC = %s. FP = %p\n", (void *) thash,
     335            sym_pc, (void *) fp);
     336        free(sym_pc);
     337
    330338        st.op_arg = NULL;
    331         st.ops = &td_stacktrace_ops;
     339        st.read_uintptr = td_read_uintptr;
    332340
    333341        while (stacktrace_fp_valid(&st, fp)) {
     
    346354                fp = nfp;
    347355        }
    348 
    349         return EOK;
    350 }
    351 
    352 static int thread_dump(uintptr_t thash)
    353 {
    354         istate_t istate;
    355         uintptr_t pc, fp;
    356         char *sym_pc;
    357         int rc;
    358 
    359         rc = udebug_regs_read(sess, thash, &istate);
    360         if (rc < 0) {
    361                 printf("Failed reading registers (%d).\n", rc);
    362                 return EIO;
    363         }
    364 
    365         pc = istate_get_pc(&istate);
    366         fp = istate_get_fp(&istate);
    367 
    368         /* Save register state for dumping to core file later. */
    369         reg_state = istate;
    370 
    371         sym_pc = fmt_sym_address(pc);
    372         printf("Thread %p: PC = %s. FP = %p\n", (void *) thash,
    373             sym_pc, (void *) fp);
    374         free(sym_pc);
    375 
    376         (void) td_stacktrace(fp, pc);
    377356
    378357        return EOK;
Note: See TracChangeset for help on using the changeset viewer.