27 #include <mach_error.h> 28 #include <mach/exception.h> 29 #include <mach/message.h> 30 #include <mach/notify.h> 31 #include <mach/vm_attributes.h> 34 #include <hurd/interrupt.h> 36 #include <hurd/msg_request.h> 37 #include <hurd/process.h> 41 #include <hurd/process_request.h> 42 #include <hurd/signal.h> 43 #include <hurd/sigpreempt.h> 54 #include <sys/ptrace.h> 76 #include "exc_request_S.h" 78 #include "process_reply_S.h" 79 #include "msg_reply_S.h" 80 #include "exc_request_U.h" 107 struct proc *run_thread,
118 #define inf_debug(_inf, msg, args...) \ 119 do { struct inf *__inf = (_inf); \ 120 debug ("{inf %d %s}: " msg, __inf->pid, \ 121 host_address_to_string (__inf) , ##args); } while (0) 137 #define INF_MSGPORT_RPC(inf, rpc_expr) \ 138 HURD_MSGPORT_RPC (proc_getmsgport (proc_server, inf->pid, &msgport), \ 139 (refport = inf->task->port, 0), 0, \ 140 msgport ? (rpc_expr) : EIEIO) 145 #define INF_RESUME_MSGPORT_RPC(inf, rpc_expr) \ 146 (inf_set_threads_resume_sc_for_signal_thread (inf) \ 147 ? ({ kern_return_t __e; \ 149 __e = INF_MSGPORT_RPC (inf, rpc_expr); \ 284 while (delta-- > 0 && !
err)
294 while (delta++ < 0 && !
err)
370 will_modify ?
" (with intention to modify)" :
"");
383 (thread_state_t) &
proc->
state, &state_size);
405 return task_get_exception_port (
proc->
port, port);
407 return thread_get_exception_port (
proc->
port, port);
416 return task_set_exception_port (
proc->
port, port);
418 return thread_set_exception_port (
proc->
port, port);
425 mach_port_t exc_port;
432 mach_port_deallocate (mach_task_self (),
proc->
exc_port);
452 kern_return_t
err = 0;
456 if (cur_exc_port != exc_port)
465 mach_port_deallocate (mach_task_self (), cur_exc_port);
480 warning (
_(
"Error setting exception port for %s: %s"),
495 kern_return_t
err = 0;
510 warning (
_(
"Error setting exception port for %s: %s"),
552 mach_port_t prev_port = MACH_PORT_NULL;
581 mach_port_request_notification (mach_task_self (),
port,
582 MACH_NOTIFY_DEAD_NAME, 1,
584 MACH_MSG_TYPE_MAKE_SEND_ONCE,
587 warning (
_(
"Couldn't request notification for port %lu: %s"),
592 if (prev_port != MACH_PORT_NULL)
593 mach_port_deallocate (mach_task_self (), prev_port);
639 mach_port_deallocate (mach_task_self (),
proc->
port);
734 err = mach_port_allocate (mach_task_self (),
756 task_port = MACH_PORT_NULL;
762 error (
_(
"Error getting task for pid %d: %s"),
769 task_suspend (task_port);
771 if (task && task->
port != task_port)
778 if (task_port != MACH_PORT_NULL)
804 mach_msg_type_number_t noise_len = 0;
806 mach_msg_type_number_t pi_len = 0;
810 (procinfo_t *) &pi, &pi_len, &noise, &noise_len);
815 inf->
nomsg = !!(pi->state & PI_NOMSG);
818 vm_deallocate (mach_task_self (), (vm_address_t) pi,
819 pi_len *
sizeof (*(procinfo_t) 0));
821 vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len);
831 mach_msg_type_number_t noise_len = 0;
833 mach_msg_type_number_t pi_len = 0;
834 int info_flags = PI_FETCH_TASKINFO;
835 int suspend_count = -1;
840 (procinfo_t *) &pi, &pi_len, &noise, &noise_len);
847 if (
inf->
task->
cur_sc < pi->taskinfo.suspend_count && suspend_count == -1)
853 suspend_count = pi->taskinfo.suspend_count;
857 suspend_count = pi->taskinfo.suspend_count;
859 vm_deallocate (mach_task_self (), (vm_address_t) pi,
860 pi_len *
sizeof (*(procinfo_t) 0));
862 vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len);
866 if (!
query (
_(
"Pid %d has an additional task suspend count of %d;" 869 error (
_(
"Additional task suspend count left untouched."));
888 sigset_t mask = on ? ~(sigset_t) 0 : 0;
891 INIT_TRACEMASK, mask));
896 warning (
_(
"Can't modify tracing state for pid %d: %s"),
897 inf->
pid,
"No signal thread");
901 warning (
_(
"Can't modify tracing state for pid %d: %s"),
928 int task_running = (task->
sc == 0), thread_running = 0;
949 (thread_running && task_running) ?
"" :
"not ");
951 inf->
running = thread_running && task_running;
975 thread = thread->
next;
989 thread = thread->
next;
1009 thread_array_t threads;
1010 mach_msg_type_number_t num_threads, i;
1021 kern_return_t
err = task_threads (task->
port, &threads, &num_threads);
1040 mach_msg_type_number_t search_start = 0;
1042 struct proc *matched[num_threads + 1];
1044 struct proc *last = 0;
1048 memset (matched, 0,
sizeof (matched));
1052 mach_msg_type_number_t left;
1054 for (i = search_start, left = num_threads; left; i++, left--)
1056 if (i >= num_threads)
1058 if (thread->
port == threads[i])
1061 matched[i] = thread;
1063 thread = thread->
next;
1072 thread->
port = MACH_PORT_NULL;
1075 last->
next = thread;
1081 for (i = 0; i < num_threads; i++)
1085 mach_port_deallocate (mach_task_self (), threads[i]);
1093 last->
next = thread;
1097 proc_debug (thread,
"new thread: %lu", threads[i]);
1115 vm_deallocate (mach_task_self (),
1116 (vm_address_t) threads, (num_threads *
sizeof (
thread_t)));
1137 struct proc *run_thread,
int run_others)
1139 struct proc *thread;
1143 if (thread == run_thread)
1145 else if (run_others)
1157 struct proc *thread;
1182 struct proc *thread;
1259 struct proc *thread;
1305 struct proc *thread;
1320 struct proc *thread;
1338 kern_return_t
err = 0;
1341 #define NAME gdb_signal_to_name (sig) 1343 if (host_sig >= _NSIG)
1362 " task = %lu, thread = %lu, exc = %d" 1363 ", code = %d, subcode = %d",
1367 exception_raise_request (e->
handler,
1368 e->
reply, MACH_MSG_TYPE_MOVE_SEND_ONCE,
1373 error (
_(
"Can't forward spontaneous exception (%s)."),
NAME);
1384 msg_sig_post_untraced_request (msgport,
1386 MACH_MSG_TYPE_MAKE_SEND_ONCE,
1404 " (so resuming signal thread)",
NAME);
1407 msg_sig_post_untraced (msgport, host_sig,
1413 warning (
_(
"Can't deliver signal %s: No signal thread."),
NAME);
1436 struct proc *thread;
1439 thread_resume (thread->
port);
1458 extern "C" int exc_server (mach_msg_header_t *, mach_msg_header_t *);
1459 extern "C" int msg_reply_server (mach_msg_header_t *, mach_msg_header_t *);
1460 extern "C" int notify_server (mach_msg_header_t *, mach_msg_header_t *);
1470 mach_msg_header_t hdr;
1471 mach_msg_type_t
type;
1475 struct proc *thread;
1487 error (
_(
"There are no threads; try again later."));
1531 err = mach_msg (&msg.hdr, MACH_RCV_MSG | MACH_RCV_INTERRUPT,
1533 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1544 if (
err == EMACH_RCV_INTERRUPTED)
1552 mach_msg_header_t hdr;
1553 mach_msg_type_t err_type;
1567 error (
_(
"Got a strange event, msg id = %d."), msg.hdr.msgh_id);
1570 error (
_(
"Handling event, msgid = %d: %s"),
1586 inf_debug (
inf,
"pending_execs, ignoring minor event");
1646 inf_debug (
inf,
"returning ptid = %s, status = %s (%d)",
1663 thread_t thread_port, task_t task_port,
1664 int exception,
int code,
int subcode)
1670 "thread = %lu, task = %lu, exc = %d, code = %d, subcode = %d",
1671 thread_port, task_port, exception,
code, subcode);
1683 mach_port_deallocate (mach_task_self (), thread_port);
1684 mach_port_deallocate (mach_task_self (), task_port);
1695 if (exception == EXC_BREAKPOINT)
1699 mach_port_deallocate (mach_task_self (),
reply_port);
1719 mach_port_mod_refs (mach_task_self (),
1739 mach_port_deallocate (mach_task_self (),
reply_port);
1751 warning (
_(
"Pid %d died with unknown exit status, using SIGKILL."),
1785 thread->
port = MACH_PORT_NULL;
1793 mach_port_deallocate (mach_task_self (), dead_port);
1800 #define ILL_RPC(fun, ...) \ 1801 extern kern_return_t fun (__VA_ARGS__); \ 1802 kern_return_t fun (__VA_ARGS__) \ 1804 warning (_("illegal rpc: %s"), #fun); \ 1808 ILL_RPC (do_mach_notify_no_senders,
1809 mach_port_t
notify, mach_port_mscount_t count)
1810 ILL_RPC (do_mach_notify_port_deleted,
1812 ILL_RPC (do_mach_notify_msg_accepted,
1814 ILL_RPC (do_mach_notify_port_destroyed,
1816 ILL_RPC (do_mach_notify_send_once,
1822 S_proc_wait_reply (mach_port_t reply, kern_return_t
err,
1827 inf_debug (
inf,
"err = %s, pid = %d, status = 0x%x, sigcode = %d",
1849 warning (
_(
"Can't wait for pid %d: %s"),
1874 ILL_RPC (S_proc_setmsgport_reply,
1876 mach_port_t oldmsgport)
1877 ILL_RPC (S_proc_getmsgport_reply,
1879 mach_port_t msgports)
1880 ILL_RPC (S_proc_pid2task_reply,
1882 ILL_RPC (S_proc_task2pid_reply,
1884 ILL_RPC (S_proc_task2proc_reply,
1886 ILL_RPC (S_proc_proc2task_reply,
1888 ILL_RPC (S_proc_pid2proc_reply,
1890 ILL_RPC (S_proc_getprocinfo_reply,
1893 data_t
threadwaits, mach_msg_type_number_t threadwaitsCnt)
1894 ILL_RPC (S_proc_getprocargs_reply,
1896 data_t procargs, mach_msg_type_number_t procargsCnt)
1897 ILL_RPC (S_proc_getprocenv_reply,
1899 data_t
procenv, mach_msg_type_number_t procenvCnt)
1900 ILL_RPC (S_proc_getloginid_reply,
1902 ILL_RPC (S_proc_getloginpids_reply,
1904 pidarray_t
pids, mach_msg_type_number_t pidsCnt)
1905 ILL_RPC (S_proc_getlogin_reply,
1909 ILL_RPC (S_proc_getsessionpgids_reply,
1911 pidarray_t pgidset, mach_msg_type_number_t pgidsetCnt)
1912 ILL_RPC (S_proc_getsessionpids_reply,
1914 pidarray_t
pidset, mach_msg_type_number_t pidsetCnt)
1915 ILL_RPC (S_proc_getsidport_reply,
1917 mach_port_t sessport)
1918 ILL_RPC (S_proc_getpgrp_reply,
1920 ILL_RPC (S_proc_getpgrppids_reply,
1922 pidarray_t
pidset, mach_msg_type_number_t pidsetCnt)
1923 ILL_RPC (S_proc_get_tty_reply,
1925 ILL_RPC (S_proc_getnports_reply,
1927 mach_msg_type_number_t nports)
1928 ILL_RPC (S_proc_is_important_reply,
1930 boolean_t essential)
1931 ILL_RPC (S_proc_get_code_reply,
1933 vm_address_t start_code, vm_address_t end_code)
1938 S_msg_sig_post_untraced_reply (mach_port_t reply, kern_return_t
err)
1967 ILL_RPC (S_msg_sig_post_reply,
1968 mach_port_t reply, kern_return_t
err)
1971 static mach_port_msgcount_t
1972 port_msgs_queued (mach_port_t port)
1974 struct mach_port_status
status;
1976 mach_port_get_receive_status (mach_task_self (), port, &
status);
1981 return status.mps_msgcount;
2003 ptid_t ptid,
int step,
enum gdb_signal sig)
2005 struct proc *step_thread = 0;
2016 if (sig == GDB_SIGNAL_0 &&
inf->
nomsg)
2026 warning (
_(
"Aborting %s with unforwarded exception %s."),
2055 error (
_(
"Can't run single thread id %s: no such thread!"),
2065 warning (
_(
"Can't step thread id %s: no such thread."),
2086 task_terminate (task->
port);
2130 if (
ptrace (PTRACE_TRACEME) != 0)
2136 const char *exec_file,
const std::string &allargs,
2146 NULL, NULL, NULL, NULL);
2203 if (
pid == getpid ())
2204 error (
_(
"I refuse to debug myself!"));
2245 renumber_threads (0);
2288 error (
_(
"to_stop target function not implemented"));
2307 vm_address_t low_address = (vm_address_t) trunc_page (addr);
2308 vm_size_t aligned_length =
2309 (vm_size_t) round_page (addr + length) - low_address;
2311 mach_msg_type_number_t copy_count;
2314 err = vm_read (task, low_address, aligned_length, &copied, ©_count);
2318 err = hurd_safe_copyin (myaddr, (
void *) (addr - low_address + copied),
2326 err = vm_deallocate (mach_task_self (), copied, copy_count);
2328 warning (
_(
"gnu_read_inferior vm_deallocate failed: %s"),
2334 #define CHK_GOTO_OUT(str,ret) \ 2335 do if (ret != KERN_SUCCESS) { errstr = #str; goto out; } while(0) 2351 const gdb_byte *myaddr,
int length)
2354 vm_address_t low_address = (vm_address_t) trunc_page (addr);
2355 vm_size_t aligned_length =
2356 (vm_size_t) round_page (addr + length) - low_address;
2358 mach_msg_type_number_t copy_count;
2361 char *errstr =
"Bug in gnu_write_inferior";
2367 err = vm_read (task,
2376 err = hurd_safe_copyout ((
void *) (addr - low_address + copied),
2385 vm_size_t remaining_length = aligned_length;
2386 vm_address_t region_address = low_address;
2390 while (region_address < low_address + aligned_length)
2393 vm_prot_t max_protection;
2394 vm_inherit_t inheritance;
2396 mach_port_t object_name;
2398 vm_size_t region_length = remaining_length;
2399 vm_address_t old_address = region_address;
2401 err = vm_region (task,
2413 if (old_address != region_address)
2415 warning (
_(
"No memory at 0x%lx. Nothing written"),
2422 if (!(max_protection & VM_PROT_WRITE))
2424 warning (
_(
"Memory at address 0x%lx is unwritable. " 2436 region_element->
start = region_address;
2437 region_element->
length = region_length;
2440 region_element->
next = region_head;
2441 region_head = region_element;
2443 region_address += region_length;
2444 remaining_length = remaining_length - region_length;
2453 if (!(
scan->protection & VM_PROT_WRITE))
2455 err = vm_protect (task,
2459 scan->protection | VM_PROT_WRITE);
2464 err = vm_write (task,
2473 if (!(
scan->protection & VM_PROT_WRITE))
2475 err = vm_protect (task,
2490 (void) vm_deallocate (mach_task_self (),
2495 if (
err != KERN_SUCCESS)
2497 warning (
_(
"%s: %s"), errstr, mach_error_string (
err));
2519 if (task == MACH_PORT_NULL)
2522 if (writebuf != NULL)
2560 ElfW(auxv_t) auxv[2];
2562 if (task == MACH_PORT_NULL)
2564 if (writebuf != NULL)
2567 if (memaddr ==
sizeof (auxv))
2569 if (memaddr >
sizeof (auxv))
2577 err = proc_get_entry (
proc, &entry);
2582 auxv[0].a_type = AT_ENTRY;
2583 auxv[0].a_un.a_val = entry;
2584 auxv[1].a_type = AT_NULL;
2585 auxv[1].a_un.a_val = 0;
2591 if (memaddr + len >
sizeof (auxv))
2592 len =
sizeof (auxv) - memaddr;
2594 memcpy (readbuf, (
gdb_byte *) &auxv + memaddr, len);
2604 const char *annex,
gdb_byte *readbuf,
2626 vm_address_t region_address, last_region_address, last_region_end;
2627 vm_prot_t last_protection;
2632 if (task == MACH_PORT_NULL)
2635 region_address = last_region_address = last_region_end =
VM_MIN_ADDRESS;
2636 last_protection = VM_PROT_NONE;
2637 while (region_address < VM_MAX_ADDRESS)
2640 vm_prot_t max_protection;
2641 vm_inherit_t inheritance;
2643 mach_port_t object_name;
2645 vm_size_t region_length = VM_MAX_ADDRESS - region_address;
2646 vm_address_t old_address = region_address;
2648 err = vm_region (task,
2657 if (
err == KERN_NO_SPACE)
2659 if (
err != KERN_SUCCESS)
2661 warning (
_(
"vm_region failed: %s"), mach_error_string (
err));
2665 if (
protection == last_protection && region_address == last_region_end)
2668 last_region_end = region_address += region_length;
2673 if (last_protection != VM_PROT_NONE)
2674 (*func) (last_region_address,
2675 last_region_end - last_region_address,
2676 last_protection & VM_PROT_READ,
2677 last_protection & VM_PROT_WRITE,
2678 last_protection & VM_PROT_EXECUTE,
2681 last_region_address = region_address;
2682 last_region_end = region_address += region_length;
2688 if (last_region_end > last_region_address && last_protection != VM_PROT_NONE)
2689 (*func) (last_region_address, last_region_end - last_region_address,
2690 last_protection & VM_PROT_READ,
2691 last_protection & VM_PROT_WRITE,
2692 last_protection & VM_PROT_EXECUTE,
2704 static char tid_str[80];
2709 xsnprintf (tid_str,
sizeof (tid_str),
"Thread %d.%d",
2725 static char tid_str[80];
2727 xsnprintf (tid_str,
sizeof (tid_str),
"bogus thread id %d",
tid);
2778 "name of a thread property, or \"default\".\n");
2785 "name of a thread property, or \"default\".\n");
2792 "by the name of a thread property.\n");
2799 "by the name of a thread property.\n");
2808 int val = strtoul (args, &arg_end, 10);
2810 if (*args && *arg_end ==
'\0')
2813 error (
_(
"Illegal argument for \"%s\" command, should be an integer."),
2820 if (!args || strcmp (args, t_val) == 0)
2822 else if (strcmp (args, f_val) == 0)
2825 error (
_(
"Illegal argument for \"%s\" command, " 2826 "should be \"%s\" or \"%s\"."),
2827 cmd_prefix, t_val, f_val);
2830 #define parse_bool_arg(args, cmd_prefix) \ 2831 _parse_bool_arg (args, "on", "off", cmd_prefix) 2837 error (
_(
"Garbage after \"%s\" command: `%s'"), cmd_prefix, args);
2841 static struct proc *
2848 error (
_(
"No current thread."));
2859 error (
_(
"No current process."));
2900 "set task detach-suspend-count");
2906 check_empty (args,
"show task detach-suspend-count");
2908 "suspend count of %d when detaching.\n",
2930 sc ?
"are" :
"aren't",
2931 !sc &&
inf->
pause_sc ?
" (but the task is)" :
"");
2957 parse_int_arg (args,
"set thread default detach-suspend-count");
2963 check_empty (args,
"show thread default detach-suspend-count");
2976 mach_msg_type_name_t port_type;
2979 error (
_(
"No inferior task."));
2982 name, MACH_MSG_TYPE_COPY_SEND,
2985 error (
_(
"Couldn't extract send right %lu from inferior: %s"),
3001 error (
_(
"Can't set exception port for %s: %s"),
3012 error (
_(
"No argument to \"set task exception-port\" command."));
3037 if (!args || (!isdigit (*args) && strcmp (args,
"none") != 0))
3038 error (
_(
"Illegal argument to \"set signal-thread\" command.\n" 3039 "Should be a thread ID, or \"none\"."));
3041 if (strcmp (args,
"none") == 0)
3128 " of a task property.\n");
3185 print_port_info (right, 0,
inf->
task->
port, PORTINFO_DETAILS,
3196 print_task_ports_info (
inf->
task->
port, only, PORTINFO_DETAILS,
3240 Set whether the new threads are suspended while gdb has control.\n\ 3241 This property normally has no effect because the whole task is\n\ 3242 suspended, however, that may be disabled with \"set task pause off\".\n\ 3243 The default value is \"off\"."),
3246 Show whether new threads are suspended while gdb has control."),
3250 Set whether new threads are allowed to run (once gdb has noticed them)."),
3253 Show whether new threads are allowed to run (once gdb has noticed them)."),
3257 _(
"Set the default detach-suspend-count value for new threads."),
3260 _(
"Show the default detach-suspend-count value for new threads."),
3264 Set whether the inferior process's signals will be intercepted.\n\ 3265 Mach exceptions (such as breakpoint traps) are not affected."),
3269 Show whether the inferior process's signals will be intercepted."),
3274 Set the thread that gdb thinks is the libc signal thread.\n\ 3275 This thread is run when delivering a signal to a non-stopped process."),
3279 Set the thread that gdb thinks is the libc signal thread."),
3284 Set whether gdb thinks the inferior process is stopped as with SIGSTOP.\n\ 3285 Stopped process will be continued by sending them a signal."),
3288 Show whether gdb thinks the inferior process is stopped as with SIGSTOP."),
3292 Set whether exceptions in the inferior process will be trapped.\n\ 3293 When exceptions are turned off, neither breakpoints nor single-stepping\n\ 3299 Show whether exceptions in the inferior process will be trapped."),
3303 _(
"Command prefix for setting task attributes."),
3306 _(
"Command prefix for showing task attributes."),
3310 Set whether the task is suspended while gdb has control.\n\ 3311 A value of \"on\" takes effect immediately, otherwise nothing happens\n\ 3312 until the next time the program is continued.\n\ 3313 When setting this to \"off\", \"set thread default pause on\" can be\n\ 3314 used to pause individual threads by default instead."),
3317 _(
"Show whether the task is suspended while gdb has control."),
3321 _(
"Set the suspend count will leave on the thread when detaching."),
3324 _(
"Show the suspend count will leave " 3325 "on the thread when detaching."),
3329 Set the task exception port to which we forward exceptions.\n\ 3330 The argument should be the value of the send right in the task."),
3339 Set task options so that we interfere as little as possible.\n\ 3340 This is the same as setting `task pause', `exceptions', and\n\ 3341 `signals' to the opposite value."),
3346 _(
"Show information about the task's send rights"));
3348 _(
"Show information about the task's receive rights"));
3350 _(
"Show information about the task's port rights"));
3352 _(
"Show information about the task's port sets"));
3354 _(
"Show information about the task's dead names"));
3383 sc ?
"is" :
"isn't",
3403 thread->
run_sc == 0 ?
"is" :
"isn't");
3410 "set thread detach-suspend-count");
3418 check_empty (args,
"show thread detach-suspend-count");
3420 " of %d when detaching.\n",
3431 error (
_(
"No argument to \"set thread exception-port\" command."));
3454 thread_basic_info_data_t _info;
3455 thread_basic_info_t info = &_info;
3456 mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT;
3458 thread_info (thread->
port, THREAD_BASIC_INFO, (
int *) &info, &info_len);
3461 thread->
sc = info->suspend_count;
3465 vm_deallocate (mach_task_self (), (vm_address_t) info,
3466 info_len *
sizeof (
int));
3474 _(
"Command prefix for setting thread properties."),
3477 _(
"Command prefix for setting default thread properties."),
3481 _(
"Command prefix for showing thread properties."),
3484 _(
"Command prefix for showing default thread properties."),
3489 Set whether the current thread is suspended while gdb has control.\n\ 3490 A value of \"on\" takes effect immediately, otherwise nothing happens\n\ 3491 until the next time the program is continued. This property normally\n\ 3492 has no effect because the whole task is suspended, however, that may\n\ 3493 be disabled with \"set task pause off\".\n\ 3494 The default value is \"off\"."),
3497 Show whether the current thread is suspended while gdb has control."),
3501 _(
"Set whether the current thread is allowed to run."),
3504 _(
"Show whether the current thread is allowed to run."),
3508 Set the suspend count will leave on the thread when detaching.\n\ 3509 Note that this is relative to suspend count when gdb noticed the thread;\n\ 3510 use the `thread takeover-suspend-count' to force it to an absolute value."),
3513 Show the suspend count will leave on the thread when detaching.\n\ 3514 Note that this is relative to suspend count when gdb noticed the thread;\n\ 3515 use the `thread takeover-suspend-count' to force it to an absolute value."),
3519 Set the thread exception port to which we forward exceptions.\n\ 3520 This overrides the task exception port.\n\ 3521 The argument should be the value of the send right in the task."),
3528 Force the threads absolute suspend-count to be gdb's.\n\ 3529 Prior to giving this command, gdb's thread suspend-counts are relative\n\ 3530 to the thread's initial suspend-count when gdb notices the threads."),
3543 _(
"Set debugging output for the gnu backend."),
3544 _(
"Show debugging output for the gnu backend."),
3552 #ifdef FLUSH_INFERIOR_CACHE 3560 flush_inferior_icache (
CORE_ADDR pc,
int amount)
3562 vm_machine_attribute_val_t flush = MATTR_VAL_ICACHE_FLUSH;
3570 if (ret != KERN_SUCCESS)
struct gdbarch * target_gdbarch(void)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
static ptid_t gnu_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options)
struct value * value_mark(void)
void inf_set_pid(struct inf *inf, pid_t pid)
void() inf_threads_ftype(struct proc *thread, void *arg)
static constexpr ptid_t tid
struct thread_info * add_thread(ptid_t ptid)
static void info_recv_rights_cmd(const char *args, int from_tty)
static void show_task_cmd(const char *args, int from_tty)
#define THREAD_STATE_CLEAR_TRACED(state)
static int gnu_read_inferior(task_t task, CORE_ADDR addr, gdb_byte *myaddr, int length)
int(* to_find_memory_regions)(struct target_ops *, find_memory_region_ftype func, void *data) TARGET_DEFAULT_FUNC(dummy_find_memory_regions)
struct target_waitstatus status
static void gnu_create_inferior(struct target_ops *ops, const char *exec_file, const std::string &allargs, char **env, int from_tty)
static struct proc * inf_port_to_thread(struct inf *inf, mach_port_t port)
static void set_thread_default_run_cmd(const char *args, int from_tty)
int ptid_get_pid(const ptid_t &ptid)
static void show_sig_thread_cmd(const char *args, int from_tty)
char * proc_string(struct proc *proc)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
#define INF_MSGPORT_RPC(inf, rpc_expr)
void inf_set_threads_resume_sc(struct inf *inf, struct proc *run_thread, int run_others)
int __proc_pid(struct proc *proc)
static void set_signals_cmd(int arg, int from_tty)
LONGEST value_as_long(struct value *val)
struct cmd_list_element * show_thread_default_cmd_list
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int procinfo_t mach_msg_type_number_t data_t mach_msg_type_number_t threadwaitsCnt mach_port_t kern_return_t data_t mach_msg_type_number_t procenvCnt mach_port_t kern_return_t pidarray_t mach_msg_type_number_t pidsCnt mach_port_t kern_return_t pid_t sid mach_port_t kern_return_t pidarray_t pidset
static void info_port_rights(const char *args, mach_port_type_t only)
void warning(const char *fmt,...)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t rusage
static void scan(struct macro_buffer *dest, struct macro_buffer *src, struct macro_name_list *no_loop, macro_lookup_ftype *lookup_func, void *lookup_baton)
int query(const char *ctlstr,...)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int sigcode
void push_target(struct target_ops *t)
char * get_exec_file(int err)
static const char * gnu_pid_to_str(struct target_ops *ops, ptid_t ptid)
static void steal_exc_port(struct proc *proc, mach_port_t name)
unsigned long fetched_regs
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
void inf_continue(struct inf *inf)
static void show_exceptions_cmd(const char *args, int from_tty)
void * memset(T *s, int c, size_t n)=delete
const char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
union target_waitstatus::@174 value
static int gnu_find_memory_regions(struct target_ops *self, find_memory_region_ftype func, void *data)
void inf_attach(struct inf *inf, int pid)
void inf_startup(struct inf *inf, int pid)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
static struct inf * cur_inf(void)
void inf_restore_exc_ports(struct inf *inf)
static void set_noninvasive_cmd(const char *args, int from_tty)
static void set_thread_detach_sc_cmd(const char *args, int from_tty)
void inf_threads(struct inf *inf, inf_threads_ftype *f, void *arg)
static void thread_takeover_sc_cmd(const char *args, int from_tty)
static void set_thread_exc_port_cmd(const char *args, int from_tty)
#define THREAD_STATE_FLAVOR
static void set_task_exc_port_cmd(const char *args, int from_tty)
static void info_port_sets_cmd(const char *args, int from_tty)
#define inf_debug(_inf, msg, args...)
void inf_cleanup(struct inf *inf)
static void set_exceptions_cmd(int arg, int from_tty)
int default_thread_detach_sc
void inf_child_maybe_unpush_target(struct target_ops *ops)
#define INF_RESUME_MSGPORT_RPC(inf, rpc_expr)
void inf_clear_wait(struct inf *inf)
static void set_sig_thread_cmd(const char *args, int from_tty)
static void set_thread_pause_cmd(const char *args, int from_tty)
void inf_resume(struct inf *inf)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int procinfo_t mach_msg_type_number_t data_t mach_msg_type_number_t threadwaitsCnt mach_port_t kern_return_t data_t procenv
static void show_thread_pause_cmd(const char *args, int from_tty)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
static void info_port_rights_cmd(const char *args, int from_tty)
#define host_address_to_string(ADDR)
ptid_t ptid_build(int pid, long lwp, long tid)
static void set_thread_default_detach_sc_cmd(const char *args, int from_tty)
int inf_set_threads_resume_sc_for_signal_thread(struct inf *inf)
struct proc * step_thread
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
static void add_thread_commands(void)
static struct cmd_list_element * set_task_cmd_list
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
void proc_abort(struct proc *proc, int force)
kern_return_t do_mach_notify_dead_name(mach_port_t notify, mach_port_t dead_port)
static void show_task_pause_cmd(const char *args, int from_tty)
mach_port_t kern_return_t return_code
struct cmd_list_element * setlist
static void set_thread_default_pause_cmd(const char *args, int from_tty)
kern_return_t S_exception_raise_request(mach_port_t port, mach_port_t reply_port, thread_t thread_port, task_t task_port, int exception, int code, int subcode)
static int _parse_bool_arg(const char *args, char *t_val, char *f_val, char *cmd_prefix)
kern_return_t proc_get_exception_port(struct proc *proc, mach_port_t *port)
static void gnu_mourn_inferior(struct target_ops *ops)
static process_t proc_server
thread_state_data_t state
void inf_set_step_thread(struct inf *inf, struct proc *proc)
void inf_signal(struct inf *inf, enum gdb_signal sig)
static void show_thread_default_pause_cmd(const char *args, int from_tty)
static void gnu_detach(struct target_ops *ops, const char *args, int from_tty)
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
struct proc * _proc_free(struct proc *proc)
struct cmd_list_element * showlist
static int parse_int_arg(const char *args, char *cmd_prefix)
struct target_ops * gnu_target(void)
#define CHK_GOTO_OUT(str, ret)
static void show_task_detach_sc_cmd(const char *args, int from_tty)
#define THREAD_STATE_SET_TRACED(state)
#define parse_bool_arg(args, cmd_prefix)
ptid_t pid_to_ptid(int pid)
struct proc * signal_thread
void store_waitstatus(struct target_waitstatus *ourstatus, int hoststatus)
static void gnu_attach(struct target_ops *ops, const char *args, int from_tty)
char * pulongest(ULONGEST u)
int gdb_signal_to_host(enum gdb_signal)
enum gdb_signal gdb_signal_from_host(int)
static void inf_validate_task_sc(struct inf *inf)
static void show_thread_default_run_cmd(const char *args, int from_tty)
void target_mourn_inferior(ptid_t ptid)
int inf_update_suspends(struct inf *inf)
void thread_change_ptid(ptid_t old_ptid, ptid_t new_ptid)
mach_port_t saved_exc_port
static void set_thread_run_cmd(const char *args, int from_tty)
static void set_task_cmd(const char *args, int from_tty)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int procinfo_t mach_msg_type_number_t data_t threadwaits
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
static void show_thread_run_cmd(const char *args, int from_tty)
struct vm_region_list * next
static void info_send_rights_cmd(const char *args, int from_tty)
static void show_signals_cmd(const char *args, int from_tty)
struct thread_info * add_thread_silent(ptid_t ptid)
const char * gdb_signal_to_name(enum gdb_signal)
unsigned int pending_execs
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
static struct inf * make_inf()
void printf_unfiltered(const char *format,...)
void inf_validate_procs(struct inf *inf)
struct cmd_list_element * setdebuglist
static void inf_set_traced(struct inf *inf, int on)
void(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
void inf_child_mourn_inferior(struct target_ops *ops)
ptid_t gdb_startup_inferior(pid_t pid, int num_traps)
void _initialize_gnu_nat(void)
static void gnu_kill_inferior(struct target_ops *ops)
long ptid_get_lwp(const ptid_t &ptid)
static void add_task_commands(void)
static void inf_task_died_status(struct inf *inf)
void inf_detach(struct inf *inf)
void proc_steal_exc_port(struct proc *proc, mach_port_t exc_port)
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
void inf_steal_exc_ports(struct inf *inf)
int inf_update_procs(struct inf *inf)
static void gnu_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal sig)
struct value * parse_to_comma_and_eval(const char **expp)
static int gnu_write_inferior(task_t task, CORE_ADDR addr, const gdb_byte *myaddr, int length)
static void set_task_detach_sc_cmd(const char *args, int from_tty)
static enum target_xfer_status gnu_xfer_auxv(gdb_byte *readbuf, const gdb_byte *writebuf, CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
int exc_server(mach_msg_header_t *, mach_msg_header_t *)
struct thread_info * parse_thread_id(const char *tidstr, const char **end)
struct inf * gnu_current_inf
static void show_stopped_cmd(const char *args, int from_tty)
struct target_ops * inf_child_target(void)
static void show_thread_default_detach_sc_cmd(const char *args, int from_tty)
kern_return_t proc_set_exception_port(struct proc *proc, mach_port_t port)
static void info_dead_names_cmd(const char *args, int from_tty)
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
void trace_start_error_with_name(const char *string)
static mach_port_t _proc_get_exc_port(struct proc *proc)
static void set_task_pause_cmd(int arg, int from_tty)
static void set_stopped_cmd(const char *args, int from_tty)
static void check_empty(const char *args, char *cmd_prefix)
void(* to_stop)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
static void gnu_ptrace_me(void)
pid_t fork_inferior(const char *exec_file_arg, const std::string &allargs, char **env, void(*traceme_fun)(), void(*init_trace_fun)(int), void(*pre_trace_fun)(), const char *shell_file_arg, void(*exec_fun)(const char *file, char *const *argv, char *const *env))
int xsnprintf(char *str, size_t size, const char *format,...)
CORE_ADDR parse_and_eval_address(const char *exp)
enum target_waitkind kind
void(* to_kill)(struct target_ops *) TARGET_DEFAULT_NORETURN(noprocess())
void detach_inferior(int pid)
char * safe_strerror(int)
static int inf_pick_first_thread(void)
const char * target_pid_to_str(ptid_t ptid)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int process_reply_server(mach_msg_header_t *, mach_msg_header_t *)
int parse_pid_to_attach(const char *args)
int default_thread_run_sc
struct obstack region_obstack
int proc_update_sc(struct proc *proc)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int procinfo_t mach_msg_type_number_t data_t mach_msg_type_number_t threadwaitsCnt mach_port_t kern_return_t data_t mach_msg_type_number_t procenvCnt mach_port_t kern_return_t pidarray_t pids
void value_free_to_mark(const struct value *mark)
static struct cmd_list_element * show_task_cmd_list
void inf_suspend(struct inf *inf)
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
#define START_INFERIOR_TRAPS_EXPECTED
struct inferior * current_inferior(void)
struct cmd_list_element * add_info_alias(const char *name, const char *oldname, int abbrev_flag)
static void inf_validate_procinfo(struct inf *inf)
unsigned long long ULONGEST
void proc_restore_exc_port(struct proc *proc)
static void set_thread_default_cmd(const char *args, int from_tty)
#define proc_is_task(proc)
static void show_thread_default_cmd(const char *args, int from_tty)
struct cmd_list_element * set_thread_cmd_list
#define THREAD_STATE_SIZE
struct cmd_list_element * showdebuglist
#define proc_is_thread(proc)
struct proc * make_proc(struct inf *inf, mach_port_t port, int tid)
int notify_server(mach_msg_header_t *, mach_msg_header_t *)
int proc_trace(struct proc *proc, int set)
void(* to_create_inferior)(struct target_ops *, const char *, const std::string &, char **, int)
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
struct cmd_list_element * thread_cmd_list
void(* to_attach)(struct target_ops *ops, const char *, int)
void gdb_flush(struct ui_file *file)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int procinfo_t mach_msg_type_number_t procinfoCnt
static enum target_xfer_status gnu_xfer_memory(gdb_byte *readbuf, const gdb_byte *writebuf, CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
static enum target_xfer_status gnu_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
static void show_thread_detach_sc_cmd(const char *args, int from_tty)
int(* find_memory_region_ftype)(CORE_ADDR addr, unsigned long size, int read, int write, int exec, int modified, void *data)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_FUNC(default_target_wait)
int default_thread_pause_sc
thread_state_t proc_get_state(struct proc *proc, int will_modify)
static void inf_update_signal_thread(struct inf *inf)
static void show_thread_cmd(const char *args, int from_tty)
void error(const char *fmt,...)
static int next_thread_id
static struct inf * active_inf(void)
static void set_thread_cmd(const char *args, int from_tty)
static void gnu_stop(struct target_ops *self, ptid_t ptid)
int msg_reply_server(mach_msg_header_t *, mach_msg_header_t *)
void inferior_appeared(struct inferior *inf, int pid)
static struct proc * cur_thread(void)
struct proc * inf_tid_to_thread(struct inf *inf, int tid)
#define proc_debug(_proc, msg, args...)
static int gnu_thread_alive(struct target_ops *ops, ptid_t ptid)
struct cmd_list_element * show_thread_cmd_list
struct cmd_list_element * set_thread_default_cmd_list