/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * MemoryMapping is a helper class which describes an entry in the Linux * /proc/<pid>/smaps file. See procfs(5) for details on the entry format. * * The GetMemoryMappings() function returns an array of such entries, sorted by * start address, one for each entry in the current process's address space.
*/
namespace mozilla {
enumclass VMFlag : uint8_t {
Readable, // rd - readable
Writable, // wr - writable
Executable, // ex - executable
Shared, // sh - shared
MayRead, // mr - may read
MayWrite, // mw - may write
MayExecute, // me - may execute
MayShare, // ms - may share
GrowsDown, // gd - stack segment grows down
PurePFN, // pf - pure PFN range
DisabledWrite, // dw - disabled write to the mapped file
Locked, // lo - pages are locked in memory
IO, // io - memory mapped I/O area
Sequential, // sr - sequential read advise provided
Random, // rr - random read advise provided
NoFork, // dc - do not copy area on fork
NoExpand, // de - do not expand area on remapping
Accountable, // ac - area is accountable
NotReserved, // nr - swap space is not reserved for the area
HugeTLB, // ht - area uses huge tlb pages
NonLinear, // nl - non-linear mapping
ArchSpecific, // ar - architecture specific flag
NoCore, // dd - do not include area into core dump
SoftDirty, // sd - soft-dirty flag
MixedMap, // mm - mixed map area
HugePage, // hg - huge page advise flag
NoHugePage, // nh - no-huge page advise flag
Mergeable, // mg - mergeable advise flag
};
using VMFlagSet = EnumSet<VMFlag, uint32_t>;
class MemoryMapping final { public: enumclass Perm : uint8_t {
Read,
Write,
Execute,
Shared, Private,
};
// Dumps a string representation of the entry, similar to its format in the // smaps file, to the given string. Mainly useful for debugging. void Dump(nsACString& aOut) const;
// These comparison operators are used for binary searching sorted arrays of // MemoryMapping entries to find the one which contains a given pointer. booloperator==(constvoid* aPtr) const { return Includes(aPtr); } booloperator<(constvoid* aPtr) const { return mStart < uintptr_t(aPtr); }
// Contains the name and offset of one of the above size_t fields, for use in // parsing in dumping. The below helpers contain a list of the fields, and map // Field entries to the appropriate member in a class instance. struct Field { constchar* mName;
size_t mOffset;
};