Stack tracing on Linux ?
Georg Wrede
georg.wrede at iki.fi
Thu Apr 2 11:41:20 PDT 2009
Fawzi Mohamed wrote:
> Well inlined functions will have no frame, also last call optimization
> (tail optimization) removes the frame.
If I were to write a compiler, then using "-g -debug", etc. would make
sure neither happens!
> the backtrace typically gets the return address (i.e. the adress of the
> next instruction, not of the calling instruction).
> Normally the code tries to guess the calling instruction as the one
> before the return instruction, but it does not always work.
A first idea is to have the compiler insert a few NOPs when compiling
with -debug, but then again if it were that easy, somebody else would've
thought of it already.
> So one has to expect that the backtrace might miss some frames.
> But normally this is not a problem.
While I've seldom needed debuggin tools or stack tracing, I can imagine
they're indispensable for people who have to quickly fix others' code. I
guess most folks here, especially Walter(?) really do most of their
coding on "new" and "own" things, where there's less need for such? But
in a busy corporate environment with dozens of coders on the project,
and people having to debug (or actually ending up because the called
function doesn't work right) each other's code, it's different.
> The tracing of tango svn version (that uses libc backtrace) seems to
> work rather well.
> It does not give you the names, but as said that is due to a license
> problem.
Aarrghhh. What most frustrates me is when something obvious can't be
done because of external trivialities.
> gdb uses the same tools (and libbdf), that as jive has shown works well
> (but is GPL).
> So I think that things are working as expected, even if maybe not as you
> would like :)
It's a shame.
More information about the Digitalmars-d
mailing list