Lines Matching refs:proc

78 /* If we've sent a proc_wait_request to the proc server, the pid of the
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);
164 struct proc *thread; /* The thread in question. */
173 struct proc *task; /* The mach task. */
174 struct proc *threads; /* A linked list of all threads in TASK. */
186 /* One thread proc in INF may be in `single-stepping mode'. This is it. */
187 struct proc *step_thread;
190 struct proc *signal_thread;
198 /* True if the process has stopped (in the proc server sense). Note that
199 since a proc server `stop' leaves the signal thread running, the inf can
230 threads -- see the definition of those fields in struct proc. */
247 __proc_pid (struct proc *proc)
249 return proc->inf->pid;
257 proc_update_sc (struct proc *proc)
261 int delta = proc->sc - proc->cur_sc;
264 proc_debug (proc, "sc: %d --> %d", proc->cur_sc, proc->sc);
266 if (proc->sc == 0 && proc->state_changed)
269 gdb_assert (proc_is_thread (proc));
270 proc_debug (proc, "storing back changed thread state");
271 err = thread_set_state (proc->port, THREAD_STATE_FLAVOR,
272 (thread_state_t) &proc->state, THREAD_STATE_SIZE);
274 proc->state_changed = 0;
281 if (proc_is_task (proc))
282 err = task_suspend (proc->port);
284 err = thread_suspend (proc->port);
291 if (proc_is_task (proc))
292 err = task_resume (proc->port);
294 err = thread_resume (proc->port);
298 proc->cur_sc = proc->sc;
301 running = !err && proc->sc == 0;
303 proc_debug (proc, "is %s", err ? "dead" : running ? "running" : "suspended");
305 proc_debug (proc, "err = %s", safe_strerror (err));
309 proc->aborted = 0;
310 proc->state_valid = proc->state_changed = 0;
311 proc->fetched_regs = 0;
319 /* Thread_abort is called on PROC if needed. PROC must be a thread proc.
324 proc_abort (struct proc *proc, int force)
326 gdb_assert (proc_is_thread (proc));
328 if (!proc->aborted)
330 struct inf *inf = proc->inf;
331 int running = (proc->cur_sc == 0 && inf->task->cur_sc == 0);
335 proc->sc = 1;
336 inf_update_suspends (proc->inf);
338 warning ("Stopped %s.", proc_string (proc));
340 else if (proc == inf->wait.thread && inf->wait.exc.reply && !force)
347 thread_abort (proc->port);
348 proc_debug (proc, "aborted");
349 proc->aborted = 1;
352 proc_debug (proc, "not aborting");
361 proc_get_state (struct proc *proc, int will_modify)
363 int was_aborted = proc->aborted;
365 proc_debug (proc, "updating state info%s",
368 proc_abort (proc, will_modify);
370 if (!was_aborted && proc->aborted)
372 proc->state_valid = 0;
374 if (!proc->state_valid)
378 thread_get_state (proc->port, THREAD_STATE_FLAVOR,
379 (thread_state_t) &proc->state, &state_size);
380 proc_debug (proc, "getting thread state");
381 proc->state_valid = !err;
384 if (proc->state_valid)
387 proc->state_changed = 1;
388 return (thread_state_t) &proc->state;
398 proc_get_exception_port (struct proc * proc, mach_port_t * port)
400 if (proc_is_task (proc))
401 return task_get_exception_port (proc->port, port);
403 return thread_get_exception_port (proc->port, port);
408 proc_set_exception_port (struct proc * proc, mach_port_t port)
410 proc_debug (proc, "setting exception port: %d", port);
411 if (proc_is_task (proc))
412 return task_set_exception_port (proc->port, port);
414 return thread_set_exception_port (proc->port, port);
417 /* Get PROC's exception port, cleaning up a bit if proc has died. */
419 _proc_get_exc_port (struct proc *proc)
422 error_t err = proc_get_exception_port (proc, &exc_port);
427 if (proc->exc_port)
428 mach_port_deallocate (mach_task_self (), proc->exc_port);
429 proc->exc_port = MACH_PORT_NULL;
430 if (proc->saved_exc_port)
431 mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
432 proc->saved_exc_port = MACH_PORT_NULL;
441 proc_steal_exc_port (struct proc *proc, mach_port_t exc_port)
443 mach_port_t cur_exc_port = _proc_get_exc_port (proc);
449 proc_debug (proc, "inserting exception port: %d", exc_port);
453 err = proc_set_exception_port (proc, exc_port);
455 if (err || cur_exc_port == proc->exc_port)
457 just keep the old saved port which is what the proc set. */
465 if (proc->saved_exc_port)
466 mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
467 proc->saved_exc_port = cur_exc_port;
470 proc_debug (proc, "saved exception port: %d", proc->saved_exc_port);
473 proc->exc_port = exc_port;
476 proc_string (proc), safe_strerror (err));
484 proc_restore_exc_port (struct proc *proc)
486 mach_port_t cur_exc_port = _proc_get_exc_port (proc);
492 proc_debug (proc, "restoring real exception port");
494 if (proc->exc_port == cur_exc_port)
496 err = proc_set_exception_port (proc, proc->saved_exc_port);
498 if (proc->saved_exc_port)
499 mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
500 proc->saved_exc_port = MACH_PORT_NULL;
503 proc->exc_port = MACH_PORT_NULL;
506 proc_string (proc), safe_strerror (err));
515 proc_trace (struct proc *proc, int set)
517 thread_state_t state = proc_get_state (proc, 1);
522 proc_debug (proc, "tracing %s", set ? "on" : "off");
528 if (proc->exc_port == MACH_PORT_NULL)
529 proc_steal_exc_port (proc, proc->inf->event_port);
543 /* Returns a new proc structure with the given fields. Also adds a
545 struct proc *
550 struct proc *proc = xmalloc (sizeof (struct proc));
552 proc->port = port;
553 proc->tid = tid;
554 proc->inf = inf;
555 proc->next = 0;
556 proc->saved_exc_port = MACH_PORT_NULL;
557 proc->exc_port = MACH_PORT_NULL;
559 proc->sc = 0;
560 proc->cur_sc = 0;
564 proc->run_sc = inf->default_thread_run_sc;
565 proc->pause_sc = inf->default_thread_pause_sc;
566 proc->detach_sc = inf->default_thread_detach_sc;
567 proc->resume_sc = proc->run_sc;
569 proc->aborted = 0;
570 proc->dead = 0;
571 proc->state_valid = 0;
572 proc->state_changed = 0;
574 proc_debug (proc, "is new");
588 proc_debug (proc, "notifications to: %d", inf->event_port);
595 if (proc_is_task (proc))
597 proc_steal_exc_port (proc, inf->event_port);
601 proc_steal_exc_port (proc, MACH_PORT_NULL);
604 return proc;
609 struct proc *
610 _proc_free (struct proc *proc)
612 struct inf *inf = proc->inf;
613 struct proc *next = proc->next;
615 proc_debug (proc, "freeing...");
617 if (proc == inf->step_thread)
620 if (proc == inf->wait.thread)
622 if (proc == inf->signal_thread)
625 if (proc->port != MACH_PORT_NULL)
627 if (proc->exc_port != MACH_PORT_NULL)
629 proc_restore_exc_port (proc);
630 if (proc->cur_sc != 0)
633 proc->sc = 0;
634 proc_update_sc (proc);
636 mach_port_deallocate (mach_task_self (), proc->port);
639 xfree (proc);
751 struct proc *task = inf->task;
796 proc server state. Note that the traced field is only updated from
797 the proc server state if we do not have a message port. If we do
847 /* The proc server might have suspended the task while stopping
849 Refetch the suspend count. The proc server should be
921 struct proc *task = inf->task;
923 because we'll change a thread only if it already has an existing proc
930 struct proc *thread;
969 /* Converts a GDB pid to a struct proc. */
970 struct proc *
973 struct proc *thread = inf->threads;
983 /* Converts a thread port to a struct proc. */
984 struct proc *
987 struct proc *thread = inf->threads;
1004 struct proc *task = inf->task;
1034 struct proc *matched[num_threads + 1];
1036 struct proc *last = 0;
1038 struct proc *thread = inf->threads;
1109 struct proc *run_thread, int run_others)
1111 struct proc *thread;
1129 struct proc *thread;
1154 struct proc *thread;
1173 inf_set_step_thread (struct inf *inf, struct proc *thread)
1225 struct proc *task = inf->task;
1234 struct proc *thread;
1281 struct proc *thread;
1296 struct proc *thread;
1402 process_t proc;
1403 error_t err = proc_pid2proc (proc_server, inf->pid, &proc);
1409 err = proc_mark_cont (proc);
1412 struct proc *thread;
1445 struct proc *thread;
1471 /* Always get information on events from the proc server. */
1476 /* The proc server is single-threaded, and only allows a single
1503 (3) wait reply from the proc server. */
1646 struct proc *thread = inf_port_to_thread (inf, thread_port);
1758 struct proc *thread = inf_port_to_thread (inf, dead_port);
1838 replies in order because the proc server is single threaded. */
1961 struct proc *step_thread = 0;
2002 struct proc *thread = inf_tid_to_thread (inf, PIDGET (tid));
2029 struct proc *task = current_inferior->task;
2587 /* Return printable description of proc. */
2589 proc_string (struct proc *proc)
2592 if (proc_is_task (proc))
2593 sprintf (tid_str, "process %d", proc->inf->pid);
2596 proc->inf->pid, pid_to_thread_id (MERGEPID (proc->tid, 0)));
2605 struct proc *thread = inf_tid_to_thread (inf, tid);
2742 static struct proc *
2746 struct proc *thread = inf_tid_to_thread (inf, PIDGET (inferior_ptid));
2861 steal_exc_port (struct proc *proc, mach_port_t name)
2867 if (!proc || !proc->inf->task)
2870 err = mach_port_extract_right (proc->inf->task->port,
2877 if (proc->saved_exc_port)
2879 mach_port_deallocate (mach_task_self (), proc->saved_exc_port);
2881 proc->saved_exc_port = port;
2883 if (!proc->exc_port)
2887 proc->exc_port = proc->inf->event_port;
2888 err = proc_set_exception_port (proc, proc->exc_port);
2890 proc_string (proc), safe_strerror (err));
3253 struct proc *thread = cur_thread ();
3265 struct proc *thread = cur_thread ();
3277 struct proc *thread = cur_thread ();
3284 struct proc *thread = cur_thread ();
3301 struct proc *thread = cur_thread ();
3312 struct proc *thread = cur_thread ();
3322 struct proc *thread = cur_thread ();
3334 struct proc *thread = cur_thread ();