Changeset 1735f3e in mainline for uspace/lib/libc/generic/stacktrace.c


Ignore:
Timestamp:
2010-01-31T18:22:37Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fc2e71e
Parents:
430de97 (diff), 2e07f62c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from mainline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/generic/stacktrace.c

    r430de97 r1735f3e  
    11/*
    22 * Copyright (c) 2009 Jakub Jermar
     3 * Copyright (c) 2010 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3637#include <stdio.h>
    3738#include <sys/types.h>
     39#include <errno.h>
    3840
    39 void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc)
     41static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
     42
     43void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
    4044{
    41         while (frame_pointer_validate(fp)) {
     45        stacktrace_t st;
     46        uintptr_t nfp;
     47
     48        st.op_arg = NULL;
     49        st.read_uintptr = stacktrace_read_uintptr;
     50
     51        while (stacktrace_fp_valid(&st, fp)) {
    4252                printf("%p: %p()\n", fp, pc);
    43                 pc = return_address_get(fp);
    44                 fp = frame_pointer_prev(fp);
     53                (void) stacktrace_ra_get(&st, fp, &pc);
     54                (void) stacktrace_fp_prev(&st, fp, &nfp);
     55                fp = nfp;
    4556        }
    4657}
    4758
    48 void stack_trace(void)
     59void stacktrace_print(void)
    4960{
    50         stack_trace_fp_pc(frame_pointer_get(), program_counter_get());
     61        stacktrace_prepare();
     62        stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get());
    5163        /*
    5264         * Prevent the tail call optimization of the previous call by
    5365         * making it a non-tail call.
    5466         */
    55         (void) frame_pointer_get();
     67        (void) stacktrace_fp_get();
     68}
     69
     70static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data)
     71{
     72        (void) arg;
     73        *data = *((uintptr_t *) addr);
     74        return EOK;
    5675}
    5776
Note: See TracChangeset for help on using the changeset viewer.