diff --git a/riscv/processor.cc b/riscv/processor.cc index 1ab97ce0..64ecdf8e 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -75,8 +75,12 @@ processor_t::~processor_t() #ifdef RISCV_ENABLE_HISTOGRAM if (histogram_enabled) { - fprintf(stderr, "PC Histogram size:%zu\n", pc_histogram.size()); - for (auto it : pc_histogram) + std::vector> ordered_histo(pc_histogram.begin(), pc_histogram.end()); + std::sort(ordered_histo.begin(), ordered_histo.end(), + [](auto& lhs, auto& rhs) { return lhs.second < rhs.second; }); + + fprintf(stderr, "PC Histogram size:%zu\n", ordered_histo.size()); + for (auto it : ordered_histo) fprintf(stderr, "%0" PRIx64 " %" PRIu64 "\n", it.first, it.second); } #endif