From: Nicholas Nethercote Date: Tue, 22 Apr 2003 21:41:40 +0000 (+0000) Subject: Added "Int exitcode" argument to SK_(fini)(), because it could be useful X-Git-Tag: svn/VALGRIND_2_0_0~221 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=092c9b944b9ff1fd0ac8ced06d187edfd853ef20;p=thirdparty%2Fvalgrind.git Added "Int exitcode" argument to SK_(fini)(), because it could be useful for skins. Changed lackey to print out the exit code. Changed AUTOMAKE_OPTIONS back to 1.5 (whoops) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1538 --- diff --git a/Makefile.am b/Makefile.am index cdb6f36c82..9e9e1d67e6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ -AUTOMAKE_OPTIONS = 1.4 +AUTOMAKE_OPTIONS = 1.5 ## coregrind must come before memcheck, addrcheck, helgrind, for ## vg_replace_malloc.o. diff --git a/addrcheck/ac_main.c b/addrcheck/ac_main.c index 2df76da660..1e259cd951 100644 --- a/addrcheck/ac_main.c +++ b/addrcheck/ac_main.c @@ -1243,7 +1243,7 @@ void SK_(post_clo_init) ( void ) { } -void SK_(fini) ( void ) +void SK_(fini) ( Int exitcode ) { MAC_(common_fini)( ac_detect_memory_leaks ); } diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index 24a69d2a3b..943b4989a5 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -1674,7 +1674,7 @@ void percentify(Int n, Int pow, Int field_width, char buf[]) for (i = 0; i < space; i++) buf[i] = ' '; } -void SK_(fini)(void) +void SK_(fini)(Int exitcode) { CC D_total; ULong L2_total_m, L2_total_mr, L2_total_mw, diff --git a/corecheck/cc_main.c b/corecheck/cc_main.c index 340a78df85..b30d94c966 100644 --- a/corecheck/cc_main.c +++ b/corecheck/cc_main.c @@ -56,7 +56,7 @@ UCodeBlock* SK_(instrument)(UCodeBlock* cb, Addr a) return cb; } -void SK_(fini)(void) +void SK_(fini)(Int exitcode) { } diff --git a/coregrind/vg_default.c b/coregrind/vg_default.c index 800e258c3e..6aea85e25d 100644 --- a/coregrind/vg_default.c +++ b/coregrind/vg_default.c @@ -89,7 +89,7 @@ UCodeBlock* SK_(instrument)(UCodeBlock* cb, Addr not_used) } __attribute__ ((weak)) -void SK_(fini)(void) +void SK_(fini)(Int exitcode) { fund_panic("SK_(fini)"); } diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 902b5f072b..513aa8c944 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -1480,7 +1480,7 @@ void VG_(main) ( void ) if (VG_(needs).core_errors || VG_(needs).skin_errors) VG_(show_all_errors)(); - SK_(fini)(); + SK_(fini)( VG_(exitcode) ); VG_(do_sanity_checks)( True /*include expensive checks*/ ); diff --git a/example/ex_main.c b/example/ex_main.c index 0f57ddccef..5e39381736 100644 --- a/example/ex_main.c +++ b/example/ex_main.c @@ -28,7 +28,7 @@ UCodeBlock* SK_(instrument)(UCodeBlock* cb, Addr a) return cb; } -void SK_(fini)(void) +void SK_(fini)(exitcode) { } diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index 340d311825..e85d15f08f 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -3394,7 +3394,7 @@ void SK_(post_clo_init)(void) } -void SK_(fini)(void) +void SK_(fini)(Int exitcode) { if (DEBUG_LOCK_TABLE) { pp_all_LockSets(); diff --git a/include/vg_skin.h b/include/vg_skin.h index 2fe3e22551..24b1599647 100644 --- a/include/vg_skin.h +++ b/include/vg_skin.h @@ -1653,8 +1653,11 @@ extern void SK_(post_clo_init)( void ); 'orig_addr' is the address of the first instruction in the block. */ extern UCodeBlock* SK_(instrument) ( UCodeBlock* cb, Addr orig_addr ); -/* Finish up, print out any results, etc. */ -extern void SK_(fini) ( void ); +/* Finish up, print out any results, etc. `exitcode' is program's exit + code. The shadow (if the `shadow_regs' need is set) can be found with + VG_(get_shadow_archreg)(R_EBX), since %ebx holds the argument to the + exit() syscall. */ +extern void SK_(fini) ( Int exitcode ); /* ------------------------------------------------------------------ */ diff --git a/lackey/lk_main.c b/lackey/lk_main.c index 4770063114..a226922113 100644 --- a/lackey/lk_main.c +++ b/lackey/lk_main.c @@ -201,7 +201,7 @@ UCodeBlock* SK_(instrument)(UCodeBlock* cb_in, Addr orig_addr) return cb; } -void SK_(fini)(void) +void SK_(fini)(Int exitcode) { VG_(message)(Vg_UserMsg, "Counted %d calls to _dl_runtime_resolve()", n_dlrr_calls); @@ -227,6 +227,8 @@ void SK_(fini)(void) VG_(message)(Vg_UserMsg, " UInstrs : x86_instr = %3u : 10", 10 * n_UInstrs / n_x86_instrs); + VG_(message)(Vg_UserMsg, ""); + VG_(message)(Vg_UserMsg, "Exit code: %d", exitcode); } /*--------------------------------------------------------------------*/ diff --git a/lackey/tests/filter_stderr b/lackey/tests/filter_stderr index 6fd7ebdbe9..1f415be4b4 100755 --- a/lackey/tests/filter_stderr +++ b/lackey/tests/filter_stderr @@ -22,6 +22,8 @@ $dir/../../tests/filter_stderr_basic | # UInstrs : BB = 111 : 10 # UInstrs : x86_instr = 27 : 10 # +# Exit code: 0 +# # ...so chop all lines between first and last (inclusive) sed "/^Counted [0-9]\+ calls to _dl_runtime_resolve()$/ , \ /UInstrs : x86_instrs = [0-9]\+ : [0-9]\+/ \ diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index e77456107d..149bb23815 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -1613,7 +1613,7 @@ void SK_(post_clo_init) ( void ) { } -void SK_(fini) ( void ) +void SK_(fini) ( Int exitcode ) { MAC_(common_fini)( MC_(detect_memory_leaks) ); diff --git a/none/nl_main.c b/none/nl_main.c index b823bb51f1..a7283dcf1e 100644 --- a/none/nl_main.c +++ b/none/nl_main.c @@ -53,7 +53,7 @@ UCodeBlock* SK_(instrument)(UCodeBlock* cb, Addr a) return cb; } -void SK_(fini)(void) +void SK_(fini)(Int exitcode) { }