pmap_common.c revision 186f7fbf5e07d046b50e4e15c32b21f109b76c80
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * CDDL HEADER START
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * The contents of this file are subject to the terms of the
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * Common Development and Distribution License (the "License").
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * You may not use this file except in compliance with the License.
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * or http://www.opensolaris.org/os/licensing.
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * See the License for the specific language governing permissions
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * and limitations under the License.
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * When distributing Covered Code, include this CDDL HEADER in each
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * If applicable, add the following below this CDDL HEADER, with the
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * fields enclosed by brackets "[]" replaced with your own identifying
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * information: Portions Copyright [yyyy] [name of copyright owner]
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * CDDL HEADER END
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * Use is subject to license terms.
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * We compare the high memory addresses since stacks are faulted in from
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * high memory addresses to low memory addresses, and our prmap_t
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * structures identify only the range of addresses that have been faulted
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz uintptr_t a = (uintptr_t)as->lwps_stack.ss_sp + as->lwps_stack.ss_size;
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz uintptr_t b = (uintptr_t)bs->lwps_stack.ss_sp + bs->lwps_stack.ss_size;
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * Create labels for non-anon, non-heap mappings
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowiczmake_name(struct ps_prochandle *Pr, int lflag, uintptr_t addr,
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz const char *mapname, char *buf, size_t bufsz)
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz if (Pobjname(Pr, addr, buf, bufsz) != NULL)
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz if (Pobjname_resolved(Pr, addr, buf, bufsz) != NULL) {
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz /* Verify that the path exists */
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz if ((len = resolvepath(buf, buf, bufsz)) > 0) {
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz if (Pstate(Pr) == PS_DEAD || *mapname == '\0')
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz /* first see if we can find a path via /proc */
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (void) snprintf(path, sizeof (path), "/proc/%d/path/%s",
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz /* fall back to object information reported by /proc */
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz "/proc/%d/object/%s", (int)Psp->pr_pid, mapname);
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (void) snprintf(buf, bufsz, "dev:%lu,%lu ino:%lu",
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (ulong_t)major(dev), (ulong_t)minor(dev), ino);
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz * Create label for anon mappings
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowiczanon_name(char *name, const pstatus_t *Psp, lwpstack_t *stacks, uint_t nstacks,
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz uintptr_t vaddr, size_t size, int mflags, int shmid, int *mtypesp)
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (void) snprintf(name, PATH_MAX, " [ %s shmid=null ]",
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (mflags & MA_NORESERVE) ? "ism" : "dism");
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (void) snprintf(name, PATH_MAX, " [ %s shmid=0x%x ]",
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (mflags & MA_NORESERVE) ? "ism" : "dism", shmid);
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (void) sprintf(name, " [ shmid=0x%x ]", shmid);
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz } else if (vaddr + size > Psp->pr_stkbase &&
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz vaddr < Psp->pr_stkbase + Psp->pr_stksize) {
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz vaddr < Psp->pr_brkbase + Psp->pr_brksize) {
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (stk = bsearch(&key, stacks, nstacks, sizeof (stacks[0]),
186f7fbf5e07d046b50e4e15c32b21f109b76c80Edward Pilatowicz (void) snprintf(name, PATH_MAX, " [ %s tid=%d ]",