MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / sample_process_stack

Function sample_process_stack

packages/server/src/api/routes.rs:2026–2048  ·  view source on GitHub ↗
(
    State(state): State<AppState>,
    Path((udid, pid)): Path<(String, i32)>,
    Query(query): Query<StackSampleRequestQuery>,
)

Source from the content-addressed store, hash-verified

2024}
2025
2026async 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
2050async fn performance_foreground_process(state: &AppState, udid: &str) -> Option<ForegroundProcess> {
2051 let foreground = foreground_app_for_simulator(state, udid)

Callers

nothing calls this directly

Calls 5

is_android_idFunction · 0.85
sample_stackFunction · 0.85
jsonFunction · 0.85
list_processesMethod · 0.80

Tested by

no test coverage detected