process_metrics.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. // Copyright (c) 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This file contains routines for gathering resource statistics for processes
  5. // running on the system.
  6. #ifndef BASE_PROCESS_PROCESS_METRICS_H_
  7. #define BASE_PROCESS_PROCESS_METRICS_H_
  8. #include <stddef.h>
  9. #include <stdint.h>
  10. #include <memory>
  11. #include <string>
  12. #include "base/base_export.h"
  13. #include "base/gtest_prod_util.h"
  14. #include "base/macros.h"
  15. #include "base/process/process_handle.h"
  16. #include "base/time/time.h"
  17. #include "base/values.h"
  18. #include "build/build_config.h"
  19. #if defined(OS_MACOSX)
  20. #include <mach/mach.h>
  21. #include "base/process/port_provider_mac.h"
  22. #if !defined(OS_IOS)
  23. #include <mach/mach_vm.h>
  24. #endif
  25. #endif
  26. #if defined(OS_WIN)
  27. #include "base/win/scoped_handle.h"
  28. #include "base/win/windows_types.h"
  29. #endif
  30. namespace base {
  31. // Full declaration is in process_metrics_iocounters.h.
  32. struct IoCounters;
  33. #if defined(OS_LINUX) || defined(OS_ANDROID)
  34. // Minor and major page fault counts since the process creation.
  35. // Both counts are process-wide, and exclude child processes.
  36. //
  37. // minor: Number of page faults that didn't require disk IO.
  38. // major: Number of page faults that required disk IO.
  39. struct PageFaultCounts {
  40. int64_t minor;
  41. int64_t major;
  42. };
  43. #endif // defined(OS_LINUX) || defined(OS_ANDROID)
  44. // Convert a POSIX timeval to microseconds.
  45. BASE_EXPORT int64_t TimeValToMicroseconds(const struct timeval& tv);
  46. // Provides performance metrics for a specified process (CPU usage and IO
  47. // counters). Use CreateCurrentProcessMetrics() to get an instance for the
  48. // current process, or CreateProcessMetrics() to get an instance for an
  49. // arbitrary process. Then, access the information with the different get
  50. // methods.
  51. //
  52. // This class exposes a few platform-specific APIs for parsing memory usage, but
  53. // these are not intended to generalize to other platforms, since the memory
  54. // models differ substantially.
  55. //
  56. // To obtain consistent memory metrics, use the memory_instrumentation service.
  57. //
  58. // For further documentation on memory, see
  59. // https://chromium.googlesource.com/chromium/src/+/HEAD/docs/README.md
  60. class BASE_EXPORT ProcessMetrics {
  61. public:
  62. ~ProcessMetrics();
  63. // Creates a ProcessMetrics for the specified process.
  64. #if !defined(OS_MACOSX) || defined(OS_IOS)
  65. static std::unique_ptr<ProcessMetrics> CreateProcessMetrics(
  66. ProcessHandle process);
  67. #else
  68. // The port provider needs to outlive the ProcessMetrics object returned by
  69. // this function. If NULL is passed as provider, the returned object
  70. // only returns valid metrics if |process| is the current process.
  71. static std::unique_ptr<ProcessMetrics> CreateProcessMetrics(
  72. ProcessHandle process,
  73. PortProvider* port_provider);
  74. #endif // !defined(OS_MACOSX) || defined(OS_IOS)
  75. // Creates a ProcessMetrics for the current process. This a cross-platform
  76. // convenience wrapper for CreateProcessMetrics().
  77. static std::unique_ptr<ProcessMetrics> CreateCurrentProcessMetrics();
  78. #if defined(OS_LINUX) || defined(OS_ANDROID)
  79. // Resident Set Size is a Linux/Android specific memory concept. Do not
  80. // attempt to extend this to other platforms.
  81. BASE_EXPORT size_t GetResidentSetSize() const;
  82. #endif
  83. // Returns the percentage of time spent executing, across all threads of the
  84. // process, in the interval since the last time the method was called. Since
  85. // this considers the total execution time across all threads in a process,
  86. // the result can easily exceed 100% in multi-thread processes running on
  87. // multi-core systems. In general the result is therefore a value in the
  88. // range 0% to SysInfo::NumberOfProcessors() * 100%.
  89. //
  90. // To obtain the percentage of total available CPU resources consumed by this
  91. // process over the interval, the caller must divide by NumberOfProcessors().
  92. //
  93. // Since this API measures usage over an interval, it will return zero on the
  94. // first call, and an actual value only on the second and subsequent calls.
  95. double GetPlatformIndependentCPUUsage();
  96. // Returns the cumulative CPU usage across all threads of the process since
  97. // process start. In case of multi-core processors, a process can consume CPU
  98. // at a rate higher than wall-clock time, e.g. two cores at full utilization
  99. // will result in a time delta of 2 seconds/per 1 wall-clock second.
  100. TimeDelta GetCumulativeCPUUsage();
  101. // Returns the number of average idle cpu wakeups per second since the last
  102. // call.
  103. int GetIdleWakeupsPerSecond();
  104. #if defined(OS_MACOSX)
  105. // Returns the number of average "package idle exits" per second, which have
  106. // a higher energy impact than a regular wakeup, since the last call.
  107. //
  108. // From the powermetrics man page:
  109. // "With the exception of some Mac Pro systems, Mac and
  110. // iOS systems are typically single package systems, wherein all CPUs are
  111. // part of a single processor complex (typically a single IC die) with shared
  112. // logic that can include (depending on system specifics) shared last level
  113. // caches, an integrated memory controller etc. When all CPUs in the package
  114. // are idle, the hardware can power-gate significant portions of the shared
  115. // logic in addition to each individual processor's logic, as well as take
  116. // measures such as placing DRAM in to self-refresh (also referred to as
  117. // auto-refresh), place interconnects into lower-power states etc"
  118. int GetPackageIdleWakeupsPerSecond();
  119. // Returns "Energy Impact", a synthetic power estimation metric displayed by
  120. // macOS in Activity Monitor and the battery menu.
  121. int GetEnergyImpact();
  122. #endif
  123. // Retrieves accounting information for all I/O operations performed by the
  124. // process.
  125. // If IO information is retrieved successfully, the function returns true
  126. // and fills in the IO_COUNTERS passed in. The function returns false
  127. // otherwise.
  128. bool GetIOCounters(IoCounters* io_counters) const;
  129. // Returns the number of bytes transferred to/from disk per second, across all
  130. // threads of the process, in the interval since the last time the method was
  131. // called.
  132. //
  133. // Since this API measures usage over an interval, it will return zero on the
  134. // first call, and an actual value only on the second and subsequent calls.
  135. uint64_t GetDiskUsageBytesPerSecond();
  136. // Returns the cumulative disk usage in bytes across all threads of the
  137. // process since process start.
  138. uint64_t GetCumulativeDiskUsageInBytes();
  139. #if defined(OS_POSIX)
  140. // Returns the number of file descriptors currently open by the process, or
  141. // -1 on error.
  142. int GetOpenFdCount() const;
  143. // Returns the soft limit of file descriptors that can be opened by the
  144. // process, or -1 on error.
  145. int GetOpenFdSoftLimit() const;
  146. #endif // defined(OS_POSIX)
  147. #if defined(OS_LINUX) || defined(OS_ANDROID)
  148. // Bytes of swap as reported by /proc/[pid]/status.
  149. uint64_t GetVmSwapBytes() const;
  150. // Minor and major page fault count as reported by /proc/[pid]/stat.
  151. // Returns true for success.
  152. bool GetPageFaultCounts(PageFaultCounts* counts) const;
  153. #endif // defined(OS_LINUX) || defined(OS_ANDROID)
  154. // Returns total memory usage of malloc.
  155. size_t GetMallocUsage();
  156. private:
  157. #if !defined(OS_MACOSX) || defined(OS_IOS)
  158. explicit ProcessMetrics(ProcessHandle process);
  159. #else
  160. ProcessMetrics(ProcessHandle process, PortProvider* port_provider);
  161. #endif // !defined(OS_MACOSX) || defined(OS_IOS)
  162. #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_AIX)
  163. int CalculateIdleWakeupsPerSecond(uint64_t absolute_idle_wakeups);
  164. #endif
  165. #if defined(OS_MACOSX)
  166. // The subset of wakeups that cause a "package exit" can be tracked on macOS.
  167. // See |GetPackageIdleWakeupsForSecond| comment for more info.
  168. int CalculatePackageIdleWakeupsPerSecond(
  169. uint64_t absolute_package_idle_wakeups);
  170. #endif
  171. #if defined(OS_WIN)
  172. win::ScopedHandle process_;
  173. #else
  174. ProcessHandle process_;
  175. #endif
  176. // Used to store the previous times and CPU usage counts so we can
  177. // compute the CPU usage between calls.
  178. TimeTicks last_cpu_time_;
  179. #if !defined(OS_FREEBSD) || !defined(OS_POSIX)
  180. TimeDelta last_cumulative_cpu_;
  181. #endif
  182. // Used to store the previous times and disk usage counts so we can
  183. // compute the disk usage between calls.
  184. TimeTicks last_disk_usage_time_;
  185. // Number of bytes transferred to/from disk in bytes.
  186. uint64_t last_cumulative_disk_usage_ = 0;
  187. #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_AIX)
  188. // Same thing for idle wakeups.
  189. TimeTicks last_idle_wakeups_time_;
  190. uint64_t last_absolute_idle_wakeups_;
  191. #endif
  192. #if defined(OS_MACOSX)
  193. // And same thing for package idle exit wakeups.
  194. TimeTicks last_package_idle_wakeups_time_;
  195. uint64_t last_absolute_package_idle_wakeups_;
  196. double last_energy_impact_;
  197. // In mach_absolute_time units.
  198. uint64_t last_energy_impact_time_;
  199. #endif
  200. #if !defined(OS_IOS)
  201. #if defined(OS_MACOSX)
  202. // Queries the port provider if it's set.
  203. mach_port_t TaskForPid(ProcessHandle process) const;
  204. PortProvider* port_provider_;
  205. #endif // defined(OS_MACOSX)
  206. #endif // !defined(OS_IOS)
  207. DISALLOW_COPY_AND_ASSIGN(ProcessMetrics);
  208. };
  209. // Returns the memory committed by the system in KBytes.
  210. // Returns 0 if it can't compute the commit charge.
  211. BASE_EXPORT size_t GetSystemCommitCharge();
  212. // Returns the number of bytes in a memory page. Do not use this to compute
  213. // the number of pages in a block of memory for calling mincore(). On some
  214. // platforms, e.g. iOS, mincore() uses a different page size from what is
  215. // returned by GetPageSize().
  216. BASE_EXPORT size_t GetPageSize();
  217. // Returns the maximum number of file descriptors that can be open by a process
  218. // at once. If the number is unavailable, a conservative best guess is returned.
  219. BASE_EXPORT size_t GetMaxFds();
  220. // Returns the maximum number of handles that can be open at once per process.
  221. BASE_EXPORT size_t GetHandleLimit();
  222. #if defined(OS_POSIX)
  223. // Increases the file descriptor soft limit to |max_descriptors| or the OS hard
  224. // limit, whichever is lower. If the limit is already higher than
  225. // |max_descriptors|, then nothing happens.
  226. BASE_EXPORT void IncreaseFdLimitTo(unsigned int max_descriptors);
  227. #endif // defined(OS_POSIX)
  228. #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \
  229. defined(OS_ANDROID) || defined(OS_AIX) || defined(OS_FUCHSIA)
  230. // Data about system-wide memory consumption. Values are in KB. Available on
  231. // Windows, Mac, Linux, Android and Chrome OS.
  232. //
  233. // Total memory are available on all platforms that implement
  234. // GetSystemMemoryInfo(). Total/free swap memory are available on all platforms
  235. // except on Mac. Buffers/cached/active_anon/inactive_anon/active_file/
  236. // inactive_file/dirty/reclaimable/pswpin/pswpout/pgmajfault are available on
  237. // Linux/Android/Chrome OS. Shmem/slab/gem_objects/gem_size are Chrome OS only.
  238. // Speculative/file_backed/purgeable are Mac and iOS only.
  239. // Free is absent on Windows (see "avail_phys" below).
  240. struct BASE_EXPORT SystemMemoryInfoKB {
  241. SystemMemoryInfoKB();
  242. SystemMemoryInfoKB(const SystemMemoryInfoKB& other);
  243. // Serializes the platform specific fields to value.
  244. std::unique_ptr<DictionaryValue> ToValue() const;
  245. int total = 0;
  246. #if !defined(OS_WIN)
  247. int free = 0;
  248. #endif
  249. #if defined(OS_WIN)
  250. // "This is the amount of physical memory that can be immediately reused
  251. // without having to write its contents to disk first. It is the sum of the
  252. // size of the standby, free, and zero lists." (MSDN).
  253. // Standby: not modified pages of physical ram (file-backed memory) that are
  254. // not actively being used.
  255. int avail_phys = 0;
  256. #endif
  257. #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_AIX)
  258. // This provides an estimate of available memory as described here:
  259. // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
  260. // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always
  261. // be 0 in earlier kernel versions.
  262. // Note: it includes _all_ file-backed memory (active + inactive).
  263. int available = 0;
  264. #endif
  265. #if !defined(OS_MACOSX)
  266. int swap_total = 0;
  267. int swap_free = 0;
  268. #endif
  269. #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_AIX) || \
  270. defined(OS_FUCHSIA)
  271. int buffers = 0;
  272. int cached = 0;
  273. int active_anon = 0;
  274. int inactive_anon = 0;
  275. int active_file = 0;
  276. int inactive_file = 0;
  277. int dirty = 0;
  278. int reclaimable = 0;
  279. #endif // defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_AIX) ||
  280. // defined(OS_FUCHSIA)
  281. #if defined(OS_CHROMEOS)
  282. int shmem = 0;
  283. int slab = 0;
  284. // Gem data will be -1 if not supported.
  285. int gem_objects = -1;
  286. long long gem_size = -1;
  287. #endif // defined(OS_CHROMEOS)
  288. #if defined(OS_MACOSX)
  289. int speculative = 0;
  290. int file_backed = 0;
  291. int purgeable = 0;
  292. #endif // defined(OS_MACOSX)
  293. };
  294. // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed
  295. // from /proc/meminfo and /proc/vmstat. On Windows/Mac, it is obtained using
  296. // system API calls.
  297. //
  298. // Fills in the provided |meminfo| structure. Returns true on success.
  299. // Exposed for memory debugging widget.
  300. BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo);
  301. #endif // defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) ||
  302. // defined(OS_ANDROID) || defined(OS_AIX) || defined(OS_FUCHSIA)
  303. #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_AIX)
  304. // Parse the data found in /proc/<pid>/stat and return the sum of the
  305. // CPU-related ticks. Returns -1 on parse error.
  306. // Exposed for testing.
  307. BASE_EXPORT int ParseProcStatCPU(StringPiece input);
  308. // Get the number of threads of |process| as available in /proc/<pid>/stat.
  309. // This should be used with care as no synchronization with running threads is
  310. // done. This is mostly useful to guarantee being single-threaded.
  311. // Returns 0 on failure.
  312. BASE_EXPORT int GetNumberOfThreads(ProcessHandle process);
  313. // /proc/self/exe refers to the current executable.
  314. BASE_EXPORT extern const char kProcSelfExe[];
  315. // Parses a string containing the contents of /proc/meminfo
  316. // returns true on success or false for a parsing error
  317. // Exposed for testing.
  318. BASE_EXPORT bool ParseProcMeminfo(StringPiece input,
  319. SystemMemoryInfoKB* meminfo);
  320. // Data from /proc/vmstat.
  321. struct BASE_EXPORT VmStatInfo {
  322. // Serializes the platform specific fields to value.
  323. std::unique_ptr<DictionaryValue> ToValue() const;
  324. unsigned long pswpin = 0;
  325. unsigned long pswpout = 0;
  326. unsigned long pgmajfault = 0;
  327. };
  328. // Retrieves data from /proc/vmstat about system-wide vm operations.
  329. // Fills in the provided |vmstat| structure. Returns true on success.
  330. BASE_EXPORT bool GetVmStatInfo(VmStatInfo* vmstat);
  331. // Parses a string containing the contents of /proc/vmstat
  332. // returns true on success or false for a parsing error
  333. // Exposed for testing.
  334. BASE_EXPORT bool ParseProcVmstat(StringPiece input, VmStatInfo* vmstat);
  335. // Data from /proc/diskstats about system-wide disk I/O.
  336. struct BASE_EXPORT SystemDiskInfo {
  337. SystemDiskInfo();
  338. SystemDiskInfo(const SystemDiskInfo& other);
  339. // Serializes the platform specific fields to value.
  340. std::unique_ptr<Value> ToValue() const;
  341. uint64_t reads = 0;
  342. uint64_t reads_merged = 0;
  343. uint64_t sectors_read = 0;
  344. uint64_t read_time = 0;
  345. uint64_t writes = 0;
  346. uint64_t writes_merged = 0;
  347. uint64_t sectors_written = 0;
  348. uint64_t write_time = 0;
  349. uint64_t io = 0;
  350. uint64_t io_time = 0;
  351. uint64_t weighted_io_time = 0;
  352. };
  353. // Checks whether the candidate string is a valid disk name, [hsv]d[a-z]+
  354. // for a generic disk or mmcblk[0-9]+ for the MMC case.
  355. // Names of disk partitions (e.g. sda1) are not valid.
  356. BASE_EXPORT bool IsValidDiskName(StringPiece candidate);
  357. // Retrieves data from /proc/diskstats about system-wide disk I/O.
  358. // Fills in the provided |diskinfo| structure. Returns true on success.
  359. BASE_EXPORT bool GetSystemDiskInfo(SystemDiskInfo* diskinfo);
  360. // Returns the amount of time spent in user space since boot across all CPUs.
  361. BASE_EXPORT TimeDelta GetUserCpuTimeSinceBoot();
  362. #endif // defined(OS_LINUX) || defined(OS_ANDROID)
  363. #if defined(OS_CHROMEOS)
  364. // Data from files in directory /sys/block/zram0 about ZRAM usage.
  365. struct BASE_EXPORT SwapInfo {
  366. SwapInfo()
  367. : num_reads(0),
  368. num_writes(0),
  369. compr_data_size(0),
  370. orig_data_size(0),
  371. mem_used_total(0) {
  372. }
  373. // Serializes the platform specific fields to value.
  374. std::unique_ptr<Value> ToValue() const;
  375. uint64_t num_reads = 0;
  376. uint64_t num_writes = 0;
  377. uint64_t compr_data_size = 0;
  378. uint64_t orig_data_size = 0;
  379. uint64_t mem_used_total = 0;
  380. };
  381. // Parses a string containing the contents of /sys/block/zram0/mm_stat.
  382. // This should be used for the new ZRAM sysfs interfaces.
  383. // Returns true on success or false for a parsing error.
  384. // Exposed for testing.
  385. BASE_EXPORT bool ParseZramMmStat(StringPiece mm_stat_data, SwapInfo* swap_info);
  386. // Parses a string containing the contents of /sys/block/zram0/stat
  387. // This should be used for the new ZRAM sysfs interfaces.
  388. // Returns true on success or false for a parsing error.
  389. // Exposed for testing.
  390. BASE_EXPORT bool ParseZramStat(StringPiece stat_data, SwapInfo* swap_info);
  391. // In ChromeOS, reads files from /sys/block/zram0 that contain ZRAM usage data.
  392. // Fills in the provided |swap_data| structure.
  393. // Returns true on success or false for a parsing error.
  394. BASE_EXPORT bool GetSwapInfo(SwapInfo* swap_info);
  395. #endif // defined(OS_CHROMEOS)
  396. struct BASE_EXPORT SystemPerformanceInfo {
  397. SystemPerformanceInfo();
  398. SystemPerformanceInfo(const SystemPerformanceInfo& other);
  399. // Serializes the platform specific fields to value.
  400. std::unique_ptr<Value> ToValue() const;
  401. // Total idle time of all processes in the system (units of 100 ns).
  402. uint64_t idle_time = 0;
  403. // Number of bytes read.
  404. uint64_t read_transfer_count = 0;
  405. // Number of bytes written.
  406. uint64_t write_transfer_count = 0;
  407. // Number of bytes transferred (e.g. DeviceIoControlFile)
  408. uint64_t other_transfer_count = 0;
  409. // The amount of read operations.
  410. uint64_t read_operation_count = 0;
  411. // The amount of write operations.
  412. uint64_t write_operation_count = 0;
  413. // The amount of other operations.
  414. uint64_t other_operation_count = 0;
  415. // The number of pages written to the system's pagefiles.
  416. uint64_t pagefile_pages_written = 0;
  417. // The number of write operations performed on the system's pagefiles.
  418. uint64_t pagefile_pages_write_ios = 0;
  419. // The number of pages of physical memory available to processes running on
  420. // the system.
  421. uint64_t available_pages = 0;
  422. // The number of pages read from disk to resolve page faults.
  423. uint64_t pages_read = 0;
  424. // The number of read operations initiated to resolve page faults.
  425. uint64_t page_read_ios = 0;
  426. };
  427. // Retrieves performance counters from the operating system.
  428. // Fills in the provided |info| structure. Returns true on success.
  429. BASE_EXPORT bool GetSystemPerformanceInfo(SystemPerformanceInfo* info);
  430. // Collects and holds performance metrics for system memory and disk.
  431. // Provides functionality to retrieve the data on various platforms and
  432. // to serialize the stored data.
  433. class BASE_EXPORT SystemMetrics {
  434. public:
  435. SystemMetrics();
  436. static SystemMetrics Sample();
  437. // Serializes the system metrics to value.
  438. std::unique_ptr<Value> ToValue() const;
  439. private:
  440. FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics);
  441. size_t committed_memory_;
  442. #if defined(OS_LINUX) || defined(OS_ANDROID)
  443. SystemMemoryInfoKB memory_info_;
  444. VmStatInfo vmstat_info_;
  445. SystemDiskInfo disk_info_;
  446. #endif
  447. #if defined(OS_CHROMEOS)
  448. SwapInfo swap_info_;
  449. #endif
  450. #if defined(OS_WIN)
  451. SystemPerformanceInfo performance_;
  452. #endif
  453. };
  454. #if defined(OS_MACOSX) && !defined(OS_IOS)
  455. enum class MachVMRegionResult {
  456. // There were no more memory regions between |address| and the end of the
  457. // virtual address space.
  458. Finished,
  459. // All output parameters are invalid.
  460. Error,
  461. // All output parameters are filled in.
  462. Success
  463. };
  464. // Returns info on the first memory region at or after |address|, including
  465. // resident memory and share mode. On Success, |size| reflects the size of the
  466. // memory region.
  467. // |size| and |info| are output parameters, only valid on Success.
  468. // |address| is an in-out parameter, than represents both the address to start
  469. // looking, and the start address of the memory region.
  470. BASE_EXPORT MachVMRegionResult GetTopInfo(mach_port_t task,
  471. mach_vm_size_t* size,
  472. mach_vm_address_t* address,
  473. vm_region_top_info_data_t* info);
  474. // Returns info on the first memory region at or after |address|, including
  475. // protection values. On Success, |size| reflects the size of the
  476. // memory region.
  477. // Returns info on the first memory region at or after |address|, including
  478. // resident memory and share mode.
  479. // |size| and |info| are output parameters, only valid on Success.
  480. BASE_EXPORT MachVMRegionResult GetBasicInfo(mach_port_t task,
  481. mach_vm_size_t* size,
  482. mach_vm_address_t* address,
  483. vm_region_basic_info_64* info);
  484. #endif // defined(OS_MACOSX) && !defined(OS_IOS)
  485. } // namespace base
  486. #endif // BASE_PROCESS_PROCESS_METRICS_H_