diff options
author | Ian Lance Taylor <iant@google.com> | 2007-10-14 06:49:14 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-10-14 06:49:14 +0000 |
commit | 75f2446ec3c13eca3fe0c7cfdbb232e760d36596 (patch) | |
tree | a243e4c2c79cd8790a316a38b552507b62bf0421 /gold/errors.h | |
parent | eb4dfdd470e49ab56eed5cead19704e0926530d0 (diff) | |
download | gdb-75f2446ec3c13eca3fe0c7cfdbb232e760d36596.zip gdb-75f2446ec3c13eca3fe0c7cfdbb232e760d36596.tar.gz gdb-75f2446ec3c13eca3fe0c7cfdbb232e760d36596.tar.bz2 |
Run all error handling through an Errors object. Delete output file
on error.
Diffstat (limited to 'gold/errors.h')
-rw-r--r-- | gold/errors.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/gold/errors.h b/gold/errors.h new file mode 100644 index 0000000..545c463 --- /dev/null +++ b/gold/errors.h @@ -0,0 +1,111 @@ +// errors.h -- handle errors for gold -*- C++ -*- + +// Copyright 2006, 2007 Free Software Foundation, Inc. +// Written by Ian Lance Taylor <iant@google.com>. + +// This file is part of gold. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +// MA 02110-1301, USA. + +#ifndef GOLD_ERRORS_H +#define GOLD_ERRORS_H + +#include <cstdarg> + +#include "gold-threads.h" + +namespace gold +{ + +class Symbol; +template<int size, bool big_endian> +struct Relocate_info; + +// This class handles errors for gold. There is a single instance +// which is used by all threads. If and when we make the gold code +// more amenable to being used in a library, we will make this an +// abstract interface class, and expect the caller to provide their +// own instantiation. + +class Errors +{ + public: + Errors(const char* program_name); + + // Report a fatal error. After printing the error, this must exit. + void + fatal(const char* format, va_list) ATTRIBUTE_NORETURN; + + // Report an error and continue. + void + error(const char* format, va_list); + + // Report a warning and continue. + void + warning(const char* format, va_list); + + // Report an error at a reloc location. + template<int size, bool big_endian> + void + error_at_location(const Relocate_info<size, big_endian>* relinfo, + size_t relnum, off_t reloffset, + const char* format, va_list); + + // Report a warning at a reloc location. + template<int size, bool big_endian> + void + warning_at_location(const Relocate_info<size, big_endian>* relinfo, + size_t relnum, off_t reloffset, + const char* format, va_list); + + // Issue an undefined symbol error. SYM is the undefined symbol. + // RELINFO is the general relocation info. RELNUM is the number of + // the reloc, and RELOFFSET is the reloc's offset. + template<int size, bool big_endian> + void + undefined_symbol(const Symbol* sym, + const Relocate_info<size, big_endian>* relinfo, + size_t relnum, off_t reloffset); + + // Return the number of errors. + int + error_count() const + { return this->error_count_; } + + private: + Errors(const Errors&); + Errors& operator=(const Errors&); + + // The number of times we report an undefined symbol. + static const int max_undefined_error_report = 5; + + // The name of the program. + const char* program_name_; + // This class can be accessed from multiple threads. This lock is + // used to control access to the data structures. + Lock lock_; + // Numbers of errors reported. + int error_count_; + // Number of warnings reported. + int warning_count_; + // A map counting the numbers of times we have seen an undefined + // symbol. + Unordered_map<const Symbol*, int> undefined_symbols_; +}; + +} // End namespace gold. + +#endif // !defined(GOLD_ERRORS_H) |