@@ -182,8 +182,8 @@ static int run_count = 1;
182182static bool no_inherit = false;
183183static bool scale = true;
184184static bool no_aggr = false;
185- static pid_t target_pid = -1 ;
186- static pid_t target_tid = -1 ;
185+ static const char * target_pid ;
186+ static const char * target_tid ;
187187static pid_t child_pid = -1 ;
188188static bool null_run = false;
189189static int detailed_run = 0 ;
@@ -296,7 +296,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
296296 if (system_wide )
297297 return perf_evsel__open_per_cpu (evsel , evsel_list -> cpus ,
298298 group , group_fd );
299- if (target_pid == -1 && target_tid == -1 ) {
299+ if (! target_pid && ! target_tid ) {
300300 attr -> disabled = 1 ;
301301 attr -> enable_on_exec = 1 ;
302302 }
@@ -446,7 +446,7 @@ static int run_perf_stat(int argc __used, const char **argv)
446446 exit (-1 );
447447 }
448448
449- if (target_tid == -1 && target_pid == -1 && !system_wide )
449+ if (! target_tid && ! target_pid && !system_wide )
450450 evsel_list -> threads -> map [0 ] = child_pid ;
451451
452452 /*
@@ -968,14 +968,14 @@ static void print_stat(int argc, const char **argv)
968968 if (!csv_output ) {
969969 fprintf (output , "\n" );
970970 fprintf (output , " Performance counter stats for " );
971- if ( target_pid == -1 && target_tid == -1 ) {
971+ if (! target_pid && ! target_tid ) {
972972 fprintf (output , "\'%s" , argv [0 ]);
973973 for (i = 1 ; i < argc ; i ++ )
974974 fprintf (output , " %s" , argv [i ]);
975- } else if (target_pid != -1 )
976- fprintf (output , "process id \'%d " , target_pid );
975+ } else if (target_pid )
976+ fprintf (output , "process id \'%s " , target_pid );
977977 else
978- fprintf (output , "thread id \'%d " , target_tid );
978+ fprintf (output , "thread id \'%s " , target_tid );
979979
980980 fprintf (output , "\'" );
981981 if (run_count > 1 )
@@ -1049,10 +1049,10 @@ static const struct option options[] = {
10491049 "event filter" , parse_filter ),
10501050 OPT_BOOLEAN ('i' , "no-inherit" , & no_inherit ,
10511051 "child tasks do not inherit counters" ),
1052- OPT_INTEGER ('p' , "pid" , & target_pid ,
1053- "stat events on existing process id" ),
1054- OPT_INTEGER ('t' , "tid" , & target_tid ,
1055- "stat events on existing thread id" ),
1052+ OPT_STRING ('p' , "pid" , & target_pid , "pid" ,
1053+ "stat events on existing process id" ),
1054+ OPT_STRING ('t' , "tid" , & target_tid , "tid" ,
1055+ "stat events on existing thread id" ),
10561056 OPT_BOOLEAN ('a' , "all-cpus" , & system_wide ,
10571057 "system-wide collection from all CPUs" ),
10581058 OPT_BOOLEAN ('g' , "group" , & group ,
@@ -1190,7 +1190,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
11901190 } else if (big_num_opt == 0 ) /* User passed --no-big-num */
11911191 big_num = false;
11921192
1193- if (!argc && target_pid == -1 && target_tid == -1 )
1193+ if (!argc && ! target_pid && ! target_tid )
11941194 usage_with_options (stat_usage , options );
11951195 if (run_count <= 0 )
11961196 usage_with_options (stat_usage , options );
@@ -1206,10 +1206,11 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
12061206 if (add_default_attributes ())
12071207 goto out ;
12081208
1209- if (target_pid != -1 )
1209+ if (target_pid )
12101210 target_tid = target_pid ;
12111211
1212- evsel_list -> threads = thread_map__new (target_pid , target_tid , UINT_MAX );
1212+ evsel_list -> threads = thread_map__new_str (target_pid ,
1213+ target_tid , UINT_MAX );
12131214 if (evsel_list -> threads == NULL ) {
12141215 pr_err ("Problems finding threads of monitor\n" );
12151216 usage_with_options (stat_usage , options );
0 commit comments