This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Add extra debugging output for files and descriptors.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8265ef950202a4bf0d3444802ad5d7087b4b185d

commit 8265ef950202a4bf0d3444802ad5d7087b4b185d
Author: Cary Coutant <ccoutant@google.com>
Date:   Mon Feb 2 11:47:58 2015 -0800

    Add extra debugging output for files and descriptors.
    
    gold/
    	* descriptors.cc (Descriptors::open): Set artificially-low limit for
    	file descriptors when debugging enabled. Add debug output.
    	(Descriptors::release): Add debug output.
    	(Descriptors::close_some_descriptor): Likewise.
    	(Descriptors::close_all): Likewise.
    	* fileread.cc (File_read::lock): Likewise.
    	(File_read::unlock): Likewise.

Diff:
---
 gold/descriptors.cc | 17 +++++++++++++++++
 gold/fileread.cc    |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/gold/descriptors.cc b/gold/descriptors.cc
index 04916c6..c55d45b 100644
--- a/gold/descriptors.cc
+++ b/gold/descriptors.cc
@@ -28,6 +28,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#include "debug.h"
 #include "parameters.h"
 #include "options.h"
 #include "gold-threads.h"
@@ -81,6 +82,9 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
 
   gold_assert(lock_initialized || descriptor < 0);
 
+  if (is_debugging_enabled(DEBUG_FILES))
+    this->limit_ = 8;
+
   if (descriptor >= 0)
     {
       Hold_lock hl(*this->lock_);
@@ -99,6 +103,8 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
 	      pod->stack_next = -1;
 	      pod->is_on_stack = false;
 	    }
+	  gold_debug(DEBUG_FILES, "Reused existing descriptor %d for \"%s\"",
+		     descriptor, name);
 	  return descriptor;
 	}
     }
@@ -128,6 +134,8 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
 	      errno = ENOENT;
 	    }
 
+	  gold_debug(DEBUG_FILES, "Opened new descriptor %d for \"%s\"",
+		     new_descriptor, name);
 	  return new_descriptor;
 	}
 
@@ -162,6 +170,8 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
 	    if (this->current_ >= this->limit_)
 	      this->close_some_descriptor();
 
+	    gold_debug(DEBUG_FILES, "Opened new descriptor %d for \"%s\"",
+		       new_descriptor, name);
 	    return new_descriptor;
 	  }
 	}
@@ -209,6 +219,9 @@ Descriptors::release(int descriptor, bool permanent)
 	  pod->is_on_stack = true;
 	}
     }
+
+  gold_debug(DEBUG_FILES, "Released descriptor %d for \"%s\"",
+	     descriptor, pod->name);
 }
 
 // Close some descriptor.  The lock is held when this is called.  We
@@ -233,6 +246,8 @@ Descriptors::close_some_descriptor()
 	  if (::close(i) < 0)
 	    gold_warning(_("while closing %s: %s"), pod->name, strerror(errno));
 	  --this->current_;
+	  gold_debug(DEBUG_FILES, "Closed descriptor %d for \"%s\"",
+		     i, pod->name);
 	  pod->name = NULL;
 	  if (last < 0)
 	    this->stack_top_ = pod->stack_next;
@@ -265,6 +280,8 @@ Descriptors::close_all()
 	{
 	  if (::close(i) < 0)
 	    gold_warning(_("while closing %s: %s"), pod->name, strerror(errno));
+	  gold_debug(DEBUG_FILES, "Closed descriptor %d for \"%s\" (close_all)",
+		     static_cast<int>(i), pod->name);
 	  pod->name = NULL;
 	  pod->stack_next = -1;
 	  pod->is_on_stack = false;
diff --git a/gold/fileread.cc b/gold/fileread.cc
index cf70981..0bd8320 100644
--- a/gold/fileread.cc
+++ b/gold/fileread.cc
@@ -293,6 +293,7 @@ void
 File_read::lock(const Task* task)
 {
   gold_assert(this->released_);
+  gold_debug(DEBUG_FILES, "Locking file \"%s\"", this->name_.c_str());
   this->token_.add_writer(task);
   this->released_ = false;
 }
@@ -302,6 +303,7 @@ File_read::lock(const Task* task)
 void
 File_read::unlock(const Task* task)
 {
+  gold_debug(DEBUG_FILES, "Unlocking file \"%s\"", this->name_.c_str());
   this->release();
   this->token_.remove_writer(task);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]