1833016 Members
2271 Online
110048 Solutions
New Discussion

C expert needed

 
SOLVED
Go to solution
Stefan Farrelly
Honored Contributor

C expert needed

 
Im from Palmerston North, New Zealand, but somehow ended up in London...
21 REPLIES 21
eran maor
Honored Contributor

Re: C expert needed

Hi

first i wanted to say that i m not an c expert
and i tried to compile the c program and i m getting all the time /usr/ccs/bin/ld: aa: Not a valid object file (invalid system id) .

but i wanted to tell you that i saw the same error with the command ipcs .

and over there the error was that a file was missing from the /stand .

RESOLUTION
A file in /stand is probably missing, most likely vmunix. Check
/stand to make sure everything that should be there is present.

Also verify permissions on the /stand directory and the files in it.

At least these files should be in /stand:

-rw-r--r-- 1 root sys 19 Jul 9 1999 bootconf
drwxr-xr-x 2 root root 1024 Jan 16 2001 build
-rw-r--r-- 1 root root 1568 Aug 23 2000 ioconfig
-r--r--r-- 1 root sys 82 May 19 1999 kernrel
drwxr-xr-x 2 root root 8192 May 19 1999 lost+found
-rw------- 1 root root 12 Nov 19 11:17 rootconf
-rw-rw-r-- 1 root sys 543 Jan 16 2001 system
-rwxr-xr-x 1 root sys 10065744 Jan 16 2001 vmunix


i will also check the primission .

now i will try to find a c expert that will help me with the c program
love computers
Paula J Frazer-Campbell
Honored Contributor

Re: C expert needed

Hi

Do you have :-

/usr/include/nlist.h


Paula
If you can spell SysAdmin then you is one - anon
Stefan Farrelly
Honored Contributor

Re: C expert needed


Thanks for the reply Eran but /stand/vmunix is definitely there and the permissions are fine. Im running it as root so no permission problems and the box is recently rebuilt nice and clean and all my other nifty scripts and C programs run aok.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Stefan Farrelly
Honored Contributor

Re: C expert needed

Hi Paula,

thanks, yes its there. All include files are there or it wouldnt compile. It compiles clean with.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Helen French
Honored Contributor

Re: C expert needed

Hi Stefan,

Not sure whether this helps or not, but this says to check the existence of files in /stand directory and the permissions:

http://us-support3.external.hp.com/cki/bin/doc.pl/sid=841cb8280d787ca834/screen=ckiDisplayDocument?docId=200000058669640

HTH,
Shiju

Life is a promise, fulfill it!
Robin Wakefield
Honored Contributor

Re: C expert needed

Hi Stefan,

Can you check the source, I'm getting an error on line 77, the printf on line 76 is not complete:

...
printf("HW page size is %d bytes\n",
printf("TLB is %s\n",unified_tlb?"unified":"separate");
...

unless my session's not working correctly?

Thx, Robin.
Volker Borowski
Honored Contributor

Re: C expert needed

Hi Stefan,

kernel="/stand/vmunix";
if (nlist(kernel, namelist) < 0)
{
kernel = "/hp-ux";
if (nlist(kernel, namelist) < 0)
cleanup("nlist");
}

The error message comes from the "cleanup" routine. Which is called after both(!) calls of nlist failed!
Since the basic routine causing the error is "nlist", I checked out "man nlist".

It is a systemcall, receiving an array with the names you like to extract, but

Once the nlist function has been called, the variable names are augmented with symbol information.

requires the object file to have symbol information. This is rarely the case for a compiled kernel. "nlist" has no qualification why it fails, so there ar only few reasons:
- file does not exist or is not accessible (easy to check)
- file is no object file (unlikely, because your system is runnning)
- file does not contain a symbol table

I think this program requires the kernel to be compiled with debug option to provide the symbol table. Now I just surfed SAM a bit, but found no options how to turn on kernel debugging or compile a kernel with symbol tables.

Do not know if this really helps....
Volker
Volker Borowski
Honored Contributor

Re: C expert needed

OK,

found something else:

/stand/build/config.mk

contains the makefile for the kernel.

Browse for DOSDEBUG and read through the comment section in this area. May be the originator of this Program is able to give you more info how to build your kernel for this.

# Debug kernels (-DOSDEBUG) produce symbolic stack traces as a debugging
# aid. Non-debug kernels produce purely numeric stack traces. They're
# not as convenient, but the memory overhead (~300KB) of storing the
# names of every kernel function is too high for the production kernel.


Volker
Stefan Farrelly
Honored Contributor

Re: C expert needed

Hi Robin,

Its taken me an hour to login to the itrc again!"$%%^&*. Talk about annoying. Heres a tail of the cache.c program so you can see the last few lines;

printf("\nOne cache line is %d bytes\n",
cache_tlb_parms.ic_conf.blocksize*16);
printf("Cache lines per chunk: %d\n",
cache_tlb_parms.ic_conf.lines_per_chunk );
printf("HW page size is %d bytes\n",
cache_tlb_parms.it_conf.page_size?4096:2048);
}

Tried attaching the file as a txt file also - been trying for half an hour - keeps hanging!"$%^&*@#

Volker - thanks for the info. Will look into it.

Cheers,

Stefan
Im from Palmerston North, New Zealand, but somehow ended up in London...
Volker Borowski
Honored Contributor

Re: C expert needed

Stefan,

I just added completed line 76 like this

76 printf("HW page size is %d bytes\n", 0);

and habe been able to compile and run the program without problem on 11.00 32-bit.

So my symbol theory is wrong :-(

May be you are running a 64-Bit version ?

Which may require the use of the "nlist64"-systemcall according to the mentioned man-page.

Volker

PS: Would be nice to complete line 76 with the correct value to get the HW page size reported.
Stefan Farrelly
Honored Contributor

Re: C expert needed

Hi Volker,

I get the same error wether on 10.20, 11/32 or 11/64. But I see youre point about nlist64, I will change this for an 11/64bit system and retry.

So you got it to run aok ? what was the output ??

Cheers,

Stefan
Im from Palmerston North, New Zealand, but somehow ended up in London...
Stefan Farrelly
Honored Contributor

Re: C expert needed

I still cant attach the file - it just hangs. Will try again to cut and paste in a bigger chunk.....


/**************************************************************************

This program prints size and organization of TLB and cache
Can be compiled without any specific options.
Can be run by a user that has read access to /dev/mem.

Author: Georges Aureau
Modified by Bernd Bausch

**************************************************************************/

#include
#include
#include
#include
#include

struct nlist namelist[] = {
{"cache_tlb_parms"},
{"cpu_has_hw_tlb_assist"},
{0}
};

cleanup(msg) { perror(msg); exit(1); }

main()
{
int hwtlb;
int unified_cache,unified_tlb;
char *kernel;
int core;
struct pdc_cache_rtn_block cache_tlb_parms;

kernel="/stand/build/vmunix_test";
if (nlist(kernel, namelist) < 0)
{
kernel = "/hp-ux";
if (nlist(kernel, namelist) < 0)
cleanup("nlist");
}

if ((core = open("/dev/mem", O_RDONLY)) < 0) cleanup("open kmem");

if (lseek(core, namelist[1].n_value, 0) < 0)
cleanup("lseek");

if (read(core, &hwtlb, sizeof(hwtlb)) < 0)
cleanup("read");

if (lseek(core, namelist[0].n_value, 0) < 0)
cleanup("lseek");

if (read(core, &cache_tlb_parms, sizeof(struct pdc_cache_rtn_block)) <
0)
cleanup("read");

unified_cache = cache_tlb_parms.ic_conf.f_sel;
unified_tlb = cache_tlb_parms.it_conf.p_sel;
printf( "\n" );
printf("%sHW TLB walker%s\n",hwtlb?"":"NO ",hwtlb?" present":"" );
printf("TLB is %s\n",unified_tlb?"unified":"separate");
if ( unified_tlb )
printf("TLB size is %d entries\n", cache_tlb_parms.it_size);
else
{
printf("I TLB size is %d entries\n", cache_tlb_parms.it_size);
printf("D TLB size is %d entries\n", cache_tlb_parms.dt_size);
}

printf("\nCache is %s\n",unified_cache?"unified":"separate");
if ( unified_cache )
printf("cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.ic_size,cache_tlb_parms.ic_size/4096);
else
{
printf("I cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.ic_size,cache_tlb_parms.ic_size/4096);
printf("D cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.dc_size,cache_tlb_parms.dc_size/4096);
}


printf("\nOne cache line is %d bytes\n",
cache_tlb_parms.ic_conf.blocksize*16);
printf("Cache lines per chunk: %d\n",
cache_tlb_parms.ic_conf.lines_per_chunk );
printf("HW page size is %d bytes\n",
cache_tlb_parms.it_conf.page_size?4096:2048);
}
Im from Palmerston North, New Zealand, but somehow ended up in London...
Volker Borowski
Honored Contributor

Re: C expert needed

Like this:

# a.out

HW TLB walker present
TLB is unified
TLB size is 64 entries

Cache is separate
I cache size is 131072 bytes (room for 32 pages)
D cache size is 131072 bytes (room for 32 pages)

One cache line is 32 bytes
Cache lines per chunk: 1
HW page size is 0 bytes
TLB is unified
TLB size is 64 entries

Cache is separate
I cache size is 131072 bytes (room for 32 pages)
D cache size is 131072 bytes (room for 32 pages)

One cache line is 32 bytes
Cache lines per chunk: 1
HW page size is 4096 bytes
#

-----------------

With the first "HW page size" line is the one i padded with zero. Does it have the same value as the one in the last line ?

... Now that I see the output, it looks like there was something clipped double in your post. Could you retry an attachment version ?

Volker

BTW: this box is not patched very up to date (could be an early 2001 bundle)
Volker Borowski
Honored Contributor

Re: C expert needed

Stefan,

you modified the kernel file parameter !

# cc proc1.c
# a.out

HW TLB walker present
TLB is unified
TLB size is 64 entries

Cache is separate
I cache size is 131072 bytes (room for 32 pages)
D cache size is 131072 bytes (room for 32 pages)

One cache line is 32 bytes
Cache lines per chunk: 1
HW page size is 4096 bytes
#

but only after I rechanged

kernel="/stand/vmunix";

not "/stand/build/vmunix_test"

Cheers
Volker
Stefan Farrelly
Honored Contributor

Re: C expert needed

Hi Volker,

Cant send as an attachment - it simply hangs! been trying all afternoon. Maybe in the morning when its quieter.

What compile options did you use if any ?
What hardware are you running it on ?

Thanks,

Stefan
Im from Palmerston North, New Zealand, but somehow ended up in London...
Stefan Farrelly
Honored Contributor

Re: C expert needed

Hi Volker,

oops, only modified it to vmunix_test in the 2nd pasting because I was trying to build the kernel with debug on and point the cache program to the newly built test kernel !

I can compile aok but cant get to run on anything, C, D, K, N !!
Im from Palmerston North, New Zealand, but somehow ended up in London...
harry d brown jr
Honored Contributor

Re: C expert needed

Stefan,

Try this:

cc +DD64 tstprog.c -lelf

for 32bit OS's try

cc +DD32 tstprog.c -lelf

of course I found it here:
http://www.geocities.com/ujjwal/3264interop.html

and this seems to work:

#include
#include
#include
#include

main(argc, argv)
int argc;
char **argv;
{
struct nlist64 nl[2]; /* pointer to the list */
char nm[32]; /* name of the symbol */

/* check the command line argument */
if ( argc != 3 ) {
fprintf(stderr,"Usage: %s executable_file_name symbol_name\n");
exit(1);
}

/* Initialize the list pointer */
memset ( nl, 0, sizeof(nl) );

/* set the symbol name */
sprintf(nm,"%s\0",argv[2]);

/* set the pointer to the symbol */
nl[0].n_name = nm;

/* extract the value */
if ( -1 == nlist64(argv[1], nl) ) {
perror("nlist() failed");
exit(2);
}

/* print the data associated with the field */
printf("name %s\n",nl[0].n_name);
printf("qual %s\n",nl[0].n_qual);
printf("type %u\n",nl[0].n_type);
printf("scope %u\n",nl[0].n_scope);
printf("info %u\n",nl[0].n_info);
printf("value %lu\n",nl[0].n_value);

exit(0);
}


runs like this:

# ./nlst /stand/vmunix cpu_has_hw_tlb_assist
name cpu_has_hw_tlb_assist
qual
type 1
scope 0
info 41
value 78252672
#

and is compiled using this:
cc +DD64 -onlst test.c -lelf



live free or die
harry
Live Free or Die
Volker Borowski
Honored Contributor

Re: C expert needed

Hi Stefan,

I have an old E45

what about this ?

# ls -lrt /dev/*mem*
crw-r----- 1 bin sys 3 0x000001 May 18 1995 /dev/kmem
crw-r----- 1 bin sys 3 0x000000 May 18 1995 /dev/mem
crw-r--r-- 1 root sys 27 0x000000 Jan 17 2001 /dev/dmem
#
# ls -l /stand/vmunix
-rwxr-xr-x 1 root sys 12959956 Oct 21 1999 /stand/vmunix
#
# file /stand/vmunix
/stand/vmunix: PA-RISC1.1 executable -not stripped

.... May be the box is really not well patched, as the last kernel-build was in 1999 ... :-)

I guess this is where my C-expertiese ends.... Sorry

Volker
harry d brown jr
Honored Contributor
Solution

Re: C expert needed

Stefan,

The problem with your program is that it is looking for the kernel at both /stand/vmunix and at /hp-ux, which causes the first error.

Change your original program by replacing calls or structs to nlist64 (leave the include as is). Then remove the if hp-ux crap.

and the output should be as follows (and the compile options I used):

# cc +DD64 -onlst tst.c -lelf
# ./nlst

NO HW TLB walker
TLB is unified
TLB size is 160 entries

Cache is separate
I cache size is 524288 bytes (room for 128 pages)
D cache size is 1048576 bytes (room for 256 pages)

One cache line is 64 bytes
Cache lines per chunk: 1
HW page size is 12 bytes
TLB is unified
TLB size is 160 entries

Cache is separate
I cache size is 524288 bytes (room for 128 pages)
D cache size is 1048576 bytes (room for 256 pages)

One cache line is 64 bytes
Cache lines per chunk: 1
HW page size is 4096 bytes


LIVE FREE or die (a lonely programmer)
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: C expert needed

Stefan,

Here's the "modified" program:

#include
#include
#include
#include
#include

struct nlist64 namelist[] = {
{"cache_tlb_parms"},
{"cpu_has_hw_tlb_assist"},
{0}
};

cleanup(msg) { perror(msg); exit(1); }

main()
{
int hwtlb;
int unified_cache,unified_tlb;
char *kernel;
int core;
struct pdc_cache_rtn_block cache_tlb_parms;

kernel="/stand/vmunix";
if (nlist64(kernel, namelist) < 0)
{
//kernel = "/hp-ux";
//if (nlist(kernel, namelist) < 0)
cleanup("nlist");
}

if ((core = open("/dev/mem", O_RDONLY)) < 0) cleanup("open kmem");

if (lseek(core, namelist[1].n_value, 0) < 0)
cleanup("lseek");

if (read(core, &hwtlb, sizeof(hwtlb)) < 0)
cleanup("read");

if (lseek(core, namelist[0].n_value, 0) < 0)
cleanup("lseek");

if (read(core, &cache_tlb_parms, sizeof(struct pdc_cache_rtn_block)) <
0)
cleanup("read");

unified_cache = cache_tlb_parms.ic_conf.f_sel;
unified_tlb = cache_tlb_parms.it_conf.p_sel;
printf( "\n" );
printf("%sHW TLB walker%s\n",hwtlb?"":"NO ",hwtlb?" present":"" );
printf("TLB is %s\n",unified_tlb?"unified":"separate");
if ( unified_tlb )
printf("TLB size is %d entries\n", cache_tlb_parms.it_size);
else
{
printf("I TLB size is %d entries\n", cache_tlb_parms.it_size);
printf("D TLB size is %d entries\n", cache_tlb_parms.dt_size);
}

printf("\nCache is %s\n",unified_cache?"unified":"separate");
if ( unified_cache )
printf("cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.ic_size,cache_tlb_parms.ic_size/4096);
else
{
printf("I cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.ic_size,cache_tlb_parms.ic_size/4096);
printf("D cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.dc_size,cache_tlb_parms.dc_size/4096);
}


printf("\nOne cache line is %d bytes\n",
cache_tlb_parms.ic_conf.blocksize*16);
printf("Cache lines per chunk: %d\n",
cache_tlb_parms.ic_conf.lines_per_chunk );
printf("HW page size is %d bytes\n",12);
//
//
// I put a 12 here (above), because the code is missing something
//
//
//
printf("TLB is %s\n",unified_tlb?"unified":"separate");
if ( unified_tlb )
printf("TLB size is %d entries\n", cache_tlb_parms.it_size);
else
{
printf("I TLB size is %d entries\n", cache_tlb_parms.it_size);
printf("D TLB size is %d entries\n", cache_tlb_parms.dt_size);
}

printf("\nCache is %s\n",unified_cache?"unified":"separate");
if ( unified_cache )
printf("cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.ic_size,cache_tlb_parms.ic_size/4096);
else
{
printf("I cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.ic_size,cache_tlb_parms.ic_size/4096);
printf("D cache size is %d bytes (room for %d pages)\n",
cache_tlb_parms.dc_size,cache_tlb_parms.dc_size/4096);
}


printf("\nOne cache line is %d bytes\n",
cache_tlb_parms.ic_conf.blocksize*16);
printf("Cache lines per chunk: %d\n",
cache_tlb_parms.ic_conf.lines_per_chunk );
printf("HW page size is %d bytes\n",
cache_tlb_parms.it_conf.page_size?4096:2048);
}

live free or die
harry
Live Free or Die
Stefan Farrelly
Honored Contributor

Re: C expert needed

Thanks Volker. And thanks a ton Harry ! Its working fine now.
Im from Palmerston North, New Zealand, but somehow ended up in London...