Lines Matching refs:proc

100 struct proc *inf_tid_to_proc (struct inf *inf, int tid);
102 struct proc *run_thread,
107 void inf_set_step_thread (struct inf *inf, struct proc *proc);
117 void proc_abort (struct proc *proc, int force);
118 struct proc *make_proc (struct inf *inf, mach_port_t port, int tid);
119 struct proc *_proc_free (struct proc *proc);
120 int proc_update_sc (struct proc *proc);
121 error_t proc_get_exception_port (struct proc *proc, mach_port_t * port);
122 error_t proc_set_exception_port (struct proc *proc, mach_port_t port);
123 static mach_port_t _proc_get_exc_port (struct proc *proc);
124 void proc_steal_exc_port (struct proc *proc, mach_port_t exc_port);
125 void proc_restore_exc_port (struct proc *proc);
126 int proc_trace (struct proc *proc, int set);
163 struct proc *thread; /* The thread in question. */
172 struct proc *task; /* The mach task. */
173 struct proc *threads; /* A linked list of all threads in TASK. */
186 struct proc *step_thread;
189 struct proc *signal_thread;
246 __proc_pid (struct proc *proc) in __proc_pid() argument
248 return proc->inf->pid; in __proc_pid()
255 proc_update_sc (struct proc *proc) in proc_update_sc() argument
259 int delta = proc->sc - proc->cur_sc; in proc_update_sc()
262 proc_debug (proc, "sc: %d --> %d", proc->cur_sc, proc->sc); in proc_update_sc()
264 if (proc->sc == 0 && proc->state_changed) in proc_update_sc()
267 gdb_assert (proc_is_thread (proc)); in proc_update_sc()
268 proc_debug (proc, "storing back changed thread state"); in proc_update_sc()
269 err = thread_set_state (proc->port, THREAD_STATE_FLAVOR, in proc_update_sc()
270 (thread_state_t) &proc->state, THREAD_STATE_SIZE); in proc_update_sc()
272 proc->state_changed = 0; in proc_update_sc()
279 if (proc_is_task (proc)) in proc_update_sc()
280 err = task_suspend (proc->port); in proc_update_sc()
282 err = thread_suspend (proc->port); in proc_update_sc()
289 if (proc_is_task (proc)) in proc_update_sc()
290 err = task_resume (proc->port); in proc_update_sc()
292 err = thread_resume (proc->port); in proc_update_sc()
296 proc->cur_sc = proc->sc; in proc_update_sc()
299 running = !err && proc->sc == 0; in proc_update_sc()
301 proc_debug (proc, "is %s", err ? "dead" : running ? "running" : "suspended"); in proc_update_sc()
303 proc_debug (proc, "err = %s", safe_strerror (err)); in proc_update_sc()
307 proc->aborted = 0; in proc_update_sc()
308 proc->state_valid = proc->state_changed = 0; in proc_update_sc()
309 proc->fetched_regs = 0; in proc_update_sc()
321 proc_abort (struct proc *proc, int force) in proc_abort() argument
323 gdb_assert (proc_is_thread (proc)); in proc_abort()
325 if (!proc->aborted) in proc_abort()
327 struct inf *inf = proc->inf; in proc_abort()
328 int running = (proc->cur_sc == 0 && inf->task->cur_sc == 0); in proc_abort()
332 proc->sc = 1; in proc_abort()
333 inf_update_suspends (proc->inf); in proc_abort()
335 warning ("Stopped %s.", proc_string (proc)); in proc_abort()
337 else if (proc == inf->wait.thread && inf->wait.exc.reply && !force) in proc_abort()
344 thread_abort (proc->port); in proc_abort()
345 proc_debug (proc, "aborted"); in proc_abort()
346 proc->aborted = 1; in proc_abort()
349 proc_debug (proc, "not aborting"); in proc_abort()
358 proc_get_state (struct proc *proc, int will_modify) in proc_get_state() argument
360 int was_aborted = proc->aborted; in proc_get_state()
362 proc_debug (proc, "updating state info%s", in proc_get_state()
365 proc_abort (proc, will_modify); in proc_get_state()
367 if (!was_aborted && proc->aborted) in proc_get_state()
369 proc->state_valid = 0; in proc_get_state()
371 if (!proc->state_valid) in proc_get_state()
375 thread_get_state (proc->port, THREAD_STATE_FLAVOR, in proc_get_state()
376 (thread_state_t) &proc->state, &state_size); in proc_get_state()
377 proc_debug (proc, "getting thread state"); in proc_get_state()
378 proc->state_valid = !err; in proc_get_state()
381 if (proc->state_valid) in proc_get_state()
384 proc->state_changed = 1; in proc_get_state()
385 return (thread_state_t) &proc->state; in proc_get_state()
394 proc_get_exception_port (struct proc * proc, mach_port_t * port) in proc_get_exception_port() argument
396 if (proc_is_task (proc)) in proc_get_exception_port()
397 return task_get_exception_port (proc->port, port); in proc_get_exception_port()
399 return thread_get_exception_port (proc->port, port); in proc_get_exception_port()
404 proc_set_exception_port (struct proc * proc, mach_port_t port) in proc_set_exception_port() argument
406 proc_debug (proc, "setting exception port: %d", port); in proc_set_exception_port()
407 if (proc_is_task (proc)) in proc_set_exception_port()
408 return task_set_exception_port (proc->port, port); in proc_set_exception_port()
410 return thread_set_exception_port (proc->port, port); in proc_set_exception_port()
415 _proc_get_exc_port (struct proc *proc) in _proc_get_exc_port() argument
418 error_t err = proc_get_exception_port (proc, &exc_port); in _proc_get_exc_port()
423 if (proc->exc_port) in _proc_get_exc_port()
424 mach_port_deallocate (mach_task_self (), proc->exc_port); in _proc_get_exc_port()
425 proc->exc_port = MACH_PORT_NULL; in _proc_get_exc_port()
426 if (proc->saved_exc_port) in _proc_get_exc_port()
427 mach_port_deallocate (mach_task_self (), proc->saved_exc_port); in _proc_get_exc_port()
428 proc->saved_exc_port = MACH_PORT_NULL; in _proc_get_exc_port()
437 proc_steal_exc_port (struct proc *proc, mach_port_t exc_port) in proc_steal_exc_port() argument
439 mach_port_t cur_exc_port = _proc_get_exc_port (proc); in proc_steal_exc_port()
445 proc_debug (proc, "inserting exception port: %d", exc_port); in proc_steal_exc_port()
449 err = proc_set_exception_port (proc, exc_port); in proc_steal_exc_port()
451 if (err || cur_exc_port == proc->exc_port) in proc_steal_exc_port()
461 if (proc->saved_exc_port) in proc_steal_exc_port()
462 mach_port_deallocate (mach_task_self (), proc->saved_exc_port); in proc_steal_exc_port()
463 proc->saved_exc_port = cur_exc_port; in proc_steal_exc_port()
466 proc_debug (proc, "saved exception port: %d", proc->saved_exc_port); in proc_steal_exc_port()
469 proc->exc_port = exc_port; in proc_steal_exc_port()
472 proc_string (proc), safe_strerror (err)); in proc_steal_exc_port()
480 proc_restore_exc_port (struct proc *proc) in proc_restore_exc_port() argument
482 mach_port_t cur_exc_port = _proc_get_exc_port (proc); in proc_restore_exc_port()
488 proc_debug (proc, "restoring real exception port"); in proc_restore_exc_port()
490 if (proc->exc_port == cur_exc_port) in proc_restore_exc_port()
492 err = proc_set_exception_port (proc, proc->saved_exc_port); in proc_restore_exc_port()
494 if (proc->saved_exc_port) in proc_restore_exc_port()
495 mach_port_deallocate (mach_task_self (), proc->saved_exc_port); in proc_restore_exc_port()
496 proc->saved_exc_port = MACH_PORT_NULL; in proc_restore_exc_port()
499 proc->exc_port = MACH_PORT_NULL; in proc_restore_exc_port()
502 proc_string (proc), safe_strerror (err)); in proc_restore_exc_port()
510 proc_trace (struct proc *proc, int set) in proc_trace() argument
512 thread_state_t state = proc_get_state (proc, 1); in proc_trace()
517 proc_debug (proc, "tracing %s", set ? "on" : "off"); in proc_trace()
523 if (proc->exc_port == MACH_PORT_NULL) in proc_trace()
524 proc_steal_exc_port (proc, proc->inf->event_port); in proc_trace()
539 struct proc *
544 struct proc *proc = xmalloc (sizeof (struct proc)); in make_proc() local
546 proc->port = port; in make_proc()
547 proc->tid = tid; in make_proc()
548 proc->inf = inf; in make_proc()
549 proc->next = 0; in make_proc()
550 proc->saved_exc_port = MACH_PORT_NULL; in make_proc()
551 proc->exc_port = MACH_PORT_NULL; in make_proc()
553 proc->sc = 0; in make_proc()
554 proc->cur_sc = 0; in make_proc()
558 proc->run_sc = inf->default_thread_run_sc; in make_proc()
559 proc->pause_sc = inf->default_thread_pause_sc; in make_proc()
560 proc->detach_sc = inf->default_thread_detach_sc; in make_proc()
561 proc->resume_sc = proc->run_sc; in make_proc()
563 proc->aborted = 0; in make_proc()
564 proc->dead = 0; in make_proc()
565 proc->state_valid = 0; in make_proc()
566 proc->state_changed = 0; in make_proc()
568 proc_debug (proc, "is new"); in make_proc()
582 proc_debug (proc, "notifications to: %d", inf->event_port); in make_proc()
589 if (proc_is_task (proc)) in make_proc()
591 proc_steal_exc_port (proc, inf->event_port); in make_proc()
595 proc_steal_exc_port (proc, MACH_PORT_NULL); in make_proc()
598 return proc; in make_proc()
603 struct proc *
604 _proc_free (struct proc *proc) in _proc_free() argument
606 struct inf *inf = proc->inf; in _proc_free()
607 struct proc *next = proc->next; in _proc_free()
609 proc_debug (proc, "freeing..."); in _proc_free()
611 if (proc == inf->step_thread) in _proc_free()
614 if (proc == inf->wait.thread) in _proc_free()
616 if (proc == inf->signal_thread) in _proc_free()
619 if (proc->port != MACH_PORT_NULL) in _proc_free()
621 if (proc->exc_port != MACH_PORT_NULL) in _proc_free()
623 proc_restore_exc_port (proc); in _proc_free()
624 if (proc->cur_sc != 0) in _proc_free()
627 proc->sc = 0; in _proc_free()
628 proc_update_sc (proc); in _proc_free()
630 mach_port_deallocate (mach_task_self (), proc->port); in _proc_free()
633 xfree (proc); in _proc_free()
742 struct proc *task = inf->task; in inf_set_pid()
910 struct proc *task = inf->task; in inf_update_suspends()
919 struct proc *thread; in inf_update_suspends()
958 struct proc *
961 struct proc *thread = inf->threads; in inf_tid_to_thread()
972 struct proc *
975 struct proc *thread = inf->threads; in inf_port_to_thread()
991 struct proc *task = inf->task; in inf_validate_procs()
1021 struct proc *matched[num_threads + 1]; in inf_validate_procs()
1023 struct proc *last = 0; in inf_validate_procs()
1025 struct proc *thread = inf->threads; in inf_validate_procs()
1095 struct proc *run_thread, int run_others) in inf_set_threads_resume_sc()
1097 struct proc *thread; in inf_set_threads_resume_sc()
1114 struct proc *thread; in inf_resume()
1139 struct proc *thread; in inf_suspend()
1157 inf_set_step_thread (struct inf *inf, struct proc *thread) in inf_set_step_thread()
1207 struct proc *task = inf->task; in inf_detach()
1216 struct proc *thread; in inf_detach()
1262 struct proc *thread; in inf_steal_exc_ports()
1277 struct proc *thread; in inf_restore_exc_ports()
1381 process_t proc; in inf_continue() local
1382 error_t err = proc_pid2proc (proc_server, inf->pid, &proc); in inf_continue()
1388 err = proc_mark_cont (proc); in inf_continue()
1391 struct proc *thread; in inf_continue()
1423 struct proc *thread; in gnu_wait()
1623 struct proc *thread = inf_port_to_thread (inf, thread_port); in S_exception_raise_request()
1734 struct proc *thread = inf_port_to_thread (inf, dead_port); in do_mach_notify_dead_name()
1932 struct proc *step_thread = 0; in gnu_resume()
1973 struct proc *thread = inf_tid_to_thread (inf, PIDGET (tid)); in gnu_resume()
1999 struct proc *task = current_inferior->task; in gnu_kill_inferior()
2552 proc_string (struct proc *proc) in proc_string() argument
2555 if (proc_is_task (proc)) in proc_string()
2556 sprintf (tid_str, "process %d", proc->inf->pid); in proc_string()
2559 proc->inf->pid, pid_to_thread_id (MERGEPID (proc->tid, 0))); in proc_string()
2568 struct proc *thread = inf_tid_to_thread (inf, tid); in gnu_pid_to_str()
2703 static struct proc *
2707 struct proc *thread = inf_tid_to_thread (inf, PIDGET (inferior_ptid)); in cur_thread()
2819 steal_exc_port (struct proc *proc, mach_port_t name) in steal_exc_port() argument
2825 if (!proc || !proc->inf->task) in steal_exc_port()
2828 err = mach_port_extract_right (proc->inf->task->port, in steal_exc_port()
2835 if (proc->saved_exc_port) in steal_exc_port()
2837 mach_port_deallocate (mach_task_self (), proc->saved_exc_port); in steal_exc_port()
2839 proc->saved_exc_port = port; in steal_exc_port()
2841 if (!proc->exc_port) in steal_exc_port()
2845 proc->exc_port = proc->inf->event_port; in steal_exc_port()
2846 err = proc_set_exception_port (proc, proc->exc_port); in steal_exc_port()
2848 proc_string (proc), safe_strerror (err)); in steal_exc_port()
3205 struct proc *thread = cur_thread (); in set_thread_pause_cmd()
3217 struct proc *thread = cur_thread (); in show_thread_pause_cmd()
3229 struct proc *thread = cur_thread (); in set_thread_run_cmd()
3236 struct proc *thread = cur_thread (); in show_thread_run_cmd()
3253 struct proc *thread = cur_thread (); in show_thread_detach_sc_cmd()
3264 struct proc *thread = cur_thread (); in set_thread_exc_port_cmd()
3274 struct proc *thread = cur_thread ();
3286 struct proc *thread = cur_thread (); in thread_takeover_sc_cmd()