@@ -102,13 +102,15 @@ printusage(void)
102102 printf ("Usage example: "
103103 "./findfuncbypc --pc=0x10000 ./findfuncbypc\n" );
104104 printf (" options list:\n" );
105+ printf (" --help or -h prints this usage message and stops.\n" );
105106 printf (" --pc=(hex or decimal pc address)\n" );
106107 printf (" --printdetails \n" );
107108 printf (" prints some details of the discovery process\n" );
108109 printf (" --allinstances\n" );
109110 printf (" reports but does does not stop processing\n" );
110111 printf (" on finding pc address\n" );
111- printf (" --help or -h prints this usage message an stops.\n" );
112+ printf (" The argument following valid -- arguments must\n" );
113+ printf (" be a valid object file path\n" );
112114}
113115
114116static void target_data_destructor ( struct target_data_s * td );
@@ -155,7 +157,7 @@ main(int argc, char **argv)
155157
156158 real_path [0 ] = 0 ;
157159 memset (& target_data ,0 , sizeof (target_data ));
158- for (i = 1 ; i < ( argc - 1 ) ; ++ i ) {
160+ for (i = 1 ; i < argc ; ++ i ) {
159161 if (startswithextractnum (argv [i ],"--pc=" ,
160162 & target_pc )) {
161163 /* done */
@@ -171,15 +173,16 @@ main(int argc, char **argv)
171173 printusage ();
172174 exit (0 );
173175 } else {
174- printf ( "Unknown argument \"%s\", give up \n" , argv [ i ]);
175- exit ( 1 ) ;
176+ /* Assume next arg is a pathname.*/
177+ break ;
176178 }
177179 }
178- if (i >= (argc - 1 )) {
180+ if (i > (argc - 1 )) {
179181 printusage ();
180182 exit (1 );
181183 }
182184 filepath = argv [i ];
185+ /* Ignoring any later arguments on the command line */
183186 res = dwarf_init_path (filepath ,
184187 real_path ,
185188 PATH_LEN ,
@@ -1197,7 +1200,7 @@ check_comp_dir(Dwarf_Debug dbg,Dwarf_Die die,
11971200 td -> td_cu_highpc = highpcr ;
11981201 td -> td_cu_haslowhighpc = TRUE;
11991202 done = TRUE;
1200- res = IN_THIS_CU ;
1203+ finalres = IN_THIS_CU ;
12011204 break ;
12021205 case DW_RANGES_ADDRESS_SELECTION :
12031206 baseaddr = cur -> dwr_addr2 ;
0 commit comments