How to debug in Drupal using drupal_set_message and come to the exact line that is causing the error?

Put the following code snippet in includes/bootstrap.inc in the drupal_set_message function.. .

<code>
 if ($type == 'error') {
    $message .= '<pre>'. print_r(debug_backtrace(), 1) .'</pre>';
  }
</code>