1 .\" $NetBSD: pmap.1,v 1.14 2008/04/30 13:11:01 martin Exp $
3 .\" Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd display process memory map
51 utility lists the virtual memory mappings underlying the given
53 The start address of each entry is always given, and,
54 depending on the options given, other information such as the end
55 address, the underlying file's device and inode numbers, and various
56 protection information will be displayed, along with the path to the
57 file, if such data is available.
61 displays information for its parent process, so that when run from a
62 shell prompt, the shell's memory information is displayed.
64 PIDs are given as arguments on the command line, information for those
65 processes will be printed also.
66 If the special PID of 0 is given,
67 then information for the kernel's memory map is printed.
69 The options are as follows:
70 .Bl -tag -width XXXnumberXX
72 Dumps the vm_amap structure found at
77 information from the process's memory map.
79 mode is an amalgam of the contents of the Solaris, Linux, and
83 Enable various debug facilities.
86 is a bit mask of the values:
88 .Bl -tag -width 0x1000 -compact
90 dump the process's vmspace structure
92 dump the process's vm_map structure
94 dump the vm_map.header structure
96 dump each vm_map_entry in its entirety
98 dump the vm_amap structure attached to the vm_map_entry, if applicable
100 dump the vm_amap slot data, if present (requires 0x10)
102 dump the vm_anon data from the am_anon array, if present (requires 0x20)
104 dump the namei cache as it is traversed
107 Dumps the vm_map and vm_map_entry structures in a style similar to
110 When combined with the
112 option, the device number, inode number, name, vnode addresses, or
113 other identifying information from the vm_map_entries will be printed.
115 Dumps the vm_map_entry structure found at
118 Dumps information in a format like the contents of the maps
119 pseudo-file under the
121 file system which was, in turn, modeled after the similarly named entry
125 When combined with the
127 option, identifiers for all entries are printed.
129 Extract values associated with the name list from the specified core
130 instead of the default
133 Dumps information in the same format as the map pseudo-file of the
138 option is also given, device number, inode number, and filename
139 or other identifying information is printed.
141 Extract the name list from the specified system instead of the default
146 to print information about itself.
150 to print information about the given process.
153 occurs last on the command line, the
157 Recurse into submaps.
158 In some cases, a vm_map_entry in the kernel
159 will point to a submap.
160 Using this flag tells
162 to print the entries of the submap as well.
164 indented, and does not affect any total printed at the bottom of the
167 Dumps the vmspace structure found at
170 The Solaris style output format, modeled after the Solaris command of
172 This is the default output style.
174 Dumps the vm_map structure found at
176 Note that if you print the vm_map of a process, there may not be a way
177 to properly determine which map entries are related to the stack.
185 more information is printed, possibly including device and inode
186 numbers, file path names, or other identifying information.
187 If specified more than once, a small note will be printed in between
188 two entries that are not adjacent, making the visual identification of
189 spaces in the process's map easier to see, that indicates the number
190 of pages and the amount of memory space that is skipped.
197 options override each other, so the last one to appear on the command
199 If you do wish to see information about
201 and another process as the same time, simply omit the
203 and place the extra PID at the end of the command line.
206 exits 0 on success, and \*[Gt]0 if an error occurred.
208 While the meaning of most of the output is self-evident, some pieces of
209 it may appear to be a little inscrutable.
211 Here is a portion of the default output from
215 prompt showing the starting address of the map entry, the size of the
216 map entry, the current protection level of the map entry, and either
217 the name of the file backing the entry or some other descriptive text.
218 .Bd -literal -offset indent
220 08048000 420K read/exec /bin/sh
221 080B1000 8K read/write /bin/sh
222 080B3000 28K read/write [ anon ]
223 080BA000 16K read/write/exec [ heap ]
229 output style is selected, the first thing printed is the contents of
230 the vm_map structure, followed by the individual map entries.
231 .Bd -literal -offset indent
233 MAP 0xcf7cac84: [0x0-\*[Gt]0xbfbfe000]
234 #ent=8, sz=34041856, ref=1, version=20, flags=0x41
235 pmap=0xcf44cee0(resident=\*[Lt]unknown\*[Gt])
236 - 0xcfa3a358: 0x8048000-\*[Gt]0x80b1000: obj=0xcf45a8e8/0x0, amap=0x0/0
237 submap=F, cow=T, nc=T, prot(max)=5/7, inh=1, wc=0, adv=0
241 The value of the flags field (in hexadecimal) is taken from
243 .Aq Pa uvm/uvm_map.h :
244 .Bl -column VM_MAP_WIREFUTURE VM_MAP_WIREFUTURE -offset indent
245 .It Dv "VM_MAP_PAGEABLE" Ta No "0x01 entries are pageable"
246 .It Dv "VM_MAP_INTRSAFE" Ta No "0x02 interrupt safe map"
247 .It Dv "VM_MAP_WIREFUTURE" Ta No "0x04 future mappings are wired
248 .It Dv "VM_MAP_BUSY" Ta No "0x08 map is busy
249 .It Dv "VM_MAP_WANTLOCK" Ta No "0x10 want to write-lock
250 .It Dv "VM_MAP_DYING" Ta No "0x20 map is being destroyed
251 .It Dv "VM_MAP_TOPDOWN" Ta No "0x40 arrange map top-down
259 fields are true or false, and indicate whether the map is a submap,
260 whether it is marked for copy on write, and whether it needs a copy.
263 \&(or protection) field, along with
265 \&(maximum protection allowed) are made up of the following flags from
266 .Aq Pa uvm/uvm_extern.h :
267 .\" this column width specifically chosen so that all the header file
268 .\" excerpts appear to line up cleanly
269 .Bl -column VM_MAP_WIREFUTURE VM_MAP_WIREFUTURE -offset indent
270 .It Dv "UVM_PROT_READ" Ta No "0x01 read allowed"
271 .It Dv "UVM_PROT_WRITE" Ta No "0x02 write allowed"
272 .It Dv "UVM_PROT_EXEC" Ta No "0x04 execute allowed"
279 fields are pointers to, and offsets into, the underlying uvm_object or
281 The value for resident is always unknown because digging such
282 information out of the kernel is beyond the scope of this application.
284 The two output styles that mirror the contents of the
288 .Bd -literal -offset indent
290 0x8048000 0x80b1000 r-x rwx COW NC 1 0 0
291 0x80b1000 0x80b3000 rw- rwx COW NC 1 0 0
292 0x80b3000 0x80ba000 rw- rwx COW NNC 1 0 0
293 0x80ba000 0x80be000 rwx rwx COW NNC 1 0 0
297 08048000-080b1000 r-xp 00000000 00:00 70173 /bin/sh
298 080b1000-080b3000 rw-p 00068000 00:00 70173 /bin/sh
299 080b3000-080ba000 rw-p 00000000 00:00 0
300 080ba000-080be000 rwxp 00000000 00:00 0
304 Here the protection and maximum protection values are indicated with
309 characters, indicating read permission, write permission, and execute
310 permission, respectively.
316 values that follow indicate, again, that the map is marked for copy on
317 write and either needs or does not need a copy.
321 here, which indicates that an entry will not be copied.
323 following numbers indicate the inheritance type of the map, the wired
324 count of the map, and any advice value assigned via
327 In the second form, the permissions indicated are followed by a
331 character indicating whether the map entry is private or shared (copy
332 on write or not), and the numbers are the offset into the underlying
333 object, the device and numbers of the object if it is a file, and the
334 path to the file (if available).
336 As noted above (see section
340 output format is an amalgam of the previous output formats.
341 .Bd -literal -offset indent
343 Start End Size Offset rwxpc RWX I/W/A ...
344 08048000-080b0fff 420k 00000000 r-xp+ (rwx) 1/0/0 ...
348 In this format, the column labeled
350 contains the permissions for the mapping along with the shared/private
351 flag, and a character indicating whether the mapping needs to be
354 or has already been copied
356 and is followed by a column that indicates the maximum permissions for
360 indicates the inheritance, wired, and advice values for the map entry,
361 as previously described.
362 The pointer value at the end of the output line for entries backed by
363 vnodes is the address of the vnode in question.
381 utility and documentation was written by
383 .Aq atatat@NetBSD.org .
385 Very little will work unless
387 is reading from the correct kernel in order to retrieve the
388 proper symbol information.
390 Since processes can change state while
392 is running, some of the information printed may be inaccurate.
394 is especially important to consider when examining the kernel's map,
395 since merely executing
397 will cause some of the information to change.
399 The pathnames to files backing certain vnodes (such as the text and
400 data sections of programs and shared libraries) are extracted from the
401 kernel's namei cache which is considerably volatile.
403 found there in its entirety, as much information as was available
405 In most cases, simply running
409 with the expected path to the file will cause the information to be
410 reentered into the cache.
412 The Solaris command by the same name has some interesting command line
413 flags that would be nice to emulate here.
416 option that lists a process's reserved addresses, and the
418 option that prints resident/shared/private mapping details for each
421 Some of the output modes can be or are wider than the standard 80
422 columns of a terminal.
423 Some sort of formatting might be nice.
424 .Sh SECURITY CONSIDERATIONS
425 The Solaris command controls access to processes the user does not own
426 via the permissions of its
433 to read the requested data directly from kernel memory, no such
444 options are used, any extra privileges that