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


Ignore:
Timestamp:
2010-01-26T21:31:56Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3698e44
Parents:
80487bc5
Message:

Make stacktrace implementation in C library more generic. Use it in taskdump to print a stack trace of the faulting task.

File:
1 edited

Legend:

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

    r80487bc5 re515b21a  
    4646#include <bool.h>
    4747
     48#include <stacktrace.h>
     49
    4850#define LINE_BYTES 16
    4951
     
    5759static int connect_task(task_id_t task_id);
    5860static int parse_args(int argc, char *argv[]);
    59 static void print_syntax();
     61static void print_syntax(void);
    6062static int threads_dump(void);
    6163static int thread_dump(uintptr_t thash);
     
    6365static int area_dump(as_area_info_t *area);
    6466static void hex_dump(uintptr_t addr, void *buffer, size_t size);
     67static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value);
    6568
    6669int main(int argc, char *argv[])
     
    184187}
    185188
    186 static void print_syntax()
     189static void print_syntax(void)
    187190{
    188191        printf("Syntax: taskdump [-m] -t <task_id>\n");
     
    298301{
    299302        istate_t istate;
    300         uintptr_t pc, fp;
     303        uintptr_t pc, fp, nfp;
     304        stacktrace_t st;
    301305        int rc;
    302306
     
    311315
    312316        printf("Thread 0x%lx crashed at PC 0x%lx. FP 0x%lx\n", thash, pc, fp);
    313         printf("Istate hexdump:\n");
    314         hex_dump(0, &istate, (sizeof(istate_t) + 15) & ~15);
     317
     318        st.op_arg = NULL;
     319        st.read_uintptr = td_read_uintptr;
     320
     321        while (stacktrace_fp_valid(&st, fp)) {
     322                printf("%p: %p()\n", fp, pc);
     323
     324                rc = stacktrace_ra_get(&st, fp, &pc);
     325                if (rc != EOK)
     326                        return rc;
     327
     328                rc = stacktrace_fp_prev(&st, fp, &nfp);
     329                if (rc != EOK)
     330                        return rc;
     331
     332                fp = nfp;
     333        }
    315334
    316335        return EOK;
     
    376395}
    377396
     397static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value)
     398{
     399        uintptr_t data;
     400        int rc;
     401
     402        (void) arg;
     403
     404        rc = udebug_mem_read(phoneid, &data, addr, sizeof(data));
     405        if (rc < 0) {
     406                printf("Warning: udebug_mem_read() failed.\n");
     407                return rc;
     408        }
     409
     410        *value = data;
     411        return EOK;
     412}
     413
    378414/** @}
    379415 */
Note: See TracChangeset for help on using the changeset viewer.