Обсуждение: Stack trace

Поиск
Список
Период
Сортировка

Stack trace

От
"Bramandia Ramadhana"
Дата:
Hi all,<br /><br />Is there any way to print out the stack trace of the current location? <br /><br />I am looking for
somethinglike print_stack_trace(); that I can insert in arbitrary location in the code.<br /><br />Thank you,<br /><br
/>Regards,<br /><br />Bramandia R.<br /><br /> 

Re: Stack trace

От
Emmanuel Cecchet
Дата:
Bramandia Ramadhana wrote:
> Is there any way to print out the stack trace of the current location?
Not sure if Postgres has something in the utils for that.
You can use backtrace() in glibc. Solaris 9 libc has printstack(). Not 
sure what's available for Windows.
> I am looking for something like print_stack_trace(); that I can insert 
> in arbitrary location in the code.
Some references:
http://www.tlug.org.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV
http://www.delorie.com/gnu/docs/glibc/libc_665.html

manu

-- 
Emmanuel Cecchet
FTO @ Frog Thinker 
Open Source Development & Consulting
--
Web: http://www.frogthinker.org
email: manu@frogthinker.org
Skype: emmanuel_cecchet



Re: Stack trace

От
"Bramandia Ramadhana"
Дата:
Hm the backtrace() method does not give the line numbers of the methods in the stack trace, it only gives the hexadecimal offset. Is there anyway to retrieve the line numbers?

I have tried to Google it but to no avail.

Regards,

Bramandia R.

On Tue, Nov 4, 2008 at 12:26 PM, Emmanuel Cecchet <manu@frogthinker.org> wrote:
Bramandia Ramadhana wrote:
Is there any way to print out the stack trace of the current location?
Not sure if Postgres has something in the utils for that.
You can use backtrace() in glibc. Solaris 9 libc has printstack(). Not sure what's available for Windows.

I am looking for something like print_stack_trace(); that I can insert in arbitrary location in the code.
Some references:
http://www.tlug.org.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV
http://www.delorie.com/gnu/docs/glibc/libc_665.html

manu

--
Emmanuel Cecchet
FTO @ Frog Thinker Open Source Development & Consulting
--
Web: http://www.frogthinker.org
email: manu@frogthinker.org
Skype: emmanuel_cecchet


Re: Stack trace

От
Tom Lane
Дата:
"Bramandia Ramadhana" <bramandia@gmail.com> writes:
> Hm the backtrace() method does not give the line numbers of the methods in
> the stack trace, it only gives the hexadecimal offset. Is there anyway to
> retrieve the line numbers?

Did you build with --enable-debug?
        regards, tom lane


Re: Stack trace

От
"Bramandia Ramadhana"
Дата:
Yes, I use --enable-debug as an option in configure

Regards,

Bramandia R.

On Mon, Nov 17, 2008 at 2:11 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Bramandia Ramadhana" <bramandia@gmail.com> writes:
> Hm the backtrace() method does not give the line numbers of the methods in
> the stack trace, it only gives the hexadecimal offset. Is there anyway to
> retrieve the line numbers?

Did you build with --enable-debug?

                       regards, tom lane

Re: Stack trace

От
"Hannes Eder"
Дата:
On Mon, Nov 17, 2008 at 7:08 AM, Bramandia Ramadhana
<bramandia@gmail.com> wrote:
> Hm the backtrace() method does not give the line numbers of the methods in
> the stack trace, it only gives the hexadecimal offset. Is there anyway to
> retrieve the line numbers?

the binutil addr2line should do the trick.

Best,
Hannes