/ src / google_breakpad / processor / proc_maps_linux.h
proc_maps_linux.h
 1  // Copyright 2013 Google LLC
 2  // Use of this source code is governed by a BSD-style license that can be
 3  // found in the LICENSE file.
 4  
 5  #ifndef BASE_DEBUG_PROC_MAPS_LINUX_H_
 6  #define BASE_DEBUG_PROC_MAPS_LINUX_H_
 7  
 8  #include <string>
 9  #include <vector>
10  
11  #include "common/using_std_string.h"
12  #include "google_breakpad/common/breakpad_types.h"
13  
14  namespace google_breakpad {
15  
16  // Describes a region of mapped memory and the path of the file mapped.
17  struct MappedMemoryRegion {
18    enum Permission {
19      READ = 1 << 0,
20      WRITE = 1 << 1,
21      EXECUTE = 1 << 2,
22      PRIVATE = 1 << 3,  // If set, region is private, otherwise it is shared.
23    };
24  
25    // The address range [start,end) of mapped memory.
26    uint64_t start;
27    uint64_t end;
28  
29    // Byte offset into |path| of the range mapped into memory.
30    uint64_t offset;
31  
32    // Bitmask of read/write/execute/private/shared permissions.
33    uint8_t permissions;
34  
35    // Major and minor devices.
36    uint8_t major_device;
37    uint8_t minor_device;
38  
39    // Value of the inode.
40    uint64_t inode;
41  
42    // Name of the file mapped into memory.
43    //
44    // NOTE: path names aren't guaranteed to point at valid files. For example,
45    // "[heap]" and "[stack]" are used to represent the location of the process'
46    // heap and stack, respectively.
47    string path;
48  
49    // The line from /proc/<pid>/maps that this struct represents.
50    string line;
51  };
52  
53  // Parses /proc/<pid>/maps input data and stores in |regions|. Returns true
54  // and updates |regions| if and only if all of |input| was successfully parsed.
55  bool ParseProcMaps(const string& input,
56                     std::vector<MappedMemoryRegion>* regions);
57  
58  }  // namespace google_breakpad
59  
60  #endif  // BASE_DEBUG_PROC_MAPS_LINUX_H_