I had to write this code to be able to get the stack trace under TinyC:

#ifdef __TINYC__int backtrace(void **buffer, int size) {
        extern uint64_t *__libc_stack_end;
        uint64_t **p, *bp, *frame;
        asm ("mov %%rbp, %0;" : "=r" (bp));
        p = (uint64_t**) bp;
        int i = 0;
        while (i < size) {
                frame = p[0];
                if (frame < bp || frame > __libc_stack_end) {
                        return i;
                }
                buffer[i++] = p[1];
                p = (uint64_t**) frame;
        }
        return i;}#endif



2018-03-09 15:24 GMT+05:45 Yakov <[email protected]>:

>
>
> *#include* <execinfo.h>
> *#include* <stdio.h>
>
> *void* show_bt*() {*
>     *int* n;
>     *void* *buffer*[**111];*
>     *char* **strings*;*
>     n *=* backtrace*(*buffer*,* *111);*
>     strings *=* backtrace_symbols*(*buffer*,* n*);*
>     *while* *(*strings *&&* n*)* printf("%s\n"*,* strings*[*n*---*1*]);*
> *}*
>
> *void* c*()* *{* show_bt*(); }*
> *void* b*()* *{* c*(); }*
> *void* a*()* *{* b*(); }*
> *int* main*()* *{* a*(); }*
>
>
>
> The above code does not work on Tiny. Although works on GCC/Clang for me.
>
>
>
> *$ tcc -versiontcc version 0.9.26 (x86-64 Linux)*
>
>
> I have tried to no avail:* "-bt 100", "-g", "-rdynamic"*, also tried to
> link with gcc and ld.
>
>
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to