]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/valgrind/src/valgrind-3.6.0-svn/callgrind/dump.c
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / callgrind / dump.c
index 5c04e90bfa248be7183a75d8090480921fbb23a7..cd57f4bf77d1a8b7980cfde6873d31f36c8ab8d4 100644 (file)
@@ -29,8 +29,8 @@
 #include "config.h"
 #include "global.h"
 
-#include <pub_tool_threadstate.h>
-#include <pub_tool_libcfile.h>
+#include "pub_tool_threadstate.h"
+#include "pub_tool_libcfile.h"
 
 
 /* Dump Part Counter */
@@ -55,7 +55,7 @@ EventMapping* CLG_(dumpmap) = 0;
  *  print_fn_pos, fprint_apos, fprint_fcost, fprint_jcc,
  *  fprint_fcc_ln, dump_run_info, dump_state_info
  */
-static Char outbuf[FILENAME_LEN + FN_NAME_LEN + OBJ_NAME_LEN];
+static Char outbuf[FILENAME_LEN + FN_NAME_LEN + OBJ_NAME_LEN + COSTS_LEN];
 
 Int CLG_(get_dump_counter)(void)
 {
@@ -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;
 }