summaryrefslogtreecommitdiff
path: root/callgrind
diff options
context:
space:
mode:
authorweidendo <weidendo@a5019735-40e9-0310-863c-91ae7b9d1cf9>2011-05-11 12:28:01 +0000
committerweidendo <weidendo@a5019735-40e9-0310-863c-91ae7b9d1cf9>2011-05-11 12:28:01 +0000
commit061f079cd815952d484746cbb442aa2f1776205c (patch)
tree1d6705e0fa38a62f6b2a09af128602d1c1d62314 /callgrind
parentf5b019fb45b52a26fefa40b8fa5b518f0686dd99 (diff)
Fix bugs catched by BEAM
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11742 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'callgrind')
-rw-r--r--callgrind/dump.c24
-rw-r--r--callgrind/sim.c4
2 files changed, 18 insertions, 10 deletions
diff --git a/callgrind/dump.c b/callgrind/dump.c
index edac997c..cd57f4bf 100644
--- a/callgrind/dump.c
+++ b/callgrind/dump.c
@@ -336,6 +336,8 @@ static Bool print_fn_pos(int fd, FnPos* last, BBCC* bbcc)
{
Bool res = False;
+ CLG_ASSERT(bbcc && bbcc->cxt);
+
CLG_DEBUGIF(3) {
CLG_DEBUG(2, "+ print_fn_pos: ");
CLG_(print_cxt)(16, bbcc->cxt, bbcc->rec_index);
@@ -351,9 +353,9 @@ static Bool print_fn_pos(int fd, FnPos* last, BBCC* bbcc)
}
if (last->cxt != bbcc->cxt) {
- fn_node* last_from = (last->cxt && last->cxt->size>1) ?
+ fn_node* last_from = (last->cxt && last->cxt->size >1) ?
last->cxt->fn[1] : 0;
- fn_node* curr_from = (bbcc->cxt && bbcc->cxt->size>1) ?
+ fn_node* curr_from = (bbcc->cxt->size >1) ?
bbcc->cxt->fn[1] : 0;
if (curr_from == 0) {
if (last_from != 0) {
@@ -659,13 +661,15 @@ static void fprint_jcc(Int fd, jCC* jcc, AddrPos* curr, AddrPos* last, ULong eco
CLG_(print_jcc)(-10, jcc);
}
+ CLG_ASSERT(jcc->to !=0);
+ CLG_ASSERT(jcc->from !=0);
+
if (!get_debug_pos(jcc->to, bb_addr(jcc->to->bb), &target)) {
/* if we don't have debug info, don't switch to file "???" */
target.file = last->file;
}
- if (jcc->from &&
- (jcc->jmpkind == JmpCond || jcc->jmpkind == Ijk_Boring)) {
+ if ((jcc->jmpkind == JmpCond) || (jcc->jmpkind == Ijk_Boring)) {
/* this is a JCC for a followed conditional or boring jump. */
CLG_ASSERT(CLG_(is_zero_cost)( CLG_(sets).full, jcc->cost));
@@ -720,8 +724,6 @@ static void fprint_jcc(Int fd, jCC* jcc, AddrPos* curr, AddrPos* last, ULong eco
return;
}
- CLG_ASSERT(jcc->to !=0);
-
file = jcc->to->cxt->fn[0]->file;
obj = jcc->to->bb->obj;
@@ -1635,15 +1637,19 @@ void CLG_(dump_profile)(Char* trigger, Bool only_current_thread)
VG_(message)(Vg_DebugMsg, "Dumping done.\n");
}
-/* copy command to cmd buffer (could change) */
+/* Copy command to cmd buffer. We want to original command line
+ * (can change at runtime)
+ */
static
void init_cmdbuf(void)
{
Int i,j,size = 0;
HChar* argv;
- if (VG_(args_the_exename))
+ if (VG_(args_the_exename)) {
+ CLG_ASSERT( VG_(strlen)( VG_(args_the_exename) ) < BUF_LEN-1);
size = VG_(sprintf)(cmdbuf, " %s", VG_(args_the_exename));
+ }
for(i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
argv = * (HChar**) VG_(indexXA)( VG_(args_for_client), i );
@@ -1653,7 +1659,7 @@ void init_cmdbuf(void)
if (size < BUF_LEN) cmdbuf[size++] = argv[j];
}
- if (size == BUF_LEN) size--;
+ if (size >= BUF_LEN) size = BUF_LEN-1;
cmdbuf[size] = 0;
}
diff --git a/callgrind/sim.c b/callgrind/sim.c
index 2b8cbe47..60b2987c 100644
--- a/callgrind/sim.c
+++ b/callgrind/sim.c
@@ -977,7 +977,7 @@ void cacheuse_finish(void)
if (!CLG_(current_state).collect) return;
CLG_(bb_base) = 0;
- current_ii = &ii;
+ current_ii = &ii; /* needs to be set for update_XX_use */
CLG_(cost_base) = 0;
/* update usage counters */
@@ -995,6 +995,8 @@ void cacheuse_finish(void)
for (i = 0; i < LL.sets * LL.assoc; i++)
if (LL.loaded[i].use_base)
update_LL_use(i, 0);
+
+ current_ii = 0;
}