In Drupal 6, inside the theme() function of /includes/theme.inc, change line 617 from this:
$output = call_user_func_array($info['function'], $args);
To this:
$output = '<!-- begin ' . $info['function'] . ' -->' . call_user_func_array($info['function'], $args) . '<!-- end ' . $info['function'] . ' -->' ;
The advice about not doing this on a production site stands.