backtracexx/example.cpp
pluto
cvs at pld-linux.org
Tue Sep 5 17:03:31 CEST 2006
Author: pluto
Date: Tue Sep 5 17:03:30 2006
New Revision: 7719
Modified:
backtracexx/example.cpp
Log:
- play with setjmp/longjmp too.
Modified: backtracexx/example.cpp
==============================================================================
--- backtracexx/example.cpp (original)
+++ backtracexx/example.cpp Tue Sep 5 17:03:30 2006
@@ -1,21 +1,28 @@
#include "backtracexx.hpp"
+#include <csetjmp>
#include <csignal>
#include <iostream>
#include <iterator>
#include <stdexcept>
+jmp_buf context;
+
void signalHandler( int signalNumber )
{
backtracexx::symbolic_backtrace_type s = backtracexx::symbols( backtracexx::scan() );
std::copy( s.begin(), s.end(), std::ostream_iterator< std::string >( std::cout, "\n" ) );
- throw std::runtime_error( "fatality." );
+ longjmp( context, 1 );
}
void zoo()
{
- volatile int* p = 0;
- *p = 0;
+ if ( setjmp( context ) == 0 )
+ {
+ volatile int* p = 0;
+ *p = 0;
+ }
+ throw std::runtime_error( "still alive?" );
}
void bar( void ( *f )() )
More information about the pld-cvs-commit
mailing list