mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-04-18 04:51:43 +00:00
Reuse code and fix inconsistent array boundaries.
R=ted.mielczarek Review URL: http://breakpad.appspot.com/237001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@740 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
8322cd6586
commit
b5dfa2834d
|
@ -246,7 +246,7 @@ LinuxDumper::ElfFileIdentifierForMapping(unsigned int mapping_id,
|
||||||
|
|
||||||
void*
|
void*
|
||||||
LinuxDumper::FindBeginningOfLinuxGateSharedLibrary(const pid_t pid) const {
|
LinuxDumper::FindBeginningOfLinuxGateSharedLibrary(const pid_t pid) const {
|
||||||
char auxv_path[80];
|
char auxv_path[NAME_MAX];
|
||||||
BuildProcPath(auxv_path, pid, "auxv");
|
BuildProcPath(auxv_path, pid, "auxv");
|
||||||
|
|
||||||
// If BuildProcPath errors out due to invalid input, we'll handle it when
|
// If BuildProcPath errors out due to invalid input, we'll handle it when
|
||||||
|
@ -276,7 +276,7 @@ LinuxDumper::FindBeginningOfLinuxGateSharedLibrary(const pid_t pid) const {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LinuxDumper::EnumerateMappings(wasteful_vector<MappingInfo*>* result) const {
|
LinuxDumper::EnumerateMappings(wasteful_vector<MappingInfo*>* result) const {
|
||||||
char maps_path[80];
|
char maps_path[NAME_MAX];
|
||||||
BuildProcPath(maps_path, pid_, "maps");
|
BuildProcPath(maps_path, pid_, "maps");
|
||||||
|
|
||||||
// linux_gate_loc is the beginning of the kernel's mapping of
|
// linux_gate_loc is the beginning of the kernel's mapping of
|
||||||
|
@ -338,7 +338,7 @@ LinuxDumper::EnumerateMappings(wasteful_vector<MappingInfo*>* result) const {
|
||||||
// Parse /proc/$pid/task to list all the threads of the process identified by
|
// Parse /proc/$pid/task to list all the threads of the process identified by
|
||||||
// pid.
|
// pid.
|
||||||
bool LinuxDumper::EnumerateThreads(wasteful_vector<pid_t>* result) const {
|
bool LinuxDumper::EnumerateThreads(wasteful_vector<pid_t>* result) const {
|
||||||
char task_path[80];
|
char task_path[NAME_MAX];
|
||||||
BuildProcPath(task_path, pid_, "task");
|
BuildProcPath(task_path, pid_, "task");
|
||||||
|
|
||||||
const int fd = sys_open(task_path, O_RDONLY | O_DIRECTORY, 0);
|
const int fd = sys_open(task_path, O_RDONLY | O_DIRECTORY, 0);
|
||||||
|
@ -373,7 +373,7 @@ bool LinuxDumper::EnumerateThreads(wasteful_vector<pid_t>* result) const {
|
||||||
// available.
|
// available.
|
||||||
bool LinuxDumper::ThreadInfoGet(pid_t tid, ThreadInfo* info) {
|
bool LinuxDumper::ThreadInfoGet(pid_t tid, ThreadInfo* info) {
|
||||||
assert(info != NULL);
|
assert(info != NULL);
|
||||||
char status_path[80];
|
char status_path[NAME_MAX];
|
||||||
BuildProcPath(status_path, tid, "status");
|
BuildProcPath(status_path, tid, "status");
|
||||||
|
|
||||||
const int fd = open(status_path, O_RDONLY);
|
const int fd = open(status_path, O_RDONLY);
|
||||||
|
|
|
@ -1216,12 +1216,8 @@ class MinidumpWriter {
|
||||||
|
|
||||||
bool WriteProcFile(MDLocationDescriptor* result, pid_t pid,
|
bool WriteProcFile(MDLocationDescriptor* result, pid_t pid,
|
||||||
const char* filename) {
|
const char* filename) {
|
||||||
char buf[80];
|
char buf[NAME_MAX];
|
||||||
memcpy(buf, "/proc/", 6);
|
dumper_.BuildProcPath(buf, pid, filename);
|
||||||
const unsigned pid_len = my_int_len(pid);
|
|
||||||
my_itos(buf + 6, pid, pid_len);
|
|
||||||
buf[6 + pid_len] = '/';
|
|
||||||
memcpy(buf + 6 + pid_len + 1, filename, my_strlen(filename) + 1);
|
|
||||||
return WriteFile(result, buf);
|
return WriteFile(result, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@ TEST(MinidumpWriterTest, Setup) {
|
||||||
|
|
||||||
char templ[] = TEMPDIR "/minidump-writer-unittest-XXXXXX";
|
char templ[] = TEMPDIR "/minidump-writer-unittest-XXXXXX";
|
||||||
mktemp(templ);
|
mktemp(templ);
|
||||||
|
// Set a non-zero tid to avoid tripping asserts.
|
||||||
|
context.tid = 1;
|
||||||
ASSERT_TRUE(WriteMinidump(templ, child, &context, sizeof(context)));
|
ASSERT_TRUE(WriteMinidump(templ, child, &context, sizeof(context)));
|
||||||
struct stat st;
|
struct stat st;
|
||||||
ASSERT_EQ(stat(templ, &st), 0);
|
ASSERT_EQ(stat(templ, &st), 0);
|
||||||
|
|
Loading…
Reference in a new issue