30#include <mach_error.h>
31#include <mach/exception.h>
32#include <mach/message.h>
33#include <mach/notify.h>
34#include <mach/vm_attributes.h>
35#include <mach/vm_param.h>
38#include <hurd/interrupt.h>
40#include <hurd/msg_request.h>
41#include <hurd/process.h>
45#include <hurd/process_request.h>
46#include <hurd/signal.h>
47#include <hurd/sigpreempt.h>
58#include <sys/ptrace.h>
67#include "gdbsupport/gdb_wait.h"
72#include "gdbsupport/gdb_obstack.h"
81#include "exc_request_S.h"
83#include "process_reply_S.h"
84#include "msg_reply_S.h"
85#include "exc_request_U.h"
108#define inf_debug(_inf, msg, args...) \
109 do { struct inf *__inf = (_inf); \
110 debug ("{inf %d %s}: " msg, __inf->pid, \
111 host_address_to_string (__inf) , ##args); } while (0)
116#define INF_MSGPORT_RPC(inf, rpc_expr) \
117 HURD_MSGPORT_RPC (proc_getmsgport (proc_server, inf->pid, &msgport), \
118 (refport = inf->task->port, 0), 0, \
119 msgport ? (rpc_expr) : EIEIO)
124#define INF_RESUME_MSGPORT_RPC(inf, rpc_expr) \
125 (inf_set_threads_resume_sc_for_signal_thread (inf) \
126 ? ({ kern_return_t __e; \
128 __e = INF_MSGPORT_RPC (inf, rpc_expr); \
263 while (delta-- > 0 && !
err)
273 while (delta++ < 0 && !
err)
316 if (running && force)
349 will_modify ?
" (with intention to modify)" :
"");
362 (thread_state_t) &
proc->
state, &state_size);
384 return task_get_exception_port (
proc->
port, port);
386 return thread_get_exception_port (
proc->
port, port);
395 return task_set_exception_port (
proc->
port, port);
397 return thread_set_exception_port (
proc->
port, port);
404 mach_port_t exc_port;
411 mach_port_deallocate (mach_task_self (),
proc->
exc_port);
431 kern_return_t
err = 0;
435 if (cur_exc_port != exc_port)
444 mach_port_deallocate (mach_task_self (), cur_exc_port);
459 warning (_(
"Error setting exception port for %s: %s"),
474 kern_return_t
err = 0;
489 warning (_(
"Error setting exception port for %s: %s"),
531 mach_port_t prev_port = MACH_PORT_NULL;
560 mach_port_request_notification (mach_task_self (), port,
561 MACH_NOTIFY_DEAD_NAME, 1,
563 MACH_MSG_TYPE_MAKE_SEND_ONCE,
566 warning (_(
"Couldn't request notification for port %lu: %s"),
567 port, safe_strerror (
err));
571 if (prev_port != MACH_PORT_NULL)
572 mach_port_deallocate (mach_task_self (), prev_port);
618 mach_port_deallocate (mach_task_self (),
proc->
port);
713 err = mach_port_allocate (mach_task_self (),
716 error (_(
"Error allocating event port: %s"), safe_strerror (
err));
735 task_port = MACH_PORT_NULL;
741 error (_(
"Error getting task for pid %d: %s"),
742 pid, safe_strerror (
err));
748 task_suspend (task_port);
750 if (task && task->
port != task_port)
757 if (task_port != MACH_PORT_NULL)
783 mach_msg_type_number_t noise_len = 0;
785 mach_msg_type_number_t pi_len = 0;
789 (procinfo_t *) &pi, &pi_len, &noise, &noise_len);
794 inf->
nomsg = !!(pi->state & PI_NOMSG);
797 vm_deallocate (mach_task_self (), (vm_address_t) pi,
798 pi_len *
sizeof (*(procinfo_t) 0));
800 vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len);
810 mach_msg_type_number_t noise_len = 0;
812 mach_msg_type_number_t pi_len = 0;
813 int info_flags = PI_FETCH_TASKINFO;
814 int suspend_count = -1;
819 (procinfo_t *) &pi, &pi_len, &noise, &noise_len);
826 if (
inf->
task->
cur_sc < pi->taskinfo.suspend_count && suspend_count == -1)
832 suspend_count = pi->taskinfo.suspend_count;
836 suspend_count = pi->taskinfo.suspend_count;
838 vm_deallocate (mach_task_self (), (vm_address_t) pi,
839 pi_len *
sizeof (*(procinfo_t) 0));
841 vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len);
845 if (!
query (_(
"Pid %d has an additional task suspend count of %d;"
848 error (_(
"Additional task suspend count left untouched."));
867 sigset_t mask = on ? ~(sigset_t) 0 : 0;
870 INIT_TRACEMASK, mask));
875 warning (_(
"Can't modify tracing state for pid %d: %s"),
876 inf->
pid,
"No signal thread");
880 warning (_(
"Can't modify tracing state for pid %d: %s"),
907 int task_running = (task->
sc == 0), thread_running = 0;
928 (thread_running && task_running) ?
"" :
"not ");
930 inf->
running = thread_running && task_running;
954 thread = thread->
next;
968 thread = thread->
next;
988 thread_array_t threads;
989 mach_msg_type_number_t num_threads, i;
1000 kern_return_t
err = task_threads (task->
port, &threads, &num_threads);
1019 mach_msg_type_number_t search_start = 0;
1021 struct proc *matched[num_threads + 1];
1023 struct proc *last = 0;
1027 memset (matched, 0,
sizeof (matched));
1031 mach_msg_type_number_t left;
1033 for (i = search_start, left = num_threads; left; i++, left--)
1035 if (i >= num_threads)
1037 if (thread->
port == threads[i])
1040 matched[i] = thread;
1042 thread = thread->
next;
1051 thread->
port = MACH_PORT_NULL;
1054 last->
next = thread;
1060 for (i = 0; i < num_threads; i++)
1064 mach_port_deallocate (mach_task_self (), threads[i]);
1072 last->
next = thread;
1076 proc_debug (thread,
"new thread: %lu", threads[i]);
1078 ptid = ptid_t (
inf->
pid, thread->
tid, 0);
1094 vm_deallocate (mach_task_self (),
1095 (vm_address_t) threads, (num_threads *
sizeof (
thread_t)));
1116 struct proc *run_thread,
int run_others)
1118 struct proc *thread;
1122 if (thread == run_thread)
1124 else if (run_others)
1136 struct proc *thread;
1161 struct proc *thread;
1238 struct proc *thread;
1284 struct proc *thread;
1299 struct proc *thread;
1317 kern_return_t
err = 0;
1318 int host_sig = gdb_signal_to_host (sig);
1320#define NAME gdb_signal_to_name (sig)
1322 if (host_sig >= _NSIG)
1341 " task = %lu, thread = %lu, exc = %d"
1342 ", code = %d, subcode = %d",
1346 exception_raise_request (e->
handler,
1347 e->
reply, MACH_MSG_TYPE_MOVE_SEND_ONCE,
1352 error (_(
"Can't forward spontaneous exception (%s)."),
NAME);
1363 msg_sig_post_untraced_request (msgport,
1365 MACH_MSG_TYPE_MAKE_SEND_ONCE,
1383 " (so resuming signal thread)",
NAME);
1386 msg_sig_post_untraced (msgport, host_sig,
1392 warning (_(
"Can't deliver signal %s: No signal thread."),
NAME);
1394 warning (_(
"Delivering signal %s: %s"),
NAME, safe_strerror (
err));
1415 struct proc *thread;
1418 thread_resume (thread->
port);
1425 warning (_(
"Can't continue process: %s"), safe_strerror (
err));
1440 target_wait_flags options)
1444 mach_msg_header_t hdr;
1445 mach_msg_type_t
type;
1449 struct proc *thread;
1461 error (_(
"There are no threads; try again later."));
1466 inf_debug (
inf,
"waiting for: %s", ptid.to_string ().c_str ());
1485 warning (_(
"wait request failed: %s"), safe_strerror (
err));
1505 err = mach_msg (&msg.hdr, MACH_RCV_MSG | MACH_RCV_INTERRUPT,
1507 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1518 if (
err == EMACH_RCV_INTERRUPTED)
1521 error (_(
"Couldn't wait for an event: %s"), safe_strerror (
err));
1526 mach_msg_header_t hdr;
1527 mach_msg_type_t err_type;
1541 error (_(
"Got a strange event, msg id = %d."), msg.hdr.msgh_id);
1544 error (_(
"Handling event, msgid = %d: %s"),
1545 msg.hdr.msgh_id, safe_strerror (reply.err));
1560 inf_debug (
inf,
"pending_execs, ignoring minor event");
1592 ptid = ptid_t (
inf->
pid, thread->
tid, 0);
1593 else if (ptid == minus_one_ptid)
1598 if (!thread || thread->
port == MACH_PORT_NULL)
1608 ptid = ptid_t (
inf->
pid);
1613 && ptid != minus_one_ptid
1624 ptid.to_string ().c_str (),
1625 status->to_string ().c_str ());
1634 thread_t thread_port, task_t task_port,
1635 int exception,
int code,
int subcode)
1641 "thread = %lu, task = %lu, exc = %d, code = %d, subcode = %d",
1642 thread_port, task_port, exception,
code, subcode);
1654 mach_port_deallocate (mach_task_self (), thread_port);
1655 mach_port_deallocate (mach_task_self (), task_port);
1664 if (exception == EXC_BREAKPOINT)
1668 mach_port_deallocate (mach_task_self (),
reply_port);
1688 mach_port_mod_refs (mach_task_self (),
1701 (gdb_signal_from_host (_NSIG + exception));
1708 mach_port_deallocate (mach_task_self (),
reply_port);
1720 warning (_(
"Pid %d died with unknown exit status, using SIGKILL."),
1753 thread->
port = MACH_PORT_NULL;
1761 mach_port_deallocate (mach_task_self (), dead_port);
1768#define ILL_RPC(fun, ...) \
1769 extern "C" kern_return_t fun (__VA_ARGS__); \
1770 kern_return_t fun (__VA_ARGS__) \
1772 warning (_("illegal rpc: %s"), #fun); \
1777 mach_port_t
notify, mach_port_mscount_t count)
1778ILL_RPC (do_mach_notify_port_deleted,
1782ILL_RPC (do_mach_notify_port_destroyed,
1790S_proc_wait_reply (mach_port_t reply, kern_return_t
err,
1817 warning (_(
"Can't wait for pid %d: %s"),
1844 mach_port_t oldmsgport)
1845ILL_RPC (S_proc_getmsgport_reply,
1847 mach_port_t
msgports, mach_msg_type_name_t msgportsPoly)
1850ILL_RPC (S_proc_task2pid_reply,
1854 mach_port_t
proc, mach_msg_type_name_t procPoly)
1855ILL_RPC (S_proc_proc2task_reply,
1859 mach_port_t
proc, mach_msg_type_name_t procPoly)
1860ILL_RPC (S_proc_getprocinfo_reply,
1866 const_data_t procargs, mach_msg_type_number_t procargsCnt)
1867ILL_RPC (S_proc_getprocenv_reply,
1869 const_data_t
procenv, mach_msg_type_number_t procenvCnt)
1872ILL_RPC (S_proc_getloginpids_reply,
1874 const_pidarray_t
pids, mach_msg_type_number_t pidsCnt)
1881 const_pidarray_t pgidset, mach_msg_type_number_t pgidsetCnt)
1882ILL_RPC (S_proc_getsessionpids_reply,
1884 const_pidarray_t
pidset, mach_msg_type_number_t pidsetCnt)
1887 mach_port_t sessport)
1892 const_pidarray_t
pidset, mach_msg_type_number_t pidsetCnt)
1897 mach_msg_type_number_t nports)
1898ILL_RPC (S_proc_is_important_reply,
1900 boolean_t essential)
1903 vm_address_t start_code, vm_address_t end_code)
1908S_msg_sig_post_untraced_reply (mach_port_t reply, kern_return_t
err)
1920 warning (_(
"Signal delivery failed: %s"), safe_strerror (
err));
1935 mach_port_t reply, kern_return_t
err)
1938static mach_port_msgcount_t
1939port_msgs_queued (mach_port_t port)
1941 struct mach_port_status
status;
1943 mach_port_get_receive_status (mach_task_self (), port, &
status);
1948 return status.mps_msgcount;
1971 struct proc *step_thread = 0;
1976 ptid.to_string ().c_str (), step, sig);
1982 if (sig == GDB_SIGNAL_0 &&
inf->
nomsg)
1992 warning (_(
"Aborting %s with unforwarded exception %s."),
2005 resume_all = ptid == minus_one_ptid;
2021 error (_(
"Can't run single thread id %s: no such thread!"),
2024 ptid.to_string ().c_str ());
2032 warning (_(
"Can't step thread id %s: no such thread."),
2036 ptid.to_string ().c_str ());
2054 task_terminate (task->
port);
2098 if (
ptrace (PTRACE_TRACEME) != 0)
2104 const std::string &allargs,
2118 NULL, NULL, NULL, NULL);
2173 if (
pid == getpid ())
2174 error (_(
"I refuse to debug myself!"));
2206 renumber_threads (0);
2235 error (_(
"stop target function not implemented"));
2254 vm_address_t low_address = (vm_address_t) trunc_page (addr);
2255 vm_size_t aligned_length =
2256 (vm_size_t) round_page (addr + length) - low_address;
2258 mach_msg_type_number_t copy_count;
2261 err = vm_read (task, low_address, aligned_length, &copied, ©_count);
2265 err = hurd_safe_copyin (myaddr, (
void *) (addr - low_address + copied),
2269 warning (_(
"Read from inferior faulted: %s"), safe_strerror (
err));
2273 err = vm_deallocate (mach_task_self (), copied, copy_count);
2275 warning (_(
"gnu_read_inferior vm_deallocate failed: %s"),
2276 safe_strerror (
err));
2281#define CHK_GOTO_OUT(str,ret) \
2282 do if (ret != KERN_SUCCESS) { errstr = #str; goto out; } while(0)
2298 const gdb_byte *myaddr,
int length)
2301 vm_address_t low_address = (vm_address_t) trunc_page (addr);
2302 vm_size_t aligned_length =
2303 (vm_size_t) round_page (addr + length) - low_address;
2305 mach_msg_type_number_t copy_count;
2308 const char *errstr =
"Bug in gnu_write_inferior";
2314 err = vm_read (task,
2323 err = hurd_safe_copyout ((
void *) (addr - low_address + copied),
2332 vm_size_t remaining_length = aligned_length;
2333 vm_address_t region_address = low_address;
2337 while (region_address < low_address + aligned_length)
2340 vm_prot_t max_protection;
2341 vm_inherit_t inheritance;
2343 mach_port_t object_name;
2345 vm_size_t region_length = remaining_length;
2346 vm_address_t old_address = region_address;
2348 err = vm_region (task,
2360 if (old_address != region_address)
2362 warning (_(
"No memory at 0x%lx. Nothing written"),
2369 if (!(max_protection & VM_PROT_WRITE))
2371 warning (_(
"Memory at address 0x%lx is unwritable. "
2383 region_element->
start = region_address;
2384 region_element->
length = region_length;
2387 region_element->
next = region_head;
2388 region_head = region_element;
2390 region_address += region_length;
2391 remaining_length = remaining_length - region_length;
2400 if (!(
scan->protection & VM_PROT_WRITE))
2402 err = vm_protect (task,
2406 scan->protection | VM_PROT_WRITE);
2411 err = vm_write (task,
2420 if (!(
scan->protection & VM_PROT_WRITE))
2422 err = vm_protect (task,
2437 (void) vm_deallocate (mach_task_self (),
2442 if (
err != KERN_SUCCESS)
2444 warning (_(
"%s: %s"), errstr, mach_error_string (
err));
2458 CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
2466 if (task == MACH_PORT_NULL)
2469 if (writebuf != NULL)
2473 host_address_to_string (writebuf));
2480 host_address_to_string (readbuf));
2483 gdb_assert (res >= 0);
2488 *xfered_len = (ULONGEST) res;
2497 CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
2506 ElfW(auxv_t) auxv[2];
2508 if (task == MACH_PORT_NULL)
2510 if (writebuf != NULL)
2513 if (memaddr ==
sizeof (auxv))
2515 if (memaddr >
sizeof (auxv))
2523 err = proc_get_entry (
proc, &entry);
2528 auxv[0].a_type = AT_ENTRY;
2529 auxv[0].a_un.a_val = entry;
2530 auxv[1].a_type = AT_NULL;
2531 auxv[1].a_un.a_val = 0;
2535 host_address_to_string (readbuf));
2537 if (memaddr + len >
sizeof (auxv))
2538 len =
sizeof (auxv) - memaddr;
2540 memcpy (readbuf, (gdb_byte *) &auxv + memaddr, len);
2550 const char *annex, gdb_byte *readbuf,
2551 const gdb_byte *writebuf, ULONGEST offset,
2552 ULONGEST len, ULONGEST *xfered_len)
2559 return gnu_xfer_auxv (readbuf, writebuf, offset, len, xfered_len);
2573 vm_address_t region_address, last_region_address, last_region_end;
2574 vm_prot_t last_protection;
2579 if (task == MACH_PORT_NULL)
2582 region_address = last_region_address = last_region_end =
VM_MIN_ADDRESS;
2583 last_protection = VM_PROT_NONE;
2584 while (region_address < VM_MAX_ADDRESS)
2586 vm_prot_t protection;
2587 vm_prot_t max_protection;
2588 vm_inherit_t inheritance;
2590 mach_port_t object_name;
2592 vm_size_t region_length = VM_MAX_ADDRESS - region_address;
2594 err = vm_region (task,
2603 if (
err == KERN_NO_SPACE)
2605 if (
err != KERN_SUCCESS)
2607 warning (_(
"vm_region failed: %s"), mach_error_string (
err));
2611 if (protection == last_protection && region_address == last_region_end)
2614 last_region_end = region_address += region_length;
2619 if (last_protection != VM_PROT_NONE)
2620 (*func) (last_region_address,
2621 last_region_end - last_region_address,
2622 last_protection & VM_PROT_READ,
2623 last_protection & VM_PROT_WRITE,
2624 last_protection & VM_PROT_EXECUTE,
2628 last_region_address = region_address;
2629 last_region_end = region_address += region_length;
2630 last_protection = protection;
2635 if (last_region_end > last_region_address && last_protection != VM_PROT_NONE)
2636 (*func) (last_region_address, last_region_end - last_region_address,
2637 last_protection & VM_PROT_READ,
2638 last_protection & VM_PROT_WRITE,
2639 last_protection & VM_PROT_EXECUTE,
2652 static char tid_str[80];
2655 xsnprintf (tid_str,
sizeof (tid_str),
"process %d",
proc->
inf->
pid);
2657 xsnprintf (tid_str,
sizeof (tid_str),
"Thread %d.%d",
2666 int tid = ptid.lwp ();
2672 return string_printf (
"bogus thread id %d", tid);
2697 int val = strtoul (args, &arg_end, 10);
2699 if (*args && *arg_end ==
'\0')
2702 error (_(
"Illegal argument for \"%s\" command, should be an integer."),
2708 const char *cmd_prefix)
2710 if (!args || strcmp (args, t_val) == 0)
2712 else if (strcmp (args, f_val) == 0)
2715 error (_(
"Illegal argument for \"%s\" command, "
2716 "should be \"%s\" or \"%s\"."),
2717 cmd_prefix, t_val, f_val);
2720#define parse_bool_arg(args, cmd_prefix) \
2721 _parse_bool_arg (args, "on", "off", cmd_prefix)
2727 error (_(
"Garbage after \"%s\" command: `%s'"), cmd_prefix, args);
2738 error (_(
"No current thread."));
2749 error (_(
"No current process."));
2780 gdb_printf (
"The inferior task %s suspended while gdb has control.\n",
2790 "set task detach-suspend-count");
2796 check_empty (args,
"show task detach-suspend-count");
2797 gdb_printf (
"The inferior task will be left with a "
2798 "suspend count of %d when detaching.\n",
2819 gdb_printf (
"New threads %s suspended while gdb has control%s.\n",
2820 sc ?
"are" :
"aren't",
2821 !sc &&
inf->
pause_sc ?
" (but the task is)" :
"");
2839 gdb_printf (
"New threads %s allowed to run.\n",
2847 parse_int_arg (args,
"set thread default detach-suspend-count");
2853 check_empty (args,
"show thread default detach-suspend-count");
2854 gdb_printf (
"New threads will get a detach-suspend-count of %d.\n",
2866 mach_msg_type_name_t port_type;
2869 error (_(
"No inferior task."));
2872 name, MACH_MSG_TYPE_COPY_SEND,
2875 error (_(
"Couldn't extract send right %lu from inferior: %s"),
2891 error (_(
"Can't set exception port for %s: %s"),
2902 error (_(
"No argument to \"set task exception-port\" command."));
2918 gdb_printf (
"The inferior process %s stopped.\n",
2927 if (!args || (!isdigit (*args) && strcmp (args,
"none") != 0))
2928 error (_(
"Illegal argument to \"set signal-thread\" command.\n"
2929 "Should be a thread ID, or \"none\"."));
2931 if (strcmp (args,
"none") == 0)
2978 gdb_printf (
"The inferior process's signals %s intercepted.\n",
3007 gdb_printf (
"Exceptions in the inferior %s trapped.\n",
3017 gdb_printf (
"\"set task\" must be followed by the name"
3018 " of a task property.\n");
3075 print_port_info (right, 0,
inf->
task->
port, PORTINFO_DETAILS,
3079 error (_(
"%ld: %s."), right, safe_strerror (
err));
3086 print_task_ports_info (
inf->
task->
port, only, PORTINFO_DETAILS,
3089 error (_(
"%s."), safe_strerror (
err));
3128Set whether the new threads are suspended while gdb has control.\n\
3129This property normally has no effect because the whole task is\n\
3130suspended, however, that may be disabled with \"set task pause off\".\n\
3131The default value is \"off\"."),
3134Show whether new threads are suspended while gdb has control."),
3138Set whether new threads are allowed to run (once gdb has noticed them)."),
3141Show whether new threads are allowed to run (once gdb has noticed them)."),
3145 _(
"Set the default detach-suspend-count value for new threads."),
3148 _(
"Show the default detach-suspend-count value for new threads."),
3153Set whether the inferior process's signals will be intercepted.\n\
3154Mach exceptions (such as breakpoint traps) are not affected."),
3160Show whether the inferior process's signals will be intercepted."),
3166Set the thread that gdb thinks is the libc signal thread.\n\
3167This thread is run when delivering a signal to a non-stopped process."),
3173Set the thread that gdb thinks is the libc signal thread."),
3178Set whether gdb thinks the inferior process is stopped as with SIGSTOP.\n\
3179Stopped process will be continued by sending them a signal."),
3182Show whether gdb thinks the inferior process is stopped as with SIGSTOP."),
3187Set whether exceptions in the inferior process will be trapped.\n\
3188When exceptions are turned off, neither breakpoints nor single-stepping\n\
3194Show whether exceptions in the inferior process will be trapped."),
3198 _(
"Command prefix for setting task attributes."),
3201 _(
"Command prefix for showing task attributes."),
3205Set whether the task is suspended while gdb has control.\n\
3206A value of \"on\" takes effect immediately, otherwise nothing happens\n\
3207until the next time the program is continued.\n\
3208When setting this to \"off\", \"set thread default pause on\" can be\n\
3209used to pause individual threads by default instead."),
3212 _(
"Show whether the task is suspended while gdb has control."),
3216 _(
"Set the suspend count will leave on the thread when detaching."),
3219 _(
"Show the suspend count will leave "
3220 "on the thread when detaching."),
3225Set the task exception port to which we forward exceptions.\n\
3226The argument should be the value of the send right in the task."),
3236Set task options so that we interfere as little as possible.\n\
3237This is the same as setting `task pause', `exceptions', and\n\
3238`signals' to the opposite value."),
3243 _(
"Show information about the task's send rights."));
3245 _(
"Show information about the task's receive rights."));
3248 _(
"Show information about the task's port rights."));
3251 _(
"Show information about the task's port sets."));
3253 _(
"Show information about the task's dead names."));
3280 gdb_printf (
"Thread %s %s suspended while gdb has control%s.\n",
3282 sc ?
"is" :
"isn't",
3302 thread->
run_sc == 0 ?
"is" :
"isn't");
3309 "set thread detach-suspend-count");
3317 check_empty (args,
"show thread detach-suspend-count");
3318 gdb_printf (
"Thread %s will be left with a suspend count"
3319 " of %d when detaching.\n",
3330 error (_(
"No argument to \"set thread exception-port\" command."));
3336show_thread_cmd (
char *args,
int from_tty)
3353 thread_basic_info_data_t _info;
3354 thread_basic_info_t info = &_info;
3355 mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT;
3357 = mach_thread_info (thread->
port, THREAD_BASIC_INFO,
3358 (
int *) &info, &info_len);
3360 error ((
"%s."), safe_strerror (
err));
3361 thread->
sc = info->suspend_count;
3365 vm_deallocate (mach_task_self (), (vm_address_t) info,
3366 info_len *
sizeof (
int));
3374 _(
"Command prefix for setting thread properties."),
3375 _(
"Command prefix for showing thread properties."),
3381 _(
"Command prefix for setting default thread properties."),
3382 _(
"Command prefix for showing default thread properties."),
3388Set whether the current thread is suspended while gdb has control.\n\
3389A value of \"on\" takes effect immediately, otherwise nothing happens\n\
3390until the next time the program is continued. This property normally\n\
3391has no effect because the whole task is suspended, however, that may\n\
3392be disabled with \"set task pause off\".\n\
3393The default value is \"off\"."),
3396Show whether the current thread is suspended while gdb has control."),
3400 _(
"Set whether the current thread is allowed to run."),
3403 _(
"Show whether the current thread is allowed to run."),
3407Set the suspend count will leave on the thread when detaching.\n\
3408Note that this is relative to suspend count when gdb noticed the thread;\n\
3409use the `thread takeover-suspend-count' to force it to an absolute value."),
3412Show the suspend count will leave on the thread when detaching.\n\
3413Note that this is relative to suspend count when gdb noticed the thread;\n\
3414use the `thread takeover-suspend-count' to force it to an absolute value."),
3419Set the thread exception port to which we forward exceptions.\n\
3420This overrides the task exception port.\n\
3421The argument should be the value of the send right in the task."),
3429Force the threads absolute suspend-count to be gdb's.\n\
3430Prior to giving this command, gdb's thread suspend-counts are relative\n\
3431to the thread's initial suspend-count when gdb notices the threads."),
3445 _(
"Set debugging output for the gnu backend."),
3446 _(
"Show debugging output for the gnu backend."),
3454#ifdef FLUSH_INFERIOR_CACHE
3462flush_inferior_icache (CORE_ADDR pc,
int amount)
3464 vm_machine_attribute_val_t flush = MATTR_VAL_ICACHE_FLUSH;
3472 if (ret != KERN_SUCCESS)
3473 warning (_(
"Error flushing inferior's cache : %s"), safe_strerror (ret));
struct gdbarch * target_gdbarch(void)
void mourn_inferior() override
void maybe_unpush_target()
void push_target(struct target_ops *t)
bool target_is_pushed(const target_ops *t) const
struct cmd_list_element * showlist
struct cmd_list_element * setlist
struct cmd_list_element * showdebuglist
struct cmd_list_element * setdebuglist
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
cmd_list_element * add_info_alias(const char *name, cmd_list_element *target, int abbrev_flag)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
int(* find_memory_region_ftype)(CORE_ADDR addr, unsigned long size, int read, int write, int exec, int modified, bool memory_tagged, void *data)
struct value * parse_to_comma_and_eval(const char **expp)
CORE_ADDR parse_and_eval_address(const char *exp)
ptid_t gdb_startup_inferior(pid_t pid, int num_traps)
void trace_start_error_with_name(const char *string)
pid_t fork_inferior(const char *exec_file_arg, const std::string &allargs, char **env, void(*traceme_fun)(), gdb::function_view< void(int)> init_trace_fun, void(*pre_trace_fun)(), const char *shell_file_arg, void(*exec_fun)(const char *file, char *const *argv, char *const *env))
#define START_INFERIOR_TRAPS_EXPECTED
#define ptrace(request, pid, addr, data)
struct thread_info * add_thread(process_stratum_target *targ, ptid_t ptid)
struct thread_info * add_thread_silent(process_stratum_target *targ, ptid_t ptid)
thread_info * find_thread_ptid(inferior *inf, ptid_t ptid)
void switch_to_thread(struct thread_info *thr)
void thread_change_ptid(process_stratum_target *targ, ptid_t old_ptid, ptid_t new_ptid)
void switch_to_no_thread()
boolean_t process_reply_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
boolean_t exc_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
boolean_t notify_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
boolean_t msg_reply_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
static void set_exceptions_cmd(int arg, int from_tty)
static enum target_xfer_status gnu_xfer_memory(gdb_byte *readbuf, const gdb_byte *writebuf, CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
static void set_task_cmd(const char *args, int from_tty)
struct cmd_list_element * set_thread_cmd_list
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t rusage
struct inf * gnu_current_inf
static void show_task_cmd(const char *args, int from_tty)
static void set_thread_detach_sc_cmd(const char *args, int from_tty)
static struct cmd_list_element * set_task_cmd_list
static void info_port_rights(const char *args, mach_port_type_t only)
struct cmd_list_element * thread_cmd_list
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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 const_procinfo_t mach_msg_type_number_t const_data_t threadwaits
static void show_exceptions_cmd(const char *args, int from_tty)
int __proc_pid(struct proc *proc)
#define inf_debug(_inf, msg, args...)
static void check_empty(const char *args, const char *cmd_prefix)
static void inf_update_signal_thread(struct inf *inf)
static void show_thread_detach_sc_cmd(const char *args, int from_tty)
static struct inf * waiting_inf
char * proc_string(struct proc *proc)
static void info_port_rights_cmd(const char *args, int from_tty)
static void add_task_commands(void)
static struct inf * cur_inf(void)
static void set_signals_cmd(int arg, int from_tty)
mach_port_t kern_return_t return_code
static int inf_pick_first_thread(void)
static void inf_task_died_status(struct inf *inf)
static void set_thread_pause_cmd(const char *args, int from_tty)
static void set_thread_default_run_cmd(const char *args, int from_tty)
mach_port_t kern_return_t mach_port_t msgports
static void info_recv_rights_cmd(const char *args, int from_tty)
static void info_port_sets_cmd(const char *args, int from_tty)
static int gnu_read_inferior(task_t task, CORE_ADDR addr, gdb_byte *myaddr, int length)
struct proc * inf_tid_to_thread(struct inf *inf, int tid)
static int parse_int_arg(const char *args, const char *cmd_prefix)
struct cmd_list_element * show_thread_default_cmd_list
struct cmd_list_element * set_thread_default_cmd_list
static void set_thread_exc_port_cmd(const char *args, int from_tty)
static void info_dead_names_cmd(const char *args, int from_tty)
static process_t proc_server
static void gnu_ptrace_me(void)
#define parse_bool_arg(args, cmd_prefix)
static void show_signals_cmd(const char *args, int from_tty)
static struct inf * active_inf(void)
kern_return_t do_mach_notify_dead_name(mach_port_t notify, mach_port_t dead_port)
int inf_update_procs(struct inf *inf)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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 const_procinfo_t mach_msg_type_number_t const_data_t mach_msg_type_number_t threadwaitsCnt mach_port_t kern_return_t const_data_t mach_msg_type_number_t procenvCnt mach_port_t kern_return_t const_pidarray_t pids
static enum target_xfer_status gnu_xfer_auxv(gdb_byte *readbuf, const gdb_byte *writebuf, CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
static void show_thread_default_run_cmd(const char *args, int from_tty)
struct gnu_nat_target * gnu_target
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 void show_thread_pause_cmd(const char *args, int from_tty)
static void show_task_detach_sc_cmd(const char *args, int from_tty)
static void add_thread_commands(void)
static void set_task_exc_port_cmd(const char *args, int from_tty)
static void set_thread_default_detach_sc_cmd(const char *args, int from_tty)
static void info_send_rights_cmd(const char *args, int from_tty)
static void show_thread_run_cmd(const char *args, int from_tty)
static struct cmd_list_element * show_task_cmd_list
static int next_thread_id
static void set_task_pause_cmd(int arg, int from_tty)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
static void set_sig_thread_cmd(const char *args, int from_tty)
static void thread_takeover_sc_cmd(const char *args, int from_tty)
static int _parse_bool_arg(const char *args, const char *t_val, const char *f_val, const char *cmd_prefix)
static struct inf * make_inf()
static void set_noninvasive_cmd(const char *args, int from_tty)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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 const_procinfo_t mach_msg_type_number_t procinfoCnt
static void set_thread_default_pause_cmd(const char *args, int from_tty)
void inf_threads(struct inf *inf, inf_threads_ftype *f, void *arg)
struct cmd_list_element * show_thread_cmd_list
static int gnu_write_inferior(task_t task, CORE_ADDR addr, const gdb_byte *myaddr, int length)
static void set_thread_run_cmd(const char *args, int from_tty)
struct obstack region_obstack
static struct proc * inf_port_to_thread(struct inf *inf, mach_port_t port)
#define CHK_GOTO_OUT(str, ret)
#define INF_MSGPORT_RPC(inf, rpc_expr)
static void show_sig_thread_cmd(const char *args, int from_tty)
#define INF_RESUME_MSGPORT_RPC(inf, rpc_expr)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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 const_procinfo_t mach_msg_type_number_t const_data_t mach_msg_type_number_t threadwaitsCnt mach_port_t kern_return_t const_data_t mach_msg_type_number_t procenvCnt mach_port_t kern_return_t const_pidarray_t mach_msg_type_number_t pidsCnt mach_port_t kern_return_t pid_t sid mach_port_t kern_return_t const_pidarray_t pidset
static void set_task_detach_sc_cmd(const char *args, int from_tty)
static void show_thread_default_detach_sc_cmd(const char *args, int from_tty)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
void _initialize_gnu_nat()
static void show_stopped_cmd(const char *args, int from_tty)
static void show_task_pause_cmd(const char *args, int from_tty)
static void set_stopped_cmd(const char *args, int from_tty)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int sigcode
static struct proc * cur_thread(void)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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 const_procinfo_t mach_msg_type_number_t const_data_t mach_msg_type_number_t threadwaitsCnt mach_port_t kern_return_t const_data_t procenv
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
static void show_thread_default_pause_cmd(const char *args, int from_tty)
struct inf * gnu_current_inf
#define proc_debug(_proc, msg, args...)
#define proc_is_thread(proc)
char * proc_string(struct proc *proc)
struct proc * inf_tid_to_thread(struct inf *inf, int tid)
void() inf_threads_ftype(struct proc *thread, void *arg)
int inf_update_procs(struct inf *inf)
#define proc_is_task(proc)
target_waitstatus host_status_to_waitstatus(int hoststatus)
void inferior_appeared(struct inferior *inf, int pid)
void detach_inferior(inferior *inf)
struct inferior * current_inferior(void)
static void scan(growable_macro_buffer *dest, shared_macro_buffer *src, struct macro_name_list *no_loop, const macro_scope &scope)
#define THREAD_STATE_FLAVOR
#define THREAD_STATE_SET_TRACED(state)
#define THREAD_STATE_CLEAR_TRACED(state)
#define THREAD_STATE_SIZE
void(* func)(remote_target *remote, char *)
void inf_continue(struct inf *inf)
void inf_startup(struct inf *inf, int pid)
void detach(inferior *, int) override
void inf_set_pid(struct inf *inf, pid_t pid)
enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override
void inf_cleanup(struct inf *inf)
void inf_suspend(struct inf *inf)
void resume(ptid_t, int, enum gdb_signal) override
void create_inferior(const char *, const std::string &, char **, int) override
kern_return_t proc_set_exception_port(struct proc *proc, mach_port_t port)
mach_port_t _proc_get_exc_port(struct proc *proc)
void inf_validate_procs(struct inf *inf)
int find_memory_regions(find_memory_region_ftype func, void *data) override
int inf_set_threads_resume_sc_for_signal_thread(struct inf *inf)
int proc_trace(struct proc *proc, int set)
kern_return_t proc_get_exception_port(struct proc *proc, mach_port_t *port)
std::string pid_to_str(ptid_t) override
void inf_clear_wait(struct inf *inf)
void inf_set_traced(struct inf *inf, int on)
void inf_set_threads_resume_sc(struct inf *inf, struct proc *run_thread, int run_others)
thread_state_t proc_get_state(struct proc *proc, int will_modify)
void steal_exc_port(struct proc *proc, mach_port_t name)
void inf_detach(struct inf *inf)
void attach(const char *, int) override
void inf_set_step_thread(struct inf *inf, struct proc *proc)
int proc_update_sc(struct proc *proc)
ptid_t wait(ptid_t, struct target_waitstatus *, target_wait_flags) override
void proc_abort(struct proc *proc, int force)
struct proc * make_proc(struct inf *inf, mach_port_t port, int tid)
struct proc * _proc_free(struct proc *proc)
void proc_steal_exc_port(struct proc *proc, mach_port_t exc_port)
void mourn_inferior() override
void proc_restore_exc_port(struct proc *proc)
int inf_update_suspends(struct inf *inf)
void inf_signal(struct inf *inf, enum gdb_signal sig)
bool thread_alive(ptid_t ptid) override
void inf_resume(struct inf *inf)
void inf_validate_procinfo(struct inf *inf)
void inf_attach(struct inf *inf, int pid)
void inf_restore_exc_ports(struct inf *inf)
void inf_steal_exc_ports(struct inf *inf)
void inf_validate_task_sc(struct inf *inf)
struct target_waitstatus status
unsigned int pending_execs
struct proc * signal_thread
int default_thread_pause_sc
struct proc * step_thread
int default_thread_detach_sc
int default_thread_run_sc
unsigned long fetched_regs
thread_state_data_t state
mach_port_t saved_exc_port
virtual gdb::byte_vector virtual thread_info_to_thread_handle(struct thread_info *) TARGET_DEFAULT_RETURN(gdb voi stop)(ptid_t) TARGET_DEFAULT_IGNORE()
target_waitstatus & set_spurious()
target_waitstatus & set_signalled(gdb_signal sig)
target_waitstatus & set_stopped(gdb_signal sig)
target_waitkind kind() const
struct vm_region_list * next
void target_announce_detach(int from_tty)
void target_announce_attach(int from_tty, int pid)
std::string target_pid_to_str(ptid_t ptid)
void target_mourn_inferior(ptid_t ptid)
struct thread_info * parse_thread_id(const char *tidstr, const char **end)
int query(const char *ctlstr,...)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)
int parse_pid_to_attach(const char *args)
LONGEST value_as_long(struct value *val)
@ TARGET_WAITKIND_SPURIOUS
@ TARGET_WAITKIND_STOPPED