Pcontrol.h revision 186f7fbf5e07d046b50e4e15c32b21f109b76c80
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _PCONTROL_H
#define _PCONTROL_H
/*
* Implemention-specific include file for libproc process management.
* This is not to be seen by the clients of libproc.
*/
#include <stdio.h>
#include <gelf.h>
#include <synch.h>
#include <procfs.h>
#include <rtld_db.h>
#include <libproc.h>
#include <libctf.h>
#include <limits.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "Putil.h"
/*
* Definitions of the process control structures, internal to libproc.
* These may change without affecting clients of libproc.
*/
/*
* sym_tbl_t contains a primary and an (optional) auxiliary symbol table, which
* we wish to treat as a single logical symbol table. In this logical table,
* the data from the auxiliary table preceeds that from the primary. Symbol
* indices start at [0], which is the first item in the auxiliary table
* if there is one. The sole purpose for this is so that we can treat the
* combination of .SUNW_ldynsym and .dynsym sections as a logically single
* entity without having to violate the public interface to libelf.
*
* Both tables must share the same string table section.
*
* The symtab_getsym() function serves as a gelf_getsym() replacement
* that is aware of the two tables and makes them look like a single table
* to the caller.
*
*/
typedef struct sym_tbl { /* symbol table */
char *sym_strs; /* ptr to strings */
void *sym_elfmem; /* data for faked-up ELF handle */
} sym_tbl_t;
typedef struct file_info { /* symbol information for a mapped file */
int file_ref; /* references from map_info_t structures */
int file_fd; /* file descriptor for the mapped file */
int file_init; /* 0: initialization yet to be performed */
char *file_lname; /* load object name from rtld_db */
char *file_lbase; /* pointer to basename of file_lname */
char *file_rname; /* resolved on-disk object pathname */
char *file_rbase; /* pointer to basename of file_rname */
void *file_elfmem; /* data for faked-up ELF handle */
int file_ctf_dyn; /* does the CTF data reference the dynsym */
void *file_ctf_buf; /* CTF data for this file */
char *file_shstrs; /* section header string table */
} file_info_t;
typedef struct map_info { /* description of an address space mapping */
int map_relocate; /* associated file_map needs to be relocated */
} map_info_t;
typedef struct lwp_info { /* per-lwp information from core file */
#endif
} lwp_info_t;
typedef struct core_info { /* information specific to core files */
char core_dmodel; /* data model for core file */
int core_errno; /* error during initialization if != 0 */
char *core_platform; /* platform string from core file */
void *core_privinfo; /* system privileges info from core file */
char *core_zonename; /* zone name from core file */
#endif
} core_info_t;
typedef struct elf_file_header { /* extended ELF header */
typedef struct elf_file { /* convenience for managing ELF files */
int e_fd; /* file descriptor */
} elf_file_t;
typedef struct ps_rwops { /* ops vector for Pread() and Pwrite() */
} ps_rwops_t;
struct ps_prochandle {
int asfd; /* /proc/<pid>/as filedescriptor */
int ctlfd; /* /proc/<pid>/ctl filedescriptor */
int statfd; /* /proc/<pid>/status filedescriptor */
int agentctlfd; /* /proc/<pid>/lwp/agent/ctl */
int agentstatfd; /* /proc/<pid>/lwp/agent/status */
int info_valid; /* if zero, map and file info need updating */
char *execname; /* name of the executable file */
int nauxv; /* number of aux vector entries */
char *zoneroot; /* cached path to zone root */
};
/* flags */
struct ps_lwphandle {
int lwp_ctlfd; /* /proc/<pid>/lwp/<lwpid>/lwpctl */
int lwp_statfd; /* /proc/<pid>/lwp/<lwpid>/lwpstatus */
};
/*
* Implementation functions in the process control library.
* These are not exported to clients of the library.
*/
extern void prldump(const char *, lwpstatus_t *);
extern int dupfd(int, int);
extern int set_minfd(void);
extern int Pscantext(struct ps_prochandle *);
extern void Pinitsym(struct ps_prochandle *);
extern void Preadauxvec(struct ps_prochandle *);
extern void optimize_symtab(sym_tbl_t *);
extern char *Pfindexec(struct ps_prochandle *, const char *,
int (*)(const char *, void *), void *);
extern char *Pzonepath(struct ps_prochandle *, const char *, char *,
size_t);
size_t);
prmap_t *);
extern void Psort_mappings(struct ps_prochandle *);
extern char procfs_path[PATH_MAX];
/*
* Architecture-dependent definition of the breakpoint instruction.
*/
#endif
/*
* Simple convenience.
*/
#define TRUE 1
#define FALSE 0
#ifdef __cplusplus
}
#endif
#endif /* _PCONTROL_H */