aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbland <bland@FreeBSD.org>2003-09-09 11:35:10 +0800
committerbland <bland@FreeBSD.org>2003-09-09 11:35:10 +0800
commitbb962254bc95d9badf1cf34f85f486cca728abe3 (patch)
tree81e40ced723c5c279d7ea4729bf033685eb1ff07
parentacaeb181e8594eccf930a3268a44f43c2d21641e (diff)
downloadfreebsd-ports-gnome-bb962254bc95d9badf1cf34f85f486cca728abe3.tar.gz
freebsd-ports-gnome-bb962254bc95d9badf1cf34f85f486cca728abe3.tar.zst
freebsd-ports-gnome-bb962254bc95d9badf1cf34f85f486cca728abe3.zip
- Fixes in proctime calculation.
- Fixes in procmem calculation. - Clear libgtop_server2 responce structure to avoid use of uninitialized memory. - Retry read/write after EINTR wich in fact is not an error. - A number of glibtop_errors downgraded to glibtop_warns to avoid unxepected libgtop_server2 termination.
-rw-r--r--devel/libgtop2/Makefile2
-rw-r--r--devel/libgtop2/files/patch-ah20
-rw-r--r--devel/libgtop2/files/patch-aj205
-rw-r--r--devel/libgtop2/files/patch-lib::command.c10
-rw-r--r--devel/libgtop2/files/patch-lib::read.c28
-rw-r--r--devel/libgtop2/files/patch-lib::write.c28
-rw-r--r--devel/libgtop2/files/patch-src::daemon::io.c58
-rw-r--r--devel/libgtop2/files/patch-sysdeps::freebsd::prockernel.c145
-rw-r--r--devel/libgtop2/files/patch-sysdeps::freebsd::procmem.c40
-rw-r--r--devel/libgtop2/files/patch-sysdeps::freebsd::proctime.c67
10 files changed, 404 insertions, 199 deletions
diff --git a/devel/libgtop2/Makefile b/devel/libgtop2/Makefile
index 692c0c48330d..4f09f77f896d 100644
--- a/devel/libgtop2/Makefile
+++ b/devel/libgtop2/Makefile
@@ -7,7 +7,7 @@
PORTNAME= libgtop2
PORTVERSION= 2.0.4
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= devel gnome
MASTER_SITES= ${MASTER_SITE_GNOME}
MASTER_SITE_SUBDIR= sources/${PORTNAME:S/2$//}/2.0
diff --git a/devel/libgtop2/files/patch-ah b/devel/libgtop2/files/patch-ah
index fad02673b7ab..c01ec4e1826b 100644
--- a/devel/libgtop2/files/patch-ah
+++ b/devel/libgtop2/files/patch-ah
@@ -1,5 +1,5 @@
---- sysdeps/freebsd/procmap.c.orig Mon Jun 10 17:34:42 2002
-+++ sysdeps/freebsd/procmap.c Sat Oct 26 01:20:26 2002
+--- sysdeps/freebsd/procmap.c.orig Fri May 28 03:56:48 1999
++++ sysdeps/freebsd/procmap.c Tue Sep 9 11:38:18 2003
@@ -33,7 +33,11 @@
#include <sys/proc.h>
#include <sys/resource.h>
@@ -23,7 +23,17 @@
#endif
int count, i = 0;
int update = 0;
-@@ -114,7 +119,11 @@
+@@ -108,13 +113,19 @@
+
+ /* Get the process data */
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
+- if ((pinfo == NULL) || (count < 1))
+- glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
++ if ((pinfo == NULL) || (count < 1)) {
++ glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
++ return NULL;
++ }
+
/* Now we get the memory maps. */
if (kvm_read (server->machine.kd,
@@ -35,7 +45,7 @@
(char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace))
glibtop_error_io_r (server, "kvm_read (vmspace)");
-@@ -244,6 +253,15 @@
+@@ -244,6 +255,15 @@
&vnode, sizeof (vnode)) != sizeof (vnode))
glibtop_error_io_r (server, "kvm_read (vnode)");
@@ -51,7 +61,7 @@
if ((vnode.v_type != VREG) || (vnode.v_tag != VT_UFS) ||
!vnode.v_data) continue;
-@@ -252,13 +270,9 @@
+@@ -252,13 +272,9 @@
&inode, sizeof (inode)) != sizeof (inode))
glibtop_error_io_r (server, "kvm_read (inode)");
diff --git a/devel/libgtop2/files/patch-aj b/devel/libgtop2/files/patch-aj
index 101a29532b41..b7ea24ebab8e 100644
--- a/devel/libgtop2/files/patch-aj
+++ b/devel/libgtop2/files/patch-aj
@@ -1,6 +1,8 @@
---- sysdeps/freebsd/proclist.c.orig Thu May 27 09:04:05 1999
-+++ sysdeps/freebsd/proclist.c Fri Dec 22 18:02:59 2000
-@@ -88,9 +88,20 @@
+--- sysdeps/freebsd/proclist.c.orig Thu May 27 23:04:05 1999
++++ sysdeps/freebsd/proclist.c Sun Sep 7 20:37:30 2003
+@@ -86,13 +86,24 @@
+ pids = glibtop_realloc_r (server, pids, count * sizeof (unsigned));
+ /* Copy the pids over to this chain */
for (i=j=0; i < count; i++) {
+#if __FreeBSD_version >= 500013
+#define XXX_P_STAT ki_stat
@@ -24,8 +26,10 @@
- pids [j++] = (unsigned) pinfo[i].kp_proc.p_pid;
+ pids [j++] = (unsigned) pinfo[i].XXX_P_PID;
} /* end for */
---- sysdeps/freebsd/procstate.c.orig Sun Feb 10 09:30:11 2002
-+++ sysdeps/freebsd/procstate.c Mon Apr 29 11:42:22 2002
+ /* Set the fields in buf */
+ buf->number = j;
+--- sysdeps/freebsd/procstate.c.orig Sun Oct 17 03:01:39 1999
++++ sysdeps/freebsd/procstate.c Sun Sep 7 20:37:30 2003
@@ -28,7 +28,7 @@
#include <glibtop_suid.h>
@@ -121,8 +125,10 @@
buf->flags |= (1L << GLIBTOP_PROC_STATE_STATE);
}
--- sysdeps/freebsd/procuid.c.orig Fri Sep 17 06:08:07 1999
-+++ sysdeps/freebsd/procuid.c Thu Feb 15 01:16:50 2001
-@@ -86,13 +86,42 @@
++++ sysdeps/freebsd/procuid.c Sun Sep 7 20:37:30 2003
+@@ -84,17 +84,46 @@
+ return;
+ }
- buf->uid = pinfo [0].kp_eproc.e_pcred.p_ruid;
- buf->euid = pinfo [0].kp_eproc.e_pcred.p_svuid;
@@ -175,39 +181,13 @@
+ buf->nice = pinfo [0].XXX_P_NICE;
+ buf->priority = pinfo [0].XXX_P_PRIORITY;
---- sysdeps/freebsd/procmem.c.orig Thu May 27 13:56:49 1999
-+++ sysdeps/freebsd/procmem.c Wed Dec 27 10:16:26 2000
-@@ -139,2 +139,18 @@
-
-+#if __FreeBSD_version >= 500013
-+
-+#define XXX_P_VMSPACE ki_vmspace
-+
-+ buf->rss_rlim = pinfo [0].ki_rssize;
-+
-+ buf->vsize = buf->size = (u_int64_t) pagetok
-+ (pinfo [0].ki_tsize + pinfo [0].ki_dsize + pinfo[0].ki_ssize)
-+ << LOG1024;
-+ buf->resident = buf->rss = (u_int64_t) pagetok
-+ (pinfo [0].ki_rssize) << LOG1024;
-+
-+#else
-+
-+#define XXX_P_VMSPACE kp_proc.p_vmspace
-+
- if (kvm_read (server->machine.kd,
-@@ -156,2 +172,3 @@
- (vms->vm_rssize) << LOG1024;
-+#endif
-
-@@ -160,3 +177,3 @@
- if (kvm_read (server->machine.kd,
-- (unsigned long) pinfo [0].kp_proc.p_vmspace,
-+ (unsigned long) pinfo [0].XXX_P_VMSPACE,
- (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
---- sysdeps/freebsd/procsignal.c.orig Sun Feb 13 15:31:39 2000
-+++ sysdeps/freebsd/procsignal.c Wed Dec 27 10:22:28 2000
-@@ -69,2 +69,18 @@
+ /* Set the flags for the data we're about to return*/
+ buf->flags = _glibtop_sysdeps_proc_uid;
+--- sysdeps/freebsd/procsignal.c.orig Mon Feb 14 06:31:39 2000
++++ sysdeps/freebsd/procsignal.c Sun Sep 7 20:37:30 2003
+@@ -67,11 +67,27 @@
+ return;
+ }
+#if __FreeBSD_version >= 500013
+
@@ -226,147 +206,38 @@
+#endif
+
/* signal: mask of pending signals.
-@@ -73,3 +89,3 @@
+ * pinfo [0].kp_proc.p_siglist
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->signal [0] = pinfo [0].kp_proc.p_siglist.__bits[0];
+ buf->signal [0] = pinfo [0].XXX_P_SIGLIST.__bits[0];
#else
-@@ -82,3 +98,3 @@
+ buf->signal [0] = pinfo [0].kp_proc.p_siglist;
+ #endif
+@@ -80,7 +96,7 @@
+ * pinfo [0].kp_proc.p_sigmask
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->blocked [0] = pinfo [0].kp_proc.p_sigmask.__bits[0];
+ buf->blocked [0] = pinfo [0].XXX_P_SIGMASK.__bits[0];
#else
-@@ -91,3 +107,3 @@
+ buf->blocked [0] = pinfo [0].kp_proc.p_sigmask;
+ #endif
+@@ -89,7 +105,7 @@
+ * pinfo [0].kp_proc.p_sigignore
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore.__bits[0];
+ buf->sigignore [0] = pinfo [0].XXX_P_SIGIGNORE.__bits[0];
#else
-@@ -100,3 +116,3 @@
+ buf->sigignore [0] = pinfo [0].kp_proc.p_sigignore;
+ #endif
+@@ -98,7 +114,7 @@
+ * pinfo [0].kp_proc.p_sigcatch
+ */
#if (defined(__NetBSD__) && (NSIG > 32)) || (__FreeBSD_version >= 400011)
- buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch.__bits[0];
+ buf->sigcatch [0] = pinfo [0].XXX_P_SIGCATCH.__bits[0];
#else
---- sysdeps/freebsd/prockernel.c.orig Sat Oct 16 13:31:43 1999
-+++ sysdeps/freebsd/prockernel.c Wed Dec 27 10:50:19 2000
-@@ -36,8 +36,2 @@
+ buf->sigcatch [0] = pinfo [0].kp_proc.p_sigcatch;
#endif
--#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__))
--#include <machine/pcb.h>
--#endif
--#if defined(__FreeBSD__) && !defined(__alpha__)
--#include <machine/tss.h>
--#endif
-
-@@ -80,10 +74,4 @@
- struct kinfo_proc *pinfo;
-- struct user *u_addr = (struct user *)USRSTACK;
-- struct pstats pstats;
-- struct pcb pcb;
- int count;
-
-- char filename [BUFSIZ];
-- struct stat statb;
--
- glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
-@@ -103,7 +91,21 @@
-
-- buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE;
-+#if __FreeBSD_version >= 500013
-+
-+#define XXX_P_WCHAN ki_wchan
-+#define XXX_P_WMESG ki_wmesg
-+#define XXX_E_WMESG ki_wmesg
-+
-+#else
-+
-+#define XXX_P_WCHAN kp_proc.p_wchan
-+#define XXX_P_WMESG kp_proc.p_wmesg
-+#define XXX_E_WMESG kp_eproc.e_wmesg
-+
-+#endif
-+
-+ buf->nwchan = (unsigned long) pinfo [0].XXX_P_WCHAN &~ KERNBASE;
- buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
-
-- if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) {
-- strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg,
-+ if (pinfo [0].XXX_P_WCHAN && pinfo [0].XXX_P_WMESG) {
-+ strncpy (buf->wchan, pinfo [0].XXX_E_WMESG,
- sizeof (buf->wchan) - 1);
-@@ -115,70 +117,8 @@
-
-- /* Taken from `saveuser ()' in `/usr/src/bin/ps/ps.c'. */
--
-- /* [FIXME]: /usr/include/sys/user.h tells me that the user area
-- * may or may not be at the same kernel address in all
-- * processes, but I don't see any way to get that address.
-- * Since `ps' simply uses its own address, I think it's
-- * safe to do this here, too. */
--
-- /* NOTE: You need to mount the /proc filesystem to make
-- * `kvm_uread' work. */
--
-- sprintf (filename, "/proc/%d/mem", (int) pid);
-- if (stat (filename, &statb)) return;
--
-- glibtop_suid_enter (server);
--
-- if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
-- kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
-- (unsigned long) &u_addr->u_stats,
-- (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
-- {
-- /*
-- * The u-area might be swapped out, and we can't get
-- * at it because we have a crashdump and no swap.
-- * If it's here fill in these fields, otherwise, just
-- * leave them 0.
-- */
--
-- buf->min_flt = (u_int64_t) pstats.p_ru.ru_minflt;
-- buf->maj_flt = (u_int64_t) pstats.p_ru.ru_majflt;
-- buf->cmin_flt = (u_int64_t) pstats.p_cru.ru_minflt;
-- buf->cmaj_flt = (u_int64_t) pstats.p_cru.ru_majflt;
--
-- buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
-- }
--
-- if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
-- kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
-- (unsigned long) &u_addr->u_pcb,
-- (char *) &pcb, sizeof (pcb)) == sizeof (pcb))
-- {
--#ifdef __FreeBSD__
--#ifndef __alpha__
--#if (__FreeBSD_version >= 300003)
-- buf->kstk_esp = (u_int64_t) pcb.pcb_esp;
-- buf->kstk_eip = (u_int64_t) pcb.pcb_eip;
--#else
-- buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
-- buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
--#endif
--#else
-- /*xxx FreeBSD/Alpha? */
--#endif
--#else
-- buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
--#ifdef __bsdi__
-- buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
--#else
-- buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
--#endif
--
-- buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
--#endif
-- }
--
-- /* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */
--
-- glibtop_suid_leave (server);
-+ /* XXX: the code here was, quite frankly, junk, and almost
-+ * certainly wrong - remove it all, leave these fields
-+ * unpopulated, and give up until such time as the right
-+ * code is produced for both FreeBSD 4.x and 5.x
-+ */
-+ return;
- }
diff --git a/devel/libgtop2/files/patch-lib::command.c b/devel/libgtop2/files/patch-lib::command.c
new file mode 100644
index 000000000000..4bb3aefb1b9a
--- /dev/null
+++ b/devel/libgtop2/files/patch-lib::command.c
@@ -0,0 +1,10 @@
+--- lib/command.c.orig Tue Sep 9 09:47:58 2003
++++ lib/command.c Tue Sep 9 08:14:33 2003
+@@ -38,6 +38,7 @@
+ glibtop_init_r (&server, 0, 0);
+
+ memset (&cmnd, 0, sizeof (glibtop_command));
++ memset (&response, 0, sizeof (glibtop_response));
+
+ cmnd.command = command;
+
diff --git a/devel/libgtop2/files/patch-lib::read.c b/devel/libgtop2/files/patch-lib::read.c
new file mode 100644
index 000000000000..0190c885d713
--- /dev/null
+++ b/devel/libgtop2/files/patch-lib::read.c
@@ -0,0 +1,28 @@
+--- lib/read.c.orig Fri May 7 07:09:24 1999
++++ lib/read.c Tue Sep 9 10:02:54 2003
+@@ -21,6 +21,7 @@
+ Boston, MA 02111-1307, USA.
+ */
+
++#include <errno.h>
+ #include <glibtop/read.h>
+
+ /* Reads some data from server. */
+@@ -65,12 +66,16 @@
+ fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size);
+ #endif
+
++retry:
+ if (server->socket) {
+ do_read (server->socket, buf, size);
+ } else {
+ ret = read (server->input [0], buf, size);
+ }
+
+- if (ret < 0)
++ if (ret < 0) {
++ if (errno == EINTR)
++ goto retry;
+ glibtop_error_io_r (server, _("read %d bytes"), size);
++ }
+ }
diff --git a/devel/libgtop2/files/patch-lib::write.c b/devel/libgtop2/files/patch-lib::write.c
new file mode 100644
index 000000000000..45c2434ea72e
--- /dev/null
+++ b/devel/libgtop2/files/patch-lib::write.c
@@ -0,0 +1,28 @@
+--- lib/write.c.orig Mon Sep 8 23:05:01 2003
++++ lib/write.c Tue Sep 9 10:04:37 2003
+@@ -21,6 +21,7 @@
+ Boston, MA 02111-1307, USA.
+ */
+
++#include <errno.h>
+ #include <glibtop/write.h>
+
+ /* Writes some data to server. */
+@@ -38,12 +39,16 @@
+ fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size);
+ #endif
+
++retry:
+ if (server->socket) {
+ ret = send (server->socket, buf, size, 0);
+ } else {
+ ret = write (server->output [1], buf, size);
+ }
+
+- if (ret < 0)
++ if (ret < 0) {
++ if (errno == EINTR)
++ goto retry;
+ glibtop_error_io_r (server, _("write %d bytes"), size);
++ }
+ }
diff --git a/devel/libgtop2/files/patch-src::daemon::io.c b/devel/libgtop2/files/patch-src::daemon::io.c
new file mode 100644
index 000000000000..b4079dec132d
--- /dev/null
+++ b/devel/libgtop2/files/patch-src::daemon::io.c
@@ -0,0 +1,58 @@
+--- src/daemon/io.c.orig Tue Sep 9 09:51:15 2003
++++ src/daemon/io.c Tue Sep 9 10:07:10 2003
+@@ -21,6 +21,7 @@
+ Boston, MA 02111-1307, USA.
+ */
+
++#include <errno.h>
+ #include "daemon.h"
+
+ void
+@@ -35,9 +36,13 @@
+ resp->offset = offset;
+ resp->data_size = data_size;
+
++retry1:
+ if (s == 0) {
+- if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0)
++ if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0) {
++ if (errno == EINTR)
++ goto retry1;
+ glibtop_warn_io ("write");
++ }
+ } else {
+ if (send (s, (const void *) resp, sizeof (glibtop_response), 0) < 0)
+ glibtop_warn_io ("send");
+@@ -47,10 +52,13 @@
+ #ifdef REAL_DEBUG
+ fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size);
+ #endif
+-
++retry2:
+ if (s == 0) {
+- if (write (1, data, resp->data_size) < 0)
++ if (write (1, data, resp->data_size) < 0) {
++ if (errno == EINTR)
++ goto retry2;
+ glibtop_warn_io ("write");
++ }
+ } else {
+ if (send (s, data, resp->data_size, 0) , 0)
+ glibtop_warn_io ("send");
+@@ -66,6 +74,7 @@
+ size_t already_read = 0, remaining = total_size;
+
+ while (already_read < total_size) {
++retry:
+ if (s)
+ nread = recv (s, ptr, remaining, 0);
+ else
+@@ -77,6 +86,8 @@
+ }
+
+ if (nread <= 0) {
++ if (errno == EINTR)
++ goto retry;
+ glibtop_warn_io ("recv");
+ return 0;
+ }
diff --git a/devel/libgtop2/files/patch-sysdeps::freebsd::prockernel.c b/devel/libgtop2/files/patch-sysdeps::freebsd::prockernel.c
new file mode 100644
index 000000000000..396ae9c8d7b6
--- /dev/null
+++ b/devel/libgtop2/files/patch-sysdeps::freebsd::prockernel.c
@@ -0,0 +1,145 @@
+--- sysdeps/freebsd/prockernel.c.orig Sun Oct 17 03:31:43 1999
++++ sysdeps/freebsd/prockernel.c Tue Sep 9 11:36:35 2003
+@@ -34,12 +34,6 @@
+ #if (!defined __OpenBSD__) && (!defined __bsdi__)
+ #include <sys/user.h>
+ #endif
+-#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__))
+-#include <machine/pcb.h>
+-#endif
+-#if defined(__FreeBSD__) && !defined(__alpha__)
+-#include <machine/tss.h>
+-#endif
+
+ #include <unistd.h>
+ #include <fcntl.h>
+@@ -78,14 +72,8 @@
+ pid_t pid)
+ {
+ struct kinfo_proc *pinfo;
+- struct user *u_addr = (struct user *)USRSTACK;
+- struct pstats pstats;
+- struct pcb pcb;
+ int count;
+
+- char filename [BUFSIZ];
+- struct stat statb;
+-
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
+@@ -98,14 +86,30 @@
+
+ /* Get the process information */
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
+- if ((pinfo == NULL) || (count != 1))
+- glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
++ if ((pinfo == NULL) || (count != 1)) {
++ glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
++ return;
++ }
++
++#if __FreeBSD_version >= 500013
++
++#define XXX_P_WCHAN ki_wchan
++#define XXX_P_WMESG ki_wmesg
++#define XXX_E_WMESG ki_wmesg
+
+- buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE;
++#else
++
++#define XXX_P_WCHAN kp_proc.p_wchan
++#define XXX_P_WMESG kp_proc.p_wmesg
++#define XXX_E_WMESG kp_eproc.e_wmesg
++
++#endif
++
++ buf->nwchan = (unsigned long) pinfo [0].XXX_P_WCHAN &~ KERNBASE;
+ buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
+
+- if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) {
+- strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg,
++ if (pinfo [0].XXX_P_WCHAN && pinfo [0].XXX_P_WMESG) {
++ strncpy (buf->wchan, pinfo [0].XXX_E_WMESG,
+ sizeof (buf->wchan) - 1);
+ buf->wchan [sizeof (buf->wchan) - 1] = 0;
+ buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN);
+@@ -113,72 +117,10 @@
+ buf->wchan [0] = 0;
+ }
+
+- /* Taken from `saveuser ()' in `/usr/src/bin/ps/ps.c'. */
+-
+- /* [FIXME]: /usr/include/sys/user.h tells me that the user area
+- * may or may not be at the same kernel address in all
+- * processes, but I don't see any way to get that address.
+- * Since `ps' simply uses its own address, I think it's
+- * safe to do this here, too. */
+-
+- /* NOTE: You need to mount the /proc filesystem to make
+- * `kvm_uread' work. */
+-
+- sprintf (filename, "/proc/%d/mem", (int) pid);
+- if (stat (filename, &statb)) return;
+-
+- glibtop_suid_enter (server);
+-
+- if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+- kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
+- (unsigned long) &u_addr->u_stats,
+- (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
+- {
+- /*
+- * The u-area might be swapped out, and we can't get
+- * at it because we have a crashdump and no swap.
+- * If it's here fill in these fields, otherwise, just
+- * leave them 0.
+- */
+-
+- buf->min_flt = (u_int64_t) pstats.p_ru.ru_minflt;
+- buf->maj_flt = (u_int64_t) pstats.p_ru.ru_majflt;
+- buf->cmin_flt = (u_int64_t) pstats.p_cru.ru_minflt;
+- buf->cmaj_flt = (u_int64_t) pstats.p_cru.ru_majflt;
+-
+- buf->flags |= _glibtop_sysdeps_proc_kernel_pstats;
+- }
+-
+- if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+- kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
+- (unsigned long) &u_addr->u_pcb,
+- (char *) &pcb, sizeof (pcb)) == sizeof (pcb))
+- {
+-#ifdef __FreeBSD__
+-#ifndef __alpha__
+-#if (__FreeBSD_version >= 300003)
+- buf->kstk_esp = (u_int64_t) pcb.pcb_esp;
+- buf->kstk_eip = (u_int64_t) pcb.pcb_eip;
+-#else
+- buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
+- buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
+-#endif
+-#else
+- /*xxx FreeBSD/Alpha? */
+-#endif
+-#else
+- buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
+-#ifdef __bsdi__
+- buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
+-#else
+- buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
+-#endif
+-
+- buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
+-#endif
+- }
+-
+- /* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */
+-
+- glibtop_suid_leave (server);
++ /* XXX: the code here was, quite frankly, junk, and almost
++ * certainly wrong - remove it all, leave these fields
++ * unpopulated, and give up until such time as the right
++ * code is produced for both FreeBSD 4.x and 5.x
++ */
++ return;
+ }
diff --git a/devel/libgtop2/files/patch-sysdeps::freebsd::procmem.c b/devel/libgtop2/files/patch-sysdeps::freebsd::procmem.c
new file mode 100644
index 000000000000..a174fda33bd1
--- /dev/null
+++ b/devel/libgtop2/files/patch-sysdeps::freebsd::procmem.c
@@ -0,0 +1,40 @@
+--- sysdeps/freebsd/procmem.c.orig Fri May 28 03:56:49 1999
++++ sysdeps/freebsd/procmem.c Sun Sep 7 21:37:38 2003
+@@ -137,6 +137,23 @@
+ return;
+ }
+
++#if __FreeBSD_version >= 500013
++
++#define XXX_P_VMSPACE ki_vmspace
++
++ buf->rss_rlim = pinfo [0].ki_rssize;
++
++ buf->vsize = (u_int64_t) pinfo [0].ki_size;
++ buf->size = (u_int64_t) pagetok
++ (pinfo [0].ki_tsize + pinfo [0].ki_dsize + pinfo[0].ki_ssize)
++ << LOG1024;
++ buf->resident = buf->rss = (u_int64_t) pagetok
++ (pinfo [0].ki_rssize) << LOG1024;
++
++#else
++
++#define XXX_P_VMSPACE kp_proc.p_vmspace
++
+ if (kvm_read (server->machine.kd,
+ (unsigned long) pinfo [0].kp_proc.p_limit,
+ (char *) &plimit, sizeof (plimit)) != sizeof (plimit)) {
+@@ -154,11 +171,12 @@
+
+ buf->resident = buf->rss = (u_int64_t) pagetok
+ (vms->vm_rssize) << LOG1024;
++#endif
+
+ /* Now we get the shared memory. */
+
+ if (kvm_read (server->machine.kd,
+- (unsigned long) pinfo [0].kp_proc.p_vmspace,
++ (unsigned long) pinfo [0].XXX_P_VMSPACE,
+ (char *) &vmspace, sizeof (vmspace)) != sizeof (vmspace)) {
+ glibtop_warn_io_r (server, "kvm_read (vmspace)");
+ return;
diff --git a/devel/libgtop2/files/patch-sysdeps::freebsd::proctime.c b/devel/libgtop2/files/patch-sysdeps::freebsd::proctime.c
index f26b953a8631..8905fd21ba83 100644
--- a/devel/libgtop2/files/patch-sysdeps::freebsd::proctime.c
+++ b/devel/libgtop2/files/patch-sysdeps::freebsd::proctime.c
@@ -1,5 +1,5 @@
---- sysdeps/freebsd/proctime.c.orig Mon Jun 10 17:34:42 2002
-+++ sysdeps/freebsd/proctime.c Wed Oct 2 21:18:38 2002
+--- sysdeps/freebsd/proctime.c.orig Thu Feb 15 06:36:42 2001
++++ sysdeps/freebsd/proctime.c Tue Sep 9 11:17:56 2003
@@ -57,6 +57,7 @@
* system, and interrupt time usage.
*/
@@ -46,7 +46,17 @@
/* Provides detailed information about a process. */
-@@ -142,25 +132,25 @@
+@@ -132,9 +122,6 @@
+ struct pstats pstats;
+ int count;
+
+- char filename [BUFSIZ];
+- struct stat statb;
+-
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_time));
+@@ -142,25 +129,23 @@
/* It does not work for the swapper task. */
if (pid == 0) return;
@@ -55,17 +65,20 @@
if (server->sysdeps.proc_time == 0)
return;
-+#endif
- #ifndef __bsdi__
- sprintf (filename, "/proc/%d/mem", (int) pid);
- if (stat (filename, &statb)) return;
- #endif
+-#ifndef __bsdi__
+- sprintf (filename, "/proc/%d/mem", (int) pid);
+- if (stat (filename, &statb)) return;
-#endif
+ #endif
/* Get the process information */
pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
- if ((pinfo == NULL) || (count != 1))
- glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
+- if ((pinfo == NULL) || (count != 1))
+- glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
++ if ((pinfo == NULL) || (count != 1)) {
++ glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
++ return;
++ }
-#if (defined __FreeBSD__) && (__FreeBSD_version >= 300003)
- buf->rtime = pinfo [0].kp_proc.p_runtime;
@@ -77,13 +90,13 @@
#endif
buf->frequency = 1000000;
-@@ -192,6 +182,21 @@
+@@ -192,6 +177,21 @@
buf->flags |= _glibtop_sysdeps_proc_time_user;
#else
+#if __FreeBSD_version >= 500013
+#if __FreeBSD_version >= 500016
-+ if ((pinfo [0].ki_flag & PS_INMEM)) {
++ if ((pinfo [0].ki_sflag & PS_INMEM)) {
+#else
+ if ((pinfo [0].ki_flag & P_INMEM)) {
+#endif
@@ -92,14 +105,14 @@
+ buf->cutime = tv2sec (pinfo [0].ki_childtime);
+ buf->cstime = 0; /* XXX */
+ buf->start_time = tv2sec (pinfo [0].ki_start);
-+ buf->flags = _glibtop_sysdeps_proc_time_user;
++ buf->flags |= _glibtop_sysdeps_proc_time_user;
+ }
+
+#else
glibtop_suid_enter (server);
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
-@@ -199,29 +204,16 @@
+@@ -199,31 +199,17 @@
(unsigned long) &u_addr->u_stats,
(char *) &pstats, sizeof (pstats)) == sizeof (pstats))
{
@@ -109,8 +122,14 @@
- /* Well, we just do the same getrusage () does ... */
-
- register struct rusage *rup;
--
-- glibtop_suid_leave (server);
+
++ buf->utime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_utime);
++ buf->stime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_stime);
++ buf->cutime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_utime);
++ buf->cstime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_stime);
++ buf->start_time = tv2sec (pinfo[0].kp_eproc.e_stats.p_start);
++ buf->flags |= _glibtop_sysdeps_proc_time_user;
+ glibtop_suid_leave (server);
-
- rup = &pstats.p_ru;
- calcru(&(pinfo [0]).kp_proc,
@@ -123,16 +142,12 @@
- buf->cstime = tv2sec (pstats.p_cru.ru_stime);
-
- buf->start_time = tv2sec (pstats.p_start);
-
-+ buf->utime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_utime);
-+ buf->stime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_stime);
-+ buf->cutime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_utime);
-+ buf->cstime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_stime);
-+ buf->start_time = tv2sec (pinfo[0].kp_eproc.e_stats.p_start);
- buf->flags = _glibtop_sysdeps_proc_time_user;
-+ glibtop_suid_leave (server);
+-
+- buf->flags = _glibtop_sysdeps_proc_time_user;
}
-+#endif
-
+-
glibtop_suid_leave (server);
++#endif
#endif
+ }
+