(
State(state): State<AppState>,
Path((udid, pid)): Path<(String, i32)>,
Query(query): Query<StackSampleRequestQuery>,
)
| 2024 | } |
| 2025 | |
| 2026 | async fn sample_process_stack( |
| 2027 | State(state): State<AppState>, |
| 2028 | Path((udid, pid)): Path<(String, i32)>, |
| 2029 | Query(query): Query<StackSampleRequestQuery>, |
| 2030 | ) -> Result<Json<Value>, AppError> { |
| 2031 | if android::is_android_id(&udid) { |
| 2032 | return Err(AppError::bad_request( |
| 2033 | "Performance sampling is only supported for iOS simulators.", |
| 2034 | )); |
| 2035 | } |
| 2036 | let foreground = performance_foreground_process(&state, &udid).await; |
| 2037 | let processes = state.performance.list_processes(&udid, foreground).await?; |
| 2038 | if !processes.iter().any(|process| process.pid == pid) { |
| 2039 | return Err(AppError::bad_request(format!( |
| 2040 | "Process {pid} does not belong to simulator {udid}." |
| 2041 | ))); |
| 2042 | } |
| 2043 | let report = sample_stack(pid, query.seconds.unwrap_or(3)).await?; |
| 2044 | Ok(json(json_value!({ |
| 2045 | "udid": udid, |
| 2046 | "sample": report, |
| 2047 | }))) |
| 2048 | } |
| 2049 | |
| 2050 | async fn performance_foreground_process(state: &AppState, udid: &str) -> Option<ForegroundProcess> { |
| 2051 | let foreground = foreground_app_for_simulator(state, udid) |
nothing calls this directly
no test coverage detected