diff --git a/.gitattributes b/.gitattributes index 2ae02134e6e77a8354957a5888d8a58238287934..bf6fba63af167e27a6f87348e4c3b5eab4f73269 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,10 @@ /LICENSE.txt -text /Makefile -text c++_examples/Makefile -text +c++_examples/derived2_throw.cpp -text +c++_examples/derived3_throw.cpp -text +c++_examples/derived4_throw.cpp -text +c++_examples/derived_throw.cpp -text c++_examples/hanoi++.cpp -text c++_examples/newdel.cpp -text c++_examples/newdel_broke1.cpp -text diff --git a/c++_examples/derived2_throw.cpp b/c++_examples/derived2_throw.cpp new file mode 100644 index 0000000000000000000000000000000000000000..09d62519085c0f6f0765c2fd80a2abcaec57282a --- /dev/null +++ b/c++_examples/derived2_throw.cpp @@ -0,0 +1,53 @@ + +#include <iostream> +#include <stdlib.h> +using namespace std; + +class Base +{ + public: + Base() : a(3) { } + + int a; +}; + +class Derived : public Base +{ + public: + Derived() { a=4;} +}; + +int bar() +{ + if(getenv("THROW_CHAR")!=NULL) + throw Base(); + else if(getenv("THROW_INT")!=NULL) + throw Derived(); + else if(getenv("THROW_FLOAT")!=NULL) + throw float(3.14); + else + return 0; +} + +main() +{ + + try + { + int res= bar(); + cout<<"No Throw!"<<endl; + return res; + } + catch(Derived s) + { + cout<<"main caught Derived with val=" << s.a << endl; + } + catch(...) + { + cout<<"main caught unnamed"<<endl; + } + + return 1; + +} + diff --git a/c++_examples/derived3_throw.cpp b/c++_examples/derived3_throw.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fde802cd207bcb87a4dcd4c18b0c15968796a4a4 --- /dev/null +++ b/c++_examples/derived3_throw.cpp @@ -0,0 +1,57 @@ + +#include <iostream> +#include <stdlib.h> +using namespace std; + +class Base +{ + public: + Base() : a(3) { } + + int a; +}; + +class Derived : public Base +{ + public: + Derived() { a=4;} +}; + +int bar() +{ + if(getenv("THROW_CHAR")!=NULL) + throw Base(); + else if(getenv("THROW_INT")!=NULL) + throw Derived(); + else if(getenv("THROW_FLOAT")!=NULL) + throw float(3.14); + else + return 0; +} + +main() +{ + + try + { + int res= bar(); + cout<<"No Throw!"<<endl; + return res; + } + catch(Base s) + { + cout<<"main caught Base with val=" << s.a << endl; + } + catch(Derived s) + { + cout<<"main caught Derived with val=" << s.a << endl; + } + catch(...) + { + cout<<"main caught unnamed"<<endl; + } + + return 1; + +} + diff --git a/c++_examples/derived4_throw.cpp b/c++_examples/derived4_throw.cpp new file mode 100644 index 0000000000000000000000000000000000000000..327adc94cb4961d9278613d290b28cf715ff3b40 --- /dev/null +++ b/c++_examples/derived4_throw.cpp @@ -0,0 +1,57 @@ + +#include <iostream> +#include <stdlib.h> +using namespace std; + +class Base +{ + public: + Base() : a(3) { } + + int a; +}; + +class Derived : public Base +{ + public: + Derived() { a=4;} +}; + +int bar() +{ + if(getenv("THROW_CHAR")!=NULL) + throw Base(); + else if(getenv("THROW_INT")!=NULL) + throw Derived(); + else if(getenv("THROW_FLOAT")!=NULL) + throw float(3.14); + else + return 0; +} + +main() +{ + + try + { + int res= bar(); + cout<<"No Throw!"<<endl; + return res; + } + catch(Derived s) + { + cout<<"main caught Derived with val=" << s.a << endl; + } + catch(Base s) + { + cout<<"main caught Base with val=" << s.a << endl; + } + catch(...) + { + cout<<"main caught unnamed"<<endl; + } + + return 1; + +} + diff --git a/c++_examples/derived_throw.cpp b/c++_examples/derived_throw.cpp new file mode 100644 index 0000000000000000000000000000000000000000..33ecb9ee548c0252d5697c998026e34ae57fef34 --- /dev/null +++ b/c++_examples/derived_throw.cpp @@ -0,0 +1,53 @@ + +#include <iostream> +#include <stdlib.h> +using namespace std; + +class Base +{ + public: + Base() : a(3) { } + + int a; +}; + +class Derived : public Base +{ + public: + Derived() { a=4;} +}; + +int bar() +{ + if(getenv("THROW_CHAR")!=NULL) + throw Base(); + else if(getenv("THROW_INT")!=NULL) + throw Derived(); + else if(getenv("THROW_FLOAT")!=NULL) + throw float(3.14); + else + return 0; +} + +main() +{ + + try + { + int res= bar(); + cout<<"No Throw!"<<endl; + return res; + } + catch(Base s) + { + cout<<"main caught Base with val=" << s.a << endl; + } + catch(...) + { + cout<<"main caught unnamed"<<endl; + } + + return 1; + +} + diff --git a/c++_examples/testit.sh b/c++_examples/testit.sh index 84043898af421440c7f695719f5e140980f5295c..309dd230fcea3cd8a9bd2c589ee66240c5d1d4c7 100755 --- a/c++_examples/testit.sh +++ b/c++_examples/testit.sh @@ -1,5 +1,9 @@ #!/bin/bash +src_files="derived4_throw.cpp derived3_throw.cpp derived2_throw.cpp derived_throw.cpp simple_throw.cpp throw.cpp " +throws="THROW_INT THROW_CHAR THROW_FLOAT" + +#--------------- compare() { @@ -15,27 +19,49 @@ compare() fi } -src_files="simple_throw.cpp throw.cpp" -options="-Os -O0 -O1 -O2 -O3" -throws="THROW_INT THROW_CHAR THROW_FLOAT" +doit() +{ + src=$1 + shift + options=$* + + echo "Trying $src with options: $options " + g++ -w $options $src + rm -Rf peasoup_executable_direc* + EHIR_VERBOSE=1 $PSZ ./a.out ./xxx --step-option fill_in_indtargs:--split-eh-frame --step-option zipr:'--add-sections true' + + compare + + for throw in $throws + do + compare $throw=1 + done +} + -for src in $src_files -do - echo "Trying $src" +doit_meta() +{ + src=$1 + shift + option=$* + + doit $src $option + doit $src $option -fPIC + doit $src $option -fPIC -fPIE + doit $src $option -fPIC -fPIE -fomit-frame-pointer +} - for option in $options +main() +{ + + for src in $src_files do - echo "With $option" - g++ $option $src - rm -Rf peasoup_executable_direc* - EHIR_VERBOSE=1 $PSZ ./a.out ./xxx --step-option fill_in_indtargs:--split-eh-frame --step-option zipr:'--add-sections true' - - compare - - for throw in $throws - do - compare $throw=1 - done - + doit_meta $src "-O0" + doit_meta $src "-O1" + doit_meta $src "-O2" + doit_meta $src "-O3" + doit_meta $src "-Os" done -done +} + +main diff --git a/tools/db/pdb.createprogram.tbl b/tools/db/pdb.createprogram.tbl index afa1d7cf6dae2ed7010fbfd10856e89c5a298076..d9a88db1831aa5702d1ae5bf9c14a14619898bb7 100644 --- a/tools/db/pdb.createprogram.tbl +++ b/tools/db/pdb.createprogram.tbl @@ -120,6 +120,6 @@ CREATE TABLE #EHCS# ( ehcs_id integer, -- id of this object. tt_encoding integer, -- the encoding of the type table. - has_cleanup integer, -- whether this callsite has cleanups, even if the type table is empty. + ttov text, -- the order of TT entries to use, a 0 indicates a cleanup lp_insn_id integer -- the landing pad instruction's id. );