aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-03-13 01:46:17 +0000
committerIan Lance Taylor <iant@google.com>2008-03-13 01:46:17 +0000
commit2285a61069d360fc56b6cf7371a6fe3ac4e240b7 (patch)
tree9ec30b1d79e193e37204f5e2e06c5c42fceb5d56
parent858b27aeedf30683566a6f25045977644f0e7d23 (diff)
downloadgdb-2285a61069d360fc56b6cf7371a6fe3ac4e240b7.zip
gdb-2285a61069d360fc56b6cf7371a6fe3ac4e240b7.tar.gz
gdb-2285a61069d360fc56b6cf7371a6fe3ac4e240b7.tar.bz2
From Craig Silverstein: Implement --debug=files to track file opens,
and implement --verbose as a synonym.
-rw-r--r--gold/debug.h8
-rw-r--r--gold/dirsearch.cc22
-rw-r--r--gold/fileread.cc3
-rw-r--r--gold/options.h6
-rw-r--r--gold/parameters.cc3
-rw-r--r--gold/parameters.h4
6 files changed, 37 insertions, 9 deletions
diff --git a/gold/debug.h b/gold/debug.h
index 143c7df..69a0e29 100644
--- a/gold/debug.h
+++ b/gold/debug.h
@@ -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 }
};
diff --git a/gold/dirsearch.cc b/gold/dirsearch.cc
index 960c8eb..9380889 100644
--- a/gold/dirsearch.cc
+++ b/gold/dirsearch.cc
@@ -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());
}
}
diff --git a/gold/fileread.cc b/gold/fileread.cc
index 2931d43..14d3b0d 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -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);
diff --git a/gold/options.h b/gold/options.h
index 48cb28a..efe92e2 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -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"));
diff --git a/gold/parameters.cc b/gold/parameters.cc
index 9c57ef3..2e8bab7 100644
--- a/gold/parameters.cc
+++ b/gold/parameters.cc
@@ -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
diff --git a/gold/parameters.h b/gold/parameters.h
index 3b10228..f932f73 100644
--- a/gold/parameters.h
+++ b/gold/parameters.h
@@ -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_;
}