home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <nlist.h>
- #include <sys/file.h>
- #include <sys/user.h>
- #include <kvm.h>
-
- #include "cputt.h"
-
- /*
- INIT - Gets symbol table values for symbols in Symbollist.
- */
-
- void
- init()
- {
- register struct nlist *np;
- register struct symbol *s;
- register struct nlist *np0;
- char *getcore();
-
- /* find length of the list of desired symbols */
- for (s = Symbollist; s->s_kname; s++);
-
- /* allocate core for nlist array */
- np0 = (struct nlist*)getcore((s-Symbollist+1)*sizeof(struct nlist));
-
- /* initialize nlist array */
- for (s = Symbollist,np = np0; s->s_kname; s++,np++)
- {
- np->n_name = s->s_kname;
- np[1].n_name = (char*)0;
- np->n_value = 0;
- }
-
- /* read symbols from symbol table into nlist array */
- if (kvm_nlist(Flkvm,np0) == -1)
- {
- fprintf(stderr,"sps - Can't read symbol file \n");
- sysperror();
- }
-
- /* derive system info from nlist and store in Symbollist */
- for (s = Symbollist,np = np0; s->s_kname; s++,np++)
- {
- if (!np->n_value)
- {
- fprintf( stderr, "sps - Can't find symbol %s in %s", np->n_name);
- *s->s_info = (caddr_t)0;
- continue;
- }
-
- /* Using the obtained address, read the value into Symbollist */
- (void)getkmem((long)np->n_value, (char*)s->s_info, sizeof(caddr_t));
- }
- free((char*)np0);
- }
-