set board_info(localhost,isremote) 0 load_generic_config "unix" # The default compiler for this target. set_board_info compiler "[find_gcc]" global outdir vg_basename set vg_basename "$outdir/valgrind." global vg_count set vg_count "0" global GDB set GDB "valgrind --quiet --trace-children=no --child-silent-after-fork=yes --num-callers=50 --log-file=${vg_basename}%q{VGCOUNT} $GDB" # Support for running gdb under valgrind and checking the results. rename remote_spawn vg_remote_spawn proc remote_spawn {args} { global env vg_basename vg_count incr vg_count set env(VGCOUNT) $vg_count file delete -force ${vg_basename}$vg_count set res [uplevel vg_remote_spawn $args] return $res } rename gdb_exit vg_gdb_exit proc gdb_exit {args} { global vg_basename vg_count vg_reported # We can sometimes see multiple consecutive calls to gdb_exit # without an intervening spawn. In this case we only want to # report the valgrind results once. if {![info exists vg_reported($vg_count)]} { set vg_reported($vg_count) 1 # FIXME: how can we name this test consistently across # runs? if {[file exists ${vg_basename}$vg_count] && [file size ${vg_basename}$vg_count] > 0} { send_log "Valgrind output:\n" set fd [open ${vg_basename}$vg_count] send_log [read $fd] close $fd send_log "\n" fail "valgrind check $vg_count" } else { pass "valgrind check $vg_count" } } return [uplevel vg_gdb_exit $args] } # Valgrind slows everything down, so boost the default timeout. global gdb_test_timeout set gdb_test_timeout [expr {20 * $gdb_test_timeout}]