- DBG (SAMPLEDEBUG,
- printf ("[scale_and_align_entries] pushing 0x%lx to 0x%lx\n",
- sym->hist.scaled_addr, sym->aligned_addr + UNITS_TO_CODE));
- sym->aligned_addr += UNITS_TO_CODE;
- } /* if */
-#endif /* OFFSET_TO_CODE > 0 */
- } /* for */
-} /* scale_and_align_entries */
-
-
-/*
- * Assign samples to the symbol to which they belong.
- *
- * Histogram bin I covers some address range [BIN_LOWPC,BIN_HIGH_PC)
- * which may overlap one more symbol address ranges. If a symbol
- * overlaps with the bin's address range by O percent, then O percent
- * of the bin's count is credited to that symbol.
- *
- * There are three cases as to where BIN_LOW_PC and BIN_HIGH_PC can be
- * with respect to the symbol's address range [SYM_LOW_PC,
- * SYM_HIGH_PC) as shown in the following diagram. OVERLAP computes
- * the distance (in UNITs) between the arrows, the fraction of the
- * sample that is to be credited to the symbol which starts at
- * SYM_LOW_PC.
- *
- * sym_low_pc sym_high_pc
- * | |
- * v v
- *
- * +-----------------------------------------------+
- * | |
- * | ->| |<- ->| |<- ->| |<- |
- * | | | | | |
- * +---------+ +---------+ +---------+
- *
- * ^ ^ ^ ^ ^ ^
- * | | | | | |
- * bin_low_pc bin_high_pc bin_low_pc bin_high_pc bin_low_pc bin_high_pc
- *
- * For the VAX we assert that samples will never fall in the first two
- * bytes of any routine, since that is the entry mask, thus we call
- * scale_and_align_entries() to adjust the entry points if the entry
- * mask falls in one bin but the code for the routine doesn't start
- * until the next bin. In conjunction with the alignment of routine
- * addresses, this should allow us to have only one sample for every
- * four bytes of text space and never have any overlap (the two end
- * cases, above).
- */
-void
-DEFUN_VOID (hist_assign_samples)
+ bin_of_entry = (sym->hist.scaled_addr - r->lowpc) / hist_scale;
+ bin_of_code = ((sym->hist.scaled_addr + UNITS_TO_CODE - r->lowpc)
+ / hist_scale);
+ if (bin_of_entry < bin_of_code)
+ {
+ DBG (SAMPLEDEBUG,
+ printf ("[scale_and_align_entries] pushing 0x%lx to 0x%lx\n",
+ (unsigned long) sym->hist.scaled_addr,
+ (unsigned long) (sym->hist.scaled_addr
+ + UNITS_TO_CODE)));
+ sym->hist.scaled_addr += UNITS_TO_CODE;
+ }
+ }
+ }
+}
+
+
+/* Assign samples to the symbol to which they belong.
+
+ Histogram bin I covers some address range [BIN_LOWPC,BIN_HIGH_PC)
+ which may overlap one more symbol address ranges. If a symbol
+ overlaps with the bin's address range by O percent, then O percent
+ of the bin's count is credited to that symbol.
+
+ There are three cases as to where BIN_LOW_PC and BIN_HIGH_PC can be
+ with respect to the symbol's address range [SYM_LOW_PC,
+ SYM_HIGH_PC) as shown in the following diagram. OVERLAP computes
+ the distance (in UNITs) between the arrows, the fraction of the
+ sample that is to be credited to the symbol which starts at
+ SYM_LOW_PC.
+
+ sym_low_pc sym_high_pc
+ | |
+ v v
+
+ +-----------------------------------------------+
+ | |
+ | ->| |<- ->| |<- ->| |<- |
+ | | | | | |
+ +---------+ +---------+ +---------+
+
+ ^ ^ ^ ^ ^ ^
+ | | | | | |
+ bin_low_pc bin_high_pc bin_low_pc bin_high_pc bin_low_pc bin_high_pc
+
+ For the VAX we assert that samples will never fall in the first two
+ bytes of any routine, since that is the entry mask, thus we call
+ scale_and_align_entries() to adjust the entry points if the entry
+ mask falls in one bin but the code for the routine doesn't start
+ until the next bin. In conjunction with the alignment of routine
+ addresses, this should allow us to have only one sample for every
+ four bytes of text space and never have any overlap (the two end
+ cases, above). */
+
+static void
+hist_assign_samples_1 (histogram *r)