// descriptors.cc -- manage file descriptors for gold
-// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+// Copyright (C) 2008-2016 Free Software Foundation, Inc.
// This file is part of gold.
#include <fcntl.h>
#include <unistd.h>
+#include "debug.h"
#include "parameters.h"
#include "options.h"
#include "gold-threads.h"
gold_assert(lock_initialized || descriptor < 0);
+ if (is_debugging_enabled(DEBUG_FILES))
+ this->limit_ = 8;
+
if (descriptor >= 0)
{
Hold_lock hl(*this->lock_);
pod->stack_next = -1;
pod->is_on_stack = false;
}
+ gold_debug(DEBUG_FILES, "Reused existing descriptor %d for \"%s\"",
+ descriptor, name);
return descriptor;
}
}
errno = ENOENT;
}
+ gold_debug(DEBUG_FILES, "Opened new descriptor %d for \"%s\"",
+ new_descriptor, name);
return new_descriptor;
}
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;
}
}
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
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;
{
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;