Home | History | Annotate | Download | only in src
      1 /* Support to debug branch prediction.
      2    Copyright (C) 2007 Red Hat, Inc.
      3    This file is part of elfutils.
      4    Written by Ulrich Drepper <drepper (at) redhat.com>, 2007.
      5 
      6    This file is free software; you can redistribute it and/or modify
      7    it under the terms of the GNU General Public License as published by
      8    the Free Software Foundation; either version 3 of the License, or
      9    (at your option) any later version.
     10 
     11    elfutils is distributed in the hope that it will be useful, but
     12    WITHOUT ANY WARRANTY; without even the implied warranty of
     13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14    GNU General Public License for more details.
     15 
     16    You should have received a copy of the GNU General Public License
     17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     18 
     19 #include <stdio.h>
     20 
     21 #if DEBUGPRED
     22 extern const unsigned long int __start_predict_data;
     23 extern const unsigned long int __stop_predict_data;
     24 extern const unsigned long int __start_predict_line;
     25 extern const char *const __start_predict_file;
     26 
     27 static void
     28 __attribute__ ((destructor))
     29 predprint (void)
     30 {
     31   const unsigned long int *s = &__start_predict_data;
     32   const unsigned long int *e = &__stop_predict_data;
     33   const unsigned long int *sl = &__start_predict_line;
     34   const char *const *sf = &__start_predict_file;
     35   while (s < e)
     36     {
     37       if (s[0] != 0 || s[1] != 0)
     38 	printf ("%s:%lu: wrong=%lu, correct=%lu%s\n", *sf, *sl, s[0], s[1],
     39 		s[0] > s[1] ? "   <==== WARNING" : "");
     40       ++sl;
     41       ++sf;
     42       s += 2;
     43     }
     44 }
     45 #endif
     46