$NetBSD: patch-al,v 1.7 2000/05/02 00:27:35 fredb Exp $ --- sysdeps/freebsd/prockernel.c.orig Fri Jan 21 17:20:51 2000 +++ sysdeps/freebsd/prockernel.c Mon May 1 18:56:00 2000 @@ -34,7 +34,7 @@ #if (!defined __OpenBSD__) && (!defined __bsdi__) #include #endif -#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__)) +#if !defined(__bsdi__) && !(defined(__FreeBSD__) && defined(__alpha__)) && !defined(__NetBSD__) #include #endif #if defined(__FreeBSD__) && !defined(__alpha__) @@ -48,6 +48,11 @@ #include #endif +#if defined(__NetBSD__) && defined(__arm32__) +#include +#define KERNBASE KERNEL_BASE +#endif + static const unsigned long _glibtop_sysdeps_proc_kernel_pstats = (1L << GLIBTOP_PROC_KERNEL_MIN_FLT) + (1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) + @@ -129,8 +134,15 @@ glibtop_suid_enter (server); +#ifdef __NetBSD__ + /* On NetBSD, there is no kvm_uread(), and kvm_read() always reads + * from kernel memory. */ + + if (kvm_read (server->machine.kd, +#else if ((pinfo [0].kp_proc.p_flag & P_INMEM) && kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc, +#endif (unsigned long) &u_addr->u_stats, (char *) &pstats, sizeof (pstats)) == sizeof (pstats)) { @@ -149,8 +161,12 @@ buf->flags |= _glibtop_sysdeps_proc_kernel_pstats; } +#ifdef __NetBSD__ + if (kvm_read (server->machine.kd, +#else if ((pinfo [0].kp_proc.p_flag & P_INMEM) && kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc, +#endif (unsigned long) &u_addr->u_pcb, (char *) &pcb, sizeof (pcb)) == sizeof (pcb)) { @@ -167,14 +183,32 @@ /*xxx FreeBSD/Alpha? */ #endif #else +#ifdef __i386__ 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 +#else +#if defined(__NetBSD__) && defined(__m68k__) + buf->kstk_esp = (u_int64_t) pcb.pcb_usp; + buf->kstk_eip = (u_int64_t) 0; +#else +#if defined(__NetBSD__) && defined(__arm32__) + buf->kstk_esp = (u_int64_t) pcb.pcb_sp; + buf->kstk_eip = (u_int64_t) 0; +#else +#ifdef __NetBSD__ + /* provide some defaults for other platforms */ + buf->kstk_esp = (u_int64_t) 0; + buf->kstk_eip = (u_int64_t) 0; +#endif +#endif +#endif buf->flags |= _glibtop_sysdeps_proc_kernel_pcb; +#endif #endif }