Joshua ChaitinPollak wrote:
Hello,

I'm at my wits end. I'm building a C++ application for an embedded
device, but I'm having trouble catching exceptions within the embedded
environment. The exact same code works fine on my regular desktop
environment, with the same version of GCC (4.1.2).

I've been able to boil this down to a single source file and one compile
command:

g++ -fexceptions -frtti -o program program.cpp

Here is my program, the output from each environment, along with the
output from 'g++ -v' is below.

Thanks for any help you can give, I'm not even sure how to begin
diagnosing this further, so any hints would be appreciated.

-Josh

// BEGIN EXCEPTION TEST
#include <iostream>

class test {
  public:
  test() throw(std::exception);
};

test::test() throw(std::exception) {
    throw std::exception();
}

int main() {
  try {
    test t;
  }
  catch(std::exception e) {
    std::cout << "caught" << std::endl;
  }

  return 0;
}
// END EXCEPTION TEST


Here is what happens when I run from my embedded environment:

moya exceptionTest # g++ -fexceptions -frtti -o program program.cpp
moya exceptionTest # ./program terminate called after throwing an instance of 'std::exception'
terminate called recursively
Aborted (core dumped)
moya exceptionTest # g++ -v
Using built-in specs.
Target: i586-gentoo-linux-uclibc
Configured
with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure
--prefix=/usr --bindir=/usr/i586-gentoo-linux-uclibc/gcc-bin/4.1.2
--includedir=/usr/lib/gcc/i586-gentoo-linux-uclibc/4.1.2/include
--datadir=/usr/share/gcc-data/i586-gentoo-linux-uclibc/4.1.2
--mandir=/usr/share/gcc-data/i586-gentoo-linux-uclibc/4.1.2/man
--infodir=/usr/share/gcc-data/i586-gentoo-linux-uclibc/4.1.2/info
--with-gxx-include-dir=/usr/lib/gcc/i586-gentoo-linux-uclibc/4.1.2/include/g++-v4
 --host=i586-gentoo-linux-uclibc --build=i586-gentoo-linux-uclibc 
--disable-altivec --disable-nls --with-system-zlib --disable-checking 
--disable-werror --enable-secureplt --disable-multilib --disable-libmudflap 
--disable-libssp --disable-libgcj --enable-languages=c,c++ --enable-shared 
--enable-threads=posix --disable-__cxa_atexit --enable-target-optspace 
--enable-clocale=uclibc
Thread model: posix
gcc version 4.1.2 (Gentoo 4.1.2)


You don't say what version of uclibc you are using.
The last time I checked, exception handling on uClibc was foobar. I am not sure if it is true for the versions you are using. There may be patches floating around that make things work (I know I posted some a while back.)

David Daney.

Reply via email to