From: Philippe E. <ph...@us...> - 2002-10-05 18:13:35
|
Update of /cvsroot/oprofile/oprofile/dae In directory usw-pr-cvs1:/tmp/cvs-serv1577/dae Modified Files: opd_image.c opd_mapping.c opd_mapping.h opd_parse_proc.c Log Message: kill opd_grow_maps() regards, Phil Index: opd_image.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/dae/opd_image.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- opd_image.c 27 Sep 2002 23:12:38 -0000 1.13 +++ opd_image.c 5 Oct 2002 18:13:31 -0000 1.14 @@ -167,7 +167,7 @@ len = strlen(mangled); - for (i=0; i < op_nr_counters; i++) { + for (i = 0; i < op_nr_counters; i++) { db_tree_t * tree = &image->sample_files[i]; if (tree->base_memory) { db_close(tree); Index: opd_mapping.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/dae/opd_mapping.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- opd_mapping.c 23 Sep 2002 01:44:57 -0000 1.5 +++ opd_mapping.c 5 Oct 2002 18:13:31 -0000 1.6 @@ -63,20 +63,6 @@ /** - * opd_grow_maps - grow map structure for a process - * @param proc process to work on - * - * Grow the map structure for a process by %OPD_MAP_INC - * entries. (FIXME: should be static) - */ -void opd_grow_maps(struct opd_proc * proc) -{ - proc->maps = xrealloc(proc->maps, sizeof(struct opd_map)*(proc->max_nr_maps+OPD_MAP_INC)); - proc->max_nr_maps += OPD_MAP_INC; -} - - -/** * opd_kill_maps - delete mapping information for a process * @param proc process to work on * @@ -99,23 +85,28 @@ * @param offset file offset of mapping * @param end end of mapping * - * Add the mapping specified to the process @proc. + * Add the mapping specified to the process proc growing the maps array + * if necessary. */ -static void opd_put_mapping(struct opd_proc * proc, struct opd_image * image, - unsigned long start, unsigned long offset, unsigned long end) +void opd_add_mapping(struct opd_proc * proc, struct opd_image * image, + unsigned long start, unsigned long offset, unsigned long end) { - verbprintf("Placing mapping for process %d: 0x%.8lx-0x%.8lx, off 0x%.8lx, \"%s\" at maps pos %d\n", + struct opd_map * map = &proc->maps[proc->nr_maps]; + + verbprintf("Adding mapping for process %d: 0x%.8lx-0x%.8lx, off 0x%.8lx, \"%s\" at maps pos %d\n", proc->pid, start, end, offset, image->name, proc->nr_maps); opd_check_image_mtime(image); - proc->maps[proc->nr_maps].image = image; - proc->maps[proc->nr_maps].start = start; - proc->maps[proc->nr_maps].offset = offset; - proc->maps[proc->nr_maps].end = end; + map->image = image; + map->start = start; + map->offset = offset; + map->end = end; - if (++proc->nr_maps == proc->max_nr_maps) - opd_grow_maps(proc); + if (++proc->nr_maps == proc->max_nr_maps) { + proc->max_nr_maps += OPD_MAP_INC; + proc->maps = xrealloc(proc->maps, sizeof(struct opd_map)*(proc->max_nr_maps)); + } /* we reset last map here to force searching backwards */ proc->last_map = 0; @@ -205,5 +196,5 @@ if (image == NULL) image = opd_handle_hashmap(hash, app_name); - opd_put_mapping(proc, image, note->addr, note->offset, note->addr + note->len); + opd_add_mapping(proc, image, note->addr, note->offset, note->addr + note->len); } Index: opd_mapping.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/dae/opd_mapping.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- opd_mapping.h 10 Sep 2002 20:01:00 -0000 1.4 +++ opd_mapping.h 5 Oct 2002 18:13:31 -0000 1.5 @@ -28,7 +28,8 @@ void opd_init_hash_map(void); void opd_init_maps(struct opd_proc * proc); void opd_handle_mapping(struct op_note const * note); -void opd_grow_maps(struct opd_proc * proc); +void opd_add_mapping(struct opd_proc * proc, struct opd_image *, + unsigned long start, unsigned long offset, unsigned long end); void opd_kill_maps(struct opd_proc * proc); /** Index: opd_parse_proc.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/dae/opd_parse_proc.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- opd_parse_proc.c 2 Oct 2002 21:58:47 -0000 1.10 +++ opd_parse_proc.c 5 Oct 2002 18:13:31 -0000 1.11 @@ -43,7 +43,8 @@ static int opd_add_ascii_map(struct opd_proc * proc, char const * line, char * const image_name) { - struct opd_map * map = &proc->maps[proc->nr_maps]; + unsigned long offset, start, end; + struct opd_image * image; char const * cp = line; /* skip to protection field */ @@ -55,14 +56,14 @@ return 0; /* get start and end from "40000000-4001f000" */ - if (sscanf(line, "%lx-%lx", &map->start, &map->end) != 2) + if (sscanf(line, "%lx-%lx", &start, &end) != 2) return 0; /* "p " */ cp += 2; /* read offset */ - if (sscanf(cp, "%lx", &map->offset) != 1) + if (sscanf(cp, "%lx", &offset) != 1) return 0; while (*cp && *cp != '/') @@ -71,13 +72,11 @@ if (!*cp) return 0; - map->image = opd_get_image(cp, -1, image_name, 0); - - if (!map->image) + image = opd_get_image(cp, -1, image_name, 0); + if (!image) return 0; - if (++proc->nr_maps == proc->max_nr_maps) - opd_grow_maps(proc); + opd_add_mapping(proc, image, start, offset, end); return 1; } |