New function to support --version option

2006-10-08  Soren Sandmann <sandmann@redhat.com>

	* sysprof.c (process_options): New function to support --version option
This commit is contained in:
Soren Sandmann
2006-10-08 22:05:47 +00:00
committed by Søren Sandmann Pedersen
parent 0cf636d8fe
commit a6145207ca
3 changed files with 53 additions and 11 deletions

View File

@ -1,3 +1,7 @@
2006-10-08 Soren Sandmann <sandmann@redhat.com>
* sysprof.c (process_options): New function to support --version option
2006-10-08 Soren Sandmann <sandmann@redhat.com> 2006-10-08 Soren Sandmann <sandmann@redhat.com>
* elfparser.c (struct ElfParser): Add a cache of the text section. * elfparser.c (struct ElfParser): Add a cache of the text section.

13
TODO
View File

@ -34,10 +34,8 @@ Before 1.0.4:
Before 1.2: Before 1.2:
* Fix (potential) performance issues in symbol lookup.
* Elf bugs: * 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. - 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 - userspace can look at _stext and _etext to determine
start and end of kernel text segment start and end of kernel text segment
- copying kernel stack to userspace - copying kernel stack to userspace
- it's always 4096 bytes these days
- heuristically determine functions based on address - heuristically determine functions based on address
- is eh_frame usually loaded into memory during normal - is eh_frame usually loaded into memory during normal
operation operation
@ -66,13 +65,14 @@ Before 1.2:
- assume its the same across processes, just look at - assume its the same across processes, just look at
sysprof's own copy. sysprof's own copy.
- send copy of it to userspace once, or for every - send copy of it to userspace once, or for every
sample sample.
- regular elf - regular elf
- usually have eh_frame section which is mapped into memory - usually have eh_frame section which is mapped into memory
during normal operation during normal operation
- is usually mapped into memory
- do stackwalk in kernel based on eh_frame - 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 stackwalk in userland based on eh_frame
- do ebp based stackwalk in kernel - do ebp based stackwalk in kernel
- do ebp based stackwalk in userland - do ebp based stackwalk in userland
@ -84,7 +84,7 @@ Before 1.2:
* See if we can make "In file <blah>" not be treated as a recursive function. * See if we can make "In file <blah>" not be treated as a recursive function.
Maybe simply treat each individual address in the file as a 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. to be functions.
* Give more sensible 'error messages'. Ie., if you get permission denied for * Give more sensible 'error messages'. Ie., if you get permission denied for
@ -652,6 +652,7 @@ Later:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ALREADY DONE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -=-=-=-=-=-=-=-=-=-=-=-=-=-=- ALREADY DONE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
* Fix (potential) performance issues in symbol lookup.
- when an elf file is read, it should be checked that the various - when an elf file is read, it should be checked that the various
sections are of the right type. For example the debug information sections are of the right type. For example the debug information

View File

@ -23,6 +23,8 @@
#include <glade/glade.h> #include <glade/glade.h>
#include <errno.h> #include <errno.h>
#include <glib/gprintf.h> #include <glib/gprintf.h>
#include <string.h>
#include <stdlib.h>
#include "treeviewutils.h" #include "treeviewutils.h"
#include "profile.h" #include "profile.h"
@ -1550,11 +1552,46 @@ load_file (gpointer data)
return FALSE; 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 int
main (int argc, main (int argc,
char **argv) char **argv)
{ {
Application *app; Application *app;
const char *filename;
filename = process_options (argc, argv);
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
@ -1575,10 +1612,10 @@ main (int argc,
update_sensitivity (app); update_sensitivity (app);
if (argc > 1) if (filename)
{ {
FileOpenData *file_open_data = g_new0 (FileOpenData, 1); FileOpenData *file_open_data = g_new0 (FileOpenData, 1);
file_open_data->filename = argv[1]; file_open_data->filename = filename;
file_open_data->app = app; file_open_data->app = app;
/* This has to run at G_PRIORITY_LOW because of bug 350517 /* This has to run at G_PRIORITY_LOW because of bug 350517