finding the call stack (like tt command) - VxWorks

This is a discussion on finding the call stack (like tt command) - VxWorks ; Hi *, Do you know how the tt command is implemented? I want to be able at any function find the call stack (not only to print it but to save it to some kind of linked list) Thanks a ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: finding the call stack (like tt command)

  1. finding the call stack (like tt command)

    Hi *,
    Do you know how the tt command is implemented?
    I want to be able at any function find the call stack
    (not only to print it but to save it to some kind of linked list)
    Thanks a lot.
    Patrick



  2. Re: finding the call stack (like tt command)

    Hi:

    tt() uses calls in trcLib, which is pretty much an undocumented
    internal library. All the entry points in it are static, so you won't
    be able to call them yourself.

    So you'll just have to tracethrough the pointers yourself, and
    dump/dave what you like.

    There are decent notes in the FAQ - start with
    http://www.xs4all.nl/~borkhuis/vxworks/ppcStack.txt

    Good luck,
    lc


  3. Re: finding the call stack (like tt command)

    "PatrickC" wrote in message
    news:e3vnk1$2ou$1@mail1.sbs.de...
    > Hi *,
    > Do you know how the tt command is implemented?
    > I want to be able at any function find the call stack
    > (not only to print it but to save it to some kind of linked list)
    > Thanks a lot.
    > Patrick


    See the following in the FAQ:

    http://www.xs4all.nl/~borkhuis/vxwor...pt5.html#5.9-E



  4. Re: finding the call stack (like tt command)

    Hi Khayman,
    The link you send works perfectly but I get sometimes
    for the same thread the error:
    trcStack aborted: error in top frame
    Do you know why I get this error?
    By looking at the web I found out there is a relation
    with the stack size per thread. Thus I used the
    stackCheck command to find out the behavior of threads
    on runtime. The problem is that I do not see any overflow.
    Even if I reduce the code as follow (minimize allocated local variables on
    the stack)
    I also get the same error


    static void GetCallStackTracePrint
    (
    INSTR *caller,
    int func,
    int nargs,
    int *args
    )
    {

    }


    int xxxTrace
    (
    WIND_TCB *pTcb
    )
    {
    if (pTcb == NULL)
    return (ERROR);
    trcStack (&(pTcb->regs), (FUNCPTR) GetCallStackTracePrint, (int)pTcb);
    return (OK);
    }



    "Khayman" wrote in message
    news:Te2dnUDHdfCzaf7ZRVn-rg@comcast.com...
    > "PatrickC" wrote in message
    > news:e3vnk1$2ou$1@mail1.sbs.de...
    >> Hi *,
    >> Do you know how the tt command is implemented?
    >> I want to be able at any function find the call stack
    >> (not only to print it but to save it to some kind of linked list)
    >> Thanks a lot.
    >> Patrick

    >
    > See the following in the FAQ:
    >
    > http://www.xs4all.nl/~borkhuis/vxwor...pt5.html#5.9-E
    >
    >




  5. Re: finding the call stack (like tt command)

    "PatrickC" wrote in message
    news:e42d5c$i5g$1@mail1.sbs.de...
    > Hi Khayman,
    > The link you send works perfectly but I get sometimes
    > for the same thread the error:
    > trcStack aborted: error in top frame
    > Do you know why I get this error?


    Sorry, you got me there...

    Is the thread running C code? If it is straight assembly code, it might be
    using the stack in a non-standard manner, though that would definitely be
    abnormal.



  6. Re: finding the call stack (like tt command)

    Hi Khayman
    I resolved the problem by making the call to trcStack
    within the context on another thread. This works fine for
    me.
    Again thanks a lot for the link
    Patrick

    "Khayman" wrote in message
    news:eq6dndz7as-E-_jZRVn-jQ@comcast.com...
    > "PatrickC" wrote in message
    > news:e42d5c$i5g$1@mail1.sbs.de...
    >> Hi Khayman,
    >> The link you send works perfectly but I get sometimes
    >> for the same thread the error:
    >> trcStack aborted: error in top frame
    >> Do you know why I get this error?

    >
    > Sorry, you got me there...
    >
    > Is the thread running C code? If it is straight assembly code, it might
    > be
    > using the stack in a non-standard manner, though that would definitely be
    > abnormal.
    >
    >




  7. Re: finding the call stack (like tt command)

    PatrickC wrote:
    > Hi Khayman
    > I resolved the problem by making the call to trcStack
    > within the context on another thread. This works fine for
    > me.
    > Again thanks a lot for the link
    > Patrick
    >
    > "Khayman" wrote in message
    > news:eq6dndz7as-E-_jZRVn-jQ@comcast.com...
    > > "PatrickC" wrote in message
    > > news:e42d5c$i5g$1@mail1.sbs.de...
    > >> Hi Khayman,
    > >> The link you send works perfectly but I get sometimes
    > >> for the same thread the error:
    > >> trcStack aborted: error in top frame
    > >> Do you know why I get this error?

    > >
    > > Sorry, you got me there...
    > >
    > > Is the thread running C code? If it is straight assembly code, it might
    > > be
    > > using the stack in a non-standard manner, though that would definitely be
    > > abnormal.
    > >
    > >


    I have even seen the error message "trcStack aborted: error in top
    frame " when stacktrace is run by some other thread. But I dont know
    what is the reason for this. Is it because it finds a static function
    in the trace OR it does not find the frame pointer in the stack?

    Subhash


  8. Re: finding the call stack (like tt command)


    > Hi Khayman,
    > The link you send works perfectly but I get sometimes
    > for the same thread the error:
    > trcStack aborted: error in top frame
    > Do you know why I get this error?
    > By looking at the web I found out there is a relation
    > with the stack size per thread. Thus I used the
    > stackCheck command to find out the behavior of threads
    > on runtime. The problem is that I do not see any overflow.
    > Even if I reduce the code as follow (minimize allocated local
    > variables on
    > the stack)
    > I also get the same error
    >
    >
    > static void GetCallStackTracePrint
    > (
    > INSTR *caller,
    > int func,
    > int nargs,
    > int *args
    > )
    > {
    >
    > }
    >
    >
    > int xxxTrace
    > (
    > WIND_TCB *pTcb
    > )
    > {
    > if (pTcb == NULL)
    > return (ERROR);
    > trcStack (&(pTcb->regs), (FUNCPTR) GetCallStackTracePrint, (int)pTcb);
    > return (OK);
    > }
    >
    >
    >
    > "Khayman" wrote in message
    > news:Te2dnUDHdfCzaf7ZRVn-rg@comcast.com...
    > > "PatrickC" wrote in message
    > > news:e3vnk1$2ou$1@mail1.sbs.de...
    > >> Hi *,
    > >> Do you know how the tt command is implemented?
    > >> I want to be able at any function find the call stack
    > >> (not only to print it but to save it to some kind of linked list)
    > >> Thanks a lot.
    > >> Patrick

    > >
    > > See the following in the FAQ:
    > >
    > > http://www.xs4all.nl/~borkhuis/vxwor...pt5.html#5.9-E
    > >
    > >


    Maybe some other task is corrupting your stack.

    See also the stack checking code on the FAQ site of John Borkhuis, and
    add the taskSwitchHook which checks the stack at every taskSwitch (see
    also taskSwitchHookAdd)

    Please do yourself a BIG favor and read the John Borkhuis-VxWorks-FAQ
    and learn it by heart. It's quite interresting info.

    Another thing, to debug the stack yourself. this aint that hard as you
    might think and you'll learn quite a lot.

    Cheers,
    Renee.

    --


+ Reply to Thread