Subject: Re: kvm_nlist() lookup failed for symbol '_cp_time'
To: None <current-users@netbsd.org>
From: Bernd Ernesti <netbsd@arresum.inka.de>
List: current-users
Date: 06/30/2000 11:18:35
--%--multipart-mixed-boundary-1.19866.962356715--%
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
On Thu Jun 29 23:17:30 2000, Markus Kurek wrote:
>
> Hi,
>
> I get this on NetBSD-1.5_ALPHA compiled from sources of June, 26th.
>
> >xosview
> xosview: kvm_nlist() lookup failed for symbol '_cp_time'.
> xosview: safe_kvm_read() was attempted on EA 0
Get xosview 1.7.3 from http://lore.ece.utexas.edu/~bgrayson/xosview.html
and apply the attached patch.
I send an earlier patch on Monday to Brian but heard nothing from him yet.
Bernd
--%--multipart-mixed-boundary-1.19866.962356715--%
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Description: 'diff' output text
Content-Disposition: attachment; filename="xosview-1.7.3.patch"
*** ./bsd/kernel.cc-orig Tue Jul 6 06:09:30 1999
--- ./bsd/kernel.cc Fri Jun 30 09:45:26 2000
***************
*** 28,35 ****
#include <err.h> /* For err(), warn(), etc. BCG */
#include <errno.h>
- #include <sys/dkstat.h> /* For CPUSTATES, which tells us how
- many cpu states there are. */
#ifndef XOSVIEW_FREEBSD
#include <sys/disk.h> /* For disk statistics. */
#endif
--- 28,33 ----
***************
*** 60,73 ****
#include <sys/malloc.h>
#include <sys/sysctl.h>
#include <sys/device.h>
#include <vm/vm.h> /* XXX Is this needed? */
#else
#include <sys/vmmeter.h> /* For struct vmmeter. */
#endif
#ifdef HAVE_SWAPCTL
#include <unistd.h> /* For swapctl proto. */
! #include <vm/vm_swap.h> /* For swapent, SWAP_*. */
#include <stdlib.h> /* For malloc(), free(). */
#endif
--- 58,84 ----
#include <sys/malloc.h>
#include <sys/sysctl.h>
#include <sys/device.h>
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ <= 105010000)
#include <vm/vm.h> /* XXX Is this needed? */
+ #endif
#else
#include <sys/vmmeter.h> /* For struct vmmeter. */
#endif
+ /* For CPUSTATES, which tells us how many cpu states there are. */
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000)
+ #include <sys/sched.h>
+ #else
+ #include <sys/dkstat.h>
+ #endif
+
#ifdef HAVE_SWAPCTL
#include <unistd.h> /* For swapctl proto. */
! #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104000000)
! #include <sys/swap.h> /* For swapent, SWAP_*. */
! #else
! #include <vm/vm_swap.h>
! #endif
#include <stdlib.h> /* For malloc(), free(). */
#endif
***************
*** 100,107 ****
// This struct has the list of all the symbols we want from the kernel.
static struct nlist nlst[] =
{
! #ifdef XOSVIEW_BSDI
! // BSDI reads cp_time through sysctl
{ "_ifnet" },
#define DUMMY_0
#else
--- 111,118 ----
// This struct has the list of all the symbols we want from the kernel.
static struct nlist nlst[] =
{
! #if defined(XOSVIEW_BSDI) || (defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000))
! // BSDI and __NetBSD_Version__ >= 104260000 reads cp_time through sysctl
{ "_ifnet" },
#define DUMMY_0
#else
***************
*** 344,355 ****
}
void
BSDGetCPUTimes (long* timeArray) {
! #ifdef XOSVIEW_BSDI
struct cpustats cpu;
size_t size = sizeof(cpu);
static int mib[] = { CTL_KERN, KERN_CPUSTATS };
#endif
if (!timeArray) errx (-1, "BSDGetCPUTimes(): passed pointer was null!\n");
if (CPUSTATES != 5)
--- 355,375 ----
}
void
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000)
+ BSDGetCPUTimes (u_int64_t* timeArray) {
+ #else
BSDGetCPUTimes (long* timeArray) {
! #endif
! #if defined(XOSVIEW_BSDI)
struct cpustats cpu;
size_t size = sizeof(cpu);
static int mib[] = { CTL_KERN, KERN_CPUSTATS };
#endif
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000)
+ u_int64_t cp_time[CPUSTATES];
+ size_t ssize = sizeof(cp_time);
+ static int mib[] = { CTL_KERN, KERN_CP_TIME };
+ #endif
if (!timeArray) errx (-1, "BSDGetCPUTimes(): passed pointer was null!\n");
if (CPUSTATES != 5)
***************
*** 360,365 ****
--- 380,391 ----
bzero(&cpu, sizeof(cpu));
}
bcopy (cpu.cp_time,timeArray,sizeof (long) * CPUSTATES);
+ #elif (defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000))
+ if (sysctl(mib, 2, cp_time, &ssize, NULL, 0) < 0) {
+ fprintf(stderr, "xosview: sysctl failed: %s\n", strerror(errno));
+ bzero(cp_time, ssize);
+ }
+ bcopy (cp_time,timeArray,sizeof (u_int64_t) * CPUSTATES);
#else
safe_kvm_read_symbol (CP_TIME_SYM_INDEX, timeArray, sizeof (long) * CPUSTATES);
#endif
*** ./bsd/btrymeter.cc-orig Mon Jan 25 21:14:33 1999
--- ./bsd/btrymeter.cc Thu Jun 29 19:40:27 2000
***************
*** 48,53 ****
--- 48,54 ----
void BtryMeter::getpwrinfo( void ){
struct apm_power_info buff;
+ float minutes_left, max_left;
int error = 0;
int loadinfo = open(APMFILENAME, O_RDONLY, 0);
***************
*** 60,89 ****
error = ioctl(loadinfo, APM_IOC_GETPOWER, &buff);
if (error != -1) {
! fields_[0] = (float)buff.battery_life; // percent left
! fields_[1] = 100.0 - fields_[0]; // percent used
! float minutes_left = (float)buff.minutes_left;
!
! // minutes_left = (percent_left/100.0) * max_minutes;
! // minutes_left / (percent_left/100.0) = max_minutes;
! // minutes_left * 100.0 / percent_left = max_minutes;
! float max_left = minutes_left * 100.0 / fields_[0];
!
! //
! // Set total_ so that the graphing methods know to set the
! // relative sizes of the percent left and percent used graphs.
! //
! total_ = 100.0;
!
! //
! // This sets the actual number of minutes left. If the resource
! // xosview*batteryUsedFormat is "float", then xosview will display
! // that number to the left of the battery graph. If it's
! // "percent", then you get the percent remaining next to the
! // graph.
! //
! setUsed(minutes_left, max_left);
}
close(loadinfo);
--- 61,97 ----
error = ioctl(loadinfo, APM_IOC_GETPOWER, &buff);
if (error != -1) {
+ if (buff.battery_state != APM_BATT_ABSENT) {
! fields_[0] = (float)buff.battery_life; // percent left
! fields_[1] = 100.0 - fields_[0]; // percent used
! minutes_left = (float)buff.minutes_left;
!
! // minutes_left = (percent_left/100.0) * max_minutes;
! // minutes_left / (percent_left/100.0) = max_minutes;
! // minutes_left * 100.0 / percent_left = max_minutes;
! if (minutes_left == 0) {
! // This fix a bogus warning when the apm bios doesn't know
! // the correct remaining time.
! minutes_left = (float)0.01;
! }
! max_left = minutes_left * 100.0 / fields_[0];
!
! //
! // Set total_ so that the graphing methods know to set the
! // relative sizes of the percent left and percent used graphs.
! //
! total_ = 100.0;
!
! //
! // This sets the actual number of minutes left. If the resource
! // xosview*batteryUsedFormat is "float", then xosview will display
! // that number to the left of the battery graph. If it's
! // "percent", then you get the percent remaining next to the
! // graph.
! //
! setUsed(minutes_left, max_left);
! }
}
close(loadinfo);
*** ./bsd/cpumeter.cc-orig Tue Jul 6 06:07:09 1999
--- ./bsd/cpumeter.cc Sun Jun 25 18:56:22 2000
***************
*** 14,30 ****
//
// $Id: cpumeter.cc,v 1.17 1999/07/06 04:07:09 bgrayson Exp $
//
! #include <sys/dkstat.h> // For CPUSTATES #define. BCG
#include <stdlib.h> // For use of atoi BCG
#include "general.h"
#include "cpumeter.h"
#include "kernel.h" // For NetBSD-specific icky kvm_ code. BCG
CVSID("$Id: cpumeter.cc,v 1.17 1999/07/06 04:07:09 bgrayson Exp $");
CVSID_DOT_H(CPUMETER_H_CVSID);
CPUMeter::CPUMeter( XOSView *parent )
! #if defined(XOSVIEW_FREEBSD) || defined(XOSVIEW_BSDI)
: FieldMeterGraph( parent, 5, "CPU", "USR/NICE/SYS/INT/FREE" ){
#define FREE_INDEX 4
#else
--- 14,38 ----
//
// $Id: cpumeter.cc,v 1.17 1999/07/06 04:07:09 bgrayson Exp $
//
! #include <sys/param.h> // Needed for __NetBSD_Version__
#include <stdlib.h> // For use of atoi BCG
#include "general.h"
#include "cpumeter.h"
#include "kernel.h" // For NetBSD-specific icky kvm_ code. BCG
+ // For CPUSTATES #define. BCG
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000)
+ #include <sys/sched.h>
+ #else
+ #include <sys/dkstat.h>
+ #endif
+
CVSID("$Id: cpumeter.cc,v 1.17 1999/07/06 04:07:09 bgrayson Exp $");
CVSID_DOT_H(CPUMETER_H_CVSID);
CPUMeter::CPUMeter( XOSView *parent )
! #if defined(XOSVIEW_FREEBSD) || defined(XOSVIEW_BSDI) || \
! (defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000))
: FieldMeterGraph( parent, 5, "CPU", "USR/NICE/SYS/INT/FREE" ){
#define FREE_INDEX 4
#else
***************
*** 72,84 ****
static double lastTotal = 0, lastLastTotal = -1;
// Begin NetBSD-specific code... BCG
long tempCPU[CPUSTATES];
BSDGetCPUTimes (tempCPU);
cputime_[cpuindex_][0] = tempCPU[0];
cputime_[cpuindex_][1] = tempCPU[1];
! #if defined(XOSVIEW_FREEBSD) || defined(XOSVIEW_BSDI)
// FreeBSD seems at least to be filling cp_time[CP_INTR]. So, we add that
// as another field. (pavel 25-Jan-1998)
cputime_[cpuindex_][2] = tempCPU[2];
--- 80,97 ----
static double lastTotal = 0, lastLastTotal = -1;
// Begin NetBSD-specific code... BCG
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000)
+ u_int64_t tempCPU[CPUSTATES];
+ #else
long tempCPU[CPUSTATES];
+ #endif
BSDGetCPUTimes (tempCPU);
cputime_[cpuindex_][0] = tempCPU[0];
cputime_[cpuindex_][1] = tempCPU[1];
! #if defined(XOSVIEW_FREEBSD) || defined(XOSVIEW_BSDI) || \
! (defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000))
// FreeBSD seems at least to be filling cp_time[CP_INTR]. So, we add that
// as another field. (pavel 25-Jan-1998)
cputime_[cpuindex_][2] = tempCPU[2];
*** ./bsd/kernel.h-orig Fri May 29 23:21:36 1998
--- ./bsd/kernel.h Sun Jun 25 18:25:33 2000
***************
*** 38,45 ****
--- 38,50 ----
void
BSDCPUInit();
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000)
+ void
+ BSDGetCPUTimes(u_int64_t* timesArray);
+ #else
void
BSDGetCPUTimes(long* timesArray);
+ #endif
void
BSDNetInit();
*** ./bsd/pagemeter.h-orig Tue Oct 20 21:37:35 1998
--- ./bsd/pagemeter.h Fri Jun 30 09:45:00 2000
***************
*** 22,28 ****
--- 22,30 ----
#include "fieldmetergraph.h"
#if defined(UVM)
#include <sys/param.h>
+ #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ <= 105010000)
#include <vm/vm.h>
+ #endif
#include <uvm/uvm_extern.h>
#else
#include <sys/vmmeter.h>
*** ./config/configure.in-orig Wed Nov 17 08:08:20 1999
--- ./config/configure.in Sat May 27 19:31:33 2000
***************
*** 112,118 ****
@echo UVMyes
.endif
EOF
! uvmstring=`make -f confmkfile`
rm confmkfile
if test x$uvmstring != x ; then
AC_DEFINE(UVM)
--- 112,118 ----
@echo UVMyes
.endif
EOF
! uvmstring=`make -f confmkfile all`
rm confmkfile
if test x$uvmstring != x ; then
AC_DEFINE(UVM)
***************
*** 127,133 ****
dnl Before choosing non-UVM, check for some uvm-only symbols
dnl in the currently-running kernel.
AC_MSG_WARN(['UVM=' not found in /etc/mk.conf. Checking /netbsd for uvm symbols...])
! if test x`nm /netbsd | grep uvm_sysctl` != x ; then
AC_DEFINE(UVM)
AC_MSG_WARN([*Enabling* UVM -- 'uvm_sysctl' symbol found in /netbsd.
If this is in error, remove the define of UVM=1 from CXXFLAGS
--- 127,133 ----
dnl Before choosing non-UVM, check for some uvm-only symbols
dnl in the currently-running kernel.
AC_MSG_WARN(['UVM=' not found in /etc/mk.conf. Checking /netbsd for uvm symbols...])
! if test x"`nm /netbsd | grep uvm_sysctl`" != x"" ; then
AC_DEFINE(UVM)
AC_MSG_WARN([*Enabling* UVM -- 'uvm_sysctl' symbol found in /netbsd.
If this is in error, remove the define of UVM=1 from CXXFLAGS
*** ./config/Makefile.top.in-orig Wed Nov 17 07:30:25 1999
--- ./config/Makefile.top.in Sat May 27 20:16:01 2000
***************
*** 56,69 ****
## These next lines look really ugly. The echo statements are an
## attempt to make the output look a little nicer.
install: xosview
@echo "*** Installing executable..."
@INSTALL_PROGRAM@ @INSTALL_ARGS@ xosview $(BINDIR)
@echo "*** Installing application defaults..."
@INSTALL_DATA@ Xdefaults $(XAPPLOADDIR)/XOsview
@echo "*** Making sure $(MANDIR) exists..."
@if [ ! -d $(MANDIR) ]; then \
echo "*** Making $(MANDIR)..."; \
! mkdir $(MANDIR); \
fi
@echo "*** Installing man page..."
@INSTALL_DATA@ xosview.1 $(MANDIR)
--- 56,77 ----
## These next lines look really ugly. The echo statements are an
## attempt to make the output look a little nicer.
install: xosview
+ @if [ ! -d $(BINDIR) ]; then \
+ echo "*** Making $(BINDIR)..."; \
+ mkdir -p $(BINDIR); \
+ fi
@echo "*** Installing executable..."
@INSTALL_PROGRAM@ @INSTALL_ARGS@ xosview $(BINDIR)
+ @if [ ! -d $(XAPPLOADDIR) ]; then \
+ echo "*** Making $(XAPPLOADDIR)..."; \
+ mkdir -p $(XAPPLOADDIR); \
+ fi
@echo "*** Installing application defaults..."
@INSTALL_DATA@ Xdefaults $(XAPPLOADDIR)/XOsview
@echo "*** Making sure $(MANDIR) exists..."
@if [ ! -d $(MANDIR) ]; then \
echo "*** Making $(MANDIR)..."; \
! mkdir -p $(MANDIR); \
fi
@echo "*** Installing man page..."
@INSTALL_DATA@ xosview.1 $(MANDIR)
*** ./Xdefaults-orig Wed Nov 17 06:53:01 1999
--- ./Xdefaults Sat May 27 19:47:00 2000
***************
*** 29,34 ****
--- 29,35 ----
xosview*loadProcColor: seagreen
xosview*loadIdleColor: aquamarine
xosview*loadPriority: 20
+ xosview*loadAlarmThreshold: 2
xosview*loadCritThreshold: 5
xosview*loadWarnThreshold: 2
xosview*loadDecay: False
--%--multipart-mixed-boundary-1.19866.962356715--%--