blob: 5b2bf656f5170f0d97d01b267ef74e1742e30866 [file] [log] [blame]
Brian Carlstrom27ec9612011-09-19 20:20:38 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "mem_map.h"
18
Ian Rogersdebeb3a2014-01-23 16:54:52 -080019#include <inttypes.h>
Christopher Ferris943af7d2014-01-16 12:41:46 -080020#include <backtrace/BacktraceMap.h>
Elliott Hughesecd3a6f2012-06-06 18:16:37 -070021
Christopher Ferriscaf22ac2014-01-27 18:32:14 -080022#include "UniquePtr.h"
Elliott Hughese222ee02012-12-13 14:41:43 -080023#include "base/stringprintf.h"
24#include "ScopedFd.h"
25#include "utils.h"
26
Elliott Hughes6c9c06d2011-11-07 16:43:47 -080027#define USE_ASHMEM 1
28
29#ifdef USE_ASHMEM
30#include <cutils/ashmem.h>
31#endif
32
Brian Carlstrom27ec9612011-09-19 20:20:38 -070033namespace art {
34
Christopher Ferris943af7d2014-01-16 12:41:46 -080035static std::ostream& operator<<(
36 std::ostream& os,
37 std::pair<BacktraceMap::const_iterator, BacktraceMap::const_iterator> iters) {
38 for (BacktraceMap::const_iterator it = iters.first; it != iters.second; ++it) {
39 os << StringPrintf("0x%08x-0x%08x %c%c%c %s\n",
40 static_cast<uint32_t>(it->start),
41 static_cast<uint32_t>(it->end),
42 (it->flags & PROT_READ) ? 'r' : '-',
43 (it->flags & PROT_WRITE) ? 'w' : '-',
44 (it->flags & PROT_EXEC) ? 'x' : '-', it->name.c_str());
Elliott Hughesecd3a6f2012-06-06 18:16:37 -070045 }
46 return os;
Brian Carlstrom27ec9612011-09-19 20:20:38 -070047}
48
Stuart Monteith8dba5aa2014-03-12 12:44:01 +000049#if defined(__LP64__) && !defined(__x86_64__)
Andreas Gampe7104cbf2014-03-21 11:44:43 -070050// Where to start with low memory allocation.
51static constexpr uintptr_t LOW_MEM_START = kPageSize * 2;
52
53uintptr_t MemMap::next_mem_pos_ = LOW_MEM_START; // first page to check for low-mem extent
Stuart Monteith8dba5aa2014-03-12 12:44:01 +000054#endif
55
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -070056static bool CheckMapRequest(byte* expected_ptr, void* actual_ptr, size_t byte_count,
57 std::ostringstream* error_msg) {
58 // Handled first by caller for more specific error messages.
59 CHECK(actual_ptr != MAP_FAILED);
60
61 if (expected_ptr == nullptr) {
62 return true;
Brian Carlstrom27ec9612011-09-19 20:20:38 -070063 }
Elliott Hughesecd3a6f2012-06-06 18:16:37 -070064
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -070065 if (expected_ptr == actual_ptr) {
66 return true;
67 }
68
69 // We asked for an address but didn't get what we wanted, all paths below here should fail.
70 int result = munmap(actual_ptr, byte_count);
71 if (result == -1) {
72 PLOG(WARNING) << StringPrintf("munmap(%p, %zd) failed", actual_ptr, byte_count);
73 }
74
75 uintptr_t actual = reinterpret_cast<uintptr_t>(actual_ptr);
76 uintptr_t expected = reinterpret_cast<uintptr_t>(expected_ptr);
77 uintptr_t limit = expected + byte_count;
Brian Carlstrom27ec9612011-09-19 20:20:38 -070078
Christopher Ferriscaf22ac2014-01-27 18:32:14 -080079 UniquePtr<BacktraceMap> map(BacktraceMap::Create(getpid()));
80 if (!map->Build()) {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -070081 *error_msg << StringPrintf("Failed to build process map to determine why mmap returned "
82 "0x%08" PRIxPTR " instead of 0x%08" PRIxPTR, actual, expected);
83
84 return false;
Christopher Ferris943af7d2014-01-16 12:41:46 -080085 }
Christopher Ferriscaf22ac2014-01-27 18:32:14 -080086 for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -070087 if ((expected >= it->start && expected < it->end) // start of new within old
88 || (limit > it->start && limit < it->end) // end of new within old
89 || (expected <= it->start && limit > it->end)) { // start/end of new includes all of old
90 *error_msg
91 << StringPrintf("Requested region 0x%08" PRIxPTR "-0x%08" PRIxPTR " overlaps with "
92 "existing map 0x%08" PRIxPTR "-0x%08" PRIxPTR " (%s)\n",
93 expected, limit,
94 static_cast<uintptr_t>(it->start), static_cast<uintptr_t>(it->end),
95 it->name.c_str())
96 << std::make_pair(it, map->end());
97 return false;
98 }
Elliott Hughes96970cd2012-03-13 15:46:31 -070099 }
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700100 *error_msg << StringPrintf("Failed to mmap at expected address, mapped at "
101 "0x%08" PRIxPTR " instead of 0x%08" PRIxPTR, actual, expected);
102 return false;
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700103}
104
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700105MemMap* MemMap::MapAnonymous(const char* name, byte* expected, size_t byte_count, int prot,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800106 bool low_4gb, std::string* error_msg) {
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700107 if (byte_count == 0) {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700108 return new MemMap(name, nullptr, 0, nullptr, 0, prot);
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700109 }
Elliott Hughesecd3a6f2012-06-06 18:16:37 -0700110 size_t page_aligned_byte_count = RoundUp(byte_count, kPageSize);
Elliott Hughes6c9c06d2011-11-07 16:43:47 -0800111
112#ifdef USE_ASHMEM
Ian Rogersa40307e2013-02-22 11:32:44 -0800113 // android_os_Debug.cpp read_mapinfo assumes all ashmem regions associated with the VM are
114 // prefixed "dalvik-".
115 std::string debug_friendly_name("dalvik-");
116 debug_friendly_name += name;
117 ScopedFd fd(ashmem_create_region(debug_friendly_name.c_str(), page_aligned_byte_count));
Elliott Hughes6c9c06d2011-11-07 16:43:47 -0800118 if (fd.get() == -1) {
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700119 *error_msg = StringPrintf("ashmem_create_region failed for '%s': %s", name, strerror(errno));
120 return nullptr;
Elliott Hughes6c9c06d2011-11-07 16:43:47 -0800121 }
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700122 int flags = MAP_PRIVATE;
Elliott Hughes6c9c06d2011-11-07 16:43:47 -0800123#else
124 ScopedFd fd(-1);
125 int flags = MAP_PRIVATE | MAP_ANONYMOUS;
126#endif
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000127
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700128 // We need to store and potentially set an error number for pretty printing of errors
129 int saved_errno = 0;
130
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000131 // TODO:
132 // A page allocator would be a useful abstraction here, as
133 // 1) It is doubtful that MAP_32BIT on x86_64 is doing the right job for us
134 // 2) The linear scheme, even with simple saving of the last known position, is very crude
135#if defined(__LP64__) && !defined(__x86_64__)
136 // MAP_32BIT only available on x86_64.
137 void* actual = MAP_FAILED;
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000138 if (low_4gb && expected == nullptr) {
139 flags |= MAP_FIXED;
140
Andreas Gampe7104cbf2014-03-21 11:44:43 -0700141 bool first_run = true;
142
Andreas Gampe71a3eba2014-03-17 12:57:08 -0700143 for (uintptr_t ptr = next_mem_pos_; ptr < 4 * GB; ptr += kPageSize) {
Andreas Gampe7104cbf2014-03-21 11:44:43 -0700144 if (4U * GB - ptr < page_aligned_byte_count) {
145 // Not enough memory until 4GB.
146 if (first_run) {
147 // Try another time from the bottom;
148 next_mem_pos_ = LOW_MEM_START;
149 first_run = false;
150 continue;
151 } else {
152 // Second try failed.
153 break;
154 }
155 }
156
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000157 uintptr_t tail_ptr;
158
159 // Check pages are free.
160 bool safe = true;
161 for (tail_ptr = ptr; tail_ptr < ptr + page_aligned_byte_count; tail_ptr += kPageSize) {
162 if (msync(reinterpret_cast<void*>(tail_ptr), kPageSize, 0) == 0) {
163 safe = false;
164 break;
165 } else {
166 DCHECK_EQ(errno, ENOMEM);
167 }
168 }
169
170 next_mem_pos_ = tail_ptr; // update early, as we break out when we found and mapped a region
171
172 if (safe == true) {
173 actual = mmap(reinterpret_cast<void*>(ptr), page_aligned_byte_count, prot, flags, fd.get(),
174 0);
175 if (actual != MAP_FAILED) {
176 break;
177 }
178 } else {
179 // Skip over last page.
180 ptr = tail_ptr;
181 }
182 }
183
184 if (actual == MAP_FAILED) {
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700185 LOG(ERROR) << "Could not find contiguous low-memory space.";
186 saved_errno = ENOMEM;
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000187 }
188 } else {
189 actual = mmap(expected, page_aligned_byte_count, prot, flags, fd.get(), 0);
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700190 saved_errno = errno;
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000191 }
192
193#else
194#ifdef __x86_64__
Ian Rogersef7d42f2014-01-06 12:55:46 -0800195 if (low_4gb) {
196 flags |= MAP_32BIT;
197 }
198#endif
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700199
200 void* actual = mmap(expected, page_aligned_byte_count, prot, flags, fd.get(), 0);
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700201 saved_errno = errno;
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000202#endif
203
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700204 if (actual == MAP_FAILED) {
jeffhao8161c032012-10-31 15:50:00 -0700205 std::string maps;
206 ReadFileToString("/proc/self/maps", &maps);
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700207
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700208 *error_msg = StringPrintf("Failed anonymous mmap(%p, %zd, 0x%x, 0x%x, %d, 0): %s\n%s",
209 expected, page_aligned_byte_count, prot, flags, fd.get(),
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700210 strerror(saved_errno), maps.c_str());
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700211 return nullptr;
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700212 }
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700213 std::ostringstream check_map_request_error_msg;
214 if (!CheckMapRequest(expected, actual, page_aligned_byte_count, &check_map_request_error_msg)) {
215 *error_msg = check_map_request_error_msg.str();
216 return nullptr;
217 }
218 return new MemMap(name, reinterpret_cast<byte*>(actual), byte_count, actual,
219 page_aligned_byte_count, prot);
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700220}
221
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700222MemMap* MemMap::MapFileAtAddress(byte* expected, size_t byte_count, int prot, int flags, int fd,
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700223 off_t start, bool reuse, const char* filename,
224 std::string* error_msg) {
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700225 CHECK_NE(0, prot);
226 CHECK_NE(0, flags & (MAP_SHARED | MAP_PRIVATE));
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700227 if (reuse) {
228 // reuse means it is okay that it overlaps an existing page mapping.
229 // Only use this if you actually made the page reservation yourself.
230 CHECK(expected != nullptr);
231 flags |= MAP_FIXED;
232 } else {
233 CHECK_EQ(0, flags & MAP_FIXED);
234 }
235
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700236 if (byte_count == 0) {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700237 return new MemMap(filename, nullptr, 0, nullptr, 0, prot);
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700238 }
Ian Rogersf8adc602013-04-18 17:06:19 -0700239 // Adjust 'offset' to be page-aligned as required by mmap.
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700240 int page_offset = start % kPageSize;
241 off_t page_aligned_offset = start - page_offset;
Ian Rogersf8adc602013-04-18 17:06:19 -0700242 // Adjust 'byte_count' to be page-aligned as we will map this anyway.
Elliott Hughesecd3a6f2012-06-06 18:16:37 -0700243 size_t page_aligned_byte_count = RoundUp(byte_count + page_offset, kPageSize);
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700244 // The 'expected' is modified (if specified, ie non-null) to be page aligned to the file but not
245 // necessarily to virtual memory. mmap will page align 'expected' for us.
246 byte* page_aligned_expected = (expected == nullptr) ? nullptr : (expected - page_offset);
247
248 byte* actual = reinterpret_cast<byte*>(mmap(page_aligned_expected,
Elliott Hughesecd3a6f2012-06-06 18:16:37 -0700249 page_aligned_byte_count,
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700250 prot,
251 flags,
252 fd,
253 page_aligned_offset));
254 if (actual == MAP_FAILED) {
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700255 auto saved_errno = errno;
256
jeffhao8161c032012-10-31 15:50:00 -0700257 std::string maps;
258 ReadFileToString("/proc/self/maps", &maps);
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700259
Mathieu Chartierc7cb1902014-03-05 14:41:03 -0800260 *error_msg = StringPrintf("mmap(%p, %zd, 0x%x, 0x%x, %d, %" PRId64
261 ") of file '%s' failed: %s\n%s",
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700262 page_aligned_expected, page_aligned_byte_count, prot, flags, fd,
Brian Carlstromaa94cf32014-03-23 23:47:25 -0700263 static_cast<int64_t>(page_aligned_offset), filename,
264 strerror(saved_errno), maps.c_str());
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700265 return nullptr;
266 }
267 std::ostringstream check_map_request_error_msg;
268 if (!CheckMapRequest(expected, actual, page_aligned_byte_count, &check_map_request_error_msg)) {
269 *error_msg = check_map_request_error_msg.str();
270 return nullptr;
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700271 }
Brian Carlstrom0d6adac2014-02-05 17:39:16 -0800272 return new MemMap(filename, actual + page_offset, byte_count, actual, page_aligned_byte_count,
Mathieu Chartier1c23e1e2012-10-12 14:14:11 -0700273 prot);
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700274}
275
276MemMap::~MemMap() {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700277 if (base_begin_ == nullptr && base_size_ == 0) {
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700278 return;
279 }
Ian Rogers30fab402012-01-23 15:43:46 -0800280 int result = munmap(base_begin_, base_size_);
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700281 if (result == -1) {
282 PLOG(FATAL) << "munmap failed";
283 }
284}
285
Mathieu Chartier1c23e1e2012-10-12 14:14:11 -0700286MemMap::MemMap(const std::string& name, byte* begin, size_t size, void* base_begin,
287 size_t base_size, int prot)
288 : name_(name), begin_(begin), size_(size), base_begin_(base_begin), base_size_(base_size),
289 prot_(prot) {
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700290 if (size_ == 0) {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700291 CHECK(begin_ == nullptr);
292 CHECK(base_begin_ == nullptr);
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700293 CHECK_EQ(base_size_, 0U);
294 } else {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700295 CHECK(begin_ != nullptr);
296 CHECK(base_begin_ != nullptr);
Brian Carlstrom9004cb62013-07-26 15:48:31 -0700297 CHECK_NE(base_size_, 0U);
298 }
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700299};
300
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700301MemMap* MemMap::RemapAtEnd(byte* new_end, const char* tail_name, int tail_prot,
302 std::string* error_msg) {
Mathieu Chartiercc236d72012-07-20 10:29:05 -0700303 DCHECK_GE(new_end, Begin());
304 DCHECK_LE(new_end, End());
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700305 DCHECK_LE(begin_ + size_, reinterpret_cast<byte*>(base_begin_) + base_size_);
306 DCHECK(IsAligned<kPageSize>(begin_));
307 DCHECK(IsAligned<kPageSize>(base_begin_));
308 DCHECK(IsAligned<kPageSize>(reinterpret_cast<byte*>(base_begin_) + base_size_));
309 DCHECK(IsAligned<kPageSize>(new_end));
310 byte* old_end = begin_ + size_;
311 byte* old_base_end = reinterpret_cast<byte*>(base_begin_) + base_size_;
312 byte* new_base_end = new_end;
313 DCHECK_LE(new_base_end, old_base_end);
314 if (new_base_end == old_base_end) {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700315 return new MemMap(tail_name, nullptr, 0, nullptr, 0, tail_prot);
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700316 }
317 size_ = new_end - reinterpret_cast<byte*>(begin_);
318 base_size_ = new_base_end - reinterpret_cast<byte*>(base_begin_);
319 DCHECK_LE(begin_ + size_, reinterpret_cast<byte*>(base_begin_) + base_size_);
320 size_t tail_size = old_end - new_end;
321 byte* tail_base_begin = new_base_end;
322 size_t tail_base_size = old_base_end - new_base_end;
323 DCHECK_EQ(tail_base_begin + tail_base_size, old_base_end);
324 DCHECK(IsAligned<kPageSize>(tail_base_size));
325
326#ifdef USE_ASHMEM
327 // android_os_Debug.cpp read_mapinfo assumes all ashmem regions associated with the VM are
328 // prefixed "dalvik-".
329 std::string debug_friendly_name("dalvik-");
330 debug_friendly_name += tail_name;
331 ScopedFd fd(ashmem_create_region(debug_friendly_name.c_str(), tail_base_size));
Stuart Monteith8dba5aa2014-03-12 12:44:01 +0000332 int flags = MAP_PRIVATE | MAP_FIXED;
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700333 if (fd.get() == -1) {
334 *error_msg = StringPrintf("ashmem_create_region failed for '%s': %s",
335 tail_name, strerror(errno));
336 return nullptr;
337 }
338#else
339 ScopedFd fd(-1);
340 int flags = MAP_PRIVATE | MAP_ANONYMOUS;
341#endif
342
343 // Unmap/map the tail region.
344 int result = munmap(tail_base_begin, tail_base_size);
345 if (result == -1) {
346 std::string maps;
347 ReadFileToString("/proc/self/maps", &maps);
348 *error_msg = StringPrintf("munmap(%p, %zd) failed for '%s'\n%s",
349 tail_base_begin, tail_base_size, name_.c_str(),
350 maps.c_str());
351 return nullptr;
352 }
353 // Don't cause memory allocation between the munmap and the mmap
354 // calls. Otherwise, libc (or something else) might take this memory
355 // region. Note this isn't perfect as there's no way to prevent
356 // other threads to try to take this memory region here.
357 byte* actual = reinterpret_cast<byte*>(mmap(tail_base_begin, tail_base_size, tail_prot,
358 flags, fd.get(), 0));
359 if (actual == MAP_FAILED) {
360 std::string maps;
361 ReadFileToString("/proc/self/maps", &maps);
Mathieu Chartierc7cb1902014-03-05 14:41:03 -0800362 *error_msg = StringPrintf("anonymous mmap(%p, %zd, 0x%x, 0x%x, %d, 0) failed\n%s",
Hiroshi Yamauchifd7e7f12013-10-22 14:17:48 -0700363 tail_base_begin, tail_base_size, tail_prot, flags, fd.get(),
364 maps.c_str());
365 return nullptr;
366 }
367 return new MemMap(tail_name, actual, tail_size, actual, tail_base_size, tail_prot);
Mathieu Chartiercc236d72012-07-20 10:29:05 -0700368}
Logan Chiend88fa262012-06-06 15:23:32 +0800369
370bool MemMap::Protect(int prot) {
Hiroshi Yamauchi4fb5df82014-03-13 15:10:27 -0700371 if (base_begin_ == nullptr && base_size_ == 0) {
Ian Rogers1c849e52012-06-28 14:00:33 -0700372 prot_ = prot;
Logan Chiend88fa262012-06-06 15:23:32 +0800373 return true;
374 }
375
376 if (mprotect(base_begin_, base_size_, prot) == 0) {
Ian Rogers1c849e52012-06-28 14:00:33 -0700377 prot_ = prot;
Logan Chiend88fa262012-06-06 15:23:32 +0800378 return true;
379 }
380
Shih-wei Liaoa060ed92012-06-07 09:25:28 -0700381 PLOG(ERROR) << "mprotect(" << reinterpret_cast<void*>(base_begin_) << ", " << base_size_ << ", "
382 << prot << ") failed";
Logan Chiend88fa262012-06-06 15:23:32 +0800383 return false;
384}
385
Brian Carlstrom0d6adac2014-02-05 17:39:16 -0800386std::ostream& operator<<(std::ostream& os, const MemMap& mem_map) {
Mathieu Chartierc7cb1902014-03-05 14:41:03 -0800387 os << StringPrintf("[MemMap: %s prot=0x%x %p-%p]",
Brian Carlstrom0d6adac2014-02-05 17:39:16 -0800388 mem_map.GetName().c_str(), mem_map.GetProtect(),
389 mem_map.BaseBegin(), mem_map.BaseEnd());
390 return os;
391}
392
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700393} // namespace art