summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2008-12-02 06:50:26 +0000
committerPeter Wemm <peter@FreeBSD.org>2008-12-02 06:50:26 +0000
commit0b0845a6f2516f95aae44bb62353372441812a58 (patch)
tree7d4d591d414282afc2e1ced892651c6b88eb8d16 /libutil
parentde93bd3807fda6b4c5a3c8d607413b8869f7e8d8 (diff)
downloadpw-darwin-0b0845a6f2516f95aae44bb62353372441812a58.tar.gz
pw-darwin-0b0845a6f2516f95aae44bb62353372441812a58.tar.zst
pw-darwin-0b0845a6f2516f95aae44bb62353372441812a58.zip
Merge user/peter/kinfo branch as of r185547 into head.
This changes struct kinfo_filedesc and kinfo_vmentry such that they are same on both 32 and 64 bit platforms like i386/amd64 and won't require sysctl wrapping. Two new OIDs are assigned. The old ones are available under COMPAT_FREEBSD7 - but it isn't that simple. The superceded interface was never actually released on 7.x. The other main change is to pack the data passed to userland via the sysctl. kf_structsize and kve_structsize are reduced for the copyout. If you have a process with 100,000+ sockets open, the unpacked records require a 132MB+ copyout. With packing, it is "only" ~35MB. (Still seriously unpleasant, but not quite as devastating). A similar problem exists for the vmentry structure - have lots and lots of shared libraries and small mmaps and its copyout gets expensive too. My immediate problem is valgrind. It traditionally achieves this functionality by parsing procfs output, in a packed format. Secondly, when tracing 32 bit binaries on amd64 under valgrind, it uses a cross compiled 32 bit binary which ran directly into the differing data structures in 32 vs 64 bit mode. (valgrind uses this to track file descriptor operations and this therefore affected every single 32 bit binary) I've added two utility functions to libutil to unpack the structures into a fixed record length and to make it a little more convenient to use.
Diffstat (limited to 'libutil')
-rw-r--r--libutil/libutil.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/libutil/libutil.h b/libutil/libutil.h
index 186ee2e..3187fb3 100644
--- a/libutil/libutil.h
+++ b/libutil/libutil.h
@@ -64,6 +64,8 @@ struct termios;
struct winsize;
struct utmp;
struct in_addr;
+struct kinfo_file;
+struct kinfo_vmentry;
__BEGIN_DECLS
void clean_environment(const char * const *_white,
@@ -100,6 +102,10 @@ int realhostname_sa(char *host, size_t hsize, struct sockaddr *addr,
int kld_isloaded(const char *name);
int kld_load(const char *name);
+struct kinfo_file *
+ kinfo_getfile(pid_t _pid, int *_cntp);
+struct kinfo_vmentry *
+ kinfo_getvmmap(pid_t _pid, int *_cntp);
#ifdef _STDIO_H_ /* avoid adding new includes */
char *fparseln(FILE *, size_t *, size_t *, const char[3], int);