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
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_;
}
}
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_;
}
}
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_;
}
}
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_;
}
}
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_;
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.