The following code: StackFactory.createFrame(task).getOuter().getAddress() when called in a situation where the task has just been stoppen at the entry of the function "__libc_csu_init", returns number of commandline arguments instead of the outer frame. This happens when task's binary has no debuginfo. The mentioned function is called early during process setup, before main. I'm not sure there is anything to fix, maybe it's just a limitation of the system. I discuvered that memory pointed to by the ESP register also contains bogus address, so maybe there's no way out of this mess... and I will have to work around this in ftrace.
I have a test case for this, but it depends on symtab.SymbolFactory being able to answer Dwfl's symbol table, which is a patch that I currently have only locally. But I guess, for debugging purposes, it shouldn't be a big problem to hardcode breakpoint address to fit entry point of __libc_csu_init in any throwaway "hallo world" binary.
If there is no debug (or eh) frame info we fall back to heuristics. Like using the frame pointer. Which of course might not be used, or might not yet have been setup as is most likely the case here. Test case appreciated. But I'll try to replicate by hand as soon as I have my x86 machine up (on x86_64 __libc_csu_init seems to have eh_frame info available).
Test added as frysk.stack.TestFrame.testBogusAddressPrevFrame() commit 1e6a205bbcbe119523df8e4a569a9aa3c9aa29b3 Author: Petr Machata <pmachata@redhat.com> Date: Fri Apr 4 12:38:38 2008 +0200 Add test for #6029
It wasn't dependent on no debuginfo (there was still eh_frame info in this specific case). The problem was because the pc was not yet adjusted for the breakpoint address when the Code observer updateHit() method was called. Fixed by: commit 40fbefd8950ef47a338fd60e10ab6ed234330fc2 Author: Mark Wielaard <mwielaard@redhat.com> Date: Fri Apr 11 19:22:53 2008 +0200 Set task pc before calling any Code observers on breakpoint. Fixes bug #6029 frysk-core/frysk/proc/live/ChangeLog 2008-04-11 Mark Wielaard <mwielaard@redhat.com> * LinuxPtraceTaskState.java (Running.setupSteppingBreakpoint): Removed. (Running.handleTrappedEvent): Don't call setupSteppingBreakpoint(). (Stepping.handleTrappedEvent): Don't do stepping breakpoint sanity check. Don't call setupSteppingBreakpoint(). * LinuxPtraceTask.java (notifyCodeBreakpoint): Add stepping breakpoint sanity check. Set task pc when breakpoint found. Set steppingBreakpoint. frysk-core/frysk/stack/ChangeLog 2008-04-11 Mark Wielaard <mwielaard@redhat.com> * TestFrame.java (testBogusAddressPrevFrame): Resolved.