This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

stack-checking


hello,

I am working on an embedded system, which runs elf
images and have no underlying OS. 

I have modified GCC to check at the start of each
function whether the current stack pointer is out of
range..i.e. to check stack overflow.

My problem is how can I print diagnostic messages when
stack overflow occurs? 
Since once the overflow occurs , the functions printf
etc does not work as they themselves need stack space.

1. One solution is to reserve some stack space for
printf
etc. and signal the stack overflow
early, but that's not correct since the application
has not really exhausted the stack as of
yet.

2. another solution is to use the lower level calls
which actually prints (_write()) the string, but i
would like to format e.g.. The error messages whould
indicate the function name in which it occured etc. 

Please suggest what is the correct way to perform
stack checking in absence of OS.

Regards,
ita

________________________________________________________________________
Yahoo! India Careers: Over 65,000 jobs online
Go to: http://yahoo.naukri.com/


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