mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
Cache BinFiles by filename.
Sat Jul 9 23:20:39 2005 Soeren Sandmann <sandmann@redhat.com> * binfile.c (bin_file_new): Cache BinFiles by filename. * stackstash.c (stack_stash_free): Plug leak * process.c (process_free_maps): Plug leak * module/Makefile (install): Check that depmod exists before running it.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
3459f764d7
commit
f3b78b7944
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Sat Jul 9 23:20:39 2005 Soeren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
|
* binfile.c (bin_file_new): Cache BinFiles by filename.
|
||||||
|
|
||||||
|
* stackstash.c (stack_stash_free): Plug leak
|
||||||
|
|
||||||
|
* process.c (process_free_maps): Plug leak
|
||||||
|
|
||||||
|
* module/Makefile (install): Check that depmod exists before
|
||||||
|
running it.
|
||||||
|
|
||||||
Sun Jun 19 15:42:34 2005 Søren Sandmann <sandmann@redhat.com>
|
Sun Jun 19 15:42:34 2005 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* module/sysprof-module.c (SAMPLES_PER_SECOND): Set to 200.
|
* module/sysprof-module.c (SAMPLES_PER_SECOND): Set to 200.
|
||||||
|
|||||||
3
TODO
3
TODO
@ -191,7 +191,6 @@ http://www.linuxbase.org/spec/booksets/LSB-Embedded/LSB-Embedded/ehframe.html
|
|||||||
- Possibly a special "view details" mode, assuming that
|
- Possibly a special "view details" mode, assuming that
|
||||||
the details of a function are not that interesting
|
the details of a function are not that interesting
|
||||||
together with a tree.
|
together with a tree.
|
||||||
- consider caching [filename => bin_file]
|
|
||||||
- rethink caller list, not terribly useful at the moment.
|
- rethink caller list, not terribly useful at the moment.
|
||||||
|
|
||||||
- Have kernel module report the file the address was found in
|
- Have kernel module report the file the address was found in
|
||||||
@ -370,6 +369,8 @@ Later:
|
|||||||
|
|
||||||
DONE:
|
DONE:
|
||||||
|
|
||||||
|
* consider caching [filename => bin_file]
|
||||||
|
|
||||||
* Check the kernel we are building against, if it is SMP or
|
* Check the kernel we are building against, if it is SMP or
|
||||||
less than 2.6.11, print a warning and suggest upgrading.
|
less than 2.6.11, print a warning and suggest upgrading.
|
||||||
|
|
||||||
|
|||||||
51
binfile.c
51
binfile.c
@ -43,6 +43,7 @@ struct BinFile
|
|||||||
int n_symbols;
|
int n_symbols;
|
||||||
Symbol *symbols;
|
Symbol *symbols;
|
||||||
Symbol undefined;
|
Symbol undefined;
|
||||||
|
int ref_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bfd *
|
static bfd *
|
||||||
@ -402,33 +403,55 @@ read_symbols (BinFile *bf)
|
|||||||
bf->symbols = (Symbol *)g_array_free (symbols, FALSE);
|
bf->symbols = (Symbol *)g_array_free (symbols, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GHashTable *bin_files;
|
||||||
|
|
||||||
BinFile *
|
BinFile *
|
||||||
bin_file_new (const char *filename)
|
bin_file_new (const char *filename)
|
||||||
{
|
{
|
||||||
BinFile *bf = g_new0 (BinFile, 1);
|
BinFile *bf;
|
||||||
|
|
||||||
bf->filename = g_strdup (filename);
|
if (!bin_files)
|
||||||
|
bin_files = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
read_symbols (bf);
|
bf = g_hash_table_lookup (bin_files, filename);
|
||||||
|
if (bf)
|
||||||
bf->undefined.name = g_strdup_printf ("In file %s", filename);
|
{
|
||||||
bf->undefined.address = 0x0;
|
bf->ref_count++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bf = g_new0 (BinFile, 1);
|
||||||
|
|
||||||
|
bf->filename = g_strdup (filename);
|
||||||
|
|
||||||
|
read_symbols (bf);
|
||||||
|
|
||||||
|
bf->undefined.name = g_strdup_printf ("In file %s", filename);
|
||||||
|
bf->undefined.address = 0x0;
|
||||||
|
bf->ref_count = 1;
|
||||||
|
g_hash_table_insert (bin_files, bf->filename, bf);
|
||||||
|
}
|
||||||
|
|
||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bin_file_free (BinFile *bf)
|
bin_file_free (BinFile *bf)
|
||||||
{
|
{
|
||||||
int i;
|
if (--bf->ref_count == 0)
|
||||||
|
{
|
||||||
g_free (bf->filename);
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < bf->n_symbols; ++i)
|
g_hash_table_remove (bin_files, bf->filename);
|
||||||
g_free (bf->symbols[i].name);
|
|
||||||
g_free (bf->symbols);
|
g_free (bf->filename);
|
||||||
g_free (bf->undefined.name);
|
|
||||||
g_free (bf);
|
for (i = 0; i < bf->n_symbols; ++i)
|
||||||
|
g_free (bf->symbols[i].name);
|
||||||
|
g_free (bf->symbols);
|
||||||
|
g_free (bf->undefined.name);
|
||||||
|
g_free (bf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -43,7 +43,7 @@ distdir:
|
|||||||
|
|
||||||
install:
|
install:
|
||||||
$(KMAKE) modules_install
|
$(KMAKE) modules_install
|
||||||
depmod
|
[ -e /sbin/depmod ] && /sbin/depmod
|
||||||
|
|
||||||
install-data:
|
install-data:
|
||||||
install-exec:
|
install-exec:
|
||||||
|
|||||||
@ -183,6 +183,9 @@ process_free_maps (Process *process)
|
|||||||
for (list = process->maps; list != NULL; list = list->next)
|
for (list = process->maps; list != NULL; list = list->next)
|
||||||
{
|
{
|
||||||
Map *map = list->data;
|
Map *map = list->data;
|
||||||
|
|
||||||
|
if (map->filename)
|
||||||
|
g_free (map->filename);
|
||||||
|
|
||||||
if (map->bin_file)
|
if (map->bin_file)
|
||||||
bin_file_free (map->bin_file);
|
bin_file_free (map->bin_file);
|
||||||
|
|||||||
@ -523,7 +523,7 @@ profile_new (StackStash *stash)
|
|||||||
/* profile objects */
|
/* profile objects */
|
||||||
info.profile_objects = g_hash_table_new_full (g_str_hash, g_str_equal,
|
info.profile_objects = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
g_free, NULL);
|
g_free, NULL);
|
||||||
|
|
||||||
stack_stash_foreach (stash, generate_object_table, &info);
|
stack_stash_foreach (stash, generate_object_table, &info);
|
||||||
stack_stash_foreach (stash, generate_call_tree, &info);
|
stack_stash_foreach (stash, generate_call_tree, &info);
|
||||||
link_parents (info.profile->call_tree, NULL);
|
link_parents (info.profile->call_tree, NULL);
|
||||||
@ -531,7 +531,7 @@ profile_new (StackStash *stash)
|
|||||||
g_hash_table_foreach (info.profile->nodes_by_object, compute_object_total, NULL);
|
g_hash_table_foreach (info.profile->nodes_by_object, compute_object_total, NULL);
|
||||||
|
|
||||||
g_hash_table_destroy (info.profile_objects);
|
g_hash_table_destroy (info.profile_objects);
|
||||||
|
|
||||||
return info.profile;
|
return info.profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -211,4 +211,5 @@ stack_stash_free (StackStash *stash)
|
|||||||
{
|
{
|
||||||
stack_node_free (stash->root);
|
stack_node_free (stash->root);
|
||||||
g_hash_table_destroy (stash->leaves_by_process);
|
g_hash_table_destroy (stash->leaves_by_process);
|
||||||
|
g_free (stash);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user