gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gold / errors.h
1 // errors.h -- handle errors for gold -*- C++ -*-
2
3 // Copyright (C) 2006-2020 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
5
6 // This file is part of gold.
7
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
12
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
22
23 #ifndef GOLD_ERRORS_H
24 #define GOLD_ERRORS_H
25
26 #include <cstdarg>
27 #include <string>
28
29 #include "gold-threads.h"
30
31 namespace gold
32 {
33
34 class Symbol;
35 template<int size, bool big_endian>
36 struct Relocate_info;
37
38 // This class handles errors for gold. There is a single instance
39 // which is used by all threads. If and when we make the gold code
40 // more amenable to being used in a library, we will make this an
41 // abstract interface class, and expect the caller to provide their
42 // own instantiation.
43
44 class Errors
45 {
46 public:
47 Errors(const char* program_name);
48
49 // Report a fatal error. After printing the error, this must exit.
50 void
51 fatal(const char* format, va_list) ATTRIBUTE_NORETURN;
52
53 // Report a fallback error. After printing the error, this must exit
54 // with a special status code indicating that fallback to
55 // --incremental-full is required.
56 void
57 fallback(const char* format, va_list) ATTRIBUTE_NORETURN;
58
59 // Report an error and continue.
60 void
61 error(const char* format, va_list);
62
63 // Report a warning and continue.
64 void
65 warning(const char* format, va_list);
66
67 // Print an informational message and continue.
68 void
69 info(const char* format, va_list);
70
71 // Report an error at a reloc location.
72 template<int size, bool big_endian>
73 void
74 error_at_location(const Relocate_info<size, big_endian>* relinfo,
75 size_t relnum, off_t reloffset,
76 const char* format, va_list);
77
78 // Report a warning at a reloc location.
79 template<int size, bool big_endian>
80 void
81 warning_at_location(const Relocate_info<size, big_endian>* relinfo,
82 size_t relnum, off_t reloffset,
83 const char* format, va_list);
84
85 // Issue an undefined symbol error. LOCATION is the location of
86 // the error (typically an object file name or relocation info).
87 void
88 undefined_symbol(const Symbol* sym, const std::string& location);
89
90 // Report a debugging message.
91 void
92 debug(const char* format, ...) ATTRIBUTE_PRINTF_2;
93
94 // Return the number of errors.
95 int
96 error_count() const
97 { return this->error_count_; }
98
99 // Return the number of warnings.
100 int
101 warning_count() const
102 { return this->warning_count_; }
103
104 private:
105 Errors(const Errors&);
106 Errors& operator=(const Errors&);
107
108 // Initialize the lock. We don't do this in the constructor because
109 // lock initialization wants to know whether we are using threads or
110 // not. This returns true if the lock is now initialized.
111 bool
112 initialize_lock();
113
114 // Increment a counter, holding the lock.
115 void
116 increment_counter(int*);
117
118 // The number of times we report an undefined symbol.
119 static const int max_undefined_error_report = 5;
120
121 // The name of the program.
122 const char* program_name_;
123 // This class can be accessed from multiple threads. This lock is
124 // used to control access to the data structures.
125 Lock* lock_;
126 // Used to initialize the lock_ field exactly once.
127 Initialize_lock initialize_lock_;
128 // Numbers of errors reported.
129 int error_count_;
130 // Number of warnings reported.
131 int warning_count_;
132 // A map counting the numbers of times we have seen an undefined
133 // symbol.
134 Unordered_map<const Symbol*, int> undefined_symbols_;
135 };
136
137 } // End namespace gold.
138
139 #endif // !defined(GOLD_ERRORS_H)
This page took 0.03165 seconds and 4 git commands to generate.