Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: src/client/linux/minidump_writer/linux_dumper.h

Issue 1761023002: Add an optional root prefix to Linux dumpers (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Remove assertions Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010, Google Inc. 1 // Copyright (c) 2010, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 typedef __typeof__(((elf_aux_entry*) 0)->a_un.a_val) elf_aux_val_t; 66 typedef __typeof__(((elf_aux_entry*) 0)->a_un.a_val) elf_aux_val_t;
67 67
68 // When we find the VDSO mapping in the process's address space, this 68 // When we find the VDSO mapping in the process's address space, this
69 // is the name we use for it when writing it to the minidump. 69 // is the name we use for it when writing it to the minidump.
70 // This should always be less than NAME_MAX! 70 // This should always be less than NAME_MAX!
71 const char kLinuxGateLibraryName[] = "linux-gate.so"; 71 const char kLinuxGateLibraryName[] = "linux-gate.so";
72 72
73 class LinuxDumper { 73 class LinuxDumper {
74 public: 74 public:
75 explicit LinuxDumper(pid_t pid); 75 // The |root_prefix| is prepended to mapping paths before opening them, which
76 // is useful if the crash originates from a chroot.
77 explicit LinuxDumper(pid_t pid, const char* root_prefix = "");
76 78
77 virtual ~LinuxDumper(); 79 virtual ~LinuxDumper();
78 80
79 // Parse the data for |threads| and |mappings|. 81 // Parse the data for |threads| and |mappings|.
80 virtual bool Init(); 82 virtual bool Init();
81 83
82 // Take any actions that could not be taken in Init(). LateInit() is 84 // Take any actions that could not be taken in Init(). LateInit() is
83 // called after all other caller's initialization is complete, and in 85 // called after all other caller's initialization is complete, and in
84 // particular after it has called ThreadsSuspend(), so that ptrace is 86 // particular after it has called ThreadsSuspend(), so that ptrace is
85 // available. 87 // available.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void set_crash_address(uintptr_t crash_address) { 135 void set_crash_address(uintptr_t crash_address) {
134 crash_address_ = crash_address; 136 crash_address_ = crash_address;
135 } 137 }
136 138
137 int crash_signal() const { return crash_signal_; } 139 int crash_signal() const { return crash_signal_; }
138 void set_crash_signal(int crash_signal) { crash_signal_ = crash_signal; } 140 void set_crash_signal(int crash_signal) { crash_signal_ = crash_signal; }
139 141
140 pid_t crash_thread() const { return crash_thread_; } 142 pid_t crash_thread() const { return crash_thread_; }
141 void set_crash_thread(pid_t crash_thread) { crash_thread_ = crash_thread; } 143 void set_crash_thread(pid_t crash_thread) { crash_thread_ = crash_thread; }
142 144
145 // Concatenates the |root_prefix_| and |mapping| path. Writes into |path| and
146 // returns true unless the string is too long.
147 bool GetMappingAbsolutePath(const MappingInfo& mapping,
148 char path[PATH_MAX]) const;
149
143 // Extracts the effective path and file name of from |mapping|. In most cases 150 // Extracts the effective path and file name of from |mapping|. In most cases
144 // the effective name/path are just the mapping's path and basename. In some 151 // the effective name/path are just the mapping's path and basename. In some
145 // other cases, however, a library can be mapped from an archive (e.g., when 152 // other cases, however, a library can be mapped from an archive (e.g., when
146 // loading .so libs from an apk on Android) and this method is able to 153 // loading .so libs from an apk on Android) and this method is able to
147 // reconstruct the original file name. 154 // reconstruct the original file name.
148 static void GetMappingEffectiveNameAndPath(const MappingInfo& mapping, 155 void GetMappingEffectiveNameAndPath(const MappingInfo& mapping,
149 char* file_path, 156 char* file_path,
150 size_t file_path_size, 157 size_t file_path_size,
151 char* file_name, 158 char* file_name,
152 size_t file_name_size); 159 size_t file_name_size);
153 160
154 protected: 161 protected:
155 bool ReadAuxv(); 162 bool ReadAuxv();
156 163
157 virtual bool EnumerateMappings(); 164 virtual bool EnumerateMappings();
158 165
159 virtual bool EnumerateThreads() = 0; 166 virtual bool EnumerateThreads() = 0;
160 167
161 // For the case where a running program has been deleted, it'll show up in 168 // For the case where a running program has been deleted, it'll show up in
162 // /proc/pid/maps as "/path/to/program (deleted)". If this is the case, then 169 // /proc/pid/maps as "/path/to/program (deleted)". If this is the case, then
163 // see if '/path/to/program (deleted)' matches /proc/pid/exe and return 170 // see if '/path/to/program (deleted)' matches /proc/pid/exe and return
164 // /proc/pid/exe in |path| so ELF identifier generation works correctly. This 171 // /proc/pid/exe in |path| so ELF identifier generation works correctly. This
165 // also checks to see if '/path/to/program (deleted)' exists, so it does not 172 // also checks to see if '/path/to/program (deleted)' exists, so it does not
166 // get fooled by a poorly named binary. 173 // get fooled by a poorly named binary.
167 // For programs that don't end with ' (deleted)', this is a no-op. 174 // For programs that don't end with ' (deleted)', this is a no-op.
168 // This assumes |path| is a buffer with length NAME_MAX. 175 // This assumes |path| is a buffer with length NAME_MAX.
169 // Returns true if |path| is modified. 176 // Returns true if |path| is modified.
170 bool HandleDeletedFileInMapping(char* path) const; 177 bool HandleDeletedFileInMapping(char* path) const;
171 178
172 // ID of the crashed process. 179 // ID of the crashed process.
173 const pid_t pid_; 180 const pid_t pid_;
174 181
182 // Path of the root directory to which mapping paths are relative.
183 const char* const root_prefix_;
184
175 // Virtual address at which the process crashed. 185 // Virtual address at which the process crashed.
176 uintptr_t crash_address_; 186 uintptr_t crash_address_;
177 187
178 // Signal that terminated the crashed process. 188 // Signal that terminated the crashed process.
179 int crash_signal_; 189 int crash_signal_;
180 190
181 // ID of the crashed thread. 191 // ID of the crashed thread.
182 pid_t crash_thread_; 192 pid_t crash_thread_;
183 193
184 mutable PageAllocator allocator_; 194 mutable PageAllocator allocator_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // (or Chromium crazy linker) used. This value matches the addresses produced 255 // (or Chromium crazy linker) used. This value matches the addresses produced
246 // when the non-relocation-packed library is used for breakpad symbol 256 // when the non-relocation-packed library is used for breakpad symbol
247 // generation. 257 // generation.
248 void LatePostprocessMappings(); 258 void LatePostprocessMappings();
249 #endif // __ANDROID__ 259 #endif // __ANDROID__
250 }; 260 };
251 261
252 } // namespace google_breakpad 262 } // namespace google_breakpad
253 263
254 #endif // CLIENT_LINUX_HANDLER_LINUX_DUMPER_H_ 264 #endif // CLIENT_LINUX_HANDLER_LINUX_DUMPER_H_
OLDNEW
« no previous file with comments | « src/client/linux/minidump_writer/linux_core_dumper_unittest.cc ('k') | src/client/linux/minidump_writer/linux_dumper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698