Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: base/debug/proc_maps.h

Issue 18178015: Implement /proc/self/maps/ parsing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add link Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {
Mark Mentovai 2013/07/02 19:36:57 Aren’t we not doing second-level nested namespaces
scherkus (not reviewing) 2013/07/02 21:43:01 here's the most relevant discussion I could find:
+
+#if defined(OS_LINUX) || defined(OS_ANDROID)
Mark Mentovai 2013/07/02 19:36:57 Get rid of this. Just rename the file with _linux
scherkus (not reviewing) 2013/07/02 21:43:01 Done.
+
+// Describes a region of mapped memory and the path of the file mapped.
+struct MappedMemoryRegion {
+ enum Permissions {
Mark Mentovai 2013/07/02 19:36:57 The members of this enum are single permissions, s
scherkus (not reviewing) 2013/07/02 21:43:01 Done.
+ READ = 1 << 0,
+ WRITE = 1 << 1,
+ EXECUTE = 1 << 2,
+ PRIVATE = 1 << 3, // If set, region is private otherwise it is shared.
Mark Mentovai 2013/07/02 19:36:57 Missing comma?
scherkus (not reviewing) 2013/07/02 21:43:01 Hrm. Not sure which comma is missing. I assume you
Mark Mentovai 2013/07/02 22:21:35 scherkus wrote:
+ };
+
+ // 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.
Mark Mentovai 2013/07/02 19:36:57 What’s it return otherwise? Just the contents of /
scherkus (not reviewing) 2013/07/02 21:43:01 Done.
+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_

Powered by Google App Engine
This is Rietveld 408576698