mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
Sync VEX/LICENSE.GPL with top-level COPYING file. We used 3 different addresses for writing to the FSF to receive a copy of the GPL. Replace all different variants with an URL <http://www.gnu.org/licenses/>. The following files might still have some slightly different (L)GPL copyright notice because they were derived from other programs: - files under coregrind/m_demangle which come from libiberty: cplus-dem.c, d-demangle.c, demangle.h, rust-demangle.c, safe-ctype.c and safe-ctype.h - coregrind/m_demangle/dyn-string.[hc] derived from GCC. - coregrind/m_demangle/ansidecl.h derived from glibc. - VEX files for FMA detived from glibc: host_generic_maddf.h and host_generic_maddf.c - files under coregrin/m_debuginfo derived from LZO: lzoconf.h, lzodefs.h, minilzo-inl.c and minilzo.h - files under coregrind/m_gdbserver detived from GDB: gdb/signals.h, inferiors.c, regcache.c, regcache.h, regdef.h, remote-utils.c, server.c, server.h, signals.c, target.c, target.h and utils.c Plus the following test files: - none/tests/ppc32/testVMX.c derived from testVMX. - ppc tests derived from QEMU: jm-insns.c, ppc64_helpers.h and test_isa_3_0.c - tests derived from bzip2 (with embedded GPL text in code): hackedbz2.c, origin5-bz2.c, varinfo6.c - tests detived from glibc: str_tester.c, pth_atfork1.c - test detived from GCC libgomp: tc17_sembar.c - performance tests derived from bzip2 or tinycc (with embedded GPL text in code): bz2.c, test_input_for_tinycc.c and tinycc.c
220 lines
7.8 KiB
C
220 lines
7.8 KiB
C
|
|
/*--------------------------------------------------------------------*/
|
|
/*--- For printing superblock profiles m_sbprofile.c ---*/
|
|
/*--------------------------------------------------------------------*/
|
|
|
|
/*
|
|
This file is part of Valgrind, a dynamic binary instrumentation
|
|
framework.
|
|
|
|
Copyright (C) 2012-2017 Mozilla Foundation
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
The GNU General Public License is contained in the file COPYING.
|
|
*/
|
|
|
|
/* Contributed by Julian Seward <jseward@acm.org> */
|
|
|
|
#include "pub_core_basics.h"
|
|
#include "pub_core_transtab.h"
|
|
#include "pub_core_libcbase.h"
|
|
#include "pub_core_libcprint.h"
|
|
#include "pub_core_libcassert.h"
|
|
#include "pub_core_debuginfo.h"
|
|
#include "pub_core_translate.h"
|
|
#include "pub_core_options.h"
|
|
#include "pub_core_sbprofile.h" // self
|
|
|
|
/*====================================================================*/
|
|
/*=== SB profiling ===*/
|
|
/*====================================================================*/
|
|
|
|
static UInt n_profiles = 0;
|
|
|
|
static
|
|
void show_SB_profile ( const SBProfEntry tops[], UInt n_tops,
|
|
ULong score_total, ULong ecs_done )
|
|
{
|
|
ULong score_cumul, score_cumul_saved, score_here;
|
|
Int r; /* must be signed */
|
|
|
|
HChar ecs_txt[50]; // large enough
|
|
if (ecs_done > 0) {
|
|
VG_(sprintf)(ecs_txt, "%'llu ecs done", ecs_done);
|
|
} else {
|
|
VG_(strcpy)(ecs_txt, "for the entire run");
|
|
}
|
|
|
|
vg_assert(VG_(clo_profyle_sbs));
|
|
|
|
VG_(printf)("\n");
|
|
VG_(printf)("<<<---<<<---<<<---<<<---<<<---<<<---<<<---"
|
|
"<<<---<<<---<<<---<<<---<<<---<<<\n");
|
|
VG_(printf)("<<<---<<<---<<<---<<<---<<<---<<<---<<<---"
|
|
"<<<---<<<---<<<---<<<---<<<---<<<\n");
|
|
VG_(printf)("\n");
|
|
VG_(printf)("<<< BEGIN SB Profile #%u (%s)\n",
|
|
++n_profiles, ecs_txt);
|
|
VG_(printf)("<<<\n");
|
|
VG_(printf)("\n");
|
|
|
|
VG_(printf)("Total score = %'llu\n\n", score_total);
|
|
|
|
// FIXME JRS EPOCH 28 July 2017: this is probably not right in general
|
|
DiEpoch cur_ep = VG_(current_DiEpoch)();
|
|
|
|
/* Print an initial per-block summary. */
|
|
VG_(printf)("rank ---cumulative--- -----self-----\n");
|
|
score_cumul = 0;
|
|
for (r = 0; r < n_tops; r++) {
|
|
if (tops[r].addr == 0)
|
|
continue;
|
|
if (tops[r].score == 0)
|
|
continue;
|
|
|
|
const HChar *name;
|
|
VG_(get_fnname_w_offset)(cur_ep, tops[r].addr, &name);
|
|
|
|
score_here = tops[r].score;
|
|
score_cumul += score_here;
|
|
|
|
/* Careful: do not divide by zero. score_total == 0 implies
|
|
score_cumul == 0 and also score_here == 0. */
|
|
Double percent_cumul =
|
|
score_total == 0 ? 100.0 : score_cumul * 100.0 / score_total;
|
|
Double percent_here =
|
|
score_total == 0 ? 100.0 : score_here * 100.0 / score_total;
|
|
|
|
VG_(printf)("%3d: (%9llu %5.2f%%) %9llu %5.2f%% 0x%lx %s\n",
|
|
r,
|
|
score_cumul, percent_cumul,
|
|
score_here, percent_here, tops[r].addr, name);
|
|
}
|
|
score_cumul_saved = score_cumul;
|
|
|
|
if (VG_(clo_profyle_flags) > 0) {
|
|
|
|
/* Show the details, if requested. */
|
|
VG_(printf)("\n");
|
|
VG_(printf)("-----------------------------"
|
|
"------------------------------\n");
|
|
VG_(printf)("--- SB Profile (SB details) "
|
|
" ---\n");
|
|
VG_(printf)("-----------------------------"
|
|
"------------------------------\n");
|
|
VG_(printf)("\n");
|
|
|
|
score_cumul = 0;
|
|
for (r = 0; r < n_tops; r++) {
|
|
if (tops[r].addr == 0)
|
|
continue;
|
|
if (tops[r].score == 0)
|
|
continue;
|
|
|
|
const HChar *name;
|
|
VG_(get_fnname_w_offset)(cur_ep, tops[r].addr, &name);
|
|
|
|
score_here = tops[r].score;
|
|
score_cumul += score_here;
|
|
|
|
/* Careful: do not divide by zero. score_total == 0 implies
|
|
score_cumul == 0 and also score_here == 0. */
|
|
Double percent_cumul =
|
|
score_total == 0 ? 100.0 : score_cumul * 100.0 / score_total;
|
|
Double percent_here =
|
|
score_total == 0 ? 100.0 : score_here * 100.0 / score_total;
|
|
|
|
VG_(printf)("\n");
|
|
VG_(printf)("=-=-=-=-=-=-=-=-=-=-=-=-=-= begin SB rank %d "
|
|
"=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n", r);
|
|
VG_(printf)("%3d: (%9llu %5.2f%%) %9llu %5.2f%% 0x%lx %s\n",
|
|
r,
|
|
score_cumul, percent_cumul,
|
|
score_here, percent_here, tops[r].addr, name );
|
|
VG_(printf)("\n");
|
|
VG_(discard_translations)(tops[r].addr, 1, "bb profile");
|
|
VG_(translate)(0, tops[r].addr, True, VG_(clo_profyle_flags), 0, True);
|
|
VG_(printf)("=-=-=-=-=-=-=-=-=-=-=-=-=-= end SB rank %d "
|
|
"=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n", r);
|
|
}
|
|
|
|
/* Print a final per-block summary, in reverse order, for the
|
|
convenience of people reading up from the end. */
|
|
score_cumul = score_cumul_saved;
|
|
for (r = n_tops-1; r >= 0; r--) {
|
|
if (tops[r].addr == 0)
|
|
continue;
|
|
if (tops[r].score == 0)
|
|
continue;
|
|
|
|
const HChar *name;
|
|
VG_(get_fnname_w_offset)(cur_ep, tops[r].addr, &name);
|
|
|
|
score_here = tops[r].score;
|
|
|
|
/* Careful: do not divide by zero. score_total == 0 implies
|
|
score_cumul == 0 and also score_here == 0. */
|
|
Double percent_cumul =
|
|
score_total == 0 ? 100.0 : score_cumul * 100.0 / score_total;
|
|
Double percent_here =
|
|
score_total == 0 ? 100.0 : score_here * 100.0 / score_total;
|
|
|
|
VG_(printf)("%3d: (%9llu %5.2f%%) %9llu %5.2f%% 0x%lx %s\n",
|
|
r,
|
|
score_cumul, percent_cumul,
|
|
score_here, percent_here, tops[r].addr, name );
|
|
score_cumul -= score_here;
|
|
}
|
|
VG_(printf)("rank ---cumulative--- -----self-----\n");
|
|
|
|
}
|
|
|
|
VG_(printf)("\n");
|
|
VG_(printf)(">>>\n");
|
|
VG_(printf)(">>> END SB Profile #%u (%s)\n",
|
|
n_profiles, ecs_txt);
|
|
VG_(printf)(">>>\n");
|
|
VG_(printf)(">>>--->>>--->>>--->>>--->>>--->>>--->>>---"
|
|
">>>--->>>--->>>--->>>--->>>--->>>\n");
|
|
VG_(printf)(">>>--->>>--->>>--->>>--->>>--->>>--->>>---"
|
|
">>>--->>>--->>>--->>>--->>>--->>>\n");
|
|
VG_(printf)("\n");
|
|
}
|
|
|
|
|
|
/* Get and print a profile. Also, zero out the counters so that if we
|
|
call it again later, the second call will only show new work done
|
|
since the first call. ecs_done == 0 is taken to mean this is a
|
|
run-end profile. */
|
|
void VG_(get_and_show_SB_profile) ( ULong ecs_done )
|
|
{
|
|
/* The number of blocks to show for a end-of-run profile */
|
|
# define N_MAX_END 200
|
|
/* The number of blocks to show for a mid-run profile. */
|
|
# define N_MAX_INTERVAL 20
|
|
vg_assert(N_MAX_INTERVAL <= N_MAX_END);
|
|
SBProfEntry tops[N_MAX_END];
|
|
Int nToShow = ecs_done == 0 ? N_MAX_END : N_MAX_INTERVAL;
|
|
ULong score_total = VG_(get_SB_profile)(tops, nToShow);
|
|
show_SB_profile(tops, nToShow, score_total, ecs_done);
|
|
# undef N_MAX_END
|
|
# undef N_MAX_INTERVAL
|
|
}
|
|
|
|
|
|
/*--------------------------------------------------------------------*/
|
|
/*--- end m_sbprofile.c ---*/
|
|
/*--------------------------------------------------------------------*/
|