Handle the 'attach' command.
(args)
| 952 | |
| 953 | |
| 954 | def _handle_attach(args): |
| 955 | """Handle the 'attach' command.""" |
| 956 | if not _is_process_running(args.pid): |
| 957 | raise SamplingUnknownProcessError(args.pid) |
| 958 | # Check if live mode is requested |
| 959 | if args.live: |
| 960 | _handle_live_attach(args, args.pid) |
| 961 | return |
| 962 | |
| 963 | # Use PROFILING_MODE_ALL for gecko format |
| 964 | mode = ( |
| 965 | PROFILING_MODE_ALL |
| 966 | if args.format == "gecko" |
| 967 | else _parse_mode(args.mode) |
| 968 | ) |
| 969 | |
| 970 | # Determine skip_idle based on mode |
| 971 | skip_idle = ( |
| 972 | mode != PROFILING_MODE_WALL if mode != PROFILING_MODE_ALL else False |
| 973 | ) |
| 974 | |
| 975 | output_file = None |
| 976 | if args.format == "binary": |
| 977 | output_file = args.outfile or _generate_output_filename(args.format, args.pid) |
| 978 | |
| 979 | # Create the appropriate collector |
| 980 | collector = _create_collector( |
| 981 | args.format, args.sample_interval_usec, skip_idle, args.opcodes, |
| 982 | output_file=output_file, |
| 983 | compression=getattr(args, 'compression', 'auto'), |
| 984 | diff_baseline=args.diff_baseline |
| 985 | ) |
| 986 | |
| 987 | with _get_child_monitor_context(args, args.pid): |
| 988 | collector = sample( |
| 989 | args.pid, |
| 990 | collector, |
| 991 | duration_sec=args.duration, |
| 992 | all_threads=args.all_threads, |
| 993 | realtime_stats=args.realtime_stats, |
| 994 | mode=mode, |
| 995 | async_aware=args.async_mode if args.async_aware else None, |
| 996 | native=args.native, |
| 997 | gc=args.gc, |
| 998 | opcodes=args.opcodes, |
| 999 | blocking=args.blocking, |
| 1000 | ) |
| 1001 | _handle_output(collector, args, args.pid, mode) |
| 1002 | |
| 1003 | |
| 1004 | def _handle_run(args): |
nothing calls this directly
no test coverage detected
searching dependent graphs…