diff --git a/ChangeLog b/ChangeLog index 2a37775f..08b971aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-10-08 Soren Sandmann + + * sysprof.c (process_options): New function to support --version option + 2006-10-08 Soren Sandmann * elfparser.c (struct ElfParser): Add a cache of the text section. diff --git a/TODO b/TODO index ef347c09..b91e3c54 100644 --- a/TODO +++ b/TODO @@ -34,10 +34,8 @@ Before 1.0.4: Before 1.2: -* Fix (potential) performance issues in symbol lookup. - * Elf bugs: - - Also error handling for bin_parser is necessary. + - error handling for bin_parser is necessary. - don't loop infinitely if there are cycles in the debuglink graph. @@ -58,6 +56,7 @@ Before 1.2: - userspace can look at _stext and _etext to determine start and end of kernel text segment - copying kernel stack to userspace + - it's always 4096 bytes these days - heuristically determine functions based on address - is eh_frame usually loaded into memory during normal operation @@ -66,13 +65,14 @@ Before 1.2: - assume its the same across processes, just look at sysprof's own copy. - send copy of it to userspace once, or for every - sample + sample. - regular elf - usually have eh_frame section which is mapped into memory during normal operation - - is usually mapped into memory - do stackwalk in kernel based on eh_frame + - eh_frame section is usually mapped into memory, so + no file reading in kernel would be necessary. - do stackwalk in userland based on eh_frame - do ebp based stackwalk in kernel - do ebp based stackwalk in userland @@ -84,7 +84,7 @@ Before 1.2: * See if we can make "In file " not be treated as a recursive function. Maybe simply treat each individual address in the file as a function. - Or try to parse the machine code. Places that are called are likely + Or try to parse the machine code. Positions that are called are likely to be functions. * Give more sensible 'error messages'. Ie., if you get permission denied for @@ -652,6 +652,7 @@ Later: -=-=-=-=-=-=-=-=-=-=-=-=-=-=- ALREADY DONE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +* Fix (potential) performance issues in symbol lookup. - when an elf file is read, it should be checked that the various sections are of the right type. For example the debug information diff --git a/sysprof.c b/sysprof.c index 481fcd33..98eb88d8 100644 --- a/sysprof.c +++ b/sysprof.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "treeviewutils.h" #include "profile.h" @@ -1550,11 +1552,46 @@ load_file (gpointer data) return FALSE; } +static const char * +process_options (int argc, + char **argv) +{ + int i; + gboolean show_version = FALSE; + const char *filename = NULL; + + for (i = 1; i < argc; ++i) + { + char *option = argv[i]; + + if (strcmp (option, "--version") == 0) + { + show_version = TRUE; + } + else if (!filename) + { + filename = argv[i]; + } + } + + if (show_version) + { + g_print ("%s %s\n", APPLICATION_NAME, PACKAGE_VERSION); + + exit (1); + } + + return filename; +} + int main (int argc, char **argv) { Application *app; + const char *filename; + + filename = process_options (argc, argv); gtk_init (&argc, &argv); @@ -1567,20 +1604,20 @@ main (int argc, */ g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE); #endif - + app = application_new (); - + if (!build_gui (app)) return -1; update_sensitivity (app); - if (argc > 1) + if (filename) { FileOpenData *file_open_data = g_new0 (FileOpenData, 1); - file_open_data->filename = argv[1]; + file_open_data->filename = filename; file_open_data->app = app; - + /* This has to run at G_PRIORITY_LOW because of bug 350517 */ g_idle_add_full (G_PRIORITY_LOW, load_file, file_open_data, NULL);