The indentation in LibGTop was done with the following command:

find . -name \*.[ch] | xargs -i emacs -batch {} \
		-l /gnome/compile/libgtop/misc/format.el -f save-buffer

December 26, 1999
Martin
This commit is contained in:
Martin Baulig
1999-12-26 14:05:32 +00:00
parent d7f088bef0
commit f1a6e1ead8
272 changed files with 6300 additions and 5751 deletions

View File

@@ -1,3 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* $Id$ */
/* Copyright (C) 1998 Joshua Sled
@@ -67,11 +69,11 @@ static const unsigned long _glibtop_sysdeps_proc_kernel_wchan =
int
glibtop_init_proc_kernel_p (glibtop *server)
{
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel_pstats |
_glibtop_sysdeps_proc_kernel_pcb |
_glibtop_sysdeps_proc_kernel_wchan;
server->sysdeps.proc_kernel = _glibtop_sysdeps_proc_kernel_pstats |
_glibtop_sysdeps_proc_kernel_pcb |
_glibtop_sysdeps_proc_kernel_wchan;
return 0;
return 0;
}
int
@@ -79,111 +81,111 @@ glibtop_get_proc_kernel_p (glibtop *server,
glibtop_proc_kernel *buf,
pid_t pid)
{
struct kinfo_proc *pinfo;
struct user *u_addr = (struct user *)USRSTACK;
struct pstats pstats;
struct pcb pcb;
int count;
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;
char filename [BUFSIZ];
struct stat statb;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
memset (buf, 0, sizeof (glibtop_proc_kernel));
memset (buf, 0, sizeof (glibtop_proc_kernel));
if (server->sysdeps.proc_time == 0)
return -1;
if (server->sysdeps.proc_time == 0)
return -1;
/* It does not work for the swapper task. */
if (pid == 0) return -1;
/* It does not work for the swapper task. */
if (pid == 0) return -1;
/* Get the process information */
pinfo = kvm_getprocs (server->_priv->machine.kd,
KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1))
glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
/* Get the process information */
pinfo = kvm_getprocs (server->_priv->machine.kd,
KERN_PROC_PID, pid, &count);
if ((pinfo == NULL) || (count != 1))
glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
buf->nwchan = (unsigned long) pinfo [0].kp_proc.p_wchan &~ KERNBASE;
buf->flags |= (1L << GLIBTOP_PROC_KERNEL_NWCHAN);
buf->nwchan = (unsigned long) pinfo [0].kp_proc.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,
sizeof (buf->wchan) - 1);
buf->wchan [sizeof (buf->wchan) - 1] = 0;
buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN);
} else {
buf->wchan [0] = 0;
if (pinfo [0].kp_proc.p_wchan && pinfo [0].kp_proc.p_wmesg) {
strncpy (buf->wchan, pinfo [0].kp_eproc.e_wmesg,
sizeof (buf->wchan) - 1);
buf->wchan [sizeof (buf->wchan) - 1] = 0;
buf->flags |= (1L << GLIBTOP_PROC_KERNEL_WCHAN);
} else {
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 -1;
glibtop_suid_enter (server);
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->_priv->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;
}
/* 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 -1;
glibtop_suid_enter (server);
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->_priv->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->_priv->machine.kd, &(pinfo [0]).kp_proc,
(unsigned long) &u_addr->u_pcb,
(char *) &pcb, sizeof (pcb)) == sizeof (pcb))
{
if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
kvm_uread (server->_priv->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;
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;
buf->kstk_esp = (u_int64_t) pcb.pcb_ksp;
buf->kstk_eip = (u_int64_t) pcb.pcb_pc;
#endif
#else
/*xxx FreeBSD/Alpha? */
/*xxx FreeBSD/Alpha? */
#endif
#else
buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
buf->kstk_esp = (u_int64_t) pcb.pcb_tss.tss_esp0;
#ifdef __bsdi__
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.tss_eip;
#else
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
buf->kstk_eip = (u_int64_t) pcb.pcb_tss.__tss_eip;
#endif
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
buf->flags |= _glibtop_sysdeps_proc_kernel_pcb;
#endif
}
}
/* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */
/* Taken from `wchan ()' in `/usr/src/bin/ps/print.c'. */
glibtop_suid_leave (server);
glibtop_suid_leave (server);
return 0;
return 0;
}