Added implementation.
1998-08-18 Martin Baulig <martin@home-of-linux.org> * sysdeps/linux/procmap.c: Added implementation.
This commit is contained in:
committed by
Martin Baulig
parent
7ad67781ef
commit
96e630a009
@@ -1,3 +1,7 @@
|
||||
1998-08-18 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* sysdeps/linux/procmap.c: Added implementation.
|
||||
|
||||
1998-08-17 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/procmap (glibtop_map_entry): Added `offset' and
|
||||
|
@@ -39,9 +39,70 @@ glibtop_init_proc_map_s (glibtop *server)
|
||||
glibtop_map_entry *
|
||||
glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid)
|
||||
{
|
||||
char fn [BUFSIZ];
|
||||
glibtop_map_entry *entry_list = NULL;
|
||||
int rv, n = 0;
|
||||
FILE *maps;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_proc_map));
|
||||
|
||||
sprintf (fn, "/proc/%d/maps", pid);
|
||||
|
||||
maps = fopen (fn, "r");
|
||||
if (!maps) return NULL;
|
||||
|
||||
do {
|
||||
short dev_major, dev_minor;
|
||||
unsigned long start, end, offset, inode;
|
||||
char flags [5];
|
||||
size_t size;
|
||||
|
||||
rv = fscanf (maps,
|
||||
"%08lx-%08lx %4c\n %08lx %02hx:%02hx %ld",
|
||||
&start, &end, flags, &offset,
|
||||
&dev_major, &dev_minor, &inode);
|
||||
|
||||
flags [4] = 0;
|
||||
|
||||
fn [0] = fgetc (maps);
|
||||
/* printf ("fn [0] '%c' %x\n", fn [0], fn [0]); */
|
||||
|
||||
if (fn [0] != '\n' && fn [0] != EOF) {
|
||||
|
||||
fscanf (maps, "%*[ ]%[^\n]\n", fn);
|
||||
/* row->filename = glibtop_strdup_r (server, fn); */
|
||||
|
||||
} /* else row->filename = NULL; */
|
||||
|
||||
/* if (rv != EOF)
|
||||
printf ("%08lx-%08lx %s\n",
|
||||
row->VMstart, row->VMend,
|
||||
row->filename); */
|
||||
|
||||
n++;
|
||||
|
||||
size = n * sizeof (glibtop_map_entry);
|
||||
|
||||
entry_list = glibtop_realloc_r (server, entry_list, size);
|
||||
|
||||
entry_list [n-1].start = (u_int64_t) start;
|
||||
entry_list [n-1].end = (u_int64_t) end;
|
||||
entry_list [n-1].offset = (u_int64_t) offset;
|
||||
entry_list [n-1].device = (u_int64_t) (dev_major << 8) +
|
||||
(u_int64_t) dev_minor;
|
||||
entry_list [n-1].inode = (u_int64_t) inode;
|
||||
|
||||
} while (rv != EOF && rv && fn [0] != EOF);
|
||||
|
||||
return NULL;
|
||||
/* printf ("allocated: %d\n", i); */
|
||||
|
||||
fclose (maps);
|
||||
|
||||
buf->number = n;
|
||||
buf->size = sizeof (glibtop_map_entry);
|
||||
buf->total = n * sizeof (glibtop_map_entry);
|
||||
|
||||
return entry_list;
|
||||
}
|
||||
|
Reference in New Issue
Block a user