vg_annotate.in:
    - fixed a bug that was breaking the --threshold option.

vg_cachesim.c:
    - fixed a bug that meant instructions that didn't have a line number in the
      debug info were being written in cachegrind.out with whatever was the
      last known line number.  Now using 0.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@403 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in
index 4f8c846..1182190 100644
--- a/cachegrind/cg_annotate.in
+++ b/cachegrind/cg_annotate.in
@@ -121,6 +121,8 @@
 
 my $default_threshold = 99;
 
+my $single_threshold  = $default_threshold;
+
 # If on, automatically annotates all files that are involved in getting over
 # all the threshold counts.
 my $auto_annotate = 0;
@@ -200,7 +202,7 @@
 
             # --threshold=X (tolerates a trailing '%')
             } elsif ($arg =~ /^--threshold=([\d\.]+)%?$/) {
-                $thresholds[0] = $1;
+                $single_threshold = $1;
                 ($1 >= 0 && $1 <= 100) or die($usage);
 
             # --auto=yes|no
@@ -343,13 +345,14 @@
         push(@sort_order, $events{$sort_event});
     }
 
-    # If no --threshold args give, default to 99% for the primary sort event,
-    # and 0% for the rest.
+    # If multiple threshold args weren't given via --sort, stick in the single
+    # threshold (either from --threshold if used, or the default otherwise) for
+    # the primary sort event, and 0% for the rest.
     if (not @thresholds) {
         foreach my $e (@sort_order) {
             push(@thresholds, 0);
         }
-        $thresholds[0] = $default_threshold;
+        $thresholds[0] = $single_threshold;
     }
 
     my $curr_file;