mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 749518 - Use dl_iterate_phdr instead of proc/maps for Linux symbolicate. r=glandium
This commit is contained in:
parent
7e2e441f09
commit
4326516b13
@ -5,7 +5,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = $(srcdir)
|
||||
relativesrcdir = @relativesrcdir@
|
||||
@ -23,6 +23,7 @@ EXPORTS += \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/mozglue/linker \
|
||||
-I$(topsrcdir)/ipc/chromium/src \
|
||||
$(NULL)
|
||||
|
||||
@ -68,6 +69,10 @@ EXTRA_JS_MODULES = \
|
||||
Profiler.jsm \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_OLD_LINKER
|
||||
DEFINES += -DMOZ_OLD_LINKER
|
||||
endif
|
||||
|
||||
ifneq (,$(filter Android Linux,$(OS_TARGET)))
|
||||
CPPSRCS += \
|
||||
shared-libraries-linux.cc \
|
||||
|
@ -2,6 +2,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "shared-libraries.h"
|
||||
|
||||
#define PATH_MAX_TOSTRING(x) #x
|
||||
#define PATH_MAX_STRING(x) PATH_MAX_TOSTRING(x)
|
||||
#include <stdlib.h>
|
||||
@ -27,10 +29,66 @@ static ssize_t getline(char **lineptr, size_t *n, FILE *stream)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_OLD_LINKER
|
||||
// TODO fix me with proper include
|
||||
#include "nsDebug.h"
|
||||
#ifdef ANDROID
|
||||
#include "ElfLoader.h" // dl_phdr_info
|
||||
#else
|
||||
#include <link.h> // dl_phdr_info
|
||||
#endif
|
||||
#include <features.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
__attribute__((weak))
|
||||
int dl_iterate_phdr(
|
||||
int (*callback) (struct dl_phdr_info *info,
|
||||
size_t size, void *data),
|
||||
void *data);
|
||||
#endif
|
||||
|
||||
int dl_iterate_callback(struct dl_phdr_info *dl_info, size_t size, void *data)
|
||||
{
|
||||
SharedLibraryInfo& info = *reinterpret_cast<SharedLibraryInfo*>(data);
|
||||
|
||||
if (dl_info->dlpi_phnum <= 0)
|
||||
return 0;
|
||||
|
||||
unsigned long libStart = -1;
|
||||
unsigned long libEnd = 0;
|
||||
|
||||
for (size_t i = 0; i < dl_info->dlpi_phnum; i++) {
|
||||
if (dl_info->dlpi_phdr[i].p_type != PT_LOAD) {
|
||||
continue;
|
||||
}
|
||||
unsigned long start = dl_info->dlpi_addr + dl_info->dlpi_phdr[i].p_vaddr;
|
||||
unsigned long end = start + dl_info->dlpi_phdr[i].p_memsz;
|
||||
if (start < libStart)
|
||||
libStart = start;
|
||||
if (end > libEnd)
|
||||
libEnd = end;
|
||||
}
|
||||
SharedLibrary shlib(libStart, libEnd, 0, dl_info->dlpi_name);
|
||||
info.AddSharedLibrary(shlib);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
SharedLibraryInfo info;
|
||||
|
||||
#ifndef MOZ_OLD_LINKER
|
||||
dl_iterate_phdr(dl_iterate_callback, &info);
|
||||
#ifndef ANDROID
|
||||
return info;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
pid_t pid = getpid();
|
||||
char path[PATH_MAX];
|
||||
snprintf(path, PATH_MAX, "/proc/%d/maps", pid);
|
||||
FILE *maps = fopen(path, "r");
|
||||
@ -56,6 +114,12 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
|
||||
LOG("Get maps line failed");
|
||||
continue;
|
||||
}
|
||||
#if defined(ANDROID) && !defined(MOZ_OLD_LINKER)
|
||||
// Use proc/pid/maps to get the dalvik-jit section since it has
|
||||
// no associated phdrs
|
||||
if (strcmp(name, "/dev/ashmem/dalvik-jit-code-cache") != 0)
|
||||
continue;
|
||||
#endif
|
||||
SharedLibrary shlib(start, end, offset, name);
|
||||
info.AddSharedLibrary(shlib);
|
||||
if (count > 10000) {
|
||||
|
@ -27,9 +27,9 @@ public:
|
||||
#ifdef XP_WIN
|
||||
nsID aPdbSignature,
|
||||
unsigned long aPdbAge,
|
||||
char *aPdbName,
|
||||
const char *aPdbName,
|
||||
#endif
|
||||
char *aName)
|
||||
const char *aName)
|
||||
: mStart(aStart)
|
||||
, mEnd(aEnd)
|
||||
, mOffset(aOffset)
|
||||
|
Loading…
Reference in New Issue
Block a user