|
From: <sv...@va...> - 2005-06-26 20:45:32
|
Author: njn
Date: 2005-06-26 21:44:48 +0100 (Sun, 26 Jun 2005)
New Revision: 4035
Log:
Break up VG_(show_BB_profile)(), and move half of it into m_main. This
removes m_transtab's dependence on m_translate (breaking a circular
dependence) and m_debuginfo, hooray.
Modified:
trunk/coregrind/m_main.c
trunk/coregrind/m_redir.c
trunk/coregrind/m_transtab.c
trunk/coregrind/pub_core_transtab.h
Modified: trunk/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_main.c 2005-06-26 18:43:40 UTC (rev 4034)
+++ trunk/coregrind/m_main.c 2005-06-26 20:44:48 UTC (rev 4035)
@@ -52,8 +52,9 @@
#include "pub_core_redir.h"
#include "pub_core_scheduler.h"
#include "pub_core_signals.h"
-#include "pub_core_stacks.h" // Needed for VG_(register_stack)
+#include "pub_core_stacks.h" // For VG_(register_stack)
#include "pub_core_syswrap.h"
+#include "pub_core_translate.h" // For VG_(get_BB_profile)
#include "pub_core_tooliface.h"
#include "pub_core_trampoline.h"
#include "pub_core_transtab.h"
@@ -2260,6 +2261,81 @@
=20
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
+/*=3D=3D=3D BB profiling =
=3D=3D=3D*/
+/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
+
+static=20
+void show_BB_profile ( BBProfEntry tops[], UInt n_tops, ULong score_tota=
l )
+{
+ ULong score_cumul, score_here;
+ Char buf_cumul[10], buf_here[10];
+ Char name[64];
+ Int r;
+
+ VG_(printf)("\n");
+ VG_(printf)("--------------------------------------------------------=
---\n");
+ VG_(printf)("--- BEGIN BB Profile (summary of scores) =
---\n");
+ VG_(printf)("--------------------------------------------------------=
---\n");
+ VG_(printf)("\n");
+
+ VG_(printf)("Total score =3D %lld\n\n", score_total);
+
+ score_cumul =3D 0;
+ for (r =3D 0; r < n_tops; r++) {
+ if (tops[r].addr =3D=3D 0)
+ continue;
+ name[0] =3D 0;
+ VG_(get_fnname_w_offset)(tops[r].addr, name, 64);
+ name[63] =3D 0;
+ score_here =3D tops[r].score;
+ score_cumul +=3D score_here;
+ VG_(percentify)(score_cumul, score_total, 2, 6, buf_cumul);
+ VG_(percentify)(score_here, score_total, 2, 6, buf_here);
+ VG_(printf)("%3d: (%9lld %s) %9lld %s 0x%llx %s\n",
+ r,
+ score_cumul, buf_cumul,
+ score_here, buf_here, tops[r].addr, name );
+ }
+
+ VG_(printf)("\n");
+ VG_(printf)("--------------------------------------------------------=
---\n");
+ VG_(printf)("--- BB Profile (BB details) =
---\n");
+ VG_(printf)("--------------------------------------------------------=
---\n");
+ VG_(printf)("\n");
+
+ score_cumul =3D 0;
+ for (r =3D 0; r < n_tops; r++) {
+ if (tops[r].addr =3D=3D 0)
+ continue;
+ name[0] =3D 0;
+ VG_(get_fnname_w_offset)(tops[r].addr, name, 64);
+ name[63] =3D 0;
+ score_here =3D tops[r].score;
+ score_cumul +=3D score_here;
+ VG_(percentify)(score_cumul, score_total, 2, 6, buf_cumul);
+ VG_(percentify)(score_here, score_total, 2, 6, buf_here);
+ VG_(printf)("\n");
+ VG_(printf)("=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
begin BB rank %d "
+ "=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
\n\n", r);
+ VG_(printf)("%3d: (%9lld %s) %9lld %s 0x%llx %s\n",
+ r,
+ score_cumul, buf_cumul,
+ score_here, buf_here, tops[r].addr, name );
+ VG_(printf)("\n");
+ VG_(translate)(0, tops[r].addr, True, VG_(clo_profile_flags), 0);
+ VG_(printf)("=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
end BB rank %d "
+ "=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
\n\n", r);
+ }
+
+ VG_(printf)("\n");
+ VG_(printf)("--------------------------------------------------------=
---\n");
+ VG_(printf)("--- END BB Profile =
---\n");
+ VG_(printf)("--------------------------------------------------------=
---\n");
+ VG_(printf)("\n");
+}
+
+
+/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D main() =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
@@ -2849,9 +2925,14 @@
=20
if (VG_(clo_profile))
VG_(done_profiling)();
- if (VG_(clo_profile_flags) > 0)
- VG_(show_BB_profile)();
=20
+ if (VG_(clo_profile_flags) > 0) {
+ #define N_MAX 100
+ BBProfEntry tops[N_MAX];
+ ULong score_total =3D VG_(get_BB_profile) (tops, N_MAX);
+ show_BB_profile(tops, N_MAX, score_total);
+ }
+
/* Print Vex storage stats */
if (0)
LibVEX_ShowAllocStats();
Modified: trunk/coregrind/m_redir.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_redir.c 2005-06-26 18:43:40 UTC (rev 4034)
+++ trunk/coregrind/m_redir.c 2005-06-26 20:44:48 UTC (rev 4035)
@@ -203,7 +203,9 @@
return ok; =20
}
=20
-// Resolve a redir using any SegInfo if possible.
+// Resolve a redir using any SegInfo if possible. This is called whenev=
er
+// a new sym-to-addr redir is created. It covers the case where a
+// replacement function is loaded after its replacee.
static Bool resolve_redir_with_existing_seginfos(CodeRedirect *redir)
{
const SegInfo *si;
@@ -219,7 +221,8 @@
}
=20
// Resolve as many unresolved redirs as possible with this SegInfo. Thi=
s
-// should be called when a new SegInfo symtab is loaded.
+// should be called when a new SegInfo symtab is loaded. It covers the =
case
+// where a replacee function is loaded after its replacement function.
void VG_(resolve_existing_redirs_with_seginfo)(SegInfo *si)
{
CodeRedirect **prevp =3D &unresolved_redirs;
@@ -287,7 +290,9 @@
TRACE_REDIR("REDIR sym to addr: %s:%s to %p", from_lib, from_sym, to_=
addr);
=20
// Check against all existing segments to see if this redirection
- // can be resolved immediately. Then add it to the appropriate list.
+ // can be resolved immediately (as will be the case when the replacem=
ent
+ // function is loaded after the replacee). Then add it to the
+ // appropriate list.
if (resolve_redir_with_existing_seginfos(redir)) {
add_redir_to_resolved_list(redir);
} else {
Modified: trunk/coregrind/m_transtab.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_transtab.c 2005-06-26 18:43:40 UTC (rev 4034)
+++ trunk/coregrind/m_transtab.c 2005-06-26 20:44:48 UTC (rev 4035)
@@ -30,15 +30,12 @@
*/
=20
#include "pub_core_basics.h"
-#include "pub_core_debuginfo.h" // For VG_(get_fnname_w_offset)()
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcmman.h" // For VG_(get_memory_from_mmap)()
#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_tooliface.h" // For VG_(details).avg_translation_=
sizeB
-// XXX: this module should not depend on m_translate!
-#include "pub_core_translate.h" // For VG_(translate)()
#include "pub_core_transtab.h"
=20
/* #define DEBUG_TRANSTAB */
@@ -670,34 +667,23 @@
/*--- Printing out of profiling results. ---*/
/*------------------------------------------------------------*/
=20
-/* Only the top N_MAX bbs will be displayed. */
-#define N_MAX 200
-
-static TTEntry* tops[N_MAX];
-
static ULong score ( TTEntry* tte )
{
return ((ULong)tte->weight) * ((ULong)tte->count);
}
=20
-static Bool heavier ( TTEntry* t1, TTEntry* t2 )
+ULong VG_(get_BB_profile) ( BBProfEntry tops[], UInt n_tops )
{
- return score(t1) > score(t2);
-}
-
-void VG_(show_BB_profile) ( void )
-{
- Char name[64];
Int sno, i, r, s;
- ULong score_total, score_cumul, score_here;
- Char buf_cumul[10];
- Char buf_here[10];
+ ULong score_total;
=20
/* First, compute the total weighted count, and find the top N
- ttes. tops contains pointers to the most-used N_MAX blocks, in
+ ttes. tops contains pointers to the most-used n_tops blocks, in
descending order (viz, tops[0] is the highest scorer). */
- for (i =3D 0; i < N_MAX; i++)
- tops[i] =3D NULL;
+ for (i =3D 0; i < n_tops; i++) {
+ tops[i].addr =3D 0;
+ tops[i].score =3D 0;
+ }
=20
score_total =3D 0;
=20
@@ -709,95 +695,36 @@
continue;
score_total +=3D score(§ors[sno].tt[i]);
/* Find the rank for sectors[sno].tt[i]. */
- r =3D N_MAX-1;
+ r =3D n_tops-1;
while (True) {
if (r =3D=3D -1)
break;
- if (tops[r] =3D=3D NULL) {
+ if (tops[r].addr =3D=3D 0) {
r--;=20
continue;
}
- if (heavier(§ors[sno].tt[i], tops[r])) {
+ if ( score(§ors[sno].tt[i]) > tops[r].score ) {
r--;
continue;
}
break;
}
r++;
- vg_assert(r >=3D 0 && r <=3D N_MAX);
+ vg_assert(r >=3D 0 && r <=3D n_tops);
/* This bb should be placed at r, and bbs above it shifted
upwards one slot. */
- if (r < N_MAX) {
- for (s =3D N_MAX-1; s > r; s--)
+ if (r < n_tops) {
+ for (s =3D n_tops-1; s > r; s--)
tops[s] =3D tops[s-1];
- tops[r] =3D §ors[sno].tt[i];
+ tops[r].addr =3D sectors[sno].tt[i].entry;
+ tops[r].score =3D score( §ors[sno].tt[i] );
}
}
}
=20
- VG_(printf)("\n");
- VG_(printf)("--------------------------------------------------------=
----\n");
- VG_(printf)("--- BEGIN BB Profile (summary of scores) =
---\n");
- VG_(printf)("--------------------------------------------------------=
----\n");
- VG_(printf)("\n");
-
- VG_(printf)("Total score =3D %lld\n\n", score_total);
-
- score_cumul =3D 0;
- for (r =3D 0; r < N_MAX; r++) {
- if (tops[r] =3D=3D NULL)
- continue;
- name[0] =3D 0;
- VG_(get_fnname_w_offset)(tops[r]->entry, name, 64);
- name[63] =3D 0;
- score_here =3D score(tops[r]);
- score_cumul +=3D score_here;
- VG_(percentify)(score_cumul, score_total, 2, 6, buf_cumul);
- VG_(percentify)(score_here, score_total, 2, 6, buf_here);
- VG_(printf)("%3d: (%9lld %s) %9lld %s 0x%llx %s\n",
- r,
- score_cumul, buf_cumul,
- score_here, buf_here, tops[r]->entry, name );
- }
-
- VG_(printf)("\n");
- VG_(printf)("--------------------------------------------------------=
----\n");
- VG_(printf)("--- BB Profile (BB details) =
---\n");
- VG_(printf)("--------------------------------------------------------=
----\n");
- VG_(printf)("\n");
-
- score_cumul =3D 0;
- for (r =3D 0; r < N_MAX; r++) {
- if (tops[r] =3D=3D NULL)
- continue;
- name[0] =3D 0;
- VG_(get_fnname_w_offset)(tops[r]->entry, name, 64);
- name[63] =3D 0;
- score_here =3D score(tops[r]);
- score_cumul +=3D score_here;
- VG_(percentify)(score_cumul, score_total, 2, 6, buf_cumul);
- VG_(percentify)(score_here, score_total, 2, 6, buf_here);
- VG_(printf)("\n");
- VG_(printf)("=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
begin BB rank %d "
- "=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
\n\n", r);
- VG_(printf)("%3d: (%9lld %s) %9lld %s 0x%llx %s\n",
- r,
- score_cumul, buf_cumul,
- score_here, buf_here, tops[r]->entry, name );
- VG_(printf)("\n");
- VG_(translate)(0, tops[r]->entry, True, VG_(clo_profile_flags), 0)=
;
- VG_(printf)("=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
end BB rank %d "
- "=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
\n\n", r);
- }
-
- VG_(printf)("\n");
- VG_(printf)("--------------------------------------------------------=
----\n");
- VG_(printf)("--- END BB Profile =
---\n");
- VG_(printf)("--------------------------------------------------------=
----\n");
- VG_(printf)("\n");
+ return score_total;
}
=20
-
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/pub_core_transtab.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_transtab.h 2005-06-26 18:43:40 UTC (rev 4034=
)
+++ trunk/coregrind/pub_core_transtab.h 2005-06-26 20:44:48 UTC (rev 4035=
)
@@ -61,9 +61,15 @@
=20
extern UInt VG_(get_bbs_translated) ( void );
=20
-extern void VG_(show_BB_profile) ( void );
+// BB profiling stuff
=20
+typedef struct _BBProfEntry {
+ Addr64 addr;
+ ULong score;
+} BBProfEntry;
=20
+extern ULong VG_(get_BB_profile) ( BBProfEntry tops[], UInt n_tops );
+
#endif // __PUB_CORE_TRANSTAB_H
=20
/*--------------------------------------------------------------------*/
|