Changeset c1b979a in mainline for uspace/app/taskdump/taskdump.c


Ignore:
Timestamp:
2014-07-11T23:06:30Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
78192cc7
Parents:
8e4a408
Message:

Taskdump printing of fibril stacktraces.

File:
1 edited

Legend:

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

    r8e4a408 rc1b979a  
    3535#include <async.h>
    3636#include <elf/elf_linux.h>
     37#include <fibrildump.h>
    3738#include <stdio.h>
    3839#include <stdlib.h>
     
    5253#include <elf_core.h>
    5354#include <stacktrace.h>
     55#include <taskdump.h>
    5456
    5557#define LINE_BYTES 16
     
    7678static istate_t reg_state;
    7779
     80static stacktrace_ops_t td_stacktrace_ops = {
     81        .read_uintptr = td_read_uintptr
     82};
     83
    7884int main(int argc, char *argv[])
    7985{
     
    106112        if (rc < 0)
    107113                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");
    108118
    109119        udebug_end(sess);
     
    311321}
    312322
     323int td_stacktrace(uintptr_t fp, uintptr_t pc)
     324{
     325        uintptr_t nfp;
     326        stacktrace_t st;
     327        char *sym_pc;
     328        int rc;
     329
     330        st.op_arg = NULL;
     331        st.ops = &td_stacktrace_ops;
     332
     333        while (stacktrace_fp_valid(&st, fp)) {
     334                sym_pc = fmt_sym_address(pc);
     335                printf("  %p: %s\n", (void *) fp, sym_pc);
     336                free(sym_pc);
     337
     338                rc = stacktrace_ra_get(&st, fp, &pc);
     339                if (rc != EOK)
     340                        return rc;
     341
     342                rc = stacktrace_fp_prev(&st, fp, &nfp);
     343                if (rc != EOK)
     344                        return rc;
     345
     346                fp = nfp;
     347        }
     348
     349        return EOK;
     350}
     351
    313352static int thread_dump(uintptr_t thash)
    314353{
    315354        istate_t istate;
    316         uintptr_t pc, fp, nfp;
    317         stacktrace_t st;
     355        uintptr_t pc, fp;
    318356        char *sym_pc;
    319357        int rc;
     
    336374        free(sym_pc);
    337375
    338         st.op_arg = NULL;
    339         st.read_uintptr = td_read_uintptr;
    340 
    341         while (stacktrace_fp_valid(&st, fp)) {
    342                 sym_pc = fmt_sym_address(pc);
    343                 printf("  %p: %s\n", (void *) fp, sym_pc);
    344                 free(sym_pc);
    345 
    346                 rc = stacktrace_ra_get(&st, fp, &pc);
    347                 if (rc != EOK)
    348                         return rc;
    349 
    350                 rc = stacktrace_fp_prev(&st, fp, &nfp);
    351                 if (rc != EOK)
    352                         return rc;
    353 
    354                 fp = nfp;
    355         }
     376        (void) td_stacktrace(fp, pc);
    356377
    357378        return EOK;
Note: See TracChangeset for help on using the changeset viewer.