Robert, I am not sure I understand the motivation for this change. pfmon_initialize() is done early before options are parsed. Can you elaborate a bit? Thanks.
On Thu, Feb 12, 2009 at 5:38 PM, Robert Richter <robert.rich...@amd.com> wrote: > This patch changes initialization of pfmon. Now initialization runs > after options are parsed and changes to options take effect also to > pfmon_initialize(). Additionally, the functions argument argv[0] is > now taken from struct options. Initialization is also added to some > stand-alone functions that exit pfmon immediately. > > Signed-off-by: Robert Richter <robert.rich...@amd.com> > --- > pfmon/pfmon.c | 14 ++++++++++---- > pfmon/pfmon_amd64.c | 4 ++-- > 2 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/pfmon/pfmon.c b/pfmon/pfmon.c > index 7c2bbc1..6a92814 100644 > --- a/pfmon/pfmon.c > +++ b/pfmon/pfmon.c > @@ -85,7 +85,7 @@ static pfmon_support_t *pfmon_cpus[]={ > pfmon_support_t *pfmon_current; /* current pfmon support */ > program_options_t options; /* keep track of global program > options */ > > - > +static void pfmon_initialize(void); > > static void > parse_smpl_pmds(pfmon_event_set_t *set) > @@ -635,6 +635,7 @@ pfmon_list_all_events(char *pattern, int mode) > char *name; > size_t len; > > + pfmon_initialize(); > pfm_get_max_event_name_len(&len); > pfm_get_num_events(&count); > len++; /* accomodate null character */ > @@ -760,6 +761,7 @@ static size_t pfmon_option_base_size = > sizeof(pfmon_common_options); > static void > usage(char **argv) > { > + pfmon_initialize(); > printf("usage: %s [OPTIONS]... COMMAND\n", argv[0]); > > /* 1 2 3 4 5 6 > 7 8 */ > @@ -1257,6 +1259,7 @@ pfmon_show_event_info(char *event) > unsigned long lcode; > char name[PFMON_MAX_EVTNAME_LEN]; > > + pfmon_initialize(); > if (isdigit(*event)) { > > /* using strotul() allows base auto-detection */ > @@ -1300,6 +1303,7 @@ pfmon_show_info(void) > pfmon_support_t **supp; > int ret; > > + pfmon_initialize(); > pfm_get_num_counters(&num_cnt); > pfmon_print_simple_cpuinfo(stdout, "detected host CPUs: "); > printf("detected PMU model: %s\n", pfmon_current->name ? > pfmon_current->name : "None"); > @@ -1348,7 +1352,7 @@ setup_common_signals(void) > } > > static void > -pfmon_initialize(char **argv) > +pfmon_initialize(void) > { > uint64_t long_val; > pfmlib_event_t e; > @@ -1403,7 +1407,7 @@ pfmon_initialize(char **argv) > fatal_error("cannot determine max counters\n"); > } > > - if (check_forced_generic(argv[0])) { > + if (check_forced_generic(options.argv[0])) { > > if (options.opt_support_gen == 0) > fatal_error("pfmon cannot be forced to generic > mode\n"); > @@ -1867,7 +1871,7 @@ main(int argc, char **argv) > > memset(&pfmlib_options, 0, sizeof(pfmlib_options)); > > - pfmon_initialize(argv); > + options.argv = argv; > > while ((c=getopt_long(argc, argv,"+0123kuvhe:Il::L::i:Vt:S:p:", > pfmon_cmd_options, 0)) != -1) { > switch(c) { > @@ -2033,6 +2037,7 @@ main(int argc, char **argv) > > case 'S': > case 21 : > + pfmon_initialize(); > if (*optarg == '\0') > fatal_error("--smpl-module-info needs an argument\n"); > r = pfmon_find_smpl_module(optarg, > &smpl_mod, 1); > if (r != PFMLIB_SUCCESS) > @@ -2190,6 +2195,7 @@ main(int argc, char **argv) > } > } > > + pfmon_initialize(); > pfmon_verify_cmdline_options(argc, argv); > pfmon_verify_event_sets(); > > diff --git a/pfmon/pfmon_amd64.c b/pfmon/pfmon_amd64.c > index 0240135..5683818 100644 > --- a/pfmon/pfmon_amd64.c > +++ b/pfmon/pfmon_amd64.c > @@ -296,8 +296,8 @@ pfmon_support_t pfmon_amd64={ > .name = "AMD64", > .pmu_type = PFMLIB_AMD64_PMU, > .generic_pmu_type = PFMLIB_AMD64_PMU, > - .pfmon_initialize = pfmon_amd64_initialize, > - .pfmon_usage = pfmon_amd64_usage, > + .pfmon_initialize = pfmon_amd64_initialize, > + .pfmon_usage = pfmon_amd64_usage, > .pfmon_parse_options = pfmon_amd64_parse_options, > .pfmon_setup = pfmon_amd64_setup, > .pfmon_verify_cmdline = pfmon_amd64_verify_cmdline, > -- > 1.6.1.2 > > > ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ perfmon2-devel mailing list perfmon2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perfmon2-devel