aboutsummaryrefslogtreecommitdiff
path: root/src/client/linux/minidump_writer
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/linux/minidump_writer')
-rw-r--r--src/client/linux/minidump_writer/cpu_set.h5
-rw-r--r--src/client/linux/minidump_writer/cpu_set_unittest.cc5
-rw-r--r--src/client/linux/minidump_writer/directory_reader.h5
-rw-r--r--src/client/linux/minidump_writer/directory_reader_unittest.cc7
-rw-r--r--src/client/linux/minidump_writer/line_reader.h7
-rw-r--r--src/client/linux/minidump_writer/line_reader_unittest.cc19
-rw-r--r--src/client/linux/minidump_writer/linux_core_dumper.cc33
-rw-r--r--src/client/linux/minidump_writer/linux_core_dumper.h5
-rw-r--r--src/client/linux/minidump_writer/linux_core_dumper_unittest.cc5
-rw-r--r--src/client/linux/minidump_writer/linux_dumper.cc19
-rw-r--r--src/client/linux/minidump_writer/linux_dumper.h15
-rw-r--r--src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc15
-rw-r--r--src/client/linux/minidump_writer/linux_ptrace_dumper.cc10
-rw-r--r--src/client/linux/minidump_writer/linux_ptrace_dumper.h5
-rw-r--r--src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc14
-rw-r--r--src/client/linux/minidump_writer/minidump_writer.cc185
-rw-r--r--src/client/linux/minidump_writer/minidump_writer.h5
-rw-r--r--src/client/linux/minidump_writer/minidump_writer_unittest.cc24
-rw-r--r--src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc7
-rw-r--r--src/client/linux/minidump_writer/minidump_writer_unittest_utils.h5
-rw-r--r--src/client/linux/minidump_writer/pe_file.cc147
-rw-r--r--src/client/linux/minidump_writer/pe_file.h76
-rw-r--r--src/client/linux/minidump_writer/pe_structs.h225
-rw-r--r--src/client/linux/minidump_writer/proc_cpuinfo_reader.h5
-rw-r--r--src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc11
25 files changed, 713 insertions, 146 deletions
diff --git a/src/client/linux/minidump_writer/cpu_set.h b/src/client/linux/minidump_writer/cpu_set.h
index 1cca9aa5..70c1c758 100644
--- a/src/client/linux/minidump_writer/cpu_set.h
+++ b/src/client/linux/minidump_writer/cpu_set.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2013, Google Inc.
-// All rights reserved.
+// Copyright 2013 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/cpu_set_unittest.cc b/src/client/linux/minidump_writer/cpu_set_unittest.cc
index e2274bd1..1db74410 100644
--- a/src/client/linux/minidump_writer/cpu_set_unittest.cc
+++ b/src/client/linux/minidump_writer/cpu_set_unittest.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2013, Google Inc.
-// All rights reserved.
+// Copyright 2013 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/directory_reader.h b/src/client/linux/minidump_writer/directory_reader.h
index a4bde180..62bba877 100644
--- a/src/client/linux/minidump_writer/directory_reader.h
+++ b/src/client/linux/minidump_writer/directory_reader.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
+// Copyright 2009 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/directory_reader_unittest.cc b/src/client/linux/minidump_writer/directory_reader_unittest.cc
index 326f9e36..ffc5fbfd 100644
--- a/src/client/linux/minidump_writer/directory_reader_unittest.cc
+++ b/src/client/linux/minidump_writer/directory_reader_unittest.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
+// Copyright 2009 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -47,7 +46,7 @@ typedef testing::Test DirectoryReaderTest;
TEST(DirectoryReaderTest, CompareResults) {
std::set<string> dent_set;
- DIR *const dir = opendir("/proc/self");
+ DIR* const dir = opendir("/proc/self");
ASSERT_TRUE(dir != NULL);
struct dirent* dent;
diff --git a/src/client/linux/minidump_writer/line_reader.h b/src/client/linux/minidump_writer/line_reader.h
index 779cfeb6..d54a67d0 100644
--- a/src/client/linux/minidump_writer/line_reader.h
+++ b/src/client/linux/minidump_writer/line_reader.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
+// Copyright 2009 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -61,7 +60,7 @@ class LineReader {
//
// One must call |PopLine| after this function, otherwise you'll continue to
// get the same line over and over.
- bool GetNextLine(const char **line, unsigned *len) {
+ bool GetNextLine(const char** line, unsigned* len) {
for (;;) {
if (buf_used_ == 0 && hit_eof_)
return false;
diff --git a/src/client/linux/minidump_writer/line_reader_unittest.cc b/src/client/linux/minidump_writer/line_reader_unittest.cc
index 29686f04..3062c39f 100644
--- a/src/client/linux/minidump_writer/line_reader_unittest.cc
+++ b/src/client/linux/minidump_writer/line_reader_unittest.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
+// Copyright 2009 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -59,7 +58,7 @@ TEST(LineReaderTest, EmptyFile) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
- const char *line;
+ const char* line;
unsigned len;
ASSERT_FALSE(reader.GetNextLine(&line, &len));
}
@@ -69,7 +68,7 @@ TEST(LineReaderTest, OneLineTerminated) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
- const char *line;
+ const char* line;
unsigned int len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned int)1, len);
@@ -85,7 +84,7 @@ TEST(LineReaderTest, OneLine) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
- const char *line;
+ const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned)1, len);
@@ -101,7 +100,7 @@ TEST(LineReaderTest, TwoLinesTerminated) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
- const char *line;
+ const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned)1, len);
@@ -123,7 +122,7 @@ TEST(LineReaderTest, TwoLines) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
- const char *line;
+ const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ((unsigned)1, len);
@@ -147,7 +146,7 @@ TEST(LineReaderTest, MaxLength) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
- const char *line;
+ const char* line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
ASSERT_EQ(sizeof(l), len);
@@ -163,7 +162,7 @@ TEST(LineReaderTest, TooLong) {
ASSERT_TRUE(file.IsOk());
LineReader reader(file.GetFd());
- const char *line;
+ const char* line;
unsigned len;
ASSERT_FALSE(reader.GetNextLine(&line, &len));
}
diff --git a/src/client/linux/minidump_writer/linux_core_dumper.cc b/src/client/linux/minidump_writer/linux_core_dumper.cc
index 41506898..2c507c1b 100644
--- a/src/client/linux/minidump_writer/linux_core_dumper.cc
+++ b/src/client/linux/minidump_writer/linux_core_dumper.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2012, Google Inc.
-// All rights reserved.
+// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -112,8 +111,11 @@ bool LinuxCoreDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) {
#elif defined(__mips__)
stack_pointer =
reinterpret_cast<uint8_t*>(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]);
+#elif defined(__riscv)
+ stack_pointer = reinterpret_cast<uint8_t*>(
+ info->mcontext.__gregs[MD_CONTEXT_RISCV_REG_SP]);
#else
-#error "This code hasn't been ported to your platform yet."
+# error "This code hasn't been ported to your platform yet."
#endif
info->stack_pointer = reinterpret_cast<uintptr_t>(stack_pointer);
return true;
@@ -137,6 +139,16 @@ bool LinuxCoreDumper::EnumerateThreads() {
return false;
}
+ char proc_mem_path[NAME_MAX];
+ if (BuildProcPath(proc_mem_path, pid_, "mem")) {
+ int fd = open(proc_mem_path, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ if (fd != -1) {
+ core_.SetProcMem(fd);
+ } else {
+ fprintf(stderr, "Cannot open %s (%s)\n", proc_mem_path, strerror(errno));
+ }
+ }
+
core_.SetContent(mapped_core_file_.content());
if (!core_.IsValid()) {
fprintf(stderr, "Invalid core dump file\n");
@@ -198,19 +210,22 @@ bool LinuxCoreDumper::EnumerateThreads() {
info.tgid = status->pr_pgrp;
info.ppid = status->pr_ppid;
#if defined(__mips__)
-#if defined(__ANDROID__)
+# if defined(__ANDROID__)
for (int i = EF_R0; i <= EF_R31; i++)
info.mcontext.gregs[i - EF_R0] = status->pr_reg[i];
-#else // __ANDROID__
+# else // __ANDROID__
for (int i = EF_REG0; i <= EF_REG31; i++)
info.mcontext.gregs[i - EF_REG0] = status->pr_reg[i];
-#endif // __ANDROID__
+# endif // __ANDROID__
info.mcontext.mdlo = status->pr_reg[EF_LO];
info.mcontext.mdhi = status->pr_reg[EF_HI];
info.mcontext.pc = status->pr_reg[EF_CP0_EPC];
-#else // __mips__
+#elif defined(__riscv)
+ memcpy(&info.mcontext.__gregs, status->pr_reg,
+ sizeof(info.mcontext.__gregs));
+#else // __riscv
memcpy(&info.regs, status->pr_reg, sizeof(info.regs));
-#endif // __mips__
+#endif
if (first_thread) {
crash_thread_ = pid;
crash_signal_ = status->pr_info.si_signo;
diff --git a/src/client/linux/minidump_writer/linux_core_dumper.h b/src/client/linux/minidump_writer/linux_core_dumper.h
index 8a7c924b..3fc71223 100644
--- a/src/client/linux/minidump_writer/linux_core_dumper.h
+++ b/src/client/linux/minidump_writer/linux_core_dumper.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2012, Google Inc.
-// All rights reserved.
+// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc b/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc
index 77448031..157e4f89 100644
--- a/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc
+++ b/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2012, Google Inc.
-// All rights reserved.
+// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc
index ef75260e..01b06fac 100644
--- a/src/client/linux/minidump_writer/linux_dumper.cc
+++ b/src/client/linux/minidump_writer/linux_dumper.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2010, Google Inc.
-// All rights reserved.
+// Copyright 2010 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -53,6 +52,8 @@
#include "google_breakpad/common/minidump_exception_linux.h"
#include "third_party/lss/linux_syscall_support.h"
+using google_breakpad::elf::FileID;
+
#if defined(__ANDROID__)
// Android packed relocations definitions are not yet available from the
@@ -135,7 +136,7 @@ const size_t kHpageMask = (~(kHpageSize - 1));
// next is backed by some file.
// curr and next are contiguous.
// offset(next) == sizeof(curr)
-void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) {
+void TryRecoverMappings(MappingInfo* curr, MappingInfo* next) {
// Merged segments are marked with size = 0.
if (curr->size == 0 || next->size == 0)
return;
@@ -167,8 +168,8 @@ void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) {
// next and prev are backed by the same file.
// prev, curr and next are contiguous.
// offset(next) == offset(prev) + sizeof(prev) + sizeof(curr)
-void TryRecoverMappings(MappingInfo *prev, MappingInfo *curr,
- MappingInfo *next) {
+void TryRecoverMappings(MappingInfo* prev, MappingInfo* curr,
+ MappingInfo* next) {
// Merged segments are marked with size = 0.
if (prev->size == 0 || curr->size == 0 || next->size == 0)
return;
@@ -551,11 +552,11 @@ bool LinuxDumper::EnumerateMappings() {
// 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]);
+ 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 = reinterpret_cast<void *>(auxv_[AT_ENTRY]);
+ const void* entry_point_loc = reinterpret_cast<void*>(auxv_[AT_ENTRY]);
const int fd = sys_open(maps_path, O_RDONLY, 0);
if (fd < 0)
@@ -943,7 +944,7 @@ bool LinuxDumper::HandleDeletedFileInMapping(char* path) const {
char exe_link[NAME_MAX];
if (!BuildProcPath(exe_link, pid_, "exe"))
return false;
- MappingInfo new_mapping = {};
+ MappingInfo new_mapping = {0};
if (!SafeReadLink(exe_link, new_mapping.name))
return false;
char new_path[PATH_MAX];
diff --git a/src/client/linux/minidump_writer/linux_dumper.h b/src/client/linux/minidump_writer/linux_dumper.h
index f4a75d90..2d5b2e52 100644
--- a/src/client/linux/minidump_writer/linux_dumper.h
+++ b/src/client/linux/minidump_writer/linux_dumper.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2010, Google Inc.
-// All rights reserved.
+// Copyright 2010 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -60,10 +59,12 @@ namespace google_breakpad {
// Typedef for our parsing of the auxv variables in /proc/pid/auxv.
#if defined(__i386) || defined(__ARM_EABI__) || \
- (defined(__mips__) && _MIPS_SIM == _ABIO32)
+ (defined(__mips__) && _MIPS_SIM == _ABIO32) || \
+ (defined(__riscv) && __riscv_xlen == 32)
typedef Elf32_auxv_t elf_aux_entry;
#elif defined(__x86_64) || defined(__aarch64__) || \
- (defined(__mips__) && _MIPS_SIM != _ABIO32)
+ (defined(__mips__) && _MIPS_SIM != _ABIO32) || \
+ (defined(__riscv) && __riscv_xlen == 64)
typedef Elf64_auxv_t elf_aux_entry;
#endif
@@ -110,8 +111,8 @@ class LinuxDumper {
}
// These are only valid after a call to |Init|.
- const wasteful_vector<pid_t> &threads() { return threads_; }
- const wasteful_vector<MappingInfo*> &mappings() { return mappings_; }
+ const wasteful_vector<pid_t>& threads() { return threads_; }
+ const wasteful_vector<MappingInfo*>& mappings() { return mappings_; }
const MappingInfo* FindMapping(const void* address) const;
// Find the mapping which the given memory address falls in. Unlike
// FindMapping, this method uses the unadjusted mapping address
diff --git a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc
index 3ad48e50..bc1e4fbe 100644
--- a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc
+++ b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2010, Google Inc.
-// All rights reserved.
+// Copyright 2010 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -51,12 +50,14 @@
#define TID_PTR_REGISTER "rcx"
#elif defined(__mips__)
#define TID_PTR_REGISTER "$1"
+#elif defined(__riscv)
+#define TID_PTR_REGISTER "x4"
#else
#error This test has not been ported to this platform.
#endif
-void *thread_function(void *data) {
- int pipefd = *static_cast<int *>(data);
+void* thread_function(void* data) {
+ int pipefd = *static_cast<int*>(data);
volatile pid_t* thread_id = new pid_t;
*thread_id = syscall(__NR_gettid);
// Signal parent that a thread has started.
@@ -65,13 +66,13 @@ void *thread_function(void *data) {
perror("ERROR: parent notification failed");
return NULL;
}
- register volatile pid_t *thread_id_ptr asm(TID_PTR_REGISTER) = thread_id;
+ register volatile pid_t* thread_id_ptr asm(TID_PTR_REGISTER) = thread_id;
while (true)
asm volatile ("" : : "r" (thread_id_ptr));
return NULL;
}
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
if (argc < 3) {
fprintf(stderr,
"usage: linux_dumper_unittest_helper <pipe fd> <# of threads>\n");
diff --git a/src/client/linux/minidump_writer/linux_ptrace_dumper.cc b/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
index e3ddb81a..718fab7c 100644
--- a/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
+++ b/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2012, Google Inc.
-// All rights reserved.
+// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -298,8 +297,11 @@ bool LinuxPtraceDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) {
#elif defined(__mips__)
stack_pointer =
reinterpret_cast<uint8_t*>(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]);
+#elif defined(__riscv)
+ stack_pointer = reinterpret_cast<uint8_t*>(
+ info->mcontext.__gregs[MD_CONTEXT_RISCV_REG_SP]);
#else
-#error "This code hasn't been ported to your platform yet."
+# error "This code hasn't been ported to your platform yet."
#endif
info->stack_pointer = reinterpret_cast<uintptr_t>(stack_pointer);
diff --git a/src/client/linux/minidump_writer/linux_ptrace_dumper.h b/src/client/linux/minidump_writer/linux_ptrace_dumper.h
index cee58178..7828934f 100644
--- a/src/client/linux/minidump_writer/linux_ptrace_dumper.h
+++ b/src/client/linux/minidump_writer/linux_ptrace_dumper.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2012, Google Inc.
-// All rights reserved.
+// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc
index ea6b9a12..a8455165 100644
--- a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc
+++ b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
+// Copyright 2009 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -63,6 +62,8 @@
#endif
using namespace google_breakpad;
+using google_breakpad::elf::FileID;
+using google_breakpad::elf::kDefaultBuildIdSize;
namespace {
@@ -337,7 +338,7 @@ TEST_F(LinuxPtraceDumperChildTest, MappingsIncludeLinuxGate) {
ASSERT_TRUE(dumper.Init());
void* linux_gate_loc =
- reinterpret_cast<void *>(dumper.auxv()[AT_SYSINFO_EHDR]);
+ reinterpret_cast<void*>(dumper.auxv()[AT_SYSINFO_EHDR]);
ASSERT_TRUE(linux_gate_loc);
bool found_linux_gate = false;
@@ -462,6 +463,9 @@ TEST(LinuxPtraceDumperTest, VerifyStackReadWithMultipleThreads) {
#elif defined(__mips__)
pid_t* process_tid_location =
reinterpret_cast<pid_t*>(one_thread.mcontext.gregs[1]);
+#elif defined(__riscv)
+ pid_t* process_tid_location =
+ reinterpret_cast<pid_t*>(one_thread.mcontext.__gregs[4]);
#else
#error This test has not been ported to this platform.
#endif
@@ -559,6 +563,8 @@ TEST_F(LinuxPtraceDumperTest, SanitizeStackCopy) {
uintptr_t heap_addr = thread_info.regs.rcx;
#elif defined(__mips__)
uintptr_t heap_addr = thread_info.mcontext.gregs[1];
+#elif defined(__riscv)
+ uintptr_t heap_addr = thread_info.mcontext.__gregs[4];
#else
#error This test has not been ported to this platform.
#endif
diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc
index f8cdf2a1..a5f9b841 100644
--- a/src/client/linux/minidump_writer/minidump_writer.cc
+++ b/src/client/linux/minidump_writer/minidump_writer.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2010, Google Inc.
-// All rights reserved.
+// Copyright 2010 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -71,6 +70,8 @@
#include "client/linux/minidump_writer/line_reader.h"
#include "client/linux/minidump_writer/linux_dumper.h"
#include "client/linux/minidump_writer/linux_ptrace_dumper.h"
+#include "client/linux/minidump_writer/pe_file.h"
+#include "client/linux/minidump_writer/pe_structs.h"
#include "client/linux/minidump_writer/proc_cpuinfo_reader.h"
#include "client/minidump_file_writer.h"
#include "common/linux/file_id.h"
@@ -83,9 +84,9 @@ namespace {
using google_breakpad::AppMemoryList;
using google_breakpad::auto_wasteful_vector;
+using google_breakpad::elf::kDefaultBuildIdSize;
using google_breakpad::ExceptionHandler;
using google_breakpad::CpuSet;
-using google_breakpad::kDefaultBuildIdSize;
using google_breakpad::LineReader;
using google_breakpad::LinuxDumper;
using google_breakpad::LinuxPtraceDumper;
@@ -95,8 +96,11 @@ using google_breakpad::MappingInfo;
using google_breakpad::MappingList;
using google_breakpad::MinidumpFileWriter;
using google_breakpad::PageAllocator;
+using google_breakpad::PEFile;
+using google_breakpad::PEFileFormat;
using google_breakpad::ProcCpuInfoReader;
using google_breakpad::RawContextCPU;
+using google_breakpad::RSDS_DEBUG_FORMAT;
using google_breakpad::ThreadInfo;
using google_breakpad::TypedMDRVA;
using google_breakpad::UContextReader;
@@ -136,7 +140,7 @@ class MinidumpWriter {
: fd_(minidump_fd),
path_(minidump_path),
ucontext_(context ? &context->context : NULL),
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
float_state_(context ? &context->float_state : NULL),
#endif
dumper_(dumper),
@@ -468,7 +472,7 @@ class MinidumpWriter {
if (!cpu.Allocate())
return false;
my_memset(cpu.get(), 0, sizeof(RawContextCPU));
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_);
#else
UContextReader::FillCPUContext(cpu.get(), ucontext_);
@@ -632,40 +636,88 @@ class MinidumpWriter {
mod->base_of_image = mapping.start_addr;
mod->size_of_image = mapping.size;
- auto_wasteful_vector<uint8_t, kDefaultBuildIdSize> identifier_bytes(
- dumper_->allocator());
+ char file_name[NAME_MAX];
+ char file_path[NAME_MAX];
- if (identifier) {
- // GUID was provided by caller.
- identifier_bytes.insert(identifier_bytes.end(),
- identifier,
- identifier + sizeof(MDGUID));
- } else {
- // Note: ElfFileIdentifierForMapping() can manipulate the |mapping.name|.
- dumper_->ElfFileIdentifierForMapping(mapping,
- member,
- mapping_id,
- identifier_bytes);
- }
+ dumper_->GetMappingEffectiveNameAndPath(mapping, file_path,
+ sizeof(file_path), file_name,
+ sizeof(file_name));
- if (!identifier_bytes.empty()) {
- UntypedMDRVA cv(&minidump_writer_);
- if (!cv.Allocate(MDCVInfoELF_minsize + identifier_bytes.size()))
- return false;
+ RSDS_DEBUG_FORMAT rsds;
+ PEFileFormat file_format = PEFile::TryGetDebugInfo(file_path, &rsds);
+
+ if (file_format == PEFileFormat::notPeCoff) {
+ // The module is not a PE/COFF file, process as an ELF.
+ auto_wasteful_vector<uint8_t, kDefaultBuildIdSize> identifier_bytes(
+ dumper_->allocator());
- const uint32_t cv_signature = MD_CVINFOELF_SIGNATURE;
- cv.Copy(&cv_signature, sizeof(cv_signature));
- cv.Copy(cv.position() + sizeof(cv_signature), &identifier_bytes[0],
- identifier_bytes.size());
+ if (identifier) {
+ // GUID was provided by caller.
+ identifier_bytes.insert(identifier_bytes.end(), identifier,
+ identifier + sizeof(MDGUID));
+ } else {
+ // Note: ElfFileIdentifierForMapping() can manipulate the
+ // |mapping.name|, that is why we need to call the method
+ // GetMappingEffectiveNameAndPath again.
+ dumper_->ElfFileIdentifierForMapping(mapping, member, mapping_id,
+ identifier_bytes);
+ dumper_->GetMappingEffectiveNameAndPath(mapping, file_path,
+ sizeof(file_path), file_name,
+ sizeof(file_name));
+ }
+
+ if (!identifier_bytes.empty()) {
+ UntypedMDRVA cv(&minidump_writer_);
+ if (!cv.Allocate(MDCVInfoELF_minsize + identifier_bytes.size()))
+ return false;
+
+ const uint32_t cv_signature = MD_CVINFOELF_SIGNATURE;
+ cv.Copy(&cv_signature, sizeof(cv_signature));
+ cv.Copy(cv.position() + sizeof(cv_signature), &identifier_bytes[0],
+ identifier_bytes.size());
+
+ mod->cv_record = cv.location();
+ }
+ } else {
+ // The module is a PE/COFF file. Create MDCVInfoPDB70 struct for it.
+ size_t file_name_length = strlen(file_name);
+ TypedMDRVA<MDCVInfoPDB70> cv(&minidump_writer_);
+ if (!cv.AllocateObjectAndArray(file_name_length + 1, sizeof(uint8_t)))
+ return false;
+ if (!cv.CopyIndexAfterObject(0, file_name, file_name_length))
+ return false;
+ MDCVInfoPDB70* cv_ptr = cv.get();
+ cv_ptr->cv_signature = MD_CVINFOPDB70_SIGNATURE;
+ if (file_format == PEFileFormat::peWithBuildId) {
+ // Populate BuildId and age using RSDS instance.
+ cv_ptr->signature.data1 = static_cast<uint32_t>(rsds.guid[0]) << 24 |
+ static_cast<uint32_t>(rsds.guid[1]) << 16 |
+ static_cast<uint32_t>(rsds.guid[2]) << 8 |
+ static_cast<uint32_t>(rsds.guid[3]);
+ cv_ptr->signature.data2 =
+ static_cast<uint16_t>(rsds.guid[4]) << 8 | rsds.guid[5];
+ cv_ptr->signature.data3 =
+ static_cast<uint16_t>(rsds.guid[6]) << 8 | rsds.guid[7];
+ cv_ptr->signature.data4[0] = rsds.guid[8];
+ cv_ptr->signature.data4[1] = rsds.guid[9];
+ cv_ptr->signature.data4[2] = rsds.guid[10];
+ cv_ptr->signature.data4[3] = rsds.guid[11];
+ cv_ptr->signature.data4[4] = rsds.guid[12];
+ cv_ptr->signature.data4[5] = rsds.guid[13];
+ cv_ptr->signature.data4[6] = rsds.guid[14];
+ cv_ptr->signature.data4[7] = rsds.guid[15];
+ // The Age field should be reverted as well.
+ cv_ptr->age = static_cast<uint32_t>(rsds.age[0]) << 24 |
+ static_cast<uint32_t>(rsds.age[1]) << 16 |
+ static_cast<uint32_t>(rsds.age[2]) << 8 |
+ static_cast<uint32_t>(rsds.age[3]);
+ } else {
+ cv_ptr->age = 0;
+ }
mod->cv_record = cv.location();
}
- char file_name[NAME_MAX];
- char file_path[NAME_MAX];
- dumper_->GetMappingEffectiveNameAndPath(
- mapping, file_path, sizeof(file_path), file_name, sizeof(file_name));
-
MDLocationDescriptor ld;
if (!minidump_writer_.WriteString(file_path, my_strlen(file_path), &ld))
return false;
@@ -740,14 +792,14 @@ class MinidumpWriter {
}
bool WriteDSODebugStream(MDRawDirectory* dirent) {
- ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr) *>(dumper_->auxv()[AT_PHDR]);
+ ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(dumper_->auxv()[AT_PHDR]);
char* base;
int phnum = dumper_->auxv()[AT_PHNUM];
if (!phnum || !phdr)
return false;
// Assume the program base is at the beginning of the same page as the PHDR
- base = reinterpret_cast<char *>(reinterpret_cast<uintptr_t>(phdr) & ~0xfff);
+ base = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(phdr) & ~0xfff);
// Search for the program PT_DYNAMIC segment
ElfW(Addr) dyn_addr = 0;
@@ -768,7 +820,7 @@ class MinidumpWriter {
if (!dyn_addr)
return false;
- ElfW(Dyn) *dynamic = reinterpret_cast<ElfW(Dyn) *>(dyn_addr + base);
+ ElfW(Dyn)* dynamic = reinterpret_cast<ElfW(Dyn)*>(dyn_addr + base);
// The dynamic linker makes information available that helps gdb find all
// DSOs loaded into the program. If this information is indeed available,
@@ -1085,9 +1137,7 @@ class MinidumpWriter {
sys_close(fd);
cpus_present.IntersectWith(cpus_possible);
- int cpu_count = cpus_present.GetCount();
- if (cpu_count > 255)
- cpu_count = 255;
+ int cpu_count = std::min(255, cpus_present.GetCount());
sys_info->number_of_processors = static_cast<uint8_t>(cpu_count);
}
}
@@ -1205,6 +1255,59 @@ class MinidumpWriter {
return true;
}
+#elif defined(__riscv)
+ bool WriteCPUInformation(MDRawSystemInfo* sys_info) {
+ // processor_architecture should always be set, do this first
+# if __riscv_xlen == 32
+ sys_info->processor_architecture = MD_CPU_ARCHITECTURE_RISCV;
+# elif __riscv_xlen == 64
+ sys_info->processor_architecture = MD_CPU_ARCHITECTURE_RISCV64;
+# else
+# error "Unexpected __riscv_xlen"
+# endif
+
+ // /proc/cpuinfo is not readable under various sandboxed environments
+ // (e.g. Android services with the android:isolatedProcess attribute)
+ // prepare for this by setting default values now, which will be
+ // returned when this happens.
+ //
+ // Note: Bogus values are used to distinguish between failures (to
+ // read /sys and /proc files) and really badly configured kernels.
+ sys_info->number_of_processors = 0;
+ sys_info->processor_level = 0U;
+ sys_info->processor_revision = 42;
+ sys_info->cpu.other_cpu_info.processor_features[0] = 0;
+ sys_info->cpu.other_cpu_info.processor_features[1] = 0;
+
+ // Counting the number of CPUs involves parsing two sysfs files,
+ // because the content of /proc/cpuinfo will only mirror the number
+ // of 'online' cores, and thus will vary with time.
+ // See http://www.kernel.org/doc/Documentation/cputopology.txt
+ {
+ CpuSet cpus_present;
+ CpuSet cpus_possible;
+
+ int fd = sys_open("/sys/devices/system/cpu/present",
+ O_RDONLY | O_CLOEXEC, 0);
+ if (fd >= 0) {
+ cpus_present.ParseSysFile(fd);
+ sys_close(fd);
+
+ fd = sys_open("/sys/devices/system/cpu/possible",
+ O_RDONLY | O_CLOEXEC, 0);
+ if (fd >= 0) {
+ cpus_possible.ParseSysFile(fd);
+ sys_close(fd);
+
+ cpus_present.IntersectWith(cpus_possible);
+ int cpu_count = std::min(255, cpus_present.GetCount());
+ sys_info->number_of_processors = static_cast<uint8_t>(cpu_count);
+ }
+ }
+ }
+
+ return true;
+ }
#else
# error "Unsupported CPU"
#endif
@@ -1222,7 +1325,7 @@ class MinidumpWriter {
Buffers* next;
size_t len;
uint8_t data[kBufSize];
- } *buffers = reinterpret_cast<Buffers*>(Alloc(sizeof(Buffers)));
+ }* buffers = reinterpret_cast<Buffers*>(Alloc(sizeof(Buffers)));
buffers->next = NULL;
buffers->len = 0;
@@ -1333,7 +1436,7 @@ class MinidumpWriter {
const char* path_; // Path to the file where the minidum should be written.
const ucontext_t* const ucontext_; // also from the signal handler
-#if !defined(__ARM_EABI__) && !defined(__mips__)
+#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
const google_breakpad::fpstate_t* const float_state_; // ditto
#endif
LinuxDumper* dumper_;
diff --git a/src/client/linux/minidump_writer/minidump_writer.h b/src/client/linux/minidump_writer/minidump_writer.h
index e3b0b16d..24e3c7bd 100644
--- a/src/client/linux/minidump_writer/minidump_writer.h
+++ b/src/client/linux/minidump_writer/minidump_writer.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
+// Copyright 2009 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest.cc b/src/client/linux/minidump_writer/minidump_writer_unittest.cc
index 3017a49a..2601d29b 100644
--- a/src/client/linux/minidump_writer/minidump_writer_unittest.cc
+++ b/src/client/linux/minidump_writer/minidump_writer_unittest.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2011 Google Inc.
-// All rights reserved.
+// Copyright 2011 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -54,6 +53,8 @@
#include "google_breakpad/processor/minidump.h"
using namespace google_breakpad;
+using google_breakpad::elf::FileID;
+using google_breakpad::elf::kDefaultBuildIdSize;
namespace {
@@ -299,10 +300,10 @@ TEST(MinidumpWriterTest, MinidumpStacksSkippedIfRequested) {
Minidump minidump(templ);
ASSERT_TRUE(minidump.Read());
- MinidumpThreadList *threads = minidump.GetThreadList();
+ MinidumpThreadList* threads = minidump.GetThreadList();
int threads_with_stacks = 0;
for (unsigned int i = 0; i < threads->thread_count(); ++i) {
- MinidumpThread *thread = threads->GetThreadAtIndex(i);
+ MinidumpThread* thread = threads->GetThreadAtIndex(i);
if (thread->GetMemory()) {
++threads_with_stacks;
}
@@ -353,13 +354,13 @@ TEST(MinidumpWriterTest, StacksAreSanitizedIfRequested) {
#else
0x0defaced;
#endif
- MinidumpThreadList *threads = minidump.GetThreadList();
+ MinidumpThreadList* threads = minidump.GetThreadList();
for (unsigned int i = 0; i < threads->thread_count(); ++i) {
- MinidumpThread *thread = threads->GetThreadAtIndex(i);
- MinidumpMemoryRegion *mem = thread->GetMemory();
+ MinidumpThread* thread = threads->GetThreadAtIndex(i);
+ MinidumpMemoryRegion* mem = thread->GetMemory();
ASSERT_TRUE(mem != nullptr);
uint32_t sz = mem->GetSize();
- const uint8_t *data = mem->GetMemory();
+ const uint8_t* data = mem->GetMemory();
ASSERT_TRUE(memmem(data, sz, &defaced, sizeof(defaced)) != nullptr);
}
close(fds[1]);
@@ -521,7 +522,7 @@ TEST(MinidumpWriterTest, DeletedBinary) {
// Copy binary to a temp file.
AutoTempDir temp_dir;
string binpath = temp_dir.path() + "/linux-dumper-unittest-helper";
- ASSERT_TRUE(CopyFile(helper_path.c_str(), binpath.c_str()))
+ ASSERT_TRUE(CopyFile(helper_path, binpath))
<< "Failed to copy " << helper_path << " to " << binpath;
ASSERT_EQ(0, chmod(binpath.c_str(), 0755));
@@ -715,6 +716,9 @@ TEST(MinidumpWriterTest, InvalidStackPointer) {
#elif defined(__mips__)
context.context.uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP] =
invalid_stack_pointer;
+#elif defined(__riscv)
+ context.context.uc_mcontext.__gregs[MD_CONTEXT_RISCV_REG_SP] =
+ invalid_stack_pointer;
#else
# error "This code has not been ported to your platform yet."
#endif
diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc b/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc
index 9f46fa65..92cae92e 100644
--- a/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc
+++ b/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2011 Google Inc.
-// All rights reserved.
+// Copyright 2011 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -41,7 +40,7 @@ namespace google_breakpad {
string GetHelperBinary() {
string helper_path;
- char *bindir = getenv("bindir");
+ char* bindir = getenv("bindir");
if (bindir) {
helper_path = string(bindir) + "/";
} else {
diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest_utils.h b/src/client/linux/minidump_writer/minidump_writer_unittest_utils.h
index f16cc086..f93885ee 100644
--- a/src/client/linux/minidump_writer/minidump_writer_unittest_utils.h
+++ b/src/client/linux/minidump_writer/minidump_writer_unittest_utils.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2012, Google Inc.
-// All rights reserved.
+// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/pe_file.cc b/src/client/linux/minidump_writer/pe_file.cc
new file mode 100644
index 00000000..960b978b
--- /dev/null
+++ b/src/client/linux/minidump_writer/pe_file.cc
@@ -0,0 +1,147 @@
+// Copyright 2022 Google LLC
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google LLC nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <string.h>
+
+#include "client/linux/minidump_writer/pe_file.h"
+#include "client/linux/minidump_writer/pe_structs.h"
+#include "common/linux/memory_mapped_file.h"
+
+namespace google_breakpad {
+
+PEFileFormat PEFile::TryGetDebugInfo(const char* filename,
+ PRSDS_DEBUG_FORMAT debug_info) {
+ MemoryMappedFile mapped_file(filename, 0);
+ if (!mapped_file.data())
+ return PEFileFormat::notPeCoff;
+ const void* base = mapped_file.data();
+ const size_t file_size = mapped_file.size();
+
+ const IMAGE_DOS_HEADER* header =
+ TryReadStruct<IMAGE_DOS_HEADER>(base, 0, file_size);
+ if (!header || (header->e_magic != IMAGE_DOS_SIGNATURE)) {
+ return PEFileFormat::notPeCoff;
+ }
+
+ // NTHeader is at position 'e_lfanew'.
+ DWORD nt_header_offset = header->e_lfanew;
+ // First, read a common IMAGE_NT_HEADERS structure. It should contain a
+ // special flag marking whether PE module is x64 (OptionalHeader.Magic)
+ // and so-called NT_SIGNATURE in Signature field.
+ const IMAGE_NT_HEADERS* nt_header =
+ TryReadStruct<IMAGE_NT_HEADERS>(base, nt_header_offset, file_size);
+ if (!nt_header || (nt_header->Signature != IMAGE_NT_SIGNATURE)
+ || ((nt_header->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC)
+ && (nt_header->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC)))
+ return PEFileFormat::notPeCoff;
+
+ bool x64 = nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ WORD sections_number = nt_header->FileHeader.NumberOfSections;
+ DWORD debug_offset;
+ DWORD debug_size;
+ DWORD section_offset;
+ if (x64) {
+ const IMAGE_NT_HEADERS64* header_64 =
+ TryReadStruct<IMAGE_NT_HEADERS64>(base, nt_header_offset, file_size);
+ if (!header_64)
+ return PEFileFormat::peWithoutBuildId;
+ debug_offset =
+ header_64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]
+ .VirtualAddress;
+ debug_size =
+ header_64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]
+ .Size;
+ section_offset = nt_header_offset + sizeof(IMAGE_NT_HEADERS64);
+ } else {
+ const IMAGE_NT_HEADERS32* header_32 =
+ TryReadStruct<IMAGE_NT_HEADERS32>(base, nt_header_offset, file_size);
+ if (!header_32)
+ return PEFileFormat::peWithoutBuildId;
+ debug_offset =
+ header_32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]
+ .VirtualAddress;
+ debug_size =
+ header_32->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]
+ .Size;
+ section_offset = nt_header_offset + sizeof(IMAGE_NT_HEADERS32);
+ }
+
+ DWORD debug_end_pos = debug_offset + debug_size;
+ while (debug_offset < debug_end_pos) {
+ for (WORD i = 0; i < sections_number; ++i) {
+ // Section headers are placed sequentially after the NT_HEADER (32/64).
+ const IMAGE_SECTION_HEADER* section =
+ TryReadStruct<IMAGE_SECTION_HEADER>(base, section_offset, file_size);
+ if (!section)
+ return PEFileFormat::peWithoutBuildId;
+
+ section_offset += sizeof(IMAGE_SECTION_HEADER);
+
+ // Current `debug_offset` should be inside a section, stop if we find
+ // a suitable one (we don't consider any malformed sections here).
+ if ((section->VirtualAddress <= debug_offset) &&
+ (debug_offset < section->VirtualAddress + section->SizeOfRawData)) {
+ DWORD offset =
+ section->PointerToRawData + debug_offset - section->VirtualAddress;
+ // Go to the position of current ImageDebugDirectory (offset).
+ const IMAGE_DEBUG_DIRECTORY* debug_directory =
+ TryReadStruct<IMAGE_DEBUG_DIRECTORY>(base, offset, file_size);
+ if (!debug_directory)
+ return PEFileFormat::peWithoutBuildId;
+ // Process ImageDebugDirectory with CodeViewRecord type and skip
+ // all others.
+ if (debug_directory->Type == IMAGE_DEBUG_TYPE_CODEVIEW) {
+ DWORD debug_directory_size = debug_directory->SizeOfData;
+ if (debug_directory_size < sizeof(RSDS_DEBUG_FORMAT))
+ // RSDS section is malformed.
+ return PEFileFormat::peWithoutBuildId;
+ // Go to the position of current ImageDebugDirectory Raw Data
+ // (debug_directory->PointerToRawData) and read the RSDS section.
+ const RSDS_DEBUG_FORMAT* rsds =
+ TryReadStruct<RSDS_DEBUG_FORMAT>(
+ base, debug_directory->PointerToRawData, file_size);
+
+ if (!rsds)
+ return PEFileFormat::peWithoutBuildId;
+
+ memcpy(debug_info->guid, rsds->guid, sizeof(rsds->guid));
+ memcpy(debug_info->age, rsds->age, sizeof(rsds->age));
+ return PEFileFormat::peWithBuildId;
+ }
+
+ break;
+ }
+ }
+
+ debug_offset += sizeof(IMAGE_DEBUG_DIRECTORY);
+ }
+
+ return PEFileFormat::peWithoutBuildId;
+}
+
+} // namespace google_breakpad \ No newline at end of file
diff --git a/src/client/linux/minidump_writer/pe_file.h b/src/client/linux/minidump_writer/pe_file.h
new file mode 100644
index 00000000..97984ab5
--- /dev/null
+++ b/src/client/linux/minidump_writer/pe_file.h
@@ -0,0 +1,76 @@
+// Copyright 2022 Google LLC
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google LLC nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef CLIENT_LINUX_MINIDUMP_WRITER_PE_FILE_H_
+#define CLIENT_LINUX_MINIDUMP_WRITER_PE_FILE_H_
+
+#include "client/linux/minidump_writer/pe_structs.h"
+
+namespace google_breakpad {
+
+typedef enum {
+ notPeCoff = 0,
+ peWithoutBuildId = 1,
+ peWithBuildId = 2
+} PEFileFormat;
+
+class PEFile {
+ public:
+ /**
+ * Attempts to parse RSDS_DEBUG_FORMAT record from a PE (Portable
+ * Executable) file. To do this we check whether the loaded file is a PE
+ * file, and if it is - try to find IMAGE_DEBUG_DIRECTORY structure with
+ * its type set to IMAGE_DEBUG_TYPE_CODEVIEW.
+ *
+ * @param filename Filename for the module to parse.
+ * @param debug_info RSDS_DEBUG_FORMAT struct to be populated with PE debug
+ * info (GUID and age).
+ * @return
+ * notPeCoff: not PE/COFF file;
+ * peWithoutBuildId: a PE/COFF file but build-id is not set;
+ * peWithBuildId: a PE/COFF file and build-id is set.
+ */
+ static PEFileFormat TryGetDebugInfo(const char* filename,
+ PRSDS_DEBUG_FORMAT debug_info);
+
+ private:
+ template <class TStruct>
+ static const TStruct* TryReadStruct(const void* base,
+ const DWORD position,
+ const size_t file_size) {
+ if (position + sizeof(TStruct) >= file_size){
+ return nullptr;
+ }
+
+ const void* ptr = static_cast<const char*>(base) + position;
+ return reinterpret_cast<const TStruct*>(ptr);
+ }
+};
+
+} // namespace google_breakpad
+#endif // CLIENT_LINUX_MINIDUMP_WRITER_PE_FILE_H_ \ No newline at end of file
diff --git a/src/client/linux/minidump_writer/pe_structs.h b/src/client/linux/minidump_writer/pe_structs.h
new file mode 100644
index 00000000..122cc295
--- /dev/null
+++ b/src/client/linux/minidump_writer/pe_structs.h
@@ -0,0 +1,225 @@
+// Copyright 2022 Google LLC
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google LLC nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef CLIENT_LINUX_MINIDUMP_WRITER_PE_STRUCTS_H_
+#define CLIENT_LINUX_MINIDUMP_WRITER_PE_STRUCTS_H_
+
+#include <cstdint>
+
+namespace google_breakpad {
+
+typedef uint8_t BYTE;
+typedef uint16_t WORD;
+typedef uint32_t DWORD;
+typedef uint64_t ULONGLONG;
+
+#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
+#define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
+
+#define IMAGE_DEBUG_TYPE_CODEVIEW 2
+
+#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
+#define IMAGE_NT_SIGNATURE 0x00004550 // PE00
+
+#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
+#define IMAGE_DIRECTORY_ENTRY_DEBUG 6
+
+typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header
+ WORD e_magic; // Magic number
+ WORD e_cblp; // Bytes on last page of file
+ WORD e_cp; // Pages in file
+ WORD e_crlc; // Relocations
+ WORD e_cparhdr; // Size of header in paragraphs
+ WORD e_minalloc; // Minimum extra paragraphs needed
+ WORD e_maxalloc; // Maximum extra paragraphs needed
+ WORD e_ss; // Initial (relative) SS value
+ WORD e_sp; // Initial SP value
+ WORD e_csum; // Checksum
+ WORD e_ip; // Initial IP value
+ WORD e_cs; // Initial (relative) CS value
+ WORD e_lfarlc; // File address of relocation table
+ WORD e_ovno; // Overlay number
+ WORD e_res[4]; // Reserved words
+ WORD e_oemid; // OEM identifier (for e_oeminfo)
+ WORD e_oeminfo; // OEM information; e_oemid specific
+ WORD e_res2[10]; // Reserved words
+ DWORD e_lfanew; // File address of new exe header
+} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
+
+typedef struct _IMAGE_FILE_HEADER {
+ WORD Machine;
+ WORD NumberOfSections;
+ DWORD TimeDateStamp;
+ DWORD PointerToSymbolTable;
+ DWORD NumberOfSymbols;
+ WORD SizeOfOptionalHeader;
+ WORD Characteristics;
+} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
+
+typedef struct _IMAGE_DATA_DIRECTORY {
+ DWORD VirtualAddress;
+ DWORD Size;
+} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
+
+
+typedef struct _IMAGE_DEBUG_DIRECTORY {
+ DWORD Characteristics;
+ DWORD TimeDateStamp;
+ WORD MajorVersion;
+ WORD MinorVersion;
+ DWORD Type;
+ DWORD SizeOfData;
+ DWORD AddressOfRawData;
+ DWORD PointerToRawData;
+} IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
+
+typedef struct _IMAGE_OPTIONAL_HEADER64 {
+ //
+ // Standard fields - Magic.
+ //
+ WORD Magic;
+ BYTE MajorLinkerVersion;
+ BYTE MinorLinkerVersion;
+ DWORD SizeOfCode;
+ DWORD SizeOfInitializedData;
+ DWORD SizeOfUninitializedData;
+ DWORD AddressOfEntryPoint;
+ DWORD BaseOfCode;
+ //
+ // NT additional fields.
+ //
+ ULONGLONG ImageBase;
+ DWORD SectionAlignment;
+ DWORD FileAlignment;
+ WORD MajorOperatingSystemVersion;
+ WORD MinorOperatingSystemVersion;
+ WORD MajorImageVersion;
+ WORD MinorImageVersion;
+ WORD MajorSubsystemVersion;
+ WORD MinorSubsystemVersion;
+ DWORD Win32VersionValue;
+ DWORD SizeOfImage;
+ DWORD SizeOfHeaders;
+ DWORD CheckSum;
+ WORD Subsystem;
+ WORD DllCharacteristics;
+ ULONGLONG SizeOfStackReserve;
+ ULONGLONG SizeOfStackCommit;
+ ULONGLONG SizeOfHeapReserve;
+ ULONGLONG SizeOfHeapCommit;
+ DWORD LoaderFlags;
+ DWORD NumberOfRvaAndSizes;
+ IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
+} IMAGE_OPTIONAL_HEADER64, *PIMAGE_OPTIONAL_HEADER64;
+
+typedef struct _IMAGE_OPTIONAL_HEADER {
+ //
+ // Standard fields.
+ //
+ WORD Magic;
+ BYTE MajorLinkerVersion;
+ BYTE MinorLinkerVersion;
+ DWORD SizeOfCode;
+ DWORD SizeOfInitializedData;
+ DWORD SizeOfUninitializedData;
+ DWORD AddressOfEntryPoint;
+ DWORD BaseOfCode;
+ DWORD BaseOfData;
+ //
+ // NT additional fields.
+ //
+ DWORD ImageBase;
+ DWORD SectionAlignment;
+ DWORD FileAlignment;
+ WORD MajorOperatingSystemVersion;
+ WORD MinorOperatingSystemVersion;
+ WORD MajorImageVersion;
+ WORD MinorImageVersion;
+ WORD MajorSubsystemVersion;
+ WORD MinorSubsystemVersion;
+ DWORD Win32VersionValue;
+ DWORD SizeOfImage;
+ DWORD SizeOfHeaders;
+ DWORD CheckSum;
+ WORD Subsystem;
+ WORD DllCharacteristics;
+ DWORD SizeOfStackReserve;
+ DWORD SizeOfStackCommit;
+ DWORD SizeOfHeapReserve;
+ DWORD SizeOfHeapCommit;
+ DWORD LoaderFlags;
+ DWORD NumberOfRvaAndSizes;
+ IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
+} IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
+
+typedef struct _IMAGE_NT_HEADERS64 {
+ DWORD Signature;
+ IMAGE_FILE_HEADER FileHeader;
+ IMAGE_OPTIONAL_HEADER64 OptionalHeader;
+} IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64;
+
+typedef struct _IMAGE_NT_HEADERS32 {
+ DWORD Signature;
+ IMAGE_FILE_HEADER FileHeader;
+ IMAGE_OPTIONAL_HEADER32 OptionalHeader;
+} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
+
+typedef struct _IMAGE_NT_HEADERS {
+ DWORD Signature;
+ IMAGE_FILE_HEADER FileHeader;
+ IMAGE_OPTIONAL_HEADER32 OptionalHeader;
+} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
+
+#define IMAGE_SIZEOF_SHORT_NAME 8
+
+typedef struct _IMAGE_SECTION_HEADER {
+ BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
+ union {
+ DWORD PhysicalAddress;
+ DWORD VirtualSize;
+ } Misc;
+ DWORD VirtualAddress;
+ DWORD SizeOfRawData;
+ DWORD PointerToRawData;
+ DWORD PointerToRelocations;
+ DWORD PointerToLinenumbers;
+ WORD NumberOfRelocations;
+ WORD NumberOfLinenumbers;
+ DWORD Characteristics;
+} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
+
+typedef struct _RSDS_DEBUG_FORMAT {
+ DWORD signature;
+ BYTE guid[16];
+ BYTE age[4];
+ char pdbpath[1];
+} RSDS_DEBUG_FORMAT, *PRSDS_DEBUG_FORMAT;
+
+} // namespace google_breakpad
+
+#endif // CLIENT_LINUX_MINIDUMP_WRITER_PE_STRUCTS_H_ \ No newline at end of file
diff --git a/src/client/linux/minidump_writer/proc_cpuinfo_reader.h b/src/client/linux/minidump_writer/proc_cpuinfo_reader.h
index d9461bf3..5ae16dfb 100644
--- a/src/client/linux/minidump_writer/proc_cpuinfo_reader.h
+++ b/src/client/linux/minidump_writer/proc_cpuinfo_reader.h
@@ -1,5 +1,4 @@
-// Copyright (c) 2013, Google Inc.
-// All rights reserved.
+// Copyright 2013 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc b/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc
index 6037c7e6..f6d3e285 100644
--- a/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc
+++ b/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2013, Google Inc.
-// All rights reserved.
+// Copyright 2013 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -65,7 +64,7 @@ TEST(ProcCpuInfoReaderTest, EmptyFile) {
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
- const char *field;
+ const char* field;
ASSERT_FALSE(reader.GetNextField(&field));
}
@@ -74,7 +73,7 @@ TEST(ProcCpuInfoReaderTest, OneLineTerminated) {
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
- const char *field;
+ const char* field;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);
ASSERT_STREQ("bar", reader.GetValue());
@@ -87,7 +86,7 @@ TEST(ProcCpuInfoReaderTest, OneLine) {
ASSERT_TRUE(file.IsOk());
ProcCpuInfoReader reader(file.GetFd());
- const char *field;
+ const char* field;
size_t value_len;
ASSERT_TRUE(reader.GetNextField(&field));
ASSERT_STREQ("foo", field);