Function which prints stack trace of the program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • khan

    Function which prints stack trace of the program

    Hi

    I am in need to write a function which prints the stack trace of
    current program

    The need is that if any exception occurs then apart from error message
    we want to print the stack trace of the program

    Has any one does something like this
    if yes please share your experience with us

    thanks in advance

    from
    khan

  • Ian Collins

    #2
    Re: Function which prints stack trace of the program

    khan wrote:
    Hi
    >
    I am in need to write a function which prints the stack trace of
    current program
    >
    The need is that if any exception occurs then apart from error message
    we want to print the stack trace of the program
    >
    Has any one does something like this
    if yes please share your experience with us
    >
    Yes (on an embedded target), but it is very system specific, there isn't
    a portable way to do this.

    I guess one answer is to use a debugger, or some other wrapper
    application that can examine the state of yours when it bombs.

    --
    Ian Collins.

    Comment

    • James Kanze

      #3
      Re: Function which prints stack trace of the program

      On Nov 8, 10:42 am, khan <d.nayeem.k...@ gmail.comwrote:
      I am in need to write a function which prints the stack trace of
      current program
      The need is that if any exception occurs then apart from error message
      we want to print the stack trace of the program
      Has any one does something like this
      if yes please share your experience with us
      There's no portable solution, but I have code at my site
      (kanze.james.ne uf.fr) for PC (under Windwos or Linux) and Sparc
      (both 32 bit and 64 bit).

      --
      James Kanze (GABI Software) email:james.kan ze@gmail.com
      Conseils en informatique orientée objet/
      Beratung in objektorientier ter Datenverarbeitu ng
      9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

      Comment

      • Scott Gifford

        #4
        Re: Function which prints stack trace of the program

        khan <d.nayeem.khan@ gmail.comwrites :
        I am in need to write a function which prints the stack trace of
        current program
        [...]

        Funny you mention that, I was just reading this article on how to do
        this under Linux:



        That's Linux-specific. The only portable way I know of is to hack
        some macros together which use __FILE__ and __LINE__, and at each step
        catch the exception, add their stack trace information, then re-throw
        it.

        Good luck!

        ----Scott.

        Comment

        • Victor Bazarov

          #5
          Re: Function which prints stack trace of the program

          Brendon Costa wrote:
          Getting a stack trace is not simple cross platform. I have written a
          class that will get it for, Windows, Linux and Other UNIX'es (Compiled
          With GCC)
          [..] If interested i will post more information about
          this later.
          I recommend doing it in the platform newsgroup[s].

          V
          --
          Please remove capital 'A's when replying by e-mail
          I do not respond to top-posted replies, please don't ask


          Comment

          Working...