and implement --verbose as a synonym.
// The different types of debugging we support. These are bitflags.
-const int DEBUG_TASK = 1;
-const int DEBUG_SCRIPT = 2;
+const int DEBUG_TASK = 0x1;
+const int DEBUG_SCRIPT = 0x2;
+const int DEBUG_FILES = 0x4;
-const int DEBUG_ALL = DEBUG_TASK | DEBUG_SCRIPT;
+const int DEBUG_ALL = DEBUG_TASK | DEBUG_SCRIPT | DEBUG_FILES;
// Convert a debug string to the appropriate enum.
inline int
{
{ "task", DEBUG_TASK },
{ "script", DEBUG_SCRIPT },
+ { "files", DEBUG_FILES },
{ "all", DEBUG_ALL }
};
#include <sys/types.h>
#include <dirent.h>
+#include "debug.h"
#include "gold-threads.h"
#include "options.h"
#include "workqueue.h"
}
}
+// NOTE: we only log failed file-lookup attempts here. Successfully
+// lookups will eventually get logged in File_read::open.
+
std::string
Dirsearch::find(const std::string& n1, const std::string& n2,
bool *is_in_sysroot) const
*is_in_sysroot = p->is_in_sysroot();
return p->name() + '/' + n1;
}
- if (!n2.empty() && pdc->find(n2))
- {
- *is_in_sysroot = p->is_in_sysroot();
- return p->name() + '/' + n2;
+ else
+ gold_debug(DEBUG_FILES, "Attempt to open %s/%s failed",
+ p->name().c_str(), n1.c_str());
+
+ if (!n2.empty())
+ {
+ if (pdc->find(n2))
+ {
+ *is_in_sysroot = p->is_in_sysroot();
+ return p->name() + '/' + n2;
+ }
+ else
+ gold_debug(DEBUG_FILES, "Attempt to open %s/%s failed",
+ p->name().c_str(), n2.c_str());
}
}
#include <sys/uio.h>
#include "filenames.h"
+#include "debug.h"
#include "parameters.h"
#include "options.h"
#include "dirsearch.h"
gold_error(_("%s: fstat failed: %s"),
this->name_.c_str(), strerror(errno));
this->size_ = s.st_size;
+ gold_debug(DEBUG_FILES, "Attempt to open %s succeeded",
+ this->name_.c_str());
}
this->token_.add_writer(task);
N_("Alias for -d"), NULL);
DEFINE_string(debug, options::TWO_DASHES, '\0', "",
- N_("Turn on debugging"), N_("[task,script,all][,...]"));
+ N_("Turn on debugging"),
+ N_("[all,files,script,task][,...]"));
DEFINE_special(defsym, options::TWO_DASHES, '\0',
N_("Define a symbol"), N_("SYMBOL=EXPRESSION"));
DEFINE_uint64(Ttext, options::ONE_DASH, '\0', -1U,
N_("Set the address of the text segment"), N_("ADDRESS"));
+ DEFINE_bool(verbose, options::TWO_DASHES, '\0', false,
+ N_("Synonym for --debug=files"), NULL);
+
DEFINE_special(version_script, options::TWO_DASHES, '\0',
N_("Read version script"), N_("FILE"));
// For speed, we convert the options() debug var from a string to an
// enum (from debug.h).
this->debug_ = debug_string_to_enum(this->options().debug());
+ // If --verbose is set, it acts as "--debug=files".
+ if (options->verbose())
+ this->debug_ |= DEBUG_FILES;
}
void
int
debug() const
{
- gold_assert(this->options_valid());
+ // This can be called before the options are set up.
+ if (!this->options_valid())
+ return 0;
return debug_;
}