| 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..0dadbc13d3915c6d6d938378bce5a241f4cf5ab7
|
| --- /dev/null
|
| +++ b/base/debug/proc_maps.h
|
| @@ -0,0 +1,61 @@
|
| +// 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.
|
| +struct MappedMemoryRegion {
|
| + enum Permissions {
|
| + READ = 1 << 0,
|
| + WRITE = 1 << 1,
|
| + EXECUTE = 1 << 2,
|
| + PRIVATE = 1 << 3, // If set, region is private otherwise it is shared.
|
| + };
|
| +
|
| + // The address range [start,end) of mapped memory.
|
| + uintptr_t start;
|
| + uintptr_t end;
|
| +
|
| + // Byte offset into |path| of the range mapped into memory.
|
| + size_t offset;
|
| +
|
| + // Bitmask of read/write/execute/private/shared permissions.
|
| + uint8 permissions;
|
| +
|
| + // Path of the file mapped into memory.
|
| + FilePath path;
|
| +};
|
| +
|
| +// 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|. Returns true
|
| +// and updates |regions| if and only if all of |input| was successfully parsed.
|
| +//
|
| +// 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 bool ParseProcMaps(const std::string& input,
|
| + std::vector<MappedMemoryRegion>* regions);
|
| +
|
| +#endif
|
| +
|
| +} // namespace debug
|
| +} // namespace base
|
| +
|
| +#endif // BASE_DEBUG_PROC_MAPS_H_
|
|
|