Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Stack tracing
Stack tracing [message #38857] Thu, 24 January 2013 13:49 Go to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi,

Since assertion messages aren't very helpful in hunting for bugs, I decided to add some extra help to them (at least for gcc users). Modified Core/Utils.ccp/AssertFailed displays call stack similar to this one:

Stack trace:
Upp::AddStackTrace(char*, int)
Upp::AssertFailed(char const*, int, char const*)
Upp::AString<Upp::String0>::operator[](int) const
Upp::CCTalk::GetAsciiData(int, int, Upp::String&)
Upp::CCTalk::EquipmentID(int, Upp::String&)
Upp::CCTalk::FindDevs()
Upp::CCTalk::WorkingThread()
Upp::CallbackMethodAction<Upp::CCTalk, void (Upp::CCTalk::*)()>::Execute()
Upp::Callback::Execute() const
Upp::Callback::operator()() const

clone


All you need (beside modified version of Core/Utils.cpp) is '-rdynamic' added to linker options in your application.
Disadvantages? Bigger executable, much longer linking time and of course visible function names.
Debug symbols are not necessary, all function names are kept in .dynsym section.


Without -rdynamic, call stack looks like this one:
Stack trace:
() [0x82bf968]
() [0x82bfc18]
() [0x8053fbe]
() [0x8052948]
() [0x8053c51]
() [0x80522b0]
() [0x8053009]
() [0x8054d26]
() [0x825cb0a]
() [0x8050fd3]
() [0x8241889]
(
(clone


Edit:
New version of Util.cpp is uploaded.
  • Attachment: Util.cpp
    (Size: 16.75KB, Downloaded 295 times)

[Updated on: Fri, 03 May 2013 17:08]

Report message to a moderator

Re: Stack tracing [message #38859 is a reply to message #38857] Thu, 24 January 2013 19:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Nice. I will merge it into the trunk as option...

Mirek
Re: Stack tracing [message #38864 is a reply to message #38859] Thu, 24 January 2013 19:52 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
OK. I have just spotted that mingw doesn't support backtrace and all conditional blocks should be:
#if defined(PLATFORM_POSIX) && defined(COMPILER_GCC)

Re: Stack tracing [message #39817 is a reply to message #38859] Fri, 03 May 2013 17:13 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Mirek,

When can you add this patch to the trunk?

[Updated on: Fri, 03 May 2013 17:14]

Report message to a moderator

Re: Stack tracing [message #42468 is a reply to message #38859] Tue, 18 March 2014 11:17 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
mirek wrote on Thu, 24 January 2013 19:32

Nice. I will merge it into the trunk as option...
Mirek


I noticed that stack trace requires flagSTACKTRACE since revision 7000. Maybe you could also add new link option to the core package:
When GCC POSIX STACKTRACE: -rdynamic
It will add function names to a binary file when flag STACKTRACE is present.
Re: Stack tracing [message #42471 is a reply to message #42468] Tue, 18 March 2014 11:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Now thinking about it, we could also activate with "SO"?
Re: Stack tracing [message #42485 is a reply to message #42471] Wed, 19 March 2014 11:19 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
mirek wrote on Tue, 18 March 2014 11:33

we could also activate with "SO"?


Some people say that instead of adding -rdynamic it is simpler to execute:
dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
to load main binary symbol table, but I never tried it.
Re: Stack tracing [message #42496 is a reply to message #42485] Wed, 19 March 2014 19:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Zbych wrote on Wed, 19 March 2014 06:19

mirek wrote on Tue, 18 March 2014 11:33

we could also activate with "SO"?


Some people say that instead of adding -rdynamic it is simpler to execute:
dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
to load main binary symbol table, but I never tried it.



Does not seem to work..
Re: Stack tracing [message #43978 is a reply to message #42496] Fri, 05 December 2014 12:43 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi Mirek,

Could you add link option "GCC POSIX STACKTRACE: -rdynamic" to the core package?

Re: Stack tracing [message #43979 is a reply to message #43978] Fri, 05 December 2014 16:50 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Done
Previous Topic: Problem with some keyboard keys
Next Topic: Vector<int>::At does not return a default constructed value
Goto Forum:
  


Current Time: Thu Mar 28 17:08:56 CET 2024

Total time taken to generate the page: 0.01127 seconds