]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gold/errors.h
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gold / errors.h
CommitLineData
75f2446e
ILT
1// errors.h -- handle errors for gold -*- C++ -*-
2
d87bef3a 3// Copyright (C) 2006-2023 Free Software Foundation, Inc.
75f2446e
ILT
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>
a3972330 27#include <string>
75f2446e
ILT
28
29#include "gold-threads.h"
30
31namespace gold
32{
33
34class Symbol;
35template<int size, bool big_endian>
36struct 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
44class 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
e6455dfb
CC
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
75f2446e
ILT
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);
c5818ff1
CC
66
67 // Print an informational message and continue.
68 void
69 info(const char* format, va_list);
75f2446e 70
35891b47
CC
71 // Print a trace message and continue.
72 void
73 trace(const char* format, va_list);
74
75f2446e
ILT
75 // Report an error at a reloc location.
76 template<int size, bool big_endian>
77 void
78 error_at_location(const Relocate_info<size, big_endian>* relinfo,
79 size_t relnum, off_t reloffset,
80 const char* format, va_list);
81
82 // Report a warning at a reloc location.
83 template<int size, bool big_endian>
84 void
85 warning_at_location(const Relocate_info<size, big_endian>* relinfo,
86 size_t relnum, off_t reloffset,
87 const char* format, va_list);
88
f073bbf7
CD
89 // Issue an undefined symbol error. LOCATION is the location of
90 // the error (typically an object file name or relocation info).
75f2446e 91 void
f073bbf7 92 undefined_symbol(const Symbol* sym, const std::string& location);
75f2446e 93
c7912668
ILT
94 // Report a debugging message.
95 void
96 debug(const char* format, ...) ATTRIBUTE_PRINTF_2;
97
75f2446e
ILT
98 // Return the number of errors.
99 int
100 error_count() const
101 { return this->error_count_; }
102
d82a5bcc
ILT
103 // Return the number of warnings.
104 int
105 warning_count() const
106 { return this->warning_count_; }
107
75f2446e
ILT
108 private:
109 Errors(const Errors&);
110 Errors& operator=(const Errors&);
111
c7912668
ILT
112 // Initialize the lock. We don't do this in the constructor because
113 // lock initialization wants to know whether we are using threads or
2dd3e587
ILT
114 // not. This returns true if the lock is now initialized.
115 bool
c7912668
ILT
116 initialize_lock();
117
2dd3e587
ILT
118 // Increment a counter, holding the lock.
119 void
120 increment_counter(int*);
121
75f2446e
ILT
122 // The number of times we report an undefined symbol.
123 static const int max_undefined_error_report = 5;
124
125 // The name of the program.
126 const char* program_name_;
127 // This class can be accessed from multiple threads. This lock is
128 // used to control access to the data structures.
c7912668 129 Lock* lock_;
7f055c20
ILT
130 // Used to initialize the lock_ field exactly once.
131 Initialize_lock initialize_lock_;
75f2446e
ILT
132 // Numbers of errors reported.
133 int error_count_;
134 // Number of warnings reported.
135 int warning_count_;
136 // A map counting the numbers of times we have seen an undefined
137 // symbol.
138 Unordered_map<const Symbol*, int> undefined_symbols_;
139};
140
141} // End namespace gold.
142
143#endif // !defined(GOLD_ERRORS_H)