@@ -162,6 +162,12 @@ print_help()
162162 printf (" GC is enabled\n" );
163163 printf (" --disable-aux-stack-check Disable auxiliary stack overflow/underflow check\n" );
164164 printf (" --enable-dump-call-stack Enable stack trace feature\n" );
165+ printf (" --call-stack-features=<features>\n" );
166+ printf (" A comma-separated list of features when generating call stacks.\n" );
167+ printf (" By default, all features are enabled. To disable all features,\n" );
168+ printf (" provide an empty list (i.e. --call-stack-features=). This flag\n" );
169+ printf (" only only takes effect when --enable-dump-call-stack is set.\n" );
170+ printf (" Available features: bounds-checks, ip, trap-ip, values.\n" );
165171 printf (" --enable-perf-profiling Enable function performance profiling\n" );
166172 printf (" --enable-memory-profiling Enable memory usage profiling\n" );
167173 printf (" --xip A shorthand of --enable-indirect-mode --disable-llvm-intrinsics\n" );
@@ -259,6 +265,48 @@ split_string(char *str, int *count, const char *delimer)
259265 return res ;
260266}
261267
268+ static bool
269+ parse_call_stack_features (char * features_str ,
270+ AOTCallStackFeatures * out_features )
271+ {
272+ int size = 0 ;
273+ char * * features ;
274+ bool ret = true;
275+
276+ bh_assert (features_str );
277+ bh_assert (out_features );
278+
279+ /* non-empty feature list */
280+ features = split_string (features_str , & size , "," );
281+ if (!features ) {
282+ return false;
283+ }
284+
285+ while (size -- ) {
286+ if (!strcmp (features [size ], "bounds-checks" )) {
287+ out_features -> bounds_checks = true;
288+ }
289+ else if (!strcmp (features [size ], "ip" )) {
290+ out_features -> ip = true;
291+ }
292+ else if (!strcmp (features [size ], "trap-ip" )) {
293+ out_features -> trap_ip = true;
294+ }
295+ else if (!strcmp (features [size ], "values" )) {
296+ out_features -> values = true;
297+ }
298+ else {
299+ ret = false;
300+ printf ("Unsupported feature %s\n" , features [size ]);
301+ goto finish ;
302+ }
303+ }
304+
305+ finish :
306+ free (features );
307+ return ret ;
308+ }
309+
262310static uint32
263311resolve_segue_flags (char * str_flags )
264312{
@@ -356,6 +404,9 @@ main(int argc, char *argv[])
356404 option .enable_ref_types = true;
357405 option .enable_gc = false;
358406
407+ /* Set all the features to true by default */
408+ memset (& option .call_stack_features , 1 , sizeof (AOTCallStackFeatures ));
409+
359410 /* Process options */
360411 for (argc -- , argv ++ ; argc > 0 && argv [0 ][0 ] == '-' ; argc -- , argv ++ ) {
361412 if (!strcmp (argv [0 ], "-o" )) {
@@ -470,6 +521,19 @@ main(int argc, char *argv[])
470521 else if (!strcmp (argv [0 ], "--enable-dump-call-stack" )) {
471522 option .enable_aux_stack_frame = true;
472523 }
524+ else if (!strncmp (argv [0 ], "--call-stack-features=" , 22 )) {
525+ /* Reset all the features, only enable the user-defined ones */
526+ memset (& option .call_stack_features , 0 ,
527+ sizeof (AOTCallStackFeatures ));
528+
529+ if (argv [0 ][22 ] != '\0' ) {
530+ if (!parse_call_stack_features (argv [0 ] + 22 ,
531+ & option .call_stack_features )) {
532+ printf ("Failed to parse call-stack-features\n" );
533+ PRINT_HELP_AND_EXIT ();
534+ }
535+ }
536+ }
473537 else if (!strcmp (argv [0 ], "--enable-perf-profiling" )) {
474538 option .enable_aux_stack_frame = true;
475539 option .enable_perf_profiling = true;
@@ -608,6 +672,12 @@ main(int argc, char *argv[])
608672#endif
609673 }
610674
675+ if (option .enable_gc && !option .call_stack_features .values ) {
676+ LOG_WARNING ("Call stack feature 'values' must be enabled for GC. The "
677+ "feature will be enabled automatically." );
678+ option .call_stack_features .values = true;
679+ }
680+
611681 if (sgx_mode ) {
612682 option .size_level = 1 ;
613683 option .is_sgx_platform = true;
0 commit comments