diff options
author | Martin Baulig <martin@src.gnome.org> | 1998-08-06 22:55:22 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 1998-08-06 22:55:22 +0000 |
commit | 8750ff351eb913419f8497019aeeb663f04a4947 (patch) | |
tree | 61bb628e89ee78c262141334a6dbfd26d568d667 | |
parent | bfcc8c39442051ac5052362b562f48c5190f0133 (diff) | |
download | libgtop-8750ff351eb913419f8497019aeeb663f04a4947.tar.gz |
Bug fixes.
-rw-r--r-- | sysdeps/freebsd/cpu.c | 2 | ||||
-rw-r--r-- | sysdeps/freebsd/open.c | 59 |
2 files changed, 13 insertions, 48 deletions
diff --git a/sysdeps/freebsd/cpu.c b/sysdeps/freebsd/cpu.c index 8affc0e6..e6be9d7a 100644 --- a/sysdeps/freebsd/cpu.c +++ b/sysdeps/freebsd/cpu.c @@ -35,7 +35,7 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) long cp_time [CPUSTATES]; int i; - glibtop_init_p (&server, 0, 0); + glibtop_init_p (server, 0, 0); memset (buf, 0, sizeof (glibtop_cpu)); diff --git a/sysdeps/freebsd/open.c b/sysdeps/freebsd/open.c index edc6abaa..0a9e408b 100644 --- a/sysdeps/freebsd/open.c +++ b/sysdeps/freebsd/open.c @@ -57,6 +57,8 @@ void glibtop_open_p (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { + fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ()); + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ server->name = program_name; @@ -78,22 +80,19 @@ glibtop_open_p (glibtop *server, const char *program_name, server->machine.nlist_count = kvm_nlist (server->machine.kd, _glibtop_nlist); - if (server->machine.nlist_count < 0) + /* On FreeBSD, kvm_nlist () returns the number of invalid + * entries in the nlist. */ + + if (server->machine.nlist_count) glibtop_error_io_r (server, "nlist"); - - /* Make sure all of the symbols were found. */ - - if ((server->machine.nlist_count > 0) && - (_glibtop_check_nlist (server, _glibtop_nlist) > 0)) - _exit (1); - + /* Get tick frequency. */ - + (void) _glibtop_getkval (server, _glibtop_nlist [X_STATHZ].n_value, (int *) &server->machine.hz, sizeof (server->machine.hz), _glibtop_nlist [X_STATHZ].n_name); - + if (!server->machine.hz) (void) _glibtop_getkval (server, _glibtop_nlist [X_HZ].n_value, @@ -121,43 +120,6 @@ glibtop_open_p (glibtop *server, const char *program_name, * so it will fail if it is suid root and not sgid kmem. */ } -/* Used internally. Returns number of symbols that cannot be found in - * the nlist. */ - -int -_glibtop_check_nlist (void *server, register struct nlist *nlst) -{ - register int not_found; - - /* check to see if we got ALL the symbols we requested */ - /* this will write one line to stderr for every symbol not found */ - - not_found = 0; - - while (nlst->n_name != NULL) { - -#ifdef i386 - if (nlst->n_value == 0) { - glibtop_error_r (server, - "kernel: no symbol named `%s'", - nlst->n_name); - not_found++; - } -#else - if (nlst->n_type == 0) { - glibtop_error_r (server, - "kernel: no symbol named `%s'", - nlst->n_name); - not_found++; - } -#endif - - nlst++; - } - - return not_found; -} - /* Used internally. Fetches value from kernel. */ int @@ -166,6 +128,9 @@ _glibtop_getkval (void *void_server, unsigned long offset, int *ptr, { glibtop *server = (glibtop *) void_server; + fprintf (stderr, "DEBUG: kvm_read: %d - %lu - %p - %lu\n", + server->machine.kd, offset, ptr, size); + if (kvm_read (server->machine.kd, offset, ptr, size) != size) { if (*refstr == '!') return 0; |