Ignore:
Timestamp:
2010-01-07T19:06:59Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8190e63
Parents:
743e17b (diff), eca2435 (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 mainline changes.

File:
1 moved

Legend:

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

    r743e17b r985e26d2  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2009 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libcia32
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 /*
    36  * Variable argument list manipulation macros
    37  * for architectures using stack to pass arguments.
    38  */
    39  
    40 #ifndef LIBC_ia32_STACKARG_H_
    41 #define LIBC_ia32_STACKARG_H_
    42 
     35#include <stacktrace.h>
     36#include <stdio.h>
    4337#include <sys/types.h>
    4438
    45 /* dont allow to define it second time in stdarg.h */
    46 #define __VARARGS_DEFINED
     39void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc)
     40{
     41        printf("Printing stack trace:\n");
     42        printf("=====================\n");
     43        while (frame_pointer_validate(fp)) {
     44                printf("%p: %p()\n", fp, pc);
     45                pc = return_address_get(fp);
     46                fp = frame_pointer_prev(fp);
     47        }
     48        printf("=====================\n");
     49}
    4750
    48 typedef struct va_list {
    49         int pos;
    50         uint8_t *last;
    51 } va_list;
    52 
    53 #define va_start(ap, lst) \
    54         (ap).pos = sizeof(lst);                         \
    55         (ap).last = (uint8_t *) &(lst)
    56 
    57 #define va_arg(ap, type)                \
    58         (*((type *)((ap).last + ((ap).pos  += sizeof(type) ) - sizeof(type))))
    59 
    60 #define va_end(ap)
    61 
    62 
    63 #endif
     51void stack_trace(void)
     52{
     53        stack_trace_fp_pc(frame_pointer_get(), program_counter_get());
     54        /*
     55         * Prevent the tail call optimization of the previous call by
     56         * making it a non-tail call.
     57         */
     58        (void) frame_pointer_get();
     59}
    6460
    6561/** @}
Note: See TracChangeset for help on using the changeset viewer.