blob: 4845a6e2adf00cc5475664e53f7aa28111f55eb9 [file] [log] [blame]
Ben Cheng25b3c042013-11-20 14:45:36 -08001/* Support to debug branch prediction.
2 Copyright (C) 2007 Red Hat, Inc.
Elliott Hughes03333822015-02-18 22:19:45 -08003 This file is part of elfutils.
Ben Cheng25b3c042013-11-20 14:45:36 -08004 Written by Ulrich Drepper <drepper@redhat.com>, 2007.
5
Elliott Hughes03333822015-02-18 22:19:45 -08006 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.
Ben Cheng25b3c042013-11-20 14:45:36 -080010
Elliott Hughes03333822015-02-18 22:19:45 -080011 elfutils is distributed in the hope that it will be useful, but
Ben Cheng25b3c042013-11-20 14:45:36 -080012 WITHOUT ANY WARRANTY; without even the implied warranty of
Elliott Hughes03333822015-02-18 22:19:45 -080013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
Ben Cheng25b3c042013-11-20 14:45:36 -080015
Elliott Hughes03333822015-02-18 22:19:45 -080016 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/>. */
Ben Cheng25b3c042013-11-20 14:45:36 -080018
19#include <stdio.h>
20
21#if DEBUGPRED
22extern const unsigned long int __start_predict_data;
23extern const unsigned long int __stop_predict_data;
24extern const unsigned long int __start_predict_line;
25extern const char *const __start_predict_file;
26
27static void
28__attribute__ ((destructor))
29predprint (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