@@ -629,9 +629,20 @@ def _sort_to_mode(sort_choice):
629629 }
630630 return sort_map .get (sort_choice , SORT_MODE_NSAMPLES )
631631
632+
633+ def _capture_config_from_args (args ):
634+ return {
635+ "all_threads" : args .all_threads ,
636+ "native" : args .native ,
637+ "gc" : args .gc ,
638+ "opcodes" : args .opcodes ,
639+ "blocking" : args .blocking ,
640+ }
641+
642+
632643def _create_collector (format_type , sample_interval_usec , skip_idle , opcodes = False ,
633644 mode = None , output_file = None , compression = 'auto' ,
634- diff_baseline = None ):
645+ diff_baseline = None , capture_config = None ):
635646 """Create the appropriate collector based on format type.
636647
637648 Args:
@@ -645,6 +656,7 @@ def _create_collector(format_type, sample_interval_usec, skip_idle, opcodes=Fals
645656 output_file: Output file path (required for binary format)
646657 compression: Compression type for binary format ('auto', 'zstd', 'none')
647658 diff_baseline: Path to baseline binary file for differential flamegraph
659+ capture_config: Capture feature mapping for binary profiles and diffs
648660
649661 Returns:
650662 A collector instance of the appropriate type
@@ -661,15 +673,18 @@ def _create_collector(format_type, sample_interval_usec, skip_idle, opcodes=Fals
661673 return collector_class (
662674 sample_interval_usec ,
663675 baseline_binary_path = diff_baseline ,
664- skip_idle = skip_idle
676+ skip_idle = skip_idle ,
677+ mode = mode ,
678+ capture_config = capture_config ,
665679 )
666680
667681 # Binary format requires output file and compression
668682 if format_type == "binary" :
669683 if output_file is None :
670684 raise ValueError ("Binary format requires an output file" )
671685 return collector_class (output_file , sample_interval_usec , skip_idle = skip_idle ,
672- compression = compression )
686+ compression = compression , mode = mode ,
687+ capture_config = capture_config )
673688
674689 # Gecko format never skips idle (it needs both GIL and CPU data)
675690 # and is the only format that uses opcodes for interval markers
@@ -760,7 +775,9 @@ def _replay_with_reader(args, reader):
760775
761776 collector = _create_collector (
762777 args .format , interval , skip_idle = False ,
763- diff_baseline = args .diff_baseline
778+ mode = info .get ("mode" ),
779+ diff_baseline = args .diff_baseline ,
780+ capture_config = info .get ("capture_config" ),
764781 )
765782
766783 def progress_callback (current , total ):
@@ -778,6 +795,8 @@ def progress_callback(current, total):
778795 count = reader .replay_samples (collector , progress_callback )
779796 if hasattr (collector , "set_replay_stats" ):
780797 collector .set_replay_stats (info )
798+ if hasattr (collector , "set_mode" ):
799+ collector .set_mode (info .get ("mode" ))
781800 print ()
782801
783802 if args .format == "pstats" :
@@ -791,7 +810,8 @@ def progress_callback(current, total):
791810 sort_mode = _sort_to_mode (sort_choice )
792811 collector .print_stats (
793812 sort_mode , limit , not args .no_summary ,
794- PROFILING_MODE_WALL
813+ info .get ("mode" ) if info .get ("mode" ) is not None
814+ else PROFILING_MODE_WALL
795815 )
796816 else :
797817 filename = (
@@ -1179,7 +1199,8 @@ def _handle_attach(args):
11791199 args .format , args .sample_interval_usec , skip_idle , args .opcodes , mode ,
11801200 output_file = output_file ,
11811201 compression = getattr (args , 'compression' , 'auto' ),
1182- diff_baseline = args .diff_baseline
1202+ diff_baseline = args .diff_baseline ,
1203+ capture_config = _capture_config_from_args (args ),
11831204 )
11841205
11851206 with _get_child_monitor_context (args , args .pid ):
@@ -1286,7 +1307,8 @@ def _handle_run(args):
12861307 args .format , args .sample_interval_usec , skip_idle , args .opcodes , mode ,
12871308 output_file = output_file ,
12881309 compression = getattr (args , 'compression' , 'auto' ),
1289- diff_baseline = args .diff_baseline
1310+ diff_baseline = args .diff_baseline ,
1311+ capture_config = _capture_config_from_args (args ),
12901312 )
12911313
12921314 with _get_child_monitor_context (args , process .pid ):
0 commit comments