aboutsummaryrefslogtreecommitdiff
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
commitc79126688f8211ab17a893c5e80b09811d424fc1 (patch)
tree23a727f6718dc203a4e3b9ef1575e8a10b6f0d80 /gold/errors.cc
parent*** empty log message *** (diff)
downloadbinutils-gdb-c79126688f8211ab17a893c5e80b09811d424fc1.tar.gz
binutils-gdb-c79126688f8211ab17a893c5e80b09811d424fc1.tar.bz2
binutils-gdb-c79126688f8211ab17a893c5e80b09811d424fc1.zip
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 2da1a2569ed..c979463dfc2 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.