[ECOS] C++ exceptions and gcc ecos aware

Henning Baldersheim henning.baldersheim@devoll.no
Sat Mar 13 06:19:00 GMT 2004


Hi

I am trying to get c++ exception handling to work, and now I am almost there.
I have searched the archives and concluded that it is not working properly. 
So I thought that I would give it a try. Since exceptions are a compiler 
implemented feature they have to be added there.
Using gcc-3.3.3 as a template I have made a gthr-ecos.h file and changed 
the config files necessary to get it working. I am targeting powerpc. gcc 
now builds fine with libstc++ and things look good, until I throw 
something. Then I just get aborted.

I might need some hints to get going again.
As far as I can see gcc has 3 different exception schemes. sjlj-exceptions, 
unwind1 and unwind2. It seems likeunwind2 superceeds unwind1.
When I did not specify anything 'configure' choose the unwind2 method. 
However that did not work. On debugging here I can see that some something 
should have been initialized at an earlier stage, but it is not. 
__register_frame_info_bases should be called from crtbegin.o. and calls to 
__register_frame_info_table_bases should have been generated by collect2.

But when I switched to --enable-sjlj-exceptions things got a lot better. 
That seems to work very well. libstdc++ seems to be ok too. I haven't done 
too much testing, but at least iostreams work fine.

Then I have a few questions.

Which exception model is the prefered one ? I guess unwind2 is the best 
since it chose it first. Any ideas on what is missing to get it working ? 
Is there any documentation on the 2 methods.

Is there any interest in getting this into ecos ?
Here is a brief scheme of what I did.
1 - Made a gthr-ecos.h file.
2 - Made some minor changes in the config files to recognize an ecos target 
and set the correct thread model.
3 - Made a base ecos three so that I had access to the ecos include files.
4 - Made an ecos target in the configure under libstdc++v3. That was to 
avoid it refering some none-existent math functions(float only versions 
like acosf). split up functexcept.cc to avoid linking in everything if you 
just want new/delete, both with and without exceptions.
5 - Implemented the gthr-ecos.cxx and adding it to ecos. I made wrapper 
functions, based on the rtems example, in order to do testing. This can be 
moved to the gthr-ecos.h file in gcc.
6 - Disabled need for --with-newlib since it is not necessary for ecos.
7 - Implement a missing strdup function needed by libstdc++-v3.
9 - Added multilibs for -fno-exceptions. Gives libstdc++-v3 functionality 
without the code bloat of rtti and exceptions.
8 - configure with "/home/balder/src/gcc-3.3.3/configure 
--target=powerpc-eabi-ecos --enable-languages=c,c++ --with-gnu-as 
--with-gnu-ld --enable-version-specific-runtime-libs --disable-shared 
--enable-sjlj-exceptions 
--with-sysroot=/home/balder/build/ecos/phy-def_install/

It seems like most of this except for strdup depends on gcc. Is there any 
interest in getting this into gcc ?

Henning


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



More information about the Ecos-discuss mailing list