mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-01-03 13:14:45 +01:00
Refactor code in preparation of merging with the fork in Chromium OS.
This patch is part of a bigger patch that helps merging the breakpad code with the modified version in Chromium OS. Specifically, this patch makes the following changes: 1. Add a MemoryRange class for encapsulating and checking read access to a contiguous range of memory. 2. Add a MemoryMappedFile class for mapping a file into memory for read-only access. 3. Refactor other source code to use MemoryMappedFile. BUG=455 TEST=Tested the following: 1. Build on 32-bit and 64-bit Linux with gcc 4.4.3 and gcc 4.6. 2. Build on Mac OS X 10.6.8 with gcc 4.2 and clang 3.0 (with latest gmock). 3. All unit tests pass. 4. Run minidump-2-core to covnert a minidump file to a core file. Review URL: http://breakpad.appspot.com/332001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@895 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
25b886a7fd
commit
f044345c23
12 changed files with 878 additions and 65 deletions
|
|
@ -35,13 +35,10 @@
|
|||
|
||||
#include <elf.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <link.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/user.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
@ -50,6 +47,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "client/linux/minidump_writer/minidump_extension_linux.h"
|
||||
#include "common/linux/memory_mapped_file.h"
|
||||
#include "google_breakpad/common/minidump_format.h"
|
||||
#include "google_breakpad/common/minidump_cpu_x86.h"
|
||||
#include "third_party/lss/linux_syscall_support.h"
|
||||
|
|
@ -77,6 +75,8 @@
|
|||
#define ELF_ARCH EM_MIPS
|
||||
#endif
|
||||
|
||||
using google_breakpad::MemoryMappedFile;
|
||||
|
||||
static const MDRVA kInvalidMDRVA = static_cast<MDRVA>(-1);
|
||||
static bool verbose;
|
||||
|
||||
|
|
@ -970,21 +970,13 @@ main(int argc, char** argv) {
|
|||
if (argc != argi + 1)
|
||||
return usage(argv[0]);
|
||||
|
||||
const int fd = open(argv[argi], O_RDONLY);
|
||||
if (fd < 0)
|
||||
return usage(argv[0]);
|
||||
|
||||
struct stat st;
|
||||
fstat(fd, &st);
|
||||
|
||||
const void* bytes = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
close(fd);
|
||||
if (bytes == MAP_FAILED) {
|
||||
perror("Failed to mmap dump file");
|
||||
MemoryMappedFile mapped_file(argv[argi]);
|
||||
if (!mapped_file.data()) {
|
||||
fprintf(stderr, "Failed to mmap dump file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
MMappedRange dump(bytes, st.st_size);
|
||||
MMappedRange dump(mapped_file.data(), mapped_file.size());
|
||||
|
||||
const MDRawHeader* header =
|
||||
(const MDRawHeader*) dump.GetObject(0, sizeof(MDRawHeader));
|
||||
|
|
@ -1187,7 +1179,5 @@ main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
|
||||
munmap(const_cast<void*>(bytes), st.st_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue