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>
57#include <sys/ptrace.h>
66#include "gdbsupport/gdb_wait.h"
71#include "gdbsupport/gdb_obstack.h"
80#include "exc_request_S.h"
82#include "process_reply_S.h"
83#include "msg_reply_S.h"
84#include "exc_request_U.h"
107#define inf_debug(_inf, msg, args...) \
108 do { struct inf *__inf = (_inf); \
109 debug ("{inf %d %s}: " msg, __inf->pid, \
110 host_address_to_string (__inf) , ##args); } while (0)
115#define INF_MSGPORT_RPC(inf, rpc_expr) \
116 HURD_MSGPORT_RPC (proc_getmsgport (proc_server, inf->pid, &msgport), \
117 (refport = inf->task->port, 0), 0, \
118 msgport ? (rpc_expr) : EIEIO)
123#define INF_RESUME_MSGPORT_RPC(inf, rpc_expr) \
124 (inf_set_threads_resume_sc_for_signal_thread (inf) \
125 ? ({ kern_return_t __e; \
127 __e = INF_MSGPORT_RPC (inf, rpc_expr); \
262 while (delta-- > 0 && !
err)
272 while (delta++ < 0 && !
err)
315 if (running && force)
348 will_modify ?
" (with intention to modify)" :
"");
361 (thread_state_t) &
proc->
state, &state_size);
383 return task_get_exception_port (
proc->
port, port);
385 return thread_get_exception_port (
proc->
port, port);
394 return task_set_exception_port (
proc->
port, port);
396 return thread_set_exception_port (
proc->
port, port);
403 mach_port_t exc_port;
410 mach_port_deallocate (mach_task_self (),
proc->
exc_port);
430 kern_return_t
err = 0;
434 if (cur_exc_port != exc_port)
443 mach_port_deallocate (mach_task_self (), cur_exc_port);
458 warning (_(
"Error setting exception port for %s: %s"),
473 kern_return_t
err = 0;
488 warning (_(
"Error setting exception port for %s: %s"),
530 mach_port_t prev_port = MACH_PORT_NULL;
559 mach_port_request_notification (mach_task_self (), port,
560 MACH_NOTIFY_DEAD_NAME, 1,
562 MACH_MSG_TYPE_MAKE_SEND_ONCE,
565 warning (_(
"Couldn't request notification for port %lu: %s"),
566 port, safe_strerror (
err));
570 if (prev_port != MACH_PORT_NULL)
571 mach_port_deallocate (mach_task_self (), prev_port);
617 mach_port_deallocate (mach_task_self (),
proc->
port);
712 err = mach_port_allocate (mach_task_self (),
715 error (_(
"Error allocating event port: %s"), safe_strerror (
err));
734 task_port = MACH_PORT_NULL;
740 error (_(
"Error getting task for pid %d: %s"),
741 pid, safe_strerror (
err));
747 task_suspend (task_port);
749 if (task && task->
port != task_port)
756 if (task_port != MACH_PORT_NULL)
782 mach_msg_type_number_t noise_len = 0;
784 mach_msg_type_number_t pi_len = 0;
788 (procinfo_t *) &pi, &pi_len, &noise, &noise_len);
793 inf->
nomsg = !!(pi->state & PI_NOMSG);
796 vm_deallocate (mach_task_self (), (vm_address_t) pi,
797 pi_len *
sizeof (*(procinfo_t) 0));
799 vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len);
809 mach_msg_type_number_t noise_len = 0;
811 mach_msg_type_number_t pi_len = 0;
812 int info_flags = PI_FETCH_TASKINFO;
813 int suspend_count = -1;
818 (procinfo_t *) &pi, &pi_len, &noise, &noise_len);
825 if (
inf->
task->
cur_sc < pi->taskinfo.suspend_count && suspend_count == -1)
831 suspend_count = pi->taskinfo.suspend_count;
835 suspend_count = pi->taskinfo.suspend_count;
837 vm_deallocate (mach_task_self (), (vm_address_t) pi,
838 pi_len *
sizeof (*(procinfo_t) 0));
840 vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len);
844 if (!
query (_(
"Pid %d has an additional task suspend count of %d;"
847 error (_(
"Additional task suspend count left untouched."));
866 sigset_t mask = on ? ~(sigset_t) 0 : 0;
869 INIT_TRACEMASK, mask));
874 warning (_(
"Can't modify tracing state for pid %d: %s"),
875 inf->
pid,
"No signal thread");
879 warning (_(
"Can't modify tracing state for pid %d: %s"),
906 int task_running = (task->
sc == 0), thread_running = 0;
927 (thread_running && task_running) ?
"" :
"not ");
929 inf->
running = thread_running && task_running;
953 thread = thread->
next;
967 thread = thread->
next;
987 thread_array_t threads;
988 mach_msg_type_number_t num_threads, i;
999 kern_return_t
err = task_threads (task->
port, &threads, &num_threads);
1018 mach_msg_type_number_t search_start = 0;
1020 struct proc *matched[num_threads + 1];
1022 struct proc *last = 0;
1026 memset (matched, 0,
sizeof (matched));
1030 mach_msg_type_number_t left;
1032 for (i = search_start, left = num_threads; left; i++, left--)
1034 if (i >= num_threads)
1036 if (thread->
port == threads[i])
1039 matched[i] = thread;
1041 thread = thread->
next;
1050 thread->
port = MACH_PORT_NULL;
1053 last->
next = thread;
1059 for (i = 0; i < num_threads; i++)
1063 mach_port_deallocate (mach_task_self (), threads[i]);
1071 last->
next = thread;
1075 proc_debug (thread,
"new thread: %lu", threads[i]);
1077 ptid = ptid_t (
inf->
pid, thread->
tid, 0);
1093 vm_deallocate (mach_task_self (),
1094 (vm_address_t) threads, (num_threads *
sizeof (
thread_t)));
1115 struct proc *run_thread,
int run_others)
1117 struct proc *thread;
1121 if (thread == run_thread)
1123 else if (run_others)
1135 struct proc *thread;
1160 struct proc *thread;
1237 struct proc *thread;
1283 struct proc *thread;
1298 struct proc *thread;
1316 kern_return_t
err = 0;
1317 int host_sig = gdb_signal_to_host (sig);
1319#define NAME gdb_signal_to_name (sig)
1321 if (host_sig >= _NSIG)
1340 " task = %lu, thread = %lu, exc = %d"
1341 ", code = %d, subcode = %d",
1345 exception_raise_request (e->
handler,
1346 e->
reply, MACH_MSG_TYPE_MOVE_SEND_ONCE,
1351 error (_(
"Can't forward spontaneous exception (%s)."),
NAME);
1362 msg_sig_post_untraced_request (msgport,
1364 MACH_MSG_TYPE_MAKE_SEND_ONCE,
1382 " (so resuming signal thread)",
NAME);
1385 msg_sig_post_untraced (msgport, host_sig,
1391 warning (_(
"Can't deliver signal %s: No signal thread."),
NAME);
1393 warning (_(
"Delivering signal %s: %s"),
NAME, safe_strerror (
err));
1414 struct proc *thread;
1417 thread_resume (thread->
port);
1424 warning (_(
"Can't continue process: %s"), safe_strerror (
err));
1439 target_wait_flags options)
1443 mach_msg_header_t hdr;
1444 mach_msg_type_t
type;
1448 struct proc *thread;
1460 error (_(
"There are no threads; try again later."));
1465 inf_debug (
inf,
"waiting for: %s", ptid.to_string ().c_str ());
1484 warning (_(
"wait request failed: %s"), safe_strerror (
err));
1504 err = mach_msg (&msg.hdr, MACH_RCV_MSG | MACH_RCV_INTERRUPT,
1506 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
1517 if (
err == EMACH_RCV_INTERRUPTED)
1520 error (_(
"Couldn't wait for an event: %s"), safe_strerror (
err));
1525 mach_msg_header_t hdr;
1526 mach_msg_type_t err_type;
1540 error (_(
"Got a strange event, msg id = %d."), msg.hdr.msgh_id);
1543 error (_(
"Handling event, msgid = %d: %s"),
1544 msg.hdr.msgh_id, safe_strerror (reply.err));
1559 inf_debug (
inf,
"pending_execs, ignoring minor event");
1591 ptid = ptid_t (
inf->
pid, thread->
tid, 0);
1592 else if (ptid == minus_one_ptid)
1597 if (!thread || thread->
port == MACH_PORT_NULL)
1607 ptid = ptid_t (
inf->
pid);
1612 && ptid != minus_one_ptid
1623 ptid.to_string ().c_str (),
1624 status->to_string ().c_str ());
1633 thread_t thread_port, task_t task_port,
1634 int exception,
int code,
int subcode)
1640 "thread = %lu, task = %lu, exc = %d, code = %d, subcode = %d",
1641 thread_port, task_port, exception,
code, subcode);
1653 mach_port_deallocate (mach_task_self (), thread_port);
1654 mach_port_deallocate (mach_task_self (), task_port);
1663 if (exception == EXC_BREAKPOINT)
1667 mach_port_deallocate (mach_task_self (),
reply_port);
1687 mach_port_mod_refs (mach_task_self (),
1700 (gdb_signal_from_host (_NSIG + exception));
1707 mach_port_deallocate (mach_task_self (),
reply_port);
1719 warning (_(
"Pid %d died with unknown exit status, using SIGKILL."),
1752 thread->
port = MACH_PORT_NULL;
1760 mach_port_deallocate (mach_task_self (), dead_port);
1767#define ILL_RPC(fun, ...) \
1768 extern "C" kern_return_t fun (__VA_ARGS__); \
1769 kern_return_t fun (__VA_ARGS__) \
1771 warning (_("illegal rpc: %s"), #fun); \
1776 mach_port_t
notify, mach_port_mscount_t count)
1777ILL_RPC (do_mach_notify_port_deleted,
1781ILL_RPC (do_mach_notify_port_destroyed,
1789S_proc_wait_reply (mach_port_t reply, kern_return_t
err,
1816 warning (_(
"Can't wait for pid %d: %s"),
1843 mach_port_t oldmsgport)
1844ILL_RPC (S_proc_getmsgport_reply,
1846 mach_port_t
msgports, mach_msg_type_name_t msgportsPoly)
1849ILL_RPC (S_proc_task2pid_reply,
1853 mach_port_t
proc, mach_msg_type_name_t procPoly)
1854ILL_RPC (S_proc_proc2task_reply,
1858 mach_port_t
proc, mach_msg_type_name_t procPoly)
1859ILL_RPC (S_proc_getprocinfo_reply,
1865 const_data_t procargs, mach_msg_type_number_t procargsCnt)
1866ILL_RPC (S_proc_getprocenv_reply,
1868 const_data_t
procenv, mach_msg_type_number_t procenvCnt)
1871ILL_RPC (S_proc_getloginpids_reply,
1873 const_pidarray_t
pids, mach_msg_type_number_t pidsCnt)
1880 const_pidarray_t pgidset, mach_msg_type_number_t pgidsetCnt)
1881ILL_RPC (S_proc_getsessionpids_reply,
1883 const_pidarray_t
pidset, mach_msg_type_number_t pidsetCnt)
1886 mach_port_t sessport)
1891 const_pidarray_t
pidset, mach_msg_type_number_t pidsetCnt)
1896 mach_msg_type_number_t nports)
1897ILL_RPC (S_proc_is_important_reply,
1899 boolean_t essential)
1902 vm_address_t start_code, vm_address_t end_code)
1907S_msg_sig_post_untraced_reply (mach_port_t reply, kern_return_t
err)
1919 warning (_(
"Signal delivery failed: %s"), safe_strerror (
err));
1934 mach_port_t reply, kern_return_t
err)
1937static mach_port_msgcount_t
1938port_msgs_queued (mach_port_t port)
1940 struct mach_port_status
status;
1942 mach_port_get_receive_status (mach_task_self (), port, &
status);
1947 return status.mps_msgcount;
1970 struct proc *step_thread = 0;
1975 ptid.to_string ().c_str (), step, sig);
1981 if (sig == GDB_SIGNAL_0 &&
inf->
nomsg)
1991 warning (_(
"Aborting %s with unforwarded exception %s."),
2004 resume_all = ptid == minus_one_ptid;
2020 error (_(
"Can't run single thread id %s: no such thread!"),
2023 ptid.to_string ().c_str ());
2031 warning (_(
"Can't step thread id %s: no such thread."),
2035 ptid.to_string ().c_str ());
2053 task_terminate (task->
port);
2097 if (
ptrace (PTRACE_TRACEME) != 0)
2103 const std::string &allargs,
2117 NULL, NULL, NULL, NULL);
2172 if (
pid == getpid ())
2173 error (_(
"I refuse to debug myself!"));
2204 renumber_threads (0);
2233 error (_(
"stop target function not implemented"));
2252 vm_address_t low_address = (vm_address_t) trunc_page (addr);
2253 vm_size_t aligned_length =
2254 (vm_size_t) round_page (addr + length) - low_address;
2256 mach_msg_type_number_t copy_count;
2259 err = vm_read (task, low_address, aligned_length, &copied, ©_count);
2263 err = hurd_safe_copyin (myaddr, (
void *) (addr - low_address + copied),
2267 warning (_(
"Read from inferior faulted: %s"), safe_strerror (
err));
2271 err = vm_deallocate (mach_task_self (), copied, copy_count);
2273 warning (_(
"gnu_read_inferior vm_deallocate failed: %s"),
2274 safe_strerror (
err));
2279#define CHK_GOTO_OUT(str,ret) \
2280 do if (ret != KERN_SUCCESS) { errstr = #str; goto out; } while(0)
2296 const gdb_byte *myaddr,
int length)
2299 vm_address_t low_address = (vm_address_t) trunc_page (addr);
2300 vm_size_t aligned_length =
2301 (vm_size_t) round_page (addr + length) - low_address;
2303 mach_msg_type_number_t copy_count;
2306 const char *errstr =
"Bug in gnu_write_inferior";
2312 err = vm_read (task,
2321 err = hurd_safe_copyout ((
void *) (addr - low_address + copied),
2330 vm_size_t remaining_length = aligned_length;
2331 vm_address_t region_address = low_address;
2335 while (region_address < low_address + aligned_length)
2338 vm_prot_t max_protection;
2339 vm_inherit_t inheritance;
2341 mach_port_t object_name;
2343 vm_size_t region_length = remaining_length;
2344 vm_address_t old_address = region_address;
2346 err = vm_region (task,
2358 if (old_address != region_address)
2360 warning (_(
"No memory at 0x%lx. Nothing written"),
2367 if (!(max_protection & VM_PROT_WRITE))
2369 warning (_(
"Memory at address 0x%lx is unwritable. "
2381 region_element->
start = region_address;
2382 region_element->
length = region_length;
2385 region_element->
next = region_head;
2386 region_head = region_element;
2388 region_address += region_length;
2389 remaining_length = remaining_length - region_length;
2398 if (!(
scan->protection & VM_PROT_WRITE))
2400 err = vm_protect (task,
2404 scan->protection | VM_PROT_WRITE);
2409 err = vm_write (task,
2418 if (!(
scan->protection & VM_PROT_WRITE))
2420 err = vm_protect (task,
2435 (void) vm_deallocate (mach_task_self (),
2440 if (
err != KERN_SUCCESS)
2442 warning (_(
"%s: %s"), errstr, mach_error_string (
err));
2456 CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
2464 if (task == MACH_PORT_NULL)
2467 if (writebuf != NULL)
2471 host_address_to_string (writebuf));
2478 host_address_to_string (readbuf));
2481 gdb_assert (res >= 0);
2486 *xfered_len = (ULONGEST) res;
2495 CORE_ADDR memaddr, ULONGEST len, ULONGEST *xfered_len)
2504 ElfW(auxv_t) auxv[2];
2506 if (task == MACH_PORT_NULL)
2508 if (writebuf != NULL)
2511 if (memaddr ==
sizeof (auxv))
2513 if (memaddr >
sizeof (auxv))
2521 err = proc_get_entry (
proc, &entry);
2526 auxv[0].a_type = AT_ENTRY;
2527 auxv[0].a_un.a_val = entry;
2528 auxv[1].a_type = AT_NULL;
2529 auxv[1].a_un.a_val = 0;
2533 host_address_to_string (readbuf));
2535 if (memaddr + len >
sizeof (auxv))
2536 len =
sizeof (auxv) - memaddr;
2538 memcpy (readbuf, (gdb_byte *) &auxv + memaddr, len);
2548 const char *annex, gdb_byte *readbuf,
2549 const gdb_byte *writebuf, ULONGEST offset,
2550 ULONGEST len, ULONGEST *xfered_len)
2557 return gnu_xfer_auxv (readbuf, writebuf, offset, len, xfered_len);
2571 vm_address_t region_address, last_region_address, last_region_end;
2572 vm_prot_t last_protection;
2577 if (task == MACH_PORT_NULL)
2580 region_address = last_region_address = last_region_end =
VM_MIN_ADDRESS;
2581 last_protection = VM_PROT_NONE;
2582 while (region_address < VM_MAX_ADDRESS)
2584 vm_prot_t protection;
2585 vm_prot_t max_protection;
2586 vm_inherit_t inheritance;
2588 mach_port_t object_name;
2590 vm_size_t region_length = VM_MAX_ADDRESS - region_address;
2592 err = vm_region (task,
2601 if (
err == KERN_NO_SPACE)
2603 if (
err != KERN_SUCCESS)
2605 warning (_(
"vm_region failed: %s"), mach_error_string (
err));
2609 if (protection == last_protection && region_address == last_region_end)
2612 last_region_end = region_address += region_length;
2617 if (last_protection != VM_PROT_NONE)
2618 (*func) (last_region_address,
2619 last_region_end - last_region_address,
2620 last_protection & VM_PROT_READ,
2621 last_protection & VM_PROT_WRITE,
2622 last_protection & VM_PROT_EXECUTE,
2626 last_region_address = region_address;
2627 last_region_end = region_address += region_length;
2628 last_protection = protection;
2633 if (last_region_end > last_region_address && last_protection != VM_PROT_NONE)
2634 (*func) (last_region_address, last_region_end - last_region_address,
2635 last_protection & VM_PROT_READ,
2636 last_protection & VM_PROT_WRITE,
2637 last_protection & VM_PROT_EXECUTE,
2650 static char tid_str[80];
2653 xsnprintf (tid_str,
sizeof (tid_str),
"process %d",
proc->
inf->
pid);
2655 xsnprintf (tid_str,
sizeof (tid_str),
"Thread %d.%d",
2664 int tid = ptid.lwp ();
2670 return string_printf (
"bogus thread id %d", tid);
2695 int val = strtoul (args, &arg_end, 10);
2697 if (*args && *arg_end ==
'\0')
2700 error (_(
"Illegal argument for \"%s\" command, should be an integer."),
2706 const char *cmd_prefix)
2708 if (!args || strcmp (args, t_val) == 0)
2710 else if (strcmp (args, f_val) == 0)
2713 error (_(
"Illegal argument for \"%s\" command, "
2714 "should be \"%s\" or \"%s\"."),
2715 cmd_prefix, t_val, f_val);
2718#define parse_bool_arg(args, cmd_prefix) \
2719 _parse_bool_arg (args, "on", "off", cmd_prefix)
2725 error (_(
"Garbage after \"%s\" command: `%s'"), cmd_prefix, args);
2736 error (_(
"No current thread."));
2747 error (_(
"No current process."));
2778 gdb_printf (
"The inferior task %s suspended while gdb has control.\n",
2788 "set task detach-suspend-count");
2794 check_empty (args,
"show task detach-suspend-count");
2795 gdb_printf (
"The inferior task will be left with a "
2796 "suspend count of %d when detaching.\n",
2817 gdb_printf (
"New threads %s suspended while gdb has control%s.\n",
2818 sc ?
"are" :
"aren't",
2819 !sc &&
inf->
pause_sc ?
" (but the task is)" :
"");
2837 gdb_printf (
"New threads %s allowed to run.\n",
2845 parse_int_arg (args,
"set thread default detach-suspend-count");
2851 check_empty (args,
"show thread default detach-suspend-count");
2852 gdb_printf (
"New threads will get a detach-suspend-count of %d.\n",
2864 mach_msg_type_name_t port_type;
2867 error (_(
"No inferior task."));
2870 name, MACH_MSG_TYPE_COPY_SEND,
2873 error (_(
"Couldn't extract send right %lu from inferior: %s"),
2889 error (_(
"Can't set exception port for %s: %s"),
2900 error (_(
"No argument to \"set task exception-port\" command."));
2916 gdb_printf (
"The inferior process %s stopped.\n",
2925 if (!args || (!isdigit (*args) && strcmp (args,
"none") != 0))
2926 error (_(
"Illegal argument to \"set signal-thread\" command.\n"
2927 "Should be a thread ID, or \"none\"."));
2929 if (strcmp (args,
"none") == 0)
2976 gdb_printf (
"The inferior process's signals %s intercepted.\n",
3005 gdb_printf (
"Exceptions in the inferior %s trapped.\n",
3015 gdb_printf (
"\"set task\" must be followed by the name"
3016 " of a task property.\n");
3073 print_port_info (right, 0,
inf->
task->
port, PORTINFO_DETAILS,
3077 error (_(
"%ld: %s."), right, safe_strerror (
err));
3084 print_task_ports_info (
inf->
task->
port, only, PORTINFO_DETAILS,
3087 error (_(
"%s."), safe_strerror (
err));
3126Set whether the new threads are suspended while gdb has control.\n\
3127This property normally has no effect because the whole task is\n\
3128suspended, however, that may be disabled with \"set task pause off\".\n\
3129The default value is \"off\"."),
3132Show whether new threads are suspended while gdb has control."),
3136Set whether new threads are allowed to run (once gdb has noticed them)."),
3139Show whether new threads are allowed to run (once gdb has noticed them)."),
3143 _(
"Set the default detach-suspend-count value for new threads."),
3146 _(
"Show the default detach-suspend-count value for new threads."),
3151Set whether the inferior process's signals will be intercepted.\n\
3152Mach exceptions (such as breakpoint traps) are not affected."),
3158Show whether the inferior process's signals will be intercepted."),
3164Set the thread that gdb thinks is the libc signal thread.\n\
3165This thread is run when delivering a signal to a non-stopped process."),
3171Set the thread that gdb thinks is the libc signal thread."),
3176Set whether gdb thinks the inferior process is stopped as with SIGSTOP.\n\
3177Stopped process will be continued by sending them a signal."),
3180Show whether gdb thinks the inferior process is stopped as with SIGSTOP."),
3185Set whether exceptions in the inferior process will be trapped.\n\
3186When exceptions are turned off, neither breakpoints nor single-stepping\n\
3192Show whether exceptions in the inferior process will be trapped."),
3196 _(
"Command prefix for setting task attributes."),
3199 _(
"Command prefix for showing task attributes."),
3203Set whether the task is suspended while gdb has control.\n\
3204A value of \"on\" takes effect immediately, otherwise nothing happens\n\
3205until the next time the program is continued.\n\
3206When setting this to \"off\", \"set thread default pause on\" can be\n\
3207used to pause individual threads by default instead."),
3210 _(
"Show whether the task is suspended while gdb has control."),
3214 _(
"Set the suspend count will leave on the thread when detaching."),
3217 _(
"Show the suspend count will leave "
3218 "on the thread when detaching."),
3223Set the task exception port to which we forward exceptions.\n\
3224The argument should be the value of the send right in the task."),
3234Set task options so that we interfere as little as possible.\n\
3235This is the same as setting `task pause', `exceptions', and\n\
3236`signals' to the opposite value."),
3241 _(
"Show information about the task's send rights."));
3243 _(
"Show information about the task's receive rights."));
3246 _(
"Show information about the task's port rights."));
3249 _(
"Show information about the task's port sets."));
3251 _(
"Show information about the task's dead names."));
3278 gdb_printf (
"Thread %s %s suspended while gdb has control%s.\n",
3280 sc ?
"is" :
"isn't",
3300 thread->
run_sc == 0 ?
"is" :
"isn't");
3307 "set thread detach-suspend-count");
3315 check_empty (args,
"show thread detach-suspend-count");
3316 gdb_printf (
"Thread %s will be left with a suspend count"
3317 " of %d when detaching.\n",
3328 error (_(
"No argument to \"set thread exception-port\" command."));
3334show_thread_cmd (
char *args,
int from_tty)
3351 thread_basic_info_data_t _info;
3352 thread_basic_info_t info = &_info;
3353 mach_msg_type_number_t info_len = THREAD_BASIC_INFO_COUNT;
3355 = mach_thread_info (thread->
port, THREAD_BASIC_INFO,
3356 (
int *) &info, &info_len);
3358 error ((
"%s."), safe_strerror (
err));
3359 thread->
sc = info->suspend_count;
3363 vm_deallocate (mach_task_self (), (vm_address_t) info,
3364 info_len *
sizeof (
int));
3372 _(
"Command prefix for setting thread properties."),
3373 _(
"Command prefix for showing thread properties."),
3379 _(
"Command prefix for setting default thread properties."),
3380 _(
"Command prefix for showing default thread properties."),
3386Set whether the current thread is suspended while gdb has control.\n\
3387A value of \"on\" takes effect immediately, otherwise nothing happens\n\
3388until the next time the program is continued. This property normally\n\
3389has no effect because the whole task is suspended, however, that may\n\
3390be disabled with \"set task pause off\".\n\
3391The default value is \"off\"."),
3394Show whether the current thread is suspended while gdb has control."),
3398 _(
"Set whether the current thread is allowed to run."),
3401 _(
"Show whether the current thread is allowed to run."),
3405Set the suspend count will leave on the thread when detaching.\n\
3406Note that this is relative to suspend count when gdb noticed the thread;\n\
3407use the `thread takeover-suspend-count' to force it to an absolute value."),
3410Show the suspend count will leave on the thread when detaching.\n\
3411Note that this is relative to suspend count when gdb noticed the thread;\n\
3412use the `thread takeover-suspend-count' to force it to an absolute value."),
3417Set the thread exception port to which we forward exceptions.\n\
3418This overrides the task exception port.\n\
3419The argument should be the value of the send right in the task."),
3427Force the threads absolute suspend-count to be gdb's.\n\
3428Prior to giving this command, gdb's thread suspend-counts are relative\n\
3429to the thread's initial suspend-count when gdb notices the threads."),
3443 _(
"Set debugging output for the gnu backend."),
3444 _(
"Show debugging output for the gnu backend."),
3452#ifdef FLUSH_INFERIOR_CACHE
3460flush_inferior_icache (CORE_ADDR pc,
int amount)
3462 vm_machine_attribute_val_t flush = MATTR_VAL_ICACHE_FLUSH;
3470 if (ret != KERN_SUCCESS)
3471 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
thread_info * find_thread(ptid_t ptid)
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)
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)
int inf_update_procs(struct inf *inf)
#define proc_is_task(proc)
void inf_threads_ftype(struct proc *thread, void *arg)
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::array_view< const_gdb_byte > 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