diff options
author | ted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-09-19 12:55:16 +0000 |
---|---|---|
committer | ted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-09-19 12:55:16 +0000 |
commit | 0e91d185cac51ed1b2c9163afca998660ebda08e (patch) | |
tree | a154d70d8918dd48c9ec161c94fff037d05ea113 /src/client/linux/minidump_writer/linux_dumper.cc | |
parent | Allow generating minidumps from live process on Linux via ExceptionHandler (diff) | |
download | breakpad-0e91d185cac51ed1b2c9163afca998660ebda08e.tar.xz |
Minidumps never contain MD_LINUX_DSO_DEBUG info when breakpad is in a shared library
A=Mike Hommey <mh@glandium.org>
R=ted at http://breakpad.appspot.com/422002/
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1044 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/linux/minidump_writer/linux_dumper.cc')
-rw-r--r-- | src/client/linux/minidump_writer/linux_dumper.cc | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc index 6e2bbc8b..2124224e 100644 --- a/src/client/linux/minidump_writer/linux_dumper.cc +++ b/src/client/linux/minidump_writer/linux_dumper.cc @@ -66,20 +66,24 @@ inline static bool IsMappedFileOpenUnsafe( namespace google_breakpad { +// All interesting auvx entry types are below AT_SYSINFO_EHDR +#define AT_MAX AT_SYSINFO_EHDR + LinuxDumper::LinuxDumper(pid_t pid) : pid_(pid), crash_address_(0), crash_signal_(0), crash_thread_(0), threads_(&allocator_, 8), - mappings_(&allocator_) { + mappings_(&allocator_), + auxv_(&allocator_, AT_MAX + 1) { } LinuxDumper::~LinuxDumper() { } bool LinuxDumper::Init() { - return EnumerateThreads() && EnumerateMappings(); + return ReadAuxv() && EnumerateThreads() && EnumerateMappings(); } bool @@ -131,58 +135,30 @@ LinuxDumper::ElfFileIdentifierForMapping(const MappingInfo& mapping, return success; } -void* -LinuxDumper::FindBeginningOfLinuxGateSharedLibrary(pid_t pid) const { +bool LinuxDumper::ReadAuxv() { char auxv_path[NAME_MAX]; - if (!BuildProcPath(auxv_path, pid, "auxv")) - return NULL; - - // Find the AT_SYSINFO_EHDR entry for linux-gate.so - // See http://www.trilithium.com/johan/2005/08/linux-gate/ for more - // information. - int fd = sys_open(auxv_path, O_RDONLY, 0); - if (fd < 0) { - return NULL; - } - - elf_aux_entry one_aux_entry; - while (sys_read(fd, - &one_aux_entry, - sizeof(elf_aux_entry)) == sizeof(elf_aux_entry) && - one_aux_entry.a_type != AT_NULL) { - if (one_aux_entry.a_type == AT_SYSINFO_EHDR) { - sys_close(fd); - return reinterpret_cast<void*>(one_aux_entry.a_un.a_val); - } + if (!BuildProcPath(auxv_path, pid_, "auxv")) { + return false; } - sys_close(fd); - return NULL; -} - -void* -LinuxDumper::FindEntryPoint(pid_t pid) const { - char auxv_path[NAME_MAX]; - if (!BuildProcPath(auxv_path, pid, "auxv")) - return NULL; int fd = sys_open(auxv_path, O_RDONLY, 0); if (fd < 0) { - return NULL; + return false; } - // Find the AT_ENTRY entry elf_aux_entry one_aux_entry; + bool res = false; while (sys_read(fd, &one_aux_entry, sizeof(elf_aux_entry)) == sizeof(elf_aux_entry) && one_aux_entry.a_type != AT_NULL) { - if (one_aux_entry.a_type == AT_ENTRY) { - sys_close(fd); - return reinterpret_cast<void*>(one_aux_entry.a_un.a_val); + if (one_aux_entry.a_type <= AT_MAX) { + auxv_[one_aux_entry.a_type] = one_aux_entry.a_un.a_val; + res = true; } } sys_close(fd); - return NULL; + return res; } bool LinuxDumper::EnumerateMappings() { @@ -192,15 +168,17 @@ bool LinuxDumper::EnumerateMappings() { // linux_gate_loc is the beginning of the kernel's mapping of // linux-gate.so in the process. It doesn't actually show up in the - // maps list as a filename, so we use the aux vector to find it's - // load location and special case it's entry when creating the list - // of mappings. - const void* linux_gate_loc; - linux_gate_loc = FindBeginningOfLinuxGateSharedLibrary(pid_); + // maps list as a filename, but it can be found using the AT_SYSINFO_EHDR + // aux vector entry, which gives the information necessary to special + // case its entry when creating the list of mappings. + // See http://www.trilithium.com/johan/2005/08/linux-gate/ for more + // information. + const void* linux_gate_loc = + reinterpret_cast<void *>(auxv_[AT_SYSINFO_EHDR]); // Although the initial executable is usually the first mapping, it's not // guaranteed (see http://crosbug.com/25355); therefore, try to use the // actual entry point to find the mapping. - const void* entry_point_loc = FindEntryPoint(pid_); + const void* entry_point_loc = reinterpret_cast<void *>(auxv_[AT_ENTRY]); const int fd = sys_open(maps_path, O_RDONLY, 0); if (fd < 0) |