From Craig Silverstein: Implement --debug=files to track file opens,
and implement --verbose as a synonym.
This commit is contained in:
parent
858b27aeed
commit
2285a61069
6 changed files with 37 additions and 9 deletions
|
@ -31,10 +31,11 @@ namespace gold
|
|||
|
||||
// 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
|
||||
|
@ -45,6 +46,7 @@ debug_string_to_enum(const char* arg)
|
|||
{
|
||||
{ "task", DEBUG_TASK },
|
||||
{ "script", DEBUG_SCRIPT },
|
||||
{ "files", DEBUG_FILES },
|
||||
{ "all", DEBUG_ALL }
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "gold-threads.h"
|
||||
#include "options.h"
|
||||
#include "workqueue.h"
|
||||
|
@ -235,6 +236,9 @@ Dirsearch::initialize(Workqueue* workqueue,
|
|||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -253,10 +257,20 @@ Dirsearch::find(const std::string& n1, const std::string& n2,
|
|||
*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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <sys/uio.h>
|
||||
#include "filenames.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "parameters.h"
|
||||
#include "options.h"
|
||||
#include "dirsearch.h"
|
||||
|
@ -118,6 +119,8 @@ File_read::open(const Task* task, const std::string& name)
|
|||
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);
|
||||
|
|
|
@ -458,7 +458,8 @@ class General_options
|
|||
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"));
|
||||
|
@ -579,6 +580,9 @@ class General_options
|
|||
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"));
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ Parameters::set_options(const General_options* options)
|
|||
// 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
|
||||
|
|
|
@ -116,7 +116,9 @@ class Parameters
|
|||
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_;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue