Thread: Stack trace

Stack trace

From
"Bramandia Ramadhana"
Date:
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

From
Emmanuel Cecchet
Date:
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

From
"Bramandia Ramadhana"
Date:
Hm the backtrace() method does not give the line numbers of the methods in the stack trace, it only gives the
hexadecimaloffset. Is there anyway to retrieve the line numbers? <br /><br />I have tried to Google it but to no
avail.<br/><br />Regards,<br /><br />Bramandia R.<br /><br /><div class="gmail_quote">On Tue, Nov 4, 2008 at 12:26 PM,
EmmanuelCecchet <span dir="ltr"><<a href="mailto:manu@frogthinker.org">manu@frogthinker.org</a>></span> wrote:<br
/><blockquoteclass="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex;
padding-left:1ex;"><div class="Ih2E3d">Bramandia Ramadhana wrote:<br /><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Is there any way to
printout the stack trace of the current location?<br /></blockquote></div> Not sure if Postgres has something in the
utilsfor that.<br /> You can use backtrace() in glibc. Solaris 9 libc has printstack(). Not sure what's available for
Windows.<divclass="Ih2E3d"><br /><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204);
margin:0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> I am looking for something like print_stack_trace(); that I can insert
inarbitrary location in the code.<br /></blockquote></div> Some references:<br /><a
href="http://www.tlug.org.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV"
target="_blank">http://www.tlug.org.za/wiki/index.php/Obtaining_a_stack_trace_in_C_upon_SIGSEGV</a><br/><a
href="http://www.delorie.com/gnu/docs/glibc/libc_665.html"
target="_blank">http://www.delorie.com/gnu/docs/glibc/libc_665.html</a><br/><br /> manu<br /><br /> -- <br /> Emmanuel
Cecchet<br/> FTO @ Frog Thinker Open Source Development & Consulting<br /><font color="#888888"> --<br /> Web: <a
href="http://www.frogthinker.org"target="_blank">http://www.frogthinker.org</a><br /> email: <a
href="mailto:manu@frogthinker.org"target="_blank">manu@frogthinker.org</a><br /> Skype: emmanuel_cecchet<br /><br
/></font></blockquote></div><br/> 

Re: Stack trace

From
Tom Lane
Date:
"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

From
"Bramandia Ramadhana"
Date:
Yes, I use --enable-debug as an option in configure <br /><br />Regards,<br /><br />Bramandia R.<br /><br /><div
class="gmail_quote">OnMon, Nov 17, 2008 at 2:11 PM, Tom Lane <span dir="ltr"><<a
href="mailto:tgl@sss.pgh.pa.us">tgl@sss.pgh.pa.us</a>></span>wrote:<br /><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div
class="Ih2E3d">"BramandiaRamadhana" <<a href="mailto:bramandia@gmail.com">bramandia@gmail.com</a>> writes:<br />
>Hm the backtrace() method does not give the line numbers of the methods in<br /> > the stack trace, it only
givesthe hexadecimal offset. Is there anyway to<br /> > retrieve the line numbers?<br /><br /></div>Did you build
with--enable-debug?<br /><br />                        regards, tom lane<br /></blockquote></div><br /> 

Re: Stack trace

From
"Hannes Eder"
Date:
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