hi all,
Now I want to remove the libproc.so relative codes from libgtop, because
it's not stable, and I can't use them when I port libgtop to Solairs. I
checked those codes, they are only used to get the filename of Process
Memory Maps. I am working to seek a method to replace them, could
anyone could give me alternative interface?
The procedure seems is following:
>1. in open.c, open libproc.so, and set objname/pgrab/pfree.
Program is:
-----------------
dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY);
if(server->machine.libproc)
dlclose(server->machine.libproc);
server->machine.libproc = dl;
if(dl)
{
void *func;
func = dlsym(dl, "Pobjname"); /* Solaris 8 */
if(!func)
func = dlsym(dl, "proc_objname"); /* Solaris 7 */
server->machine.objname = (void (*)
(void *, uintptr_t, const char *, size_t))func;
server->machine.pgrab = (struct ps_prochandle *(*)(pid_t, int, int *))
dlsym(dl, "Pgrab");
server->machine.pfree = (void (*)(void *))dlsym(dl, "Pfree");
}
else
{
server->machine.objname = NULL;
server->machine.pgrab = NULL;
server->machine.pfree = NULL;
}
---------------------
>2. in procmap.c, create a pointer, Pr, point to ps_prochandle
Program is:
-----------------
if(server->machine.objname && server->machine.pgrab &&
server->machine.pfree)
Pr = (server->machine.pgrab)(pid, 1,&pr_err);
---------------------
3. in procmap.c, get filename.
Program is:
-----------------
if(Pr)
{
server->machine.objname(Pr, maps[i].pr_vaddr, buffer,
BUFSIZ);
if((len = resolvepath(buffer, entry[i].filename,
GLIBTOP_MAP_FILENAME_LEN)) > 0)
{
entry[i].filename[len] = 0;
entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME);
}
}
---------------------
4. in procmap.c, free the Pr.
Program is:
-----------------
if(Pr)
server->machine.pfree(Pr);
---------------------
The detailed context you could find in the enclosed files.
I appreciate for any help from you...
Thanks,
Henry
--
Henry Zhang
Software Engineer
Sun China Engineering & Research Institute
Sun Microsystems, Inc.
10/F Chuang Xin Plaza, Tsinghua Science Park
Beijing 100084, P.R. China
Tel: +86 10 8261 8200 - 82866
eMail: hua.zhang at sun.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: open.c
Type: text/x-csrc
Size: 6955 bytes
Desc: not available
URL:
<http://mail.opensolaris.org/pipermail/observability-discuss/attachments/20060714/ffc1b340/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procmap.c
Type: text/x-csrc
Size: 5536 bytes
Desc: not available
URL:
<http://mail.opensolaris.org/pipermail/observability-discuss/attachments/20060714/ffc1b340/attachment-0001.bin>