ChangeLog rotatation and copyright year update
[deliverable/binutils-gdb.git] / gold / errors.h
CommitLineData
75f2446e
ILT
1// errors.h -- handle errors for gold -*- C++ -*-
2
b90efa5b 3// Copyright (C) 2006-2015 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>
27
28#include "gold-threads.h"
29
30namespace gold
31{
32
33class Symbol;
34template<int size, bool big_endian>
35struct Relocate_info;
36
37// This class handles errors for gold. There is a single instance
38// which is used by all threads. If and when we make the gold code
39// more amenable to being used in a library, we will make this an
40// abstract interface class, and expect the caller to provide their
41// own instantiation.
42
43class Errors
44{
45 public:
46 Errors(const char* program_name);
47
48 // Report a fatal error. After printing the error, this must exit.
49 void
50 fatal(const char* format, va_list) ATTRIBUTE_NORETURN;
51
e6455dfb
CC
52 // Report a fallback error. After printing the error, this must exit
53 // with a special status code indicating that fallback to
54 // --incremental-full is required.
55 void
56 fallback(const char* format, va_list) ATTRIBUTE_NORETURN;
57
75f2446e
ILT
58 // Report an error and continue.
59 void
60 error(const char* format, va_list);
61
62 // Report a warning and continue.
63 void
64 warning(const char* format, va_list);
c5818ff1
CC
65
66 // Print an informational message and continue.
67 void
68 info(const char* format, va_list);
75f2446e
ILT
69
70 // Report an error at a reloc location.
71 template<int size, bool big_endian>
72 void
73 error_at_location(const Relocate_info<size, big_endian>* relinfo,
74 size_t relnum, off_t reloffset,
75 const char* format, va_list);
76
77 // Report a warning at a reloc location.
78 template<int size, bool big_endian>
79 void
80 warning_at_location(const Relocate_info<size, big_endian>* relinfo,
81 size_t relnum, off_t reloffset,
82 const char* format, va_list);
83
f073bbf7
CD
84 // Issue an undefined symbol error. LOCATION is the location of
85 // the error (typically an object file name or relocation info).
75f2446e 86 void
f073bbf7 87 undefined_symbol(const Symbol* sym, const std::string& location);
75f2446e 88
c7912668
ILT
89 // Report a debugging message.
90 void
91 debug(const char* format, ...) ATTRIBUTE_PRINTF_2;
92
75f2446e
ILT
93 // Return the number of errors.
94 int
95 error_count() const
96 { return this->error_count_; }
97
d82a5bcc
ILT
98 // Return the number of warnings.
99 int
100 warning_count() const
101 { return this->warning_count_; }
102
75f2446e
ILT
103 private:
104 Errors(const Errors&);
105 Errors& operator=(const Errors&);
106
c7912668
ILT
107 // Initialize the lock. We don't do this in the constructor because
108 // lock initialization wants to know whether we are using threads or
2dd3e587
ILT
109 // not. This returns true if the lock is now initialized.
110 bool
c7912668
ILT
111 initialize_lock();
112
2dd3e587
ILT
113 // Increment a counter, holding the lock.
114 void
115 increment_counter(int*);
116
75f2446e
ILT
117 // The number of times we report an undefined symbol.
118 static const int max_undefined_error_report = 5;
119
120 // The name of the program.
121 const char* program_name_;
122 // This class can be accessed from multiple threads. This lock is
123 // used to control access to the data structures.
c7912668 124 Lock* lock_;
7f055c20
ILT
125 // Used to initialize the lock_ field exactly once.
126 Initialize_lock initialize_lock_;
75f2446e
ILT
127 // Numbers of errors reported.
128 int error_count_;
129 // Number of warnings reported.
130 int warning_count_;
131 // A map counting the numbers of times we have seen an undefined
132 // symbol.
133 Unordered_map<const Symbol*, int> undefined_symbols_;
134};
135
136} // End namespace gold.
137
138#endif // !defined(GOLD_ERRORS_H)
This page took 0.377348 seconds and 4 git commands to generate.