Re: Libgtop and FreeBSD


On Tue, 7 Jul 1998, Josh Sled wrote:

> To:
> Subject: Libgtop and FreeBSD
> From: Josh Sled <jsled@scam.XCF.Berkeley.EDU>
> Sorry for the lack of word/progress on the FreeBSD port of Libgtop... 
> I still have intentions to finish what I've started, unfortunately,
> my computer seems to be conspiring against me.
> Every time I try to run test programs [to make sure I'm getting the
> data, and getting the correct data], something goes wrong.  Linking
> with the KVM library [used for getting access to the kvm_* functions
> which report on Kernel Virtual Memory] causes the program to do mysterious,
> bad things... sometimes the output code is screwed up and doesn't see the
> correct main function...  Last time I tried, the program had a bus error
> on the first kvm_ call [kvm_getprocs(...)], which strangely [and
> frustratingly] enough had worked before...  [this is still the case...
> see below]

I have now installed FreeBSD 2.2.6 on my system and a working cross
compiler from Linux to FreeBSD. The following test program worked fine
both with the cross and the native compiler:

#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <fcntl.h>

#include <sys/sysctl.h>
#include <kvm.h>

main (void)
        kvm_t *kd;
        struct kinfo_proc *pinfo;
        int count;

        kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");

        if (kd == NULL) {
                perror ("kvm_open");
                exit (1);

        pinfo = kvm_getprocs(kd, KERN_PROC_PID, 6626, &count);

        if (pinfo == NULL) {
                perror ("kvm_getprocs");
                exit (1);

        return 0;


If this doesn't work on your system, then something with your installation
is broken.

> Either I'm doing something wrong [doubtful because of the lack of complexity
> of my test programs], or FreeBSD is screwed... I can't determine which.
> I've been trying to upgrade FreeBSD, but I think I'm going to have to get
> more disk space before I can do that... and I don't even think that will solve
> the problem, since the test program didn't seem to work on a recent-release
> of FreeBSD [2.2.6 ... the current release version].
> Oy vey...
> More as it develops...
> If anyone else expresses interest in working on the port, I do have
> [somewhat] functional code... maybe they'll have more luck compiling
> than I...

Well, can you put it somewhere where other people can get it ? If you
don't know where, I have enabled anonymous ftp uploads at
''. Just log in as 'anonymous' or 'ftp' and anything
that looks like an email address as passwort and put it into the
'incoming' directory (Note: You can only upload files to this directory,
you cannot fetch them from there again).


> ...jsled
> PS. If anyone's interested or has played with libkvm in FreeBSD,
> this is what happens with the program...  it's a long shot, but maybe
> someone can help me... I'd really like to use gtop, someday...
> root@ip-206-79-223-152$ [~] gcc -ggdb -lkvm -L/usr/lib -o foo foo.c
> root@ip-206-79-223-152$ [~] gdb ./foo
> GDB is free software and you are welcome to distribute copies of it
>  under certain conditions; type "show copying" to see the conditions.
> There is absolutely no warranty for GDB; type "show warranty" for details.
> GDB 4.16 (i386-unknown-freebsd), 
> Copyright 1996 Free Software Foundation, Inc...
> (gdb) b main
> Breakpoint 1 at 0x1638: file foo.c, line 24.
> (gdb) run
> Starting program: /root/./foo 
> Breakpoint 1, main () at foo.c:24
> 24        printf("begin\n");
> (gdb) n
> begin
> 28        kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
> (gdb) 
> 30        if (kd == NULL) {
> (gdb) 
> 35        pinfo = kvm_getprocs(kd, KERN_PROC_PID, 6626, count);
> (gdb) 
> Program received signal SIGBUS, Bus error.
> 0x8019d1b in ?? () from /usr/lib/
> (gdb) bt
> #0  0x8019d1b in ?? () from /usr/lib/
> #1  0x1693 in main () at foo.c:35
> -- 
>          To unsubscribe: mail with 
>                        "unsubscribe" as the Subject.

- -----------------------------------------------------------------
   Martin Baulig - Angewandte Mathematik - Universitaet Trier,
   Key: 1024-bit key with ID C8178435 created 1997/01/24 
   ID:  67 C1 84 A0 47 F5 11 C5  5F 68 4C 84 99 05 C3 92
   Finger me for public key or fetch finger.txt from the url above
- ------------------------------------------------------------------

Version: 2.6.3i
Charset: noconv


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]