+
+ p = tmpbuf;
+ *p = '\0';
+
+ ncalls = -1;
+
+ /* If this is a function entry point, label the line no matter what.
+ * Otherwise, we're in the middle of a function, so check to see
+ * if the first basic-block address is larger than the starting
+ * address of the line. If so, then this line begins with a
+ * a portion of the previous basic-block, so print that prior
+ * execution count (if bb_annotate_all_lines is set).
+ */
+
+ if (b->is_func)
+ {
+ sprintf (p, "%d", b->ncalls);
+ p += strlen (p);
+ last_count = b->ncalls;
+ last_print = last_count;
+ ncalls = b->ncalls;
+ }
+ else if (bb_annotate_all_lines
+ && b->bb_addr[0] && b->bb_addr[0] > b->addr)
+ {
+ sprintf (p, "%d", last_count);
+ p += strlen (p);
+ last_print = last_count;
+ ncalls = last_count;
+ }
+
+ /* Loop through all of this line's basic-blocks. For each one,
+ * update last_count, then compress sequential identical counts
+ * (if bb_annotate_all_lines) and print the execution count.
+ */
+
+ for (i = 0; i < NBBS && b->bb_addr[i]; i++)
+ {
+ last_count = b->bb_calls[i];
+ if (ncalls < 0)
+ ncalls = 0;
+ ncalls += last_count;
+
+ if (bb_annotate_all_lines && last_count == last_print)
+ {
+ continue;
+ }
+
+ if (p > tmpbuf)
+ *p++ = ',';
+ sprintf (p, "%d", last_count);
+ p += strlen (p);
+
+ last_print = last_count;
+ }
+
+ /* We're done. If nothing has been printed on this line,
+ * print the last execution count (bb_annotate_all_lines),
+ * which could be from either a previous line (if there were
+ * no BBs on this line), or from this line (if all our BB
+ * counts were compressed out because they were identical).
+ */
+
+ if (bb_annotate_all_lines && p == tmpbuf)
+ {
+ sprintf (p, "%d", last_count);
+ p += strlen (p);
+ ncalls = last_count;
+ }
+
+ if (ncalls < 0)
+ {
+ int c;
+
+ for (c = 0; c < width; c++)
+ buf[c] = ' ';
+ buf[width] = '\0';
+ return;
+ }
+