From 9d6953b2aee60165b11ace650b259e97d3af3dfd Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Thu, 27 Oct 2011 13:57:29 +0000 Subject: [PATCH] added sanity check on input file for ps_analyze, and a c++ exception throwing example. Former-commit-id: 3da306b94c2b925b40aa048d870f8db5049b7585 --- .gitattributes | 1 + c++_examples/Makefile | 13 +++++++------ c++_examples/throw.cpp | 31 +++++++++++++++++++++++++++++++ tools/ps_analyze.sh | 10 ++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 c++_examples/throw.cpp diff --git a/.gitattributes b/.gitattributes index 081570451..b5e6f64b6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -38,6 +38,7 @@ c++_examples/newdel_broke4.cpp -text c++_examples/newdel_broke5.cpp -text c++_examples/newdel_broke6.cpp -text c++_examples/newdel_broke7.cpp -text +c++_examples/throw.cpp -text chopzero_src/Makefile -text chopzero_src/chopzero.c -text demos/Makefile -text diff --git a/c++_examples/Makefile b/c++_examples/Makefile index 51dc91f03..9b4dd6008 100644 --- a/c++_examples/Makefile +++ b/c++_examples/Makefile @@ -5,9 +5,9 @@ CXX=DO_NOT_USE CFLAGS=DO_NOT_USE LD=DO_NOT_USE -.SUFFIXES: .o .c .cpp .exe +.SUFFIXES: .o .c .cpp .stock .protected -exes=hanoi++.exe newdel.exe newdel_broke1.exe newdel_broke2.exe newdel_broke3.exe newdel_broke4.exe newdel_broke5.exe newdel_broke6.exe newdel_broke7.exe +exes=hanoi++.protected newdel.protected newdel_broke1.protected newdel_broke2.protected newdel_broke3.protected newdel_broke4.protected newdel_broke5.protected newdel_broke6.protected newdel_broke7.protected throw.protected all: env_check ${exes} @@ -16,10 +16,11 @@ all: env_check ${exes} .PHONY: env_check +.stock.protected: + ${PEASOUP_HOME}/tools/ps_analyze.sh $< $@ -.o.exe: - g++ $< -o $@ - ${PEASOUP_HOME}/tools/ps_analyze.sh $@ $@ +.o.stock: + g++ -static -Bstatic $< -o $@ .c.o: ${PEASOUP_HOME}/tools/ps_comp.sh $< @@ -56,7 +57,7 @@ env_check: clean: rm -f *.o *.syms *.map chopzero hanoi hanoi_overrun hanoi_heap_overrun malloc block_copy print_ptr hanoi_stack_overrun dumbledore a.out memcpy hanoi_overrun_taintedenv dumbledore_cmd hanoi_overrun_tainted hello cmd_args_005 - rm -f *.exe *.dis *.data *.idb *.log *.ncexe *.annot *.readelf temp.* *.temp *.stratafied *.asm *.SMPobjdump *.id0 *.id1 *.til *.nam + rm -f *.stock *.dis *.data *.idb *.log *.ncexe *.annot *.readelf temp.* *.temp *.stratafied *.asm *.SMPobjdump *.id0 *.id1 *.til *.nam *.protected rm -Rf concolic.files_* rm -Rf peasoup_executable_directory.* rm -f strata.log.* diff --git a/c++_examples/throw.cpp b/c++_examples/throw.cpp new file mode 100644 index 000000000..783c6bc88 --- /dev/null +++ b/c++_examples/throw.cpp @@ -0,0 +1,31 @@ + +#include <iostream> +#include <string> +using namespace std; + +void bar() +{ + throw string("Print this string"); +} + +void foo() +{ + string s=" shoult not print "; + bar(); + cout<<s<<endl; + +} +main() +{ + + try + { + foo(); + } + catch(string s) + { + cout<<"Threw string s:" << s << endl; + } + +} + diff --git a/tools/ps_analyze.sh b/tools/ps_analyze.sh index a229bbe67..981afdfa3 100755 --- a/tools/ps_analyze.sh +++ b/tools/ps_analyze.sh @@ -326,6 +326,16 @@ orig_exe=$1 newname=a shift + +# +# sanity check incoming arg. +# +if [ ! -f $orig_exe ]; then + echo ps_analyze cannot find file named $orig_exe. + echo exiting... + exit -2 +fi + # # record the new program's name # -- GitLab