This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: powerpc-eabi-gdb backtrace problem


Nick Garnett wrote:
Jonathan Larmour <jifl@eCosCentric.com> writes:


Well if there's a problem it's with the HAL. HAL_THREAD_INIT_CONTEXT
is called _after_ all the padding is added, and it's that which should
add any relevant space. For the powerpc, it already leaves
CYGARC_PPC_STACK_FRAME_SIZE which is a whole 56 bytes (which looking
at the eABI I saw, looks like overkill).

If I recall correctly the EABI needs 7 words -- 4 argument save
locations, return link, frame pointer, TOC pointer. I chose to allow
twice that just to give us a safety buffer at the top of the stack.
That plus some of them in the ABI I saw says are optional: http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF77852569970071B0D6/$file/eabi_app.pdf
Sorry about the long link.

However I also note that area
isn't initialized to anything. But then we'd see it without the stack
frame checking enabled either.

In the absence of stack checking these locations will mostly be zero,
so GDB terminates. I guess that at least the frame pointer and return
link need to be zeroed.
Well the stack checking shouldn't reach that far in general - it only fills stuff round the edges of the stack. But let's see...

Christoph, can you try the attached patch with the stack checking re-enabled to see if it fixes the problem?

Well, actually it only fixes _a_ problem... the stub shouldn't fail like it did if it gets a bad address _anyway_. GDB's heuristics can fail for other reasons, e.g. aggressive optimisation.

Jifl
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[ can rejoice because thorns have roses." -Lincoln ]-- Opinions==mine
Index: hal/powerpc/arch/current/include/hal_arch.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/powerpc/arch/current/include/hal_arch.h,v
retrieving revision 1.11
diff -u -5 -p -r1.11 hal_arch.h
--- hal/powerpc/arch/current/include/hal_arch.h	23 May 2002 23:04:12 -0000	1.11
+++ hal/powerpc/arch/current/include/hal_arch.h	18 Feb 2003 23:05:59 -0000
@@ -142,10 +142,12 @@ externC void cyg_hal_deliver_exception( 
     CYG_MACRO_START                                                           \
     register CYG_WORD _sp_ = (((CYG_WORD)_sparg_) &~15)                       \
                                  - CYGARC_PPC_STACK_FRAME_SIZE;               \
     register HAL_SavedRegisters *_regs_;                                      \
     int _i_;                                                                  \
+    ((CYG_WORD *)_sp_)[0] = 0;            /* Zero old FP and LR for EABI */   \
+    ((CYG_WORD *)_sp_)[1] = 0;            /* to make GDB backtraces sane */   \
     _regs_ = (HAL_SavedRegisters *)((_sp_) - sizeof(HAL_SavedRegisters));     \
     for( _i_ = 0; _i_ < 32; _i_++ ) (_regs_)->d[_i_] = (_id_)|_i_;            \
     (_regs_)->d[01] = (CYG_WORD)(_sp_);        /* SP = top of stack      */   \
     (_regs_)->d[03] = (CYG_WORD)(_thread_);    /* R3 = arg1 = thread ptr */   \
     (_regs_)->cr = 0;                          /* CR = 0                 */   \

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]