1/* Header file for the GIMPLE range tracing/debugging facilities.
2 Copyright (C) 2021-2023 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>
4 and Aldy Hernandez <aldyh@redhat.com>.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22#ifndef GCC_GIMPLE_RANGE_TRACE_H
23#define GCC_GIMPLE_RANGE_TRACE_H
24
25// This class manages range tracing for the ranger and gori components.
26// Tracing will provide a unique integer index whenever a new trace
27// is started. This can be used to identify where a calculation has gone wrong.
28
29class range_tracer
30{
31public:
32 range_tracer (const char *name = "");
33 unsigned header (const char *str);
34 void trailer (unsigned counter, const char *caller, bool result, tree name,
35 const vrange &r);
36 void print (unsigned counter, const char *str);
37 inline void enable_trace () { tracing = true; }
38 inline void disable_trace () { tracing = false; }
39 virtual void breakpoint (unsigned index);
40private:
41 unsigned do_header (const char *str);
42 void print_prefix (unsigned idx, bool blanks);
43 static const unsigned bump = 2;
44 unsigned indent;
45 static const unsigned name_len = 100;
46 char component[name_len];
47 bool tracing;
48};
49
50
51// If tracing is enabled, start a new trace header, returning the trace index.
52// Otherwise return 0.
53
54inline unsigned
55range_tracer::header (const char *str)
56{
57 if (tracing)
58 return do_header (str);
59 return 0;
60}
61
62// RAII class to change current dump_file and dump_flags, and restore
63// when the object goes out of scope.
64
65class push_dump_file
66{
67public:
68 push_dump_file (FILE *, dump_flags_t);
69 ~push_dump_file ();
70private:
71 FILE *old_dump_file;
72 dump_flags_t old_dump_flags;
73};
74
75void dump_ranger (FILE *);
76void dump_ranger (FILE *, const vec<basic_block> &path);
77
78#endif // GCC_GIMPLE_RANGE_TRACE_H
79

source code of gcc/gimple-range-trace.h