mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 891266 - Allow to enable faulty.lib debug log at runtime. r=nfroyd
This commit is contained in:
parent
8451ae0558
commit
fd44bdf519
@ -289,6 +289,9 @@ ElfLoader ElfLoader::Singleton;
|
||||
TemporaryRef<LibHandle>
|
||||
ElfLoader::Load(const char *path, int flags, LibHandle *parent)
|
||||
{
|
||||
/* Ensure logging is initialized or refresh if environment changed. */
|
||||
Logging::Init();
|
||||
|
||||
RefPtr<LibHandle> handle;
|
||||
|
||||
/* Handle dlopen(NULL) directly. */
|
||||
@ -313,9 +316,7 @@ ElfLoader::Load(const char *path, int flags, LibHandle *parent)
|
||||
}
|
||||
|
||||
char *abs_path = NULL;
|
||||
#ifdef MOZ_DEBUG_LINKER
|
||||
const char *requested_path = path;
|
||||
#endif
|
||||
|
||||
/* When the path is not absolute and the library is being loaded for
|
||||
* another, first try to load the library from the directory containing
|
||||
@ -410,6 +411,9 @@ ElfLoader::Register(LibHandle *handle)
|
||||
void
|
||||
ElfLoader::Forget(LibHandle *handle)
|
||||
{
|
||||
/* Ensure logging is initialized or refresh if environment changed. */
|
||||
Logging::Init();
|
||||
|
||||
LibHandleList::iterator it = std::find(handles.begin(), handles.end(), handle);
|
||||
if (it != handles.end()) {
|
||||
DEBUG_LOG("ElfLoader::Forget(%p [\"%s\"])", reinterpret_cast<void *>(handle),
|
||||
@ -981,3 +985,5 @@ SEGVHandler::__wrap_sigaction(int signum, const struct sigaction *act,
|
||||
that.action = *act;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Logging Logging::Singleton;
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef Logging_h
|
||||
#define Logging_h
|
||||
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#define LOG(...) __android_log_print(ANDROID_LOG_ERROR, "GeckoLinker", __VA_ARGS__)
|
||||
@ -36,11 +38,35 @@
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DEBUG_LINKER
|
||||
#define DEBUG_LOG LOG
|
||||
#else
|
||||
#define DEBUG_LOG(...)
|
||||
#endif
|
||||
class Logging
|
||||
{
|
||||
public:
|
||||
static bool isVerbose()
|
||||
{
|
||||
return Singleton.verbose;
|
||||
}
|
||||
|
||||
private:
|
||||
bool verbose;
|
||||
|
||||
public:
|
||||
static void Init()
|
||||
{
|
||||
const char *env = getenv("MOZ_DEBUG_LINKER");
|
||||
if (env && *env == '1')
|
||||
Singleton.verbose = true;
|
||||
}
|
||||
|
||||
private:
|
||||
static Logging Singleton;
|
||||
};
|
||||
|
||||
#define DEBUG_LOG(...) \
|
||||
do { \
|
||||
if (MOZ_UNLIKELY(Logging::isVerbose())) { \
|
||||
LOG(__VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* HAVE_64BIT_OS is not defined when building host tools, so use
|
||||
* __SIZEOF_POINTER__ */
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "Utils.h"
|
||||
#include "Logging.h"
|
||||
|
||||
Logging Logging::Singleton;
|
||||
|
||||
const char *filterName[] = {
|
||||
"none",
|
||||
"thumb",
|
||||
@ -470,6 +472,8 @@ int main(int argc, char* argv[])
|
||||
SeekableZStream::FilterId filter = SzipCompress::DEFAULT_FILTER;
|
||||
size_t dictSize = (size_t) 0;
|
||||
|
||||
Logging::Init();
|
||||
|
||||
for (firstArg = &argv[1]; argc > 2; argc--, firstArg++) {
|
||||
if (!firstArg[0] || firstArg[0][0] != '-')
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user