summaryrefslogtreecommitdiff
path: root/gold/errors.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-11-22 00:05:51 +0000
committerIan Lance Taylor <iant@google.com>2007-11-22 00:05:51 +0000
commit1b850931727a7dde9ab7163e754c3e34fbcfb266 (patch)
tree51955f56e46aee14c874d626a89a8564ebc97847 /gold/errors.cc
parent6913423cf54d35a1b05ed7c7dff91ebf967a8292 (diff)
downloadbinutils-redhat-1b850931727a7dde9ab7163e754c3e34fbcfb266.tar.gz
Add threading support.
Diffstat (limited to 'gold/errors.cc')
-rw-r--r--gold/errors.cc46
1 files changed, 39 insertions, 7 deletions
diff --git a/gold/errors.cc b/gold/errors.cc
index 2da1a2569e..c979463dfc 100644
--- a/gold/errors.cc
+++ b/gold/errors.cc
@@ -39,11 +39,20 @@ namespace gold
const int Errors::max_undefined_error_report;
Errors::Errors(const char* program_name)
- : program_name_(program_name), lock_(), error_count_(0), warning_count_(0),
- undefined_symbols_()
+ : program_name_(program_name), lock_(NULL), error_count_(0),
+ warning_count_(0), undefined_symbols_()
{
}
+// Initialize the lock_ field.
+
+void
+Errors::initialize_lock()
+{
+ if (this->lock_ == NULL)
+ this->lock_ = new Lock;
+}
+
// Report a fatal error.
void
@@ -63,8 +72,10 @@ Errors::error(const char* format, va_list args)
fprintf(stderr, "%s: ", this->program_name_);
vfprintf(stderr, format, args);
fputc('\n', stderr);
+
+ this->initialize_lock();
{
- Hold_lock h(this->lock_);
+ Hold_lock h(*this->lock_);
++this->error_count_;
}
}
@@ -77,8 +88,10 @@ Errors::warning(const char* format, va_list args)
fprintf(stderr, _("%s: warning: "), this->program_name_);
vfprintf(stderr, format, args);
fputc('\n', stderr);
+
+ this->initialize_lock();
{
- Hold_lock h(this->lock_);
+ Hold_lock h(*this->lock_);
++this->warning_count_;
}
}
@@ -95,8 +108,10 @@ Errors::error_at_location(const Relocate_info<size, big_endian>* relinfo,
relinfo->location(relnum, reloffset).c_str());
vfprintf(stderr, format, args);
fputc('\n', stderr);
+
+ this->initialize_lock();
{
- Hold_lock h(this->lock_);
+ Hold_lock h(*this->lock_);
++this->error_count_;
}
}
@@ -113,8 +128,10 @@ Errors::warning_at_location(const Relocate_info<size, big_endian>* relinfo,
relinfo->location(relnum, reloffset).c_str());
vfprintf(stderr, format, args);
fputc('\n', stderr);
+
+ this->initialize_lock();
{
- Hold_lock h(this->lock_);
+ Hold_lock h(*this->lock_);
++this->warning_count_;
}
}
@@ -127,8 +144,9 @@ Errors::undefined_symbol(const Symbol* sym,
const Relocate_info<size, big_endian>* relinfo,
size_t relnum, off_t reloffset)
{
+ this->initialize_lock();
{
- Hold_lock h(this->lock_);
+ Hold_lock h(*this->lock_);
if (++this->undefined_symbols_[sym] >= max_undefined_error_report)
return;
++this->error_count_;
@@ -138,6 +156,20 @@ Errors::undefined_symbol(const Symbol* sym,
sym->demangled_name().c_str());
}
+// Issue a debugging message.
+
+void
+Errors::debug(const char* format, ...)
+{
+ fprintf(stderr, _("%s: "), this->program_name_);
+
+ va_list args;
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+
+ fputc('\n', stderr);
+}
// The functions which the rest of the code actually calls.