xref: /titanic_50/usr/src/lib/libproc/common/Pcontrol.h (revision 186f7fbf5e07d046b50e4e15c32b21f109b76c80)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
59acbbeafSnn35248  * Common Development and Distribution License (the "License").
69acbbeafSnn35248  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*186f7fbfSEdward Pilatowicz  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_PCONTROL_H
277c478bd9Sstevel@tonic-gate #define	_PCONTROL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Implemention-specific include file for libproc process management.
317c478bd9Sstevel@tonic-gate  * This is not to be seen by the clients of libproc.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <stdio.h>
357c478bd9Sstevel@tonic-gate #include <gelf.h>
367c478bd9Sstevel@tonic-gate #include <synch.h>
377c478bd9Sstevel@tonic-gate #include <procfs.h>
387c478bd9Sstevel@tonic-gate #include <rtld_db.h>
397c478bd9Sstevel@tonic-gate #include <libproc.h>
407c478bd9Sstevel@tonic-gate #include <libctf.h>
419acbbeafSnn35248 #include <limits.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
447c478bd9Sstevel@tonic-gate extern "C" {
457c478bd9Sstevel@tonic-gate #endif
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #include "Putil.h"
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * Definitions of the process control structures, internal to libproc.
517c478bd9Sstevel@tonic-gate  * These may change without affecting clients of libproc.
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate 
54d51e9074Sab196087 /*
55d51e9074Sab196087  * sym_tbl_t contains a primary and an (optional) auxiliary symbol table, which
56d51e9074Sab196087  * we wish to treat as a single logical symbol table. In this logical table,
57d51e9074Sab196087  * the data from the auxiliary table preceeds that from the primary. Symbol
58d51e9074Sab196087  * indices start at [0], which is the first item in the auxiliary table
59d51e9074Sab196087  * if there is one. The sole purpose for this is so that we can treat the
60d51e9074Sab196087  * combination of .SUNW_ldynsym and .dynsym sections as a logically single
61d51e9074Sab196087  * entity without having to violate the public interface to libelf.
62d51e9074Sab196087  *
63d51e9074Sab196087  * Both tables must share the same string table section.
64d51e9074Sab196087  *
65d51e9074Sab196087  * The symtab_getsym() function serves as a gelf_getsym() replacement
66d51e9074Sab196087  * that is aware of the two tables and makes them look like a single table
67d51e9074Sab196087  * to the caller.
68d51e9074Sab196087  *
69d51e9074Sab196087  */
7030da1432Sahl typedef struct sym_tbl {	/* symbol table */
71d51e9074Sab196087 	Elf_Data *sym_data_pri;	/* primary table */
72d51e9074Sab196087 	Elf_Data *sym_data_aux;	/* auxiliary table */
73d51e9074Sab196087 	size_t	sym_symn_aux;	/* number of entries in auxiliary table */
74d51e9074Sab196087 	size_t	sym_symn;	/* total number of entries in both tables */
757c478bd9Sstevel@tonic-gate 	char	*sym_strs;	/* ptr to strings */
767c478bd9Sstevel@tonic-gate 	size_t	sym_strsz;	/* size of string table */
77d51e9074Sab196087 	GElf_Shdr sym_hdr_pri;	/* primary symbol table section header */
78d51e9074Sab196087 	GElf_Shdr sym_hdr_aux;	/* auxiliary symbol table section header */
797c478bd9Sstevel@tonic-gate 	GElf_Shdr sym_strhdr;	/* string table section header */
8030da1432Sahl 	Elf	*sym_elf;	/* faked-up ELF handle from core file */
8130da1432Sahl 	void	*sym_elfmem;	/* data for faked-up ELF handle */
827c478bd9Sstevel@tonic-gate 	uint_t	*sym_byname;	/* symbols sorted by name */
837c478bd9Sstevel@tonic-gate 	uint_t	*sym_byaddr;	/* symbols sorted by addr */
847c478bd9Sstevel@tonic-gate 	size_t	sym_count;	/* number of symbols in each sorted list */
857c478bd9Sstevel@tonic-gate } sym_tbl_t;
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate typedef struct file_info {	/* symbol information for a mapped file */
88fa9e4066Sahrens 	plist_t	file_list;	/* linked list */
897c478bd9Sstevel@tonic-gate 	char	file_pname[PRMAPSZ];	/* name from prmap_t */
907c478bd9Sstevel@tonic-gate 	struct map_info *file_map;	/* primary (text) mapping */
917c478bd9Sstevel@tonic-gate 	int	file_ref;	/* references from map_info_t structures */
927c478bd9Sstevel@tonic-gate 	int	file_fd;	/* file descriptor for the mapped file */
937c478bd9Sstevel@tonic-gate 	int	file_init;	/* 0: initialization yet to be performed */
947c478bd9Sstevel@tonic-gate 	GElf_Half file_etype;	/* ELF e_type from ehdr */
957c478bd9Sstevel@tonic-gate 	GElf_Half file_class;	/* ELF e_ident[EI_CLASS] from ehdr */
967c478bd9Sstevel@tonic-gate 	rd_loadobj_t *file_lo;	/* load object structure from rtld_db */
977c478bd9Sstevel@tonic-gate 	char	*file_lname;	/* load object name from rtld_db */
987c478bd9Sstevel@tonic-gate 	char	*file_lbase;	/* pointer to basename of file_lname */
99*186f7fbfSEdward Pilatowicz 	char	*file_rname;	/* resolved on-disk object pathname */
100*186f7fbfSEdward Pilatowicz 	char	*file_rbase;	/* pointer to basename of file_rname */
10130da1432Sahl 	Elf	*file_elf;	/* ELF handle so we can close */
10230da1432Sahl 	void	*file_elfmem;	/* data for faked-up ELF handle */
1037c478bd9Sstevel@tonic-gate 	sym_tbl_t file_symtab;	/* symbol table */
1047c478bd9Sstevel@tonic-gate 	sym_tbl_t file_dynsym;	/* dynamic symbol table */
1057c478bd9Sstevel@tonic-gate 	uintptr_t file_dyn_base;	/* load address for ET_DYN files */
1067c478bd9Sstevel@tonic-gate 	uintptr_t file_plt_base;	/* base address for PLT */
1077c478bd9Sstevel@tonic-gate 	size_t	file_plt_size;	/* size of PLT region */
1087c478bd9Sstevel@tonic-gate 	uintptr_t file_jmp_rel;	/* base address of PLT relocations */
1097c478bd9Sstevel@tonic-gate 	uintptr_t file_ctf_off;	/* offset of CTF data in object file */
1107c478bd9Sstevel@tonic-gate 	size_t	file_ctf_size;	/* size of CTF data in object file */
1117c478bd9Sstevel@tonic-gate 	int	file_ctf_dyn;	/* does the CTF data reference the dynsym */
1127c478bd9Sstevel@tonic-gate 	void	*file_ctf_buf;	/* CTF data for this file */
1137c478bd9Sstevel@tonic-gate 	ctf_file_t *file_ctfp;	/* CTF container for this file */
114f957ecc1Svb160487 	char	*file_shstrs;	/* section header string table */
115f957ecc1Svb160487 	size_t	file_shstrsz;	/* section header string table size */
11612e72dbbSrh87107 	uintptr_t *file_saddrs; /* section header addresses */
11712e72dbbSrh87107 	uint_t  file_nsaddrs;   /* number of section header addresses */
1187c478bd9Sstevel@tonic-gate } file_info_t;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate typedef struct map_info {	/* description of an address space mapping */
1217c478bd9Sstevel@tonic-gate 	prmap_t	map_pmap;	/* /proc description of this mapping */
1227c478bd9Sstevel@tonic-gate 	file_info_t *map_file;	/* pointer into list of mapped files */
1237c478bd9Sstevel@tonic-gate 	off64_t map_offset;	/* offset into core file (if core) */
1247c478bd9Sstevel@tonic-gate 	int map_relocate;	/* associated file_map needs to be relocated */
1257c478bd9Sstevel@tonic-gate } map_info_t;
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate typedef struct lwp_info {	/* per-lwp information from core file */
128fa9e4066Sahrens 	plist_t	lwp_list;	/* linked list */
1297c478bd9Sstevel@tonic-gate 	lwpid_t	lwp_id;		/* lwp identifier */
1307c478bd9Sstevel@tonic-gate 	lwpsinfo_t lwp_psinfo;	/* /proc/<pid>/lwp/<lwpid>/lwpsinfo data */
1317c478bd9Sstevel@tonic-gate 	lwpstatus_t lwp_status;	/* /proc/<pid>/lwp/<lwpid>/lwpstatus data */
1327c478bd9Sstevel@tonic-gate #if defined(sparc) || defined(__sparc)
1337c478bd9Sstevel@tonic-gate 	gwindows_t *lwp_gwins;	/* /proc/<pid>/lwp/<lwpid>/gwindows data */
1347c478bd9Sstevel@tonic-gate 	prxregset_t *lwp_xregs;	/* /proc/<pid>/lwp/<lwpid>/xregs data */
1357c478bd9Sstevel@tonic-gate 	int64_t *lwp_asrs;	/* /proc/<pid>/lwp/<lwpid>/asrs data */
1367c478bd9Sstevel@tonic-gate #endif
1377c478bd9Sstevel@tonic-gate } lwp_info_t;
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate typedef struct core_info {	/* information specific to core files */
1407c478bd9Sstevel@tonic-gate 	char core_dmodel;	/* data model for core file */
1417c478bd9Sstevel@tonic-gate 	int core_errno;		/* error during initialization if != 0 */
142fa9e4066Sahrens 	plist_t core_lwp_head;	/* head of list of lwp info */
1437c478bd9Sstevel@tonic-gate 	lwp_info_t *core_lwp;	/* current lwp information */
1447c478bd9Sstevel@tonic-gate 	uint_t core_nlwp;	/* number of lwp's in list */
1457c478bd9Sstevel@tonic-gate 	off64_t core_size;	/* size of core file in bytes */
1467c478bd9Sstevel@tonic-gate 	char *core_platform;	/* platform string from core file */
1477c478bd9Sstevel@tonic-gate 	struct utsname *core_uts;	/* uname(2) data from core file */
1487c478bd9Sstevel@tonic-gate 	prcred_t *core_cred;	/* process credential from core file */
1497c478bd9Sstevel@tonic-gate 	core_content_t core_content;	/* content dumped to core file */
1507c478bd9Sstevel@tonic-gate 	prpriv_t *core_priv;	/* process privileges from core file */
1517c478bd9Sstevel@tonic-gate 	size_t core_priv_size;	/* size of the privileges */
1527c478bd9Sstevel@tonic-gate 	void *core_privinfo;	/* system privileges info from core file */
1537c478bd9Sstevel@tonic-gate 	priv_impl_info_t *core_ppii;	/* NOTE entry for core_privinfo */
1547c478bd9Sstevel@tonic-gate 	char *core_zonename;	/* zone name from core file */
1557c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
1567c478bd9Sstevel@tonic-gate 	struct ssd *core_ldt;	/* LDT entries from core file */
1577c478bd9Sstevel@tonic-gate 	uint_t core_nldt;	/* number of LDT entries in core file */
1587c478bd9Sstevel@tonic-gate #endif
1597c478bd9Sstevel@tonic-gate } core_info_t;
1607c478bd9Sstevel@tonic-gate 
16130da1432Sahl typedef struct elf_file_header { /* extended ELF header */
16230da1432Sahl 	unsigned char e_ident[EI_NIDENT];
16330da1432Sahl 	Elf64_Half e_type;
16430da1432Sahl 	Elf64_Half e_machine;
16530da1432Sahl 	Elf64_Word e_version;
16630da1432Sahl 	Elf64_Addr e_entry;
16730da1432Sahl 	Elf64_Off e_phoff;
16830da1432Sahl 	Elf64_Off e_shoff;
16930da1432Sahl 	Elf64_Word e_flags;
17030da1432Sahl 	Elf64_Half e_ehsize;
17130da1432Sahl 	Elf64_Half e_phentsize;
17230da1432Sahl 	Elf64_Half e_shentsize;
17330da1432Sahl 	Elf64_Word e_phnum;	/* phdr count extended to 32 bits */
17430da1432Sahl 	Elf64_Word e_shnum;	/* shdr count extended to 32 bits */
17530da1432Sahl 	Elf64_Word e_shstrndx;	/* shdr string index extended to 32 bits */
17630da1432Sahl } elf_file_header_t;
17730da1432Sahl 
1787c478bd9Sstevel@tonic-gate typedef struct elf_file {	/* convenience for managing ELF files */
17930da1432Sahl 	elf_file_header_t e_hdr; /* Extended ELF header */
1807c478bd9Sstevel@tonic-gate 	Elf *e_elf;		/* ELF library handle */
1817c478bd9Sstevel@tonic-gate 	int e_fd;		/* file descriptor */
1827c478bd9Sstevel@tonic-gate } elf_file_t;
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate typedef struct ps_rwops {	/* ops vector for Pread() and Pwrite() */
1857c478bd9Sstevel@tonic-gate 	ssize_t (*p_pread)(struct ps_prochandle *,
1867c478bd9Sstevel@tonic-gate 	    void *, size_t, uintptr_t);
1877c478bd9Sstevel@tonic-gate 	ssize_t (*p_pwrite)(struct ps_prochandle *,
1887c478bd9Sstevel@tonic-gate 	    const void *, size_t, uintptr_t);
1897c478bd9Sstevel@tonic-gate } ps_rwops_t;
1907c478bd9Sstevel@tonic-gate 
1917c478bd9Sstevel@tonic-gate #define	HASHSIZE		1024	/* hash table size, power of 2 */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate struct ps_prochandle {
1947c478bd9Sstevel@tonic-gate 	struct ps_lwphandle **hashtab;	/* hash table for LWPs (Lgrab()) */
1957c478bd9Sstevel@tonic-gate 	mutex_t	proc_lock;	/* protects hash table; serializes Lgrab() */
1967c478bd9Sstevel@tonic-gate 	pstatus_t orig_status;	/* remembered status on Pgrab() */
1977c478bd9Sstevel@tonic-gate 	pstatus_t status;	/* status when stopped */
1987c478bd9Sstevel@tonic-gate 	psinfo_t psinfo;	/* psinfo_t from last Ppsinfo() request */
1997c478bd9Sstevel@tonic-gate 	uintptr_t sysaddr;	/* address of most recent syscall instruction */
2007c478bd9Sstevel@tonic-gate 	pid_t	pid;		/* process-ID */
2017c478bd9Sstevel@tonic-gate 	int	state;		/* state of the process, see "libproc.h" */
2027c478bd9Sstevel@tonic-gate 	uint_t	flags;		/* see defines below */
2037c478bd9Sstevel@tonic-gate 	uint_t	agentcnt;	/* Pcreate_agent()/Pdestroy_agent() ref count */
2047c478bd9Sstevel@tonic-gate 	int	asfd;		/* /proc/<pid>/as filedescriptor */
2057c478bd9Sstevel@tonic-gate 	int	ctlfd;		/* /proc/<pid>/ctl filedescriptor */
2067c478bd9Sstevel@tonic-gate 	int	statfd;		/* /proc/<pid>/status filedescriptor */
2077c478bd9Sstevel@tonic-gate 	int	agentctlfd;	/* /proc/<pid>/lwp/agent/ctl */
2087c478bd9Sstevel@tonic-gate 	int	agentstatfd;	/* /proc/<pid>/lwp/agent/status */
2097c478bd9Sstevel@tonic-gate 	int	info_valid;	/* if zero, map and file info need updating */
2107c478bd9Sstevel@tonic-gate 	map_info_t *mappings;	/* cached process mappings */
2117c478bd9Sstevel@tonic-gate 	size_t	map_count;	/* number of mappings */
2127c478bd9Sstevel@tonic-gate 	size_t	map_alloc;	/* number of mappings allocated */
2137c478bd9Sstevel@tonic-gate 	uint_t	num_files;	/* number of file elements in file_info */
214fa9e4066Sahrens 	plist_t	file_head;	/* head of mapped files w/ symbol table info */
2157c478bd9Sstevel@tonic-gate 	char	*execname;	/* name of the executable file */
2167c478bd9Sstevel@tonic-gate 	auxv_t	*auxv;		/* the process's aux vector */
2177c478bd9Sstevel@tonic-gate 	int	nauxv;		/* number of aux vector entries */
2187c478bd9Sstevel@tonic-gate 	rd_agent_t *rap;	/* cookie for rtld_db */
2197c478bd9Sstevel@tonic-gate 	map_info_t *map_exec;	/* the mapping for the executable file */
2207c478bd9Sstevel@tonic-gate 	map_info_t *map_ldso;	/* the mapping for ld.so.1 */
2217c478bd9Sstevel@tonic-gate 	const ps_rwops_t *ops;	/* pointer to ops-vector for read and write */
2227c478bd9Sstevel@tonic-gate 	core_info_t *core;	/* information specific to core (if PS_DEAD) */
2237c478bd9Sstevel@tonic-gate 	uintptr_t *ucaddrs;	/* ucontext-list addresses */
2247c478bd9Sstevel@tonic-gate 	uint_t	ucnelems;	/* number of elements in the ucaddrs list */
225*186f7fbfSEdward Pilatowicz 	char	*zoneroot;	/* cached path to zone root */
2267c478bd9Sstevel@tonic-gate };
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate /* flags */
2297c478bd9Sstevel@tonic-gate #define	CREATED		0x01	/* process was created by Pcreate() */
2307c478bd9Sstevel@tonic-gate #define	SETSIG		0x02	/* set signal trace mask before continuing */
2317c478bd9Sstevel@tonic-gate #define	SETFAULT	0x04	/* set fault trace mask before continuing */
2327c478bd9Sstevel@tonic-gate #define	SETENTRY	0x08	/* set sysentry trace mask before continuing */
2337c478bd9Sstevel@tonic-gate #define	SETEXIT		0x10	/* set sysexit trace mask before continuing */
2347c478bd9Sstevel@tonic-gate #define	SETHOLD		0x20	/* set signal hold mask before continuing */
2357c478bd9Sstevel@tonic-gate #define	SETREGS		0x40	/* set registers before continuing */
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate struct ps_lwphandle {
2387c478bd9Sstevel@tonic-gate 	struct ps_prochandle *lwp_proc;	/* process to which this lwp belongs */
2397c478bd9Sstevel@tonic-gate 	struct ps_lwphandle *lwp_hash;	/* hash table linked list */
2407c478bd9Sstevel@tonic-gate 	lwpstatus_t	lwp_status;	/* status when stopped */
2417c478bd9Sstevel@tonic-gate 	lwpsinfo_t	lwp_psinfo;	/* lwpsinfo_t from last Lpsinfo() */
2427c478bd9Sstevel@tonic-gate 	lwpid_t		lwp_id;		/* lwp identifier */
2437c478bd9Sstevel@tonic-gate 	int		lwp_state;	/* state of the lwp, see "libproc.h" */
2447c478bd9Sstevel@tonic-gate 	uint_t		lwp_flags;	/* SETHOLD and/or SETREGS */
2457c478bd9Sstevel@tonic-gate 	int		lwp_ctlfd;	/* /proc/<pid>/lwp/<lwpid>/lwpctl */
2467c478bd9Sstevel@tonic-gate 	int		lwp_statfd;	/* /proc/<pid>/lwp/<lwpid>/lwpstatus */
2477c478bd9Sstevel@tonic-gate };
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate /*
2507c478bd9Sstevel@tonic-gate  * Implementation functions in the process control library.
2517c478bd9Sstevel@tonic-gate  * These are not exported to clients of the library.
2527c478bd9Sstevel@tonic-gate  */
2537c478bd9Sstevel@tonic-gate extern	void	prldump(const char *, lwpstatus_t *);
2547c478bd9Sstevel@tonic-gate extern	int	dupfd(int, int);
2557c478bd9Sstevel@tonic-gate extern	int	set_minfd(void);
2567c478bd9Sstevel@tonic-gate extern	int	Pscantext(struct ps_prochandle *);
2577c478bd9Sstevel@tonic-gate extern	void	Pinitsym(struct ps_prochandle *);
2587c478bd9Sstevel@tonic-gate extern	void	Preadauxvec(struct ps_prochandle *);
2597c478bd9Sstevel@tonic-gate extern	void	optimize_symtab(sym_tbl_t *);
2607c478bd9Sstevel@tonic-gate extern	void	Pbuild_file_symtab(struct ps_prochandle *, file_info_t *);
2617c478bd9Sstevel@tonic-gate extern	ctf_file_t *Pbuild_file_ctf(struct ps_prochandle *, file_info_t *);
2627c478bd9Sstevel@tonic-gate extern	map_info_t *Paddr2mptr(struct ps_prochandle *, uintptr_t);
2637c478bd9Sstevel@tonic-gate extern	char 	*Pfindexec(struct ps_prochandle *, const char *,
2647c478bd9Sstevel@tonic-gate 	int (*)(const char *, void *), void *);
2657c478bd9Sstevel@tonic-gate extern	int	getlwpstatus(struct ps_prochandle *, lwpid_t, lwpstatus_t *);
2667c478bd9Sstevel@tonic-gate int	Pstopstatus(struct ps_prochandle *, long, uint32_t);
267d7755b5aSrh87107 extern	file_info_t *file_info_new(struct ps_prochandle *, map_info_t *);
268*186f7fbfSEdward Pilatowicz extern	char	*Plofspath(const char *, char *, size_t);
269*186f7fbfSEdward Pilatowicz extern	char	*Pzoneroot(struct ps_prochandle *, char *, size_t);
270*186f7fbfSEdward Pilatowicz extern	char	*Pzonepath(struct ps_prochandle *, const char *, char *,
271*186f7fbfSEdward Pilatowicz 	size_t);
272*186f7fbfSEdward Pilatowicz extern	char	*Pfindmap(struct ps_prochandle *, map_info_t *, char *,
273*186f7fbfSEdward Pilatowicz 	size_t);
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate extern	int	Padd_mapping(struct ps_prochandle *, off64_t, file_info_t *,
2767c478bd9Sstevel@tonic-gate     prmap_t *);
2777c478bd9Sstevel@tonic-gate extern	void	Psort_mappings(struct ps_prochandle *);
2787c478bd9Sstevel@tonic-gate 
2799acbbeafSnn35248 extern char	procfs_path[PATH_MAX];
280fa9e4066Sahrens 
2817c478bd9Sstevel@tonic-gate /*
2827c478bd9Sstevel@tonic-gate  * Architecture-dependent definition of the breakpoint instruction.
2837c478bd9Sstevel@tonic-gate  */
2847c478bd9Sstevel@tonic-gate #if defined(sparc) || defined(__sparc)
2857c478bd9Sstevel@tonic-gate #define	BPT	((instr_t)0x91d02001)
2867c478bd9Sstevel@tonic-gate #elif defined(__i386) || defined(__amd64)
2877c478bd9Sstevel@tonic-gate #define	BPT	((instr_t)0xcc)
2887c478bd9Sstevel@tonic-gate #endif
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  * Simple convenience.
2927c478bd9Sstevel@tonic-gate  */
2937c478bd9Sstevel@tonic-gate #define	TRUE	1
2947c478bd9Sstevel@tonic-gate #define	FALSE	0
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2977c478bd9Sstevel@tonic-gate }
2987c478bd9Sstevel@tonic-gate #endif
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate #endif	/* _PCONTROL_H */
301