WIP kinfo_file/kinfo_vmmentry tweaks. The idea:
1) to get the 32 and 64 bit versions in sync so that no shims are needed, Valgrind in particular excercises this. and: 2) reduce the size of the copyout. On large processes this turns out to be a huge problem. Valgrind also suffers from this since it needs to do this in a context that can't malloc. I want to pack the records. 3) Add new types.. 'tell me about fd N' and 'tell me about addr N'.
This commit is contained in:
parent
d8aff71262
commit
83dc2280ce
@ -2509,6 +2509,10 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS)
|
||||
SYSCTL_PROC(_kern, KERN_FILE, file, CTLTYPE_OPAQUE|CTLFLAG_RD,
|
||||
0, 0, sysctl_kern_file, "S,xfile", "Entire file table");
|
||||
|
||||
#ifdef KINFO_FILE_SIZE
|
||||
CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE);
|
||||
#endif
|
||||
|
||||
static int
|
||||
export_vnode_for_sysctl(struct vnode *vp, int type,
|
||||
struct kinfo_file *kif, struct filedesc *fdp, struct sysctl_req *req)
|
||||
|
@ -1337,6 +1337,10 @@ sysctl_kern_proc_sv_name(SYSCTL_HANDLER_ARGS)
|
||||
return (sysctl_handle_string(oidp, sv_name, 0, req));
|
||||
}
|
||||
|
||||
#ifdef KINFO_VMENTRY_SIZE
|
||||
CTASSERT(sizeof(struct kinfo_vmentry) == KINFO_VMENTRY_SIZE);
|
||||
#endif
|
||||
|
||||
static int
|
||||
sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
@ -1461,9 +1465,9 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
|
||||
kve->kve_shadow_count = 0;
|
||||
}
|
||||
|
||||
kve->kve_start = (void*)entry->start;
|
||||
kve->kve_end = (void*)entry->end;
|
||||
kve->kve_offset = (off_t)entry->offset;
|
||||
kve->kve_start = entry->start;
|
||||
kve->kve_end = entry->end;
|
||||
kve->kve_offset = entry->offset;
|
||||
|
||||
if (entry->protection & VM_PROT_READ)
|
||||
kve->kve_protection |= KVME_PROT_READ;
|
||||
|
@ -236,6 +236,9 @@ struct user {
|
||||
struct kinfo_proc u_kproc; /* eproc */
|
||||
};
|
||||
|
||||
/* When exporting paths via sysctl, give a short version */
|
||||
#define KPROC_PATH_MAX 256
|
||||
|
||||
/*
|
||||
* The KERN_PROC_FILE sysctl allows a process to dump the file descriptor
|
||||
* array of another process.
|
||||
@ -277,20 +280,25 @@ struct user {
|
||||
#define KF_FLAG_DIRECT 0x00000040
|
||||
#define KF_FLAG_HASLOCK 0x00000080
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
#define KINFO_FILE_SIZE 560
|
||||
#endif
|
||||
|
||||
struct kinfo_file {
|
||||
int kf_structsize; /* Size of kinfo_file. */
|
||||
int kf_type; /* Descriptor type. */
|
||||
int kf_fd; /* Array index. */
|
||||
int kf_ref_count; /* Reference count. */
|
||||
int kf_flags; /* Flags. */
|
||||
off_t kf_offset; /* Seek location. */
|
||||
int _kf_pad0; /* Alignment */
|
||||
uint64_t kf_offset; /* Seek location. */
|
||||
int kf_vnode_type; /* Vnode type. */
|
||||
int kf_sock_domain; /* Socket domain. */
|
||||
int kf_sock_type; /* Socket type. */
|
||||
int kf_sock_protocol; /* Socket protocol. */
|
||||
char kf_path[PATH_MAX]; /* Path to file, if any. */
|
||||
struct sockaddr_storage kf_sa_local; /* Socket address. */
|
||||
struct sockaddr_storage kf_sa_peer; /* Peer address. */
|
||||
char kf_path[KPROC_PATH_MAX]; /* Path to file, if any. */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -313,23 +321,26 @@ struct kinfo_file {
|
||||
#define KVME_FLAG_COW 0x00000001
|
||||
#define KVME_FLAG_NEEDS_COPY 0x00000002
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
#define KINFO_VMENTRY_SIZE 384
|
||||
#endif
|
||||
|
||||
struct kinfo_vmentry {
|
||||
int kve_structsize; /* Size of kinfo_vmmapentry. */
|
||||
int kve_type; /* Type of map entry. */
|
||||
void *kve_start; /* Starting pointer. */
|
||||
void *kve_end; /* Finishing pointer. */
|
||||
uint64_t kve_start; /* Starting address. */
|
||||
uint64_t kve_end; /* Finishing address. */
|
||||
uint64_t kve_offset; /* Mapping offset in object */
|
||||
uint64_t kve_fileid; /* inode number if vnode */
|
||||
uint32_t kve_fsid; /* dev_t of vnode location */
|
||||
int kve_flags; /* Flags on map entry. */
|
||||
int kve_resident; /* Number of resident pages. */
|
||||
int kve_private_resident; /* Number of private pages. */
|
||||
int kve_protection; /* Protection bitmask. */
|
||||
int kve_ref_count; /* VM obj ref count. */
|
||||
int kve_shadow_count; /* VM obj shadow count. */
|
||||
char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
|
||||
void *_kve_pspare[8]; /* Space for more stuff. */
|
||||
off_t kve_offset; /* Mapping offset in object */
|
||||
uint64_t kve_fileid; /* inode number of vnode */
|
||||
dev_t kve_fsid; /* dev_t of vnode location */
|
||||
int _kve_ispare[3]; /* Space for more stuff. */
|
||||
int _kve_ispare[15]; /* Space for more stuff. */
|
||||
char kve_path[KPROC_PATH_MAX]; /* Path to VM obj, if any. */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -343,12 +354,15 @@ struct kinfo_vmentry {
|
||||
#define KKST_STATE_SWAPPED 1 /* Stack swapped out. */
|
||||
#define KKST_STATE_RUNNING 2 /* Stack ephemeral. */
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
#define KINFO_KSTACK_SIZE 1096
|
||||
#endif
|
||||
|
||||
struct kinfo_kstack {
|
||||
lwpid_t kkst_tid; /* ID of thread. */
|
||||
int kkst_state; /* Validity of stack. */
|
||||
char kkst_trace[KKST_MAXLEN]; /* String representing stack. */
|
||||
void *_kkst_pspare[8]; /* Space for more stuff. */
|
||||
int _kkst_ispare[8]; /* Space for more stuff. */
|
||||
int _kkst_ispare[16]; /* Space for more stuff. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user