Chromium Code Reviews| Index: base/debug/proc_maps.h |
| diff --git a/base/debug/proc_maps.h b/base/debug/proc_maps.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..22119e83398387e356dfb8bd44882090b5235b03 |
| --- /dev/null |
| +++ b/base/debug/proc_maps.h |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_DEBUG_PROC_MAPS_H_ |
| +#define BASE_DEBUG_PROC_MAPS_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/base_export.h" |
| +#include "base/basictypes.h" |
| +#include "base/files/file_path.h" |
| + |
| +namespace base { |
| +namespace debug { |
| + |
| +#if defined(OS_LINUX) || defined(OS_ANDROID) |
| + |
| +// Describes a region of mapped memory and the path of the file mapped. |
| +// start: Starting address of memory range. |
| +// end: Ending address of memory range. |
| +// offset: The starting offset of the file that is mapped into memory. |
| +// path: The path of the object file that is mapped into memory. |
| +struct MappedMemoryRegion { |
| + uintptr_t start; |
| + uintptr_t end; |
| + size_t offset; |
| + FilePath path; |
|
satorux1
2013/07/01 03:59:56
maybe add the permission bits? that info would be
scherkus (not reviewing)
2013/07/01 21:59:45
Done. I'll make my stack trace code check for r+x
|
| +}; |
| + |
| +// Reads the data from /proc/self/maps. Returns an empty string if unable to |
| +// do so. |
| +BASE_EXPORT std::string ReadProcMaps(); |
| + |
| +// Parses /proc/<pid>/maps input data and stores in |regions|. Invalid input |
| +// data is skipped i.e., if |input| contains no valid data, then |regions| |
| +// will be empty. |
| +// |
| +// NOTE: Parsed path names aren't guaranteed to point at valid files. For |
| +// example, "[heap]" and "[stack]" are used to represent the location of the |
| +// process' heap and stack, respectively. |
| +BASE_EXPORT void ParseProcMaps(const std::string& input, |
|
satorux1
2013/07/01 03:59:56
Maybe return a boolean to report an error?
scherkus (not reviewing)
2013/07/01 21:59:45
Done, but made this function an all-or-nothing fun
|
| + std::vector<MappedMemoryRegion>* regions); |
| +#endif |
| + |
| +} // namespace debug |
| +} // namespace base |
| + |
| +#endif // BASE_DEBUG_PROC_MAPS_H_ |