aboutsummaryrefslogtreecommitdiff
path: root/gdb/darwin-nat.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:36:23 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:46:02 -0500
commitc583a2520616c2736cffc389c89a48b159366e6c (patch)
treeb4925f26506fcee96c16119431c01760f05db95d /gdb/darwin-nat.c
parentca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff)
downloadbinutils-users/simark/clang-format.zip
binutils-users/simark/clang-format.tar.gz
binutils-users/simark/clang-format.tar.bz2
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/darwin-nat.c')
-rw-r--r--gdb/darwin-nat.c611
1 files changed, 299 insertions, 312 deletions
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index f272f0d..d1fc0fa 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -85,9 +85,8 @@
Some Mach documentation is available for Apple xnu source package or
from the web. */
-
#define PTRACE(CMD, PID, ADDR, SIG) \
- darwin_ptrace(#CMD, CMD, (PID), (ADDR), (SIG))
+ darwin_ptrace (#CMD, CMD, (PID), (ADDR), (SIG))
static void darwin_ptrace_me (void);
@@ -126,7 +125,7 @@ static struct inferior *darwin_inf_fake_stop;
static const char *copied_shell;
#define PAGE_TRUNC(x) ((x) & ~(mach_page_size - 1))
-#define PAGE_ROUND(x) PAGE_TRUNC((x) + mach_page_size - 1)
+#define PAGE_ROUND(x) PAGE_TRUNC ((x) + mach_page_size - 1)
/* This controls output of inferior debugging. */
static unsigned int darwin_debug_flag = 0;
@@ -137,25 +136,25 @@ static unsigned int darwin_debug_flag = 0;
Once gdb is built, you must codesign it with any system-trusted signing
authority. See taskgated(8) for details. */
static const unsigned char info_plist[]
-__attribute__ ((section ("__TEXT,__info_plist"),used)) =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
- " \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
- "<plist version=\"1.0\">\n"
- "<dict>\n"
- " <key>CFBundleIdentifier</key>\n"
- " <string>org.gnu.gdb</string>\n"
- " <key>CFBundleName</key>\n"
- " <string>gdb</string>\n"
- " <key>CFBundleVersion</key>\n"
- " <string>1.0</string>\n"
- " <key>SecTaskAccess</key>\n"
- " <array>\n"
- " <string>allowed</string>\n"
- " <string>debug</string>\n"
- " </array>\n"
- "</dict>\n"
- "</plist>\n";
+ __attribute__ ((section ("__TEXT,__info_plist"), used))
+ = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
+ " \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
+ "<plist version=\"1.0\">\n"
+ "<dict>\n"
+ " <key>CFBundleIdentifier</key>\n"
+ " <string>org.gnu.gdb</string>\n"
+ " <key>CFBundleName</key>\n"
+ " <string>gdb</string>\n"
+ " <key>CFBundleVersion</key>\n"
+ " <string>1.0</string>\n"
+ " <key>SecTaskAccess</key>\n"
+ " <array>\n"
+ " <string>allowed</string>\n"
+ " <string>debug</string>\n"
+ " </array>\n"
+ "</dict>\n"
+ "</plist>\n";
static void inferior_debug (int level, const char *fmt, ...)
ATTRIBUTE_PRINTF (2, 3);
@@ -169,22 +168,22 @@ inferior_debug (int level, const char *fmt, ...)
return;
va_start (ap, fmt);
- gdb_printf (gdb_stdlog, _("[%d inferior]: "), getpid ());
+ gdb_printf (gdb_stdlog, _ ("[%d inferior]: "), getpid ());
gdb_vprintf (gdb_stdlog, fmt, ap);
va_end (ap);
}
void
-mach_check_error (kern_return_t ret, const char *file,
- unsigned int line, const char *func)
+mach_check_error (kern_return_t ret, const char *file, unsigned int line,
+ const char *func)
{
if (ret == KERN_SUCCESS)
return;
if (func == NULL)
- func = _("[UNKNOWN]");
+ func = _ ("[UNKNOWN]");
- warning (_("Mach error at \"%s:%u\" in function \"%s\": %s (0x%lx)"),
- file, line, func, mach_error_string (ret), (unsigned long) ret);
+ warning (_ ("Mach error at \"%s:%u\" in function \"%s\": %s (0x%lx)"), file,
+ line, func, mach_error_string (ret), (unsigned long) ret);
}
static const char *
@@ -215,7 +214,7 @@ unparse_exception_type (unsigned int i)
case EXC_CRASH:
return "EXC_CRASH";
default:
- snprintf (unknown_exception_buf, 32, _("unknown (%d)"), i);
+ snprintf (unknown_exception_buf, 32, _ ("unknown (%d)"), i);
return unknown_exception_buf;
}
}
@@ -230,8 +229,7 @@ unparse_exception_type (unsigned int i)
return zero in that case. */
static int
-darwin_ptrace (const char *name,
- int request, int pid, caddr_t arg3, int arg4)
+darwin_ptrace (const char *name, int request, int pid, caddr_t arg3, int arg4)
{
int ret;
@@ -240,18 +238,18 @@ darwin_ptrace (const char *name,
if (ret == -1 && errno == 0)
ret = 0;
- inferior_debug (4, _("ptrace (%s, %d, 0x%lx, %d): %d (%s)\n"),
- name, pid, (unsigned long) arg3, arg4, ret,
- (ret != 0) ? safe_strerror (errno) : _("no error"));
+ inferior_debug (4, _ ("ptrace (%s, %d, 0x%lx, %d): %d (%s)\n"), name, pid,
+ (unsigned long) arg3, arg4, ret,
+ (ret != 0) ? safe_strerror (errno) : _ ("no error"));
return ret;
}
static int
cmp_thread_t (const void *l, const void *r)
{
- thread_t tl = *(const thread_t *)l;
- thread_t tr = *(const thread_t *)r;
- return (int)(tl - tr);
+ thread_t tl = *(const thread_t *) l;
+ thread_t tr = *(const thread_t *) r;
+ return (int) (tl - tr);
}
void
@@ -317,9 +315,9 @@ darwin_nat_target::check_new_threads (inferior *inf)
= (old_ix < old_nbr) ? darwin_inf->threads[old_ix] : NULL;
thread_t old_id = old != NULL ? old->gdb_port : THREAD_NULL;
- inferior_debug
- (12, _(" new_ix:%d/%d, old_ix:%d/%d, new_id:0x%x old_id:0x%x\n"),
- new_ix, new_nbr, old_ix, old_nbr, new_id, old_id);
+ inferior_debug (
+ 12, _ (" new_ix:%d/%d, old_ix:%d/%d, new_id:0x%x old_id:0x%x\n"),
+ new_ix, new_nbr, old_ix, old_nbr, new_id, old_id);
if (old_id == new_id)
{
@@ -459,20 +457,13 @@ darwin_resume_inferior (struct inferior *inf)
static void
darwin_dump_message (mach_msg_header_t *hdr, int disp_body)
{
- gdb_printf (gdb_stdlog,
- _("message header:\n"));
- gdb_printf (gdb_stdlog,
- _(" bits: 0x%x\n"), hdr->msgh_bits);
- gdb_printf (gdb_stdlog,
- _(" size: 0x%x\n"), hdr->msgh_size);
- gdb_printf (gdb_stdlog,
- _(" remote-port: 0x%x\n"), hdr->msgh_remote_port);
- gdb_printf (gdb_stdlog,
- _(" local-port: 0x%x\n"), hdr->msgh_local_port);
- gdb_printf (gdb_stdlog,
- _(" reserved: 0x%x\n"), hdr->msgh_reserved);
- gdb_printf (gdb_stdlog,
- _(" id: 0x%x\n"), hdr->msgh_id);
+ gdb_printf (gdb_stdlog, _ ("message header:\n"));
+ gdb_printf (gdb_stdlog, _ (" bits: 0x%x\n"), hdr->msgh_bits);
+ gdb_printf (gdb_stdlog, _ (" size: 0x%x\n"), hdr->msgh_size);
+ gdb_printf (gdb_stdlog, _ (" remote-port: 0x%x\n"), hdr->msgh_remote_port);
+ gdb_printf (gdb_stdlog, _ (" local-port: 0x%x\n"), hdr->msgh_local_port);
+ gdb_printf (gdb_stdlog, _ (" reserved: 0x%x\n"), hdr->msgh_reserved);
+ gdb_printf (gdb_stdlog, _ (" id: 0x%x\n"), hdr->msgh_id);
if (disp_body)
{
@@ -481,18 +472,17 @@ darwin_dump_message (mach_msg_header_t *hdr, int disp_body)
int size;
int i;
- data = (unsigned char *)(hdr + 1);
+ data = (unsigned char *) (hdr + 1);
size = hdr->msgh_size - sizeof (mach_msg_header_t);
if (hdr->msgh_bits & MACH_MSGH_BITS_COMPLEX)
{
- mach_msg_body_t *bod = (mach_msg_body_t*)data;
- mach_msg_port_descriptor_t *desc =
- (mach_msg_port_descriptor_t *)(bod + 1);
+ mach_msg_body_t *bod = (mach_msg_body_t *) data;
+ mach_msg_port_descriptor_t *desc
+ = (mach_msg_port_descriptor_t *) (bod + 1);
int k;
NDR_record_t *ndr;
- gdb_printf (gdb_stdlog,
- _("body: descriptor_count=%u\n"),
+ gdb_printf (gdb_stdlog, _ ("body: descriptor_count=%u\n"),
bod->msgh_descriptor_count);
data += sizeof (mach_msg_body_t);
size -= sizeof (mach_msg_body_t);
@@ -500,37 +490,35 @@ darwin_dump_message (mach_msg_header_t *hdr, int disp_body)
switch (desc[k].type)
{
case MACH_MSG_PORT_DESCRIPTOR:
- gdb_printf
- (gdb_stdlog,
- _(" descr %d: type=%u (port) name=0x%x, dispo=%d\n"),
- k, desc[k].type, desc[k].name, desc[k].disposition);
+ gdb_printf (
+ gdb_stdlog,
+ _ (" descr %d: type=%u (port) name=0x%x, dispo=%d\n"), k,
+ desc[k].type, desc[k].name, desc[k].disposition);
break;
default:
- gdb_printf (gdb_stdlog,
- _(" descr %d: type=%u\n"),
- k, desc[k].type);
+ gdb_printf (gdb_stdlog, _ (" descr %d: type=%u\n"), k,
+ desc[k].type);
break;
}
data += bod->msgh_descriptor_count
- * sizeof (mach_msg_port_descriptor_t);
+ * sizeof (mach_msg_port_descriptor_t);
size -= bod->msgh_descriptor_count
- * sizeof (mach_msg_port_descriptor_t);
- ndr = (NDR_record_t *)(desc + bod->msgh_descriptor_count);
- gdb_printf
- (gdb_stdlog,
- _("NDR: mig=%02x if=%02x encod=%02x "
- "int=%02x char=%02x float=%02x\n"),
- ndr->mig_vers, ndr->if_vers, ndr->mig_encoding,
- ndr->int_rep, ndr->char_rep, ndr->float_rep);
+ * sizeof (mach_msg_port_descriptor_t);
+ ndr = (NDR_record_t *) (desc + bod->msgh_descriptor_count);
+ gdb_printf (gdb_stdlog,
+ _ ("NDR: mig=%02x if=%02x encod=%02x "
+ "int=%02x char=%02x float=%02x\n"),
+ ndr->mig_vers, ndr->if_vers, ndr->mig_encoding,
+ ndr->int_rep, ndr->char_rep, ndr->float_rep);
data += sizeof (NDR_record_t);
size -= sizeof (NDR_record_t);
}
- gdb_printf (gdb_stdlog, _(" data:"));
- ldata = (const unsigned int *)data;
+ gdb_printf (gdb_stdlog, _ (" data:"));
+ ldata = (const unsigned int *) data;
for (i = 0; i < size / sizeof (unsigned int); i++)
gdb_printf (gdb_stdlog, " %08x", ldata[i]);
- gdb_printf (gdb_stdlog, _("\n"));
+ gdb_printf (gdb_stdlog, _ ("\n"));
}
}
@@ -563,11 +551,10 @@ darwin_find_new_inferior (task_t task_port, thread_t thread_port)
darwin_deallocate_exception_ports (priv);
/* No need to remove dead_name notification, but still... */
- kret = mach_port_request_notification (gdb_task, priv->task,
- MACH_NOTIFY_DEAD_NAME, 0,
- MACH_PORT_NULL,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- &prev);
+ kret
+ = mach_port_request_notification (gdb_task, priv->task,
+ MACH_NOTIFY_DEAD_NAME, 0, MACH_PORT_NULL,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE, &prev);
if (kret != KERN_INVALID_ARGUMENT)
MACH_CHECK_ERROR (kret);
@@ -587,8 +574,7 @@ darwin_find_new_inferior (task_t task_port, thread_t thread_port)
static int
darwin_check_message_ndr (NDR_record_t *ndr)
{
- if (ndr->mig_vers != NDR_PROTOCOL_2_0
- || ndr->if_vers != NDR_PROTOCOL_2_0
+ if (ndr->mig_vers != NDR_PROTOCOL_2_0 || ndr->if_vers != NDR_PROTOCOL_2_0
|| ndr->mig_encoding != NDR_record.mig_encoding
|| ndr->int_rep != NDR_record.int_rep
|| ndr->char_rep != NDR_record.char_rep
@@ -604,8 +590,8 @@ darwin_nat_target::decode_exception_message (mach_msg_header_t *hdr,
inferior **pinf,
darwin_thread_t **pthread)
{
- mach_msg_body_t *bod = (mach_msg_body_t*)(hdr + 1);
- mach_msg_port_descriptor_t *desc = (mach_msg_port_descriptor_t *)(bod + 1);
+ mach_msg_body_t *bod = (mach_msg_body_t *) (hdr + 1);
+ mach_msg_port_descriptor_t *desc = (mach_msg_port_descriptor_t *) (bod + 1);
NDR_record_t *ndr;
integer_t *data;
struct inferior *inf;
@@ -634,12 +620,12 @@ darwin_nat_target::decode_exception_message (mach_msg_header_t *hdr,
return -1;
/* Check data representation. */
- ndr = (NDR_record_t *)(desc + 2);
+ ndr = (NDR_record_t *) (desc + 2);
if (darwin_check_message_ndr (ndr) != 0)
return -1;
/* Ok, the hard work. */
- data = (integer_t *)(ndr + 1);
+ data = (integer_t *) (ndr + 1);
task_port = desc[1].name;
thread_port = desc[0].name;
@@ -678,9 +664,9 @@ darwin_nat_target::decode_exception_message (mach_msg_header_t *hdr,
FIXME: should the exception port be restored ? */
mig_reply_error_t reply;
- inferior_debug
- (4, _("darwin_decode_exception_message: unknown task 0x%x\n"),
- task_port);
+ inferior_debug (
+ 4, _ ("darwin_decode_exception_message: unknown task 0x%x\n"),
+ task_port);
/* Free thread port (we don't know it). */
kret = mach_port_deallocate (mach_task_self (), thread_port);
@@ -689,9 +675,8 @@ darwin_nat_target::decode_exception_message (mach_msg_header_t *hdr,
darwin_encode_reply (&reply, hdr, KERN_SUCCESS);
kret = mach_msg (&reply.Head, MACH_SEND_MSG | MACH_SEND_INTERRUPT,
- reply.Head.msgh_size, 0,
- MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
+ reply.Head.msgh_size, 0, MACH_PORT_NULL,
+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
MACH_CHECK_ERROR (kret);
return 0;
@@ -723,10 +708,10 @@ darwin_nat_target::decode_exception_message (mach_msg_header_t *hdr,
thread->event.ex_type = data[0];
thread->event.data_count = data[1];
- if (hdr->msgh_size < (sizeof (*hdr) + sizeof (*bod) + 2 * sizeof (*desc)
- + sizeof (*ndr) + 2 * sizeof (integer_t)
- + data[1] * sizeof (integer_t)))
- return -1;
+ if (hdr->msgh_size
+ < (sizeof (*hdr) + sizeof (*bod) + 2 * sizeof (*desc) + sizeof (*ndr)
+ + 2 * sizeof (integer_t) + data[1] * sizeof (integer_t)))
+ return -1;
for (i = 0; i < data[1]; i++)
thread->event.ex_data[i] = data[2 + i];
@@ -740,8 +725,8 @@ darwin_nat_target::decode_exception_message (mach_msg_header_t *hdr,
static int
darwin_decode_notify_message (mach_msg_header_t *hdr, struct inferior **pinf)
{
- NDR_record_t *ndr = (NDR_record_t *)(hdr + 1);
- integer_t *data = (integer_t *)(ndr + 1);
+ NDR_record_t *ndr = (NDR_record_t *) (hdr + 1);
+ integer_t *data = (integer_t *) (ndr + 1);
struct inferior *inf;
task_t task_port;
@@ -800,9 +785,8 @@ darwin_send_reply (struct inferior *inf, darwin_thread_t *thread)
darwin_encode_reply (&reply, &thread->event.header, KERN_SUCCESS);
kret = mach_msg (&reply.Head, MACH_SEND_MSG | MACH_SEND_INTERRUPT,
- reply.Head.msgh_size, 0,
- MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
- MACH_PORT_NULL);
+ reply.Head.msgh_size, 0, MACH_PORT_NULL,
+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
MACH_CHECK_ERROR (kret);
priv->pending_messages--;
@@ -823,12 +807,12 @@ darwin_pthread_kill (darwin_thread_t *thread, int nsignal)
}
static void
-darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
- int step, int nsignal)
+darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread, int step,
+ int nsignal)
{
- inferior_debug
- (3, _("darwin_resume_thread: state=%d, thread=0x%x, step=%d nsignal=%d\n"),
- thread->msg_state, thread->gdb_port, step, nsignal);
+ inferior_debug (
+ 3, _ ("darwin_resume_thread: state=%d, thread=0x%x, step=%d nsignal=%d\n"),
+ thread->msg_state, thread->gdb_port, step, nsignal);
switch (thread->msg_state)
{
@@ -840,20 +824,20 @@ darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
int res = PTRACE (PT_THUPDATE, inf->pid,
(caddr_t) (uintptr_t) thread->gdb_port, nsignal);
if (res < 0)
- inferior_debug (1, _("ptrace THUP: res=%d\n"), res);
+ inferior_debug (1, _ ("ptrace THUP: res=%d\n"), res);
}
else if (nsignal)
{
/* Note: ptrace is allowed only if the process is stopped.
Directly send the signal to the thread. */
int res = darwin_pthread_kill (thread, nsignal);
- inferior_debug (4, _("darwin_resume_thread: kill 0x%x %d: %d\n"),
+ inferior_debug (4, _ ("darwin_resume_thread: kill 0x%x %d: %d\n"),
thread->gdb_port, nsignal, res);
thread->signaled = 1;
}
/* Set or reset single step. */
- inferior_debug (4, _("darwin_set_sstep (thread=0x%x, enable=%d)\n"),
+ inferior_debug (4, _ ("darwin_set_sstep (thread=0x%x, enable=%d)\n"),
thread->gdb_port, step);
darwin_set_sstep (thread->gdb_port, step);
thread->single_step = step;
@@ -916,9 +900,8 @@ darwin_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
{
int nsignal;
- inferior_debug
- (2, _("darwin_resume: ptid=%s, step=%d, signal=%d\n"),
- ptid.to_string ().c_str (), step, signal);
+ inferior_debug (2, _ ("darwin_resume: ptid=%s, step=%d, signal=%d\n"),
+ ptid.to_string ().c_str (), step, signal);
if (signal == GDB_SIGNAL_0)
nsignal = 0;
@@ -970,8 +953,7 @@ darwin_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
ptid_t
darwin_nat_target::decode_message (mach_msg_header_t *hdr,
- darwin_thread_t **pthread,
- inferior **pinf,
+ darwin_thread_t **pthread, inferior **pinf,
target_waitstatus *status)
{
darwin_thread_t *thread;
@@ -988,7 +970,7 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
if (res < 0)
{
/* Should not happen... */
- warning (_("darwin_wait: ill-formatted message (id=0x%x)\n"),
+ warning (_ ("darwin_wait: ill-formatted message (id=0x%x)\n"),
hdr->msgh_id);
/* FIXME: send a failure reply? */
status->set_ignore ();
@@ -1008,7 +990,7 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
thread->msg_state = DARWIN_MESSAGE;
- inferior_debug (4, _("darwin_wait: thread=0x%x, got %s\n"),
+ inferior_debug (4, _ ("darwin_wait: thread=0x%x, got %s\n"),
thread->gdb_port,
unparse_exception_type (thread->event.ex_type));
@@ -1029,9 +1011,9 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
case EXC_SOFTWARE:
if (thread->event.ex_data[0] == EXC_SOFT_SIGNAL)
{
- status->set_stopped
- (gdb_signal_from_host (thread->event.ex_data[1]));
- inferior_debug (5, _(" (signal %d: %s)\n"),
+ status->set_stopped (
+ gdb_signal_from_host (thread->event.ex_data[1]));
+ inferior_debug (5, _ (" (signal %d: %s)\n"),
thread->event.ex_data[1],
gdb_signal_to_name (status->sig ()));
@@ -1071,9 +1053,9 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
if (res < 0)
{
/* Should not happen... */
- warning
- (_("darwin_wait: ill-formatted message (id=0x%x, res=%d)\n"),
- hdr->msgh_id, res);
+ warning (
+ _ ("darwin_wait: ill-formatted message (id=0x%x, res=%d)\n"),
+ hdr->msgh_id, res);
}
*pinf = NULL;
@@ -1097,38 +1079,43 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
res_pid = wait4 (inf->pid, &wstatus, 0, NULL);
if (res_pid < 0 || res_pid != inf->pid)
{
- warning (_("wait4: res=%d: %s\n"),
- res_pid, safe_strerror (errno));
+ warning (_ ("wait4: res=%d: %s\n"), res_pid,
+ safe_strerror (errno));
status->set_ignore ();
return minus_one_ptid;
}
if (WIFEXITED (wstatus))
{
status->set_exited (WEXITSTATUS (wstatus));
- inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),
- res_pid, wstatus);
+ inferior_debug (
+ 4, _ ("darwin_wait: pid=%d exit, status=0x%x\n"), res_pid,
+ wstatus);
}
else if (WIFSTOPPED (wstatus))
{
/* Ignore stopped state, it will be handled by the next
exception. */
status->set_ignore ();
- inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"),
- res_pid);
+ inferior_debug (
+ 4, _ ("darwin_wait: pid %d received WIFSTOPPED\n"),
+ res_pid);
return minus_one_ptid;
}
else if (WIFSIGNALED (wstatus))
{
- status->set_signalled
- (gdb_signal_from_host (WTERMSIG (wstatus)));
- inferior_debug (4, _("darwin_wait: pid=%d received signal %d\n"),
- res_pid, status->sig());
+ status->set_signalled (
+ gdb_signal_from_host (WTERMSIG (wstatus)));
+ inferior_debug (
+ 4, _ ("darwin_wait: pid=%d received signal %d\n"), res_pid,
+ status->sig ());
}
else
{
status->set_ignore ();
- warning (_("Unexpected wait status after MACH_NOTIFY_DEAD_NAME "
- "notification: 0x%x"), wstatus);
+ warning (
+ _ ("Unexpected wait status after MACH_NOTIFY_DEAD_NAME "
+ "notification: 0x%x"),
+ wstatus);
return minus_one_ptid;
}
@@ -1136,7 +1123,7 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
}
else
{
- inferior_debug (4, _("darwin_wait: pid=%d\n"), inf->pid);
+ inferior_debug (4, _ ("darwin_wait: pid=%d\n"), inf->pid);
status->set_exited (0 /* Don't know. */);
return ptid_t (inf->pid, 0, 0);
}
@@ -1144,7 +1131,7 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
}
/* Unknown message. */
- warning (_("darwin: got unknown message, id: 0x%x"), hdr->msgh_id);
+ warning (_ ("darwin: got unknown message, id: 0x%x"), hdr->msgh_id);
status->set_ignore ();
return minus_one_ptid;
}
@@ -1183,18 +1170,19 @@ ptid_t
darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
{
kern_return_t kret;
+
union
{
mach_msg_header_t hdr;
char data[0x100];
} msgin;
+
mach_msg_header_t *hdr = &msgin.hdr;
ptid_t res;
darwin_thread_t *thread;
- inferior_debug
- (2, _("darwin_wait: waiting for a message ptid=%s\n"),
- ptid.to_string ().c_str ());
+ inferior_debug (2, _ ("darwin_wait: waiting for a message ptid=%s\n"),
+ ptid.to_string ().c_str ());
/* Handle fake stop events at first. */
if (darwin_inf_fake_stop != NULL)
@@ -1215,8 +1203,9 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
/* set_sigint_trap (); */
/* Wait for a message. */
- kret = mach_msg (&msgin.hdr, MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0,
- sizeof (msgin.data), darwin_port_set, 0, MACH_PORT_NULL);
+ kret
+ = mach_msg (&msgin.hdr, MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0,
+ sizeof (msgin.data), darwin_port_set, 0, MACH_PORT_NULL);
/* clear_sigint_trap (); */
@@ -1228,7 +1217,7 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
if (kret != MACH_MSG_SUCCESS)
{
- inferior_debug (5, _("mach_msg: ret=0x%x\n"), kret);
+ inferior_debug (5, _ ("mach_msg: ret=0x%x\n"), kret);
status->set_spurious ();
return minus_one_ptid;
}
@@ -1261,16 +1250,16 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
struct target_waitstatus status2;
ptid_t ptid2;
- kret = mach_msg (&msgin.hdr,
- MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0,
- sizeof (msgin.data), darwin_port_set, 1, MACH_PORT_NULL);
+ kret
+ = mach_msg (&msgin.hdr, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0,
+ sizeof (msgin.data), darwin_port_set, 1, MACH_PORT_NULL);
if (kret == MACH_RCV_TIMED_OUT)
break;
if (kret != MACH_MSG_SUCCESS)
{
- inferior_debug
- (5, _("darwin_wait: mach_msg(pending) ret=0x%x\n"), kret);
+ inferior_debug (5, _ ("darwin_wait: mach_msg(pending) ret=0x%x\n"),
+ kret);
break;
}
@@ -1292,12 +1281,12 @@ darwin_nat_target::wait_1 (ptid_t ptid, struct target_waitstatus *status)
thread->msg_state = DARWIN_RUNNING;
}
else
- inferior_debug
- (3, _("darwin_wait: thread 0x%x hit a non-gdb breakpoint\n"),
- thread->gdb_port);
+ inferior_debug (
+ 3, _ ("darwin_wait: thread 0x%x hit a non-gdb breakpoint\n"),
+ thread->gdb_port);
}
else
- inferior_debug (3, _("darwin_wait: unhandled pending message\n"));
+ inferior_debug (3, _ ("darwin_wait: unhandled pending message\n"));
}
return res;
}
@@ -1348,19 +1337,17 @@ darwin_nat_target::mourn_inferior ()
darwin_deallocate_threads (inf);
/* Remove notify_port from darwin_port_set. */
- kret = mach_port_move_member (gdb_task,
- priv->notify_port, MACH_PORT_NULL);
+ kret = mach_port_move_member (gdb_task, priv->notify_port, MACH_PORT_NULL);
MACH_CHECK_ERROR (kret);
/* Remove task port dead_name notification. */
- kret = mach_port_request_notification (gdb_task, priv->task,
- MACH_NOTIFY_DEAD_NAME, 0,
- MACH_PORT_NULL,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- &prev);
+ kret
+ = mach_port_request_notification (gdb_task, priv->task,
+ MACH_NOTIFY_DEAD_NAME, 0, MACH_PORT_NULL,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE, &prev);
/* This can fail if the task is dead. */
- inferior_debug (4, "task=0x%x, prev=0x%x, notify_port=0x%x\n",
- priv->task, prev, priv->notify_port);
+ inferior_debug (4, "task=0x%x, prev=0x%x, notify_port=0x%x\n", priv->task,
+ prev, priv->notify_port);
if (kret == KERN_SUCCESS)
{
@@ -1415,7 +1402,7 @@ darwin_nat_target::stop_inferior (inferior *inf)
res = ::kill (inf->pid, SIGSTOP);
if (res != 0)
- warning (_("cannot kill: %s"), safe_strerror (errno));
+ warning (_ ("cannot kill: %s"), safe_strerror (errno));
/* Wait until the process is really stopped. */
while (1)
@@ -1432,13 +1419,15 @@ darwin_save_exception_ports (darwin_inferior *inf)
{
kern_return_t kret;
- inf->exception_info.count =
- sizeof (inf->exception_info.ports) / sizeof (inf->exception_info.ports[0]);
+ inf->exception_info.count = sizeof (inf->exception_info.ports)
+ / sizeof (inf->exception_info.ports[0]);
- kret = task_get_exception_ports
- (inf->task, EXC_MASK_ALL, inf->exception_info.masks,
- &inf->exception_info.count, inf->exception_info.ports,
- inf->exception_info.behaviors, inf->exception_info.flavors);
+ kret = task_get_exception_ports (inf->task, EXC_MASK_ALL,
+ inf->exception_info.masks,
+ &inf->exception_info.count,
+ inf->exception_info.ports,
+ inf->exception_info.behaviors,
+ inf->exception_info.flavors);
return kret;
}
@@ -1450,9 +1439,10 @@ darwin_restore_exception_ports (darwin_inferior *inf)
for (i = 0; i < inf->exception_info.count; i++)
{
- kret = task_set_exception_ports
- (inf->task, inf->exception_info.masks[i], inf->exception_info.ports[i],
- inf->exception_info.behaviors[i], inf->exception_info.flavors[i]);
+ kret = task_set_exception_ports (inf->task, inf->exception_info.masks[i],
+ inf->exception_info.ports[i],
+ inf->exception_info.behaviors[i],
+ inf->exception_info.flavors[i]);
if (kret != KERN_SUCCESS)
return kret;
}
@@ -1485,8 +1475,8 @@ darwin_setup_exceptions (struct inferior *inf)
kret = darwin_save_exception_ports (priv);
if (kret != KERN_SUCCESS)
- error (_("Unable to save exception ports, task_get_exception_ports"
- "returned: %d"),
+ error (_ ("Unable to save exception ports, task_get_exception_ports"
+ "returned: %d"),
kret);
/* Set exception port. */
@@ -1497,8 +1487,8 @@ darwin_setup_exceptions (struct inferior *inf)
kret = task_set_exception_ports (priv->task, mask, darwin_ex_port,
EXCEPTION_DEFAULT, THREAD_STATE_NONE);
if (kret != KERN_SUCCESS)
- error (_("Unable to set exception ports, task_set_exception_ports"
- "returned: %d"),
+ error (_ ("Unable to set exception ports, task_set_exception_ports"
+ "returned: %d"),
kret);
}
@@ -1548,7 +1538,7 @@ darwin_nat_target::kill ()
ptid = wait_1 (ptid_t (inf->pid), &wstatus);
}
else if (errno != ESRCH)
- warning (_("Failed to kill inferior: kill (%d, 9) returned [%s]"),
+ warning (_ ("Failed to kill inferior: kill (%d, 9) returned [%s]"),
inf->pid, safe_strerror (errno));
target_mourn_inferior (ptid_t (inf->pid));
@@ -1561,22 +1551,22 @@ darwin_setup_request_notification (struct inferior *inf)
kern_return_t kret;
mach_port_t prev_not;
- kret = mach_port_request_notification (gdb_task, priv->task,
- MACH_NOTIFY_DEAD_NAME, 0,
- priv->notify_port,
- MACH_MSG_TYPE_MAKE_SEND_ONCE,
- &prev_not);
+ kret
+ = mach_port_request_notification (gdb_task, priv->task,
+ MACH_NOTIFY_DEAD_NAME, 0,
+ priv->notify_port,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE, &prev_not);
if (kret != KERN_SUCCESS)
- error (_("Termination notification request failed, "
- "mach_port_request_notification\n"
- "returned: %d"),
+ error (_ ("Termination notification request failed, "
+ "mach_port_request_notification\n"
+ "returned: %d"),
kret);
if (prev_not != MACH_PORT_NULL)
{
/* This is unexpected, as there should not be any previously
registered notification request. But this is not a fatal
issue, so just emit a warning. */
- warning (_("\
+ warning (_ ("\
A task termination request was registered before the debugger registered\n\
its own. This is unexpected, but should otherwise not have any actual\n\
impact on the debugging session."));
@@ -1604,14 +1594,14 @@ darwin_attach_pid (struct inferior *inf)
waitpid (inf->pid, &status, 0);
}
- error
- (_("Unable to find Mach task port for process-id %d: %s (0x%lx).\n"
+ error (
+ _ ("Unable to find Mach task port for process-id %d: %s (0x%lx).\n"
" (please check gdb is codesigned - see taskgated(8))"),
- inf->pid, mach_error_string (kret), (unsigned long) kret);
+ inf->pid, mach_error_string (kret), (unsigned long) kret);
}
- inferior_debug (2, _("inferior task: 0x%x, pid: %d\n"),
- priv->task, inf->pid);
+ inferior_debug (2, _ ("inferior task: 0x%x, pid: %d\n"), priv->task,
+ inf->pid);
if (darwin_ex_port == MACH_PORT_NULL)
{
@@ -1619,32 +1609,33 @@ darwin_attach_pid (struct inferior *inf)
kret = mach_port_allocate (gdb_task, MACH_PORT_RIGHT_RECEIVE,
&darwin_ex_port);
if (kret != KERN_SUCCESS)
- error (_("Unable to create exception port, mach_port_allocate "
- "returned: %d"),
+ error (_ ("Unable to create exception port, mach_port_allocate "
+ "returned: %d"),
kret);
- kret = mach_port_insert_right (gdb_task, darwin_ex_port,
- darwin_ex_port,
- MACH_MSG_TYPE_MAKE_SEND);
+ kret
+ = mach_port_insert_right (gdb_task, darwin_ex_port, darwin_ex_port,
+ MACH_MSG_TYPE_MAKE_SEND);
if (kret != KERN_SUCCESS)
- error (_("Unable to create exception port, mach_port_insert_right "
- "returned: %d"),
- kret);
+ error (
+ _ ("Unable to create exception port, mach_port_insert_right "
+ "returned: %d"),
+ kret);
/* Create a port set and put ex_port in it. */
kret = mach_port_allocate (gdb_task, MACH_PORT_RIGHT_PORT_SET,
&darwin_port_set);
if (kret != KERN_SUCCESS)
- error (_("Unable to create port set, mach_port_allocate "
- "returned: %d"),
+ error (_ ("Unable to create port set, mach_port_allocate "
+ "returned: %d"),
kret);
kret = mach_port_move_member (gdb_task, darwin_ex_port,
darwin_port_set);
if (kret != KERN_SUCCESS)
- error (_("Unable to move exception port into new port set, "
- "mach_port_move_member\n"
- "returned: %d"),
+ error (_ ("Unable to move exception port into new port set, "
+ "mach_port_move_member\n"
+ "returned: %d"),
kret);
}
@@ -1652,16 +1643,16 @@ darwin_attach_pid (struct inferior *inf)
kret = mach_port_allocate (gdb_task, MACH_PORT_RIGHT_RECEIVE,
&priv->notify_port);
if (kret != KERN_SUCCESS)
- error (_("Unable to create notification port, mach_port_allocate "
- "returned: %d"),
+ error (_ ("Unable to create notification port, mach_port_allocate "
+ "returned: %d"),
kret);
- kret = mach_port_move_member (gdb_task,
- priv->notify_port, darwin_port_set);
+ kret
+ = mach_port_move_member (gdb_task, priv->notify_port, darwin_port_set);
if (kret != KERN_SUCCESS)
- error (_("Unable to move notification port into new port set, "
- "mach_port_move_member\n"
- "returned: %d"),
+ error (_ ("Unable to move notification port into new port set, "
+ "mach_port_move_member\n"
+ "returned: %d"),
kret);
darwin_setup_request_notification (inf);
@@ -1731,7 +1722,7 @@ darwin_ptrace_me (void)
/* Wait until gdb is ready. */
res = read (ptrace_fds[0], &c, 1);
if (res != 0)
- trace_start_error (_("unable to read from pipe, read returned: %d"), res);
+ trace_start_error (_ ("unable to read from pipe, read returned: %d"), res);
if (close (ptrace_fds[0]) < 0)
trace_start_error_with_name ("close");
@@ -1757,7 +1748,7 @@ darwin_pre_ptrace (void)
{
ptrace_fds[0] = -1;
ptrace_fds[1] = -1;
- error (_("unable to create a pipe: %s"), safe_strerror (errno));
+ error (_ ("unable to create a pipe: %s"), safe_strerror (errno));
}
mark_fd_no_cloexec (ptrace_fds[0]);
@@ -1784,7 +1775,7 @@ darwin_nat_target::ptrace_him (int pid)
}
static void
-darwin_execvp (const char *file, char * const argv[], char * const env[])
+darwin_execvp (const char *file, char *const argv[], char *const env[])
{
posix_spawnattr_t attr;
short ps_flags = 0;
@@ -1793,8 +1784,7 @@ darwin_execvp (const char *file, char * const argv[], char * const env[])
res = posix_spawnattr_init (&attr);
if (res != 0)
{
- gdb_printf
- (gdb_stderr, "Cannot initialize attribute for posix_spawn\n");
+ gdb_printf (gdb_stderr, "Cannot initialize attribute for posix_spawn\n");
return;
}
@@ -1845,31 +1835,32 @@ copy_shell_to_cache (const char *shell, const std::string &new_name)
{
scoped_fd from_fd = gdb_open_cloexec (shell, O_RDONLY, 0);
if (from_fd.get () < 0)
- error (_("Could not open shell (%s) for reading: %s"),
- shell, safe_strerror (errno));
+ error (_ ("Could not open shell (%s) for reading: %s"), shell,
+ safe_strerror (errno));
std::string new_dir = ldirname (new_name.c_str ());
if (!mkdir_recursive (new_dir.c_str ()))
- error (_("Could not make cache directory \"%s\": %s"),
- new_dir.c_str (), safe_strerror (errno));
+ error (_ ("Could not make cache directory \"%s\": %s"), new_dir.c_str (),
+ safe_strerror (errno));
gdb::char_vector temp_name = make_temp_filename (new_name);
scoped_fd to_fd = gdb_mkostemp_cloexec (&temp_name[0]);
gdb::unlinker unlink_file_on_error (temp_name.data ());
if (to_fd.get () < 0)
- error (_("Could not open temporary file \"%s\" for writing: %s"),
+ error (_ ("Could not open temporary file \"%s\" for writing: %s"),
temp_name.data (), safe_strerror (errno));
if (fcopyfile (from_fd.get (), to_fd.get (), nullptr,
- COPYFILE_STAT | COPYFILE_DATA) != 0)
- error (_("Could not copy shell to cache as \"%s\": %s"),
+ COPYFILE_STAT | COPYFILE_DATA)
+ != 0)
+ error (_ ("Could not copy shell to cache as \"%s\": %s"),
temp_name.data (), safe_strerror (errno));
/* Be sure that the caching is atomic so that we don't get bad
results from multiple copies of gdb running at the same time. */
if (rename (temp_name.data (), new_name.c_str ()) != 0)
- error (_("Could not rename shell cache file to \"%s\": %s"),
+ error (_ ("Could not rename shell cache file to \"%s\": %s"),
new_name.c_str (), safe_strerror (errno));
unlink_file_on_error.keep ();
@@ -1898,7 +1889,7 @@ maybe_cache_shell ()
const char *shell = get_shell ();
if (!IS_ABSOLUTE_PATH (shell))
{
- warning (_("This version of macOS has System Integrity Protection.\n\
+ warning (_ ("This version of macOS has System Integrity Protection.\n\
Normally gdb would try to work around this by caching a copy of your shell,\n\
but because your shell (%s) is not an absolute path, this is being skipped."),
shell);
@@ -1908,7 +1899,7 @@ but because your shell (%s) is not an absolute path, this is being skipped."),
struct stat sb;
if (stat (shell, &sb) < 0)
{
- warning (_("This version of macOS has System Integrity Protection.\n\
+ warning (_ ("This version of macOS has System Integrity Protection.\n\
Normally gdb would try to work around this by caching a copy of your shell,\n\
but because gdb could not stat your shell (%s), this is being skipped.\n\
The error was: %s"),
@@ -1934,22 +1925,24 @@ The error was: %s"),
}
catch (const gdb_exception_error &ex)
{
- warning (_("This version of macOS has System Integrity Protection.\n\
+ warning (
+ _ ("This version of macOS has System Integrity Protection.\n\
Because `startup-with-shell' is enabled, gdb tried to work around SIP by\n\
caching a copy of your shell. However, this failed:\n\
%s\n\
If you correct the problem, gdb will automatically try again the next time\n\
you \"run\". To prevent these attempts, you can use:\n\
set startup-with-shell off"),
- ex.what ());
+ ex.what ());
return false;
}
- gdb_printf (_("Note: this version of macOS has System Integrity Protection.\n\
+ gdb_printf (
+ _ ("Note: this version of macOS has System Integrity Protection.\n\
Because `startup-with-shell' is enabled, gdb has worked around this by\n\
caching a copy of your shell. The shell used by \"run\" is now:\n\
%s\n"),
- new_name.c_str ());
+ new_name.c_str ());
}
/* We need to make sure that the new name has the correct lifetime. */
@@ -1963,8 +1956,8 @@ caching a copy of your shell. The shell used by \"run\" is now:\n\
void
darwin_nat_target::create_inferior (const char *exec_file,
- const std::string &allargs,
- char **env, int from_tty)
+ const std::string &allargs, char **env,
+ int from_tty)
{
gdb::optional<scoped_restore_tmpl<bool>> restore_startup_with_shell;
darwin_nat_target *the_target = this;
@@ -1973,21 +1966,17 @@ darwin_nat_target::create_inferior (const char *exec_file,
{
if (!maybe_cache_shell ())
{
- warning (_("startup-with-shell is now temporarily disabled"));
+ warning (_ ("startup-with-shell is now temporarily disabled"));
restore_startup_with_shell.emplace (&startup_with_shell, 0);
}
}
/* Do the hard work. */
- fork_inferior (exec_file, allargs, env, darwin_ptrace_me,
- [the_target] (int pid)
- {
- the_target->ptrace_him (pid);
- },
- darwin_pre_ptrace, copied_shell,
- darwin_execvp);
+ fork_inferior (
+ exec_file, allargs, env, darwin_ptrace_me,
+ [the_target] (int pid) { the_target->ptrace_him (pid); },
+ darwin_pre_ptrace, copied_shell, darwin_execvp);
}
-
/* Set things up such that the next call to darwin_wait will immediately
return a fake stop event for inferior INF.
@@ -2026,14 +2015,14 @@ darwin_nat_target::attach (const char *args, int from_tty)
pid = parse_pid_to_attach (args);
- if (pid == getpid ()) /* Trying to masturbate? */
- error (_("I refuse to debug myself!"));
+ if (pid == getpid ()) /* Trying to masturbate? */
+ error (_ ("I refuse to debug myself!"));
target_announce_attach (from_tty, pid);
if (pid == 0 || ::kill (pid, 0) < 0)
- error (_("Can't attach to process %d: %s (%d)"),
- pid, safe_strerror (errno), errno);
+ error (_ ("Can't attach to process %d: %s (%d)"), pid,
+ safe_strerror (errno), errno);
inf = current_inferior ();
inferior_appeared (inf, pid);
@@ -2083,8 +2072,8 @@ darwin_nat_target::detach (inferior *inf, int from_tty)
{
res = PTRACE (PT_DETACH, inf->pid, 0, 0);
if (res != 0)
- warning (_("Unable to detach from process-id %d: %s (%d)"),
- inf->pid, safe_strerror (errno), errno);
+ warning (_ ("Unable to detach from process-id %d: %s (%d)"), inf->pid,
+ safe_strerror (errno), errno);
}
darwin_reply_to_all_pending_messages (inf);
@@ -2104,8 +2093,7 @@ darwin_nat_target::pid_to_str (ptid_t ptid)
long tid = ptid.tid ();
if (tid != 0)
- return string_printf (_("Thread 0x%lx of process %u"),
- tid, ptid.pid ());
+ return string_printf (_ ("Thread 0x%lx of process %u"), tid, ptid.pid ());
return normal_pid_to_str (ptid);
}
@@ -2123,14 +2111,13 @@ darwin_nat_target::thread_alive (ptid_t ptid)
Return 0 on failure; number of bytes read / written otherwise. */
static int
-darwin_read_write_inferior (task_t task, CORE_ADDR addr,
- gdb_byte *rdaddr, const gdb_byte *wraddr,
- ULONGEST length)
+darwin_read_write_inferior (task_t task, CORE_ADDR addr, gdb_byte *rdaddr,
+ const gdb_byte *wraddr, ULONGEST length)
{
kern_return_t kret;
mach_vm_size_t res_length = 0;
- inferior_debug (8, _("darwin_read_write_inferior(task=0x%x, %s, len=%s)\n"),
+ inferior_debug (8, _ ("darwin_read_write_inferior(task=0x%x, %s, len=%s)\n"),
task, core_addr_to_string (addr), pulongest (length));
/* First read. */
@@ -2146,9 +2133,9 @@ darwin_read_write_inferior (task_t task, CORE_ADDR addr,
(mach_vm_address_t) rdaddr, &count);
if (kret != KERN_SUCCESS)
{
- inferior_debug
- (1, _("darwin_read_write_inferior: mach_vm_read failed at %s: %s"),
- core_addr_to_string (addr), mach_error_string (kret));
+ inferior_debug (
+ 1, _ ("darwin_read_write_inferior: mach_vm_read failed at %s: %s"),
+ core_addr_to_string (addr), mach_error_string (kret));
return 0;
}
return count;
@@ -2161,8 +2148,8 @@ darwin_read_write_inferior (task_t task, CORE_ADDR addr,
{
mach_vm_address_t offset = addr & (mach_page_size - 1);
mach_vm_address_t region_address = (mach_vm_address_t) (addr - offset);
- mach_vm_size_t aligned_length =
- (mach_vm_size_t) PAGE_ROUND (offset + length);
+ mach_vm_size_t aligned_length
+ = (mach_vm_size_t) PAGE_ROUND (offset + length);
vm_region_submap_short_info_data_64_t info;
mach_msg_type_number_t count = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64;
natural_t region_depth = 1000;
@@ -2171,33 +2158,34 @@ darwin_read_write_inferior (task_t task, CORE_ADDR addr,
mach_vm_size_t write_length;
/* Read page protection. */
- kret = mach_vm_region_recurse
- (task, &region_start, &region_length, &region_depth,
- (vm_region_recurse_info_t) &info, &count);
+ kret = mach_vm_region_recurse (task, &region_start, &region_length,
+ &region_depth,
+ (vm_region_recurse_info_t) &info, &count);
if (kret != KERN_SUCCESS)
{
- inferior_debug (1, _("darwin_read_write_inferior: "
- "mach_vm_region_recurse failed at %s: %s\n"),
+ inferior_debug (1,
+ _ ("darwin_read_write_inferior: "
+ "mach_vm_region_recurse failed at %s: %s\n"),
core_addr_to_string (region_address),
mach_error_string (kret));
return res_length;
}
- inferior_debug
- (9, _("darwin_read_write_inferior: "
- "mach_vm_region_recurse addr=%s, start=%s, len=%s\n"),
- core_addr_to_string (region_address),
- core_addr_to_string (region_start),
- core_addr_to_string (region_length));
+ inferior_debug (9,
+ _ ("darwin_read_write_inferior: "
+ "mach_vm_region_recurse addr=%s, start=%s, len=%s\n"),
+ core_addr_to_string (region_address),
+ core_addr_to_string (region_start),
+ core_addr_to_string (region_length));
/* Check for holes in memory. */
if (region_start > region_address)
{
- warning (_("No memory at %s (vs %s+0x%x). Nothing written"),
+ warning (_ ("No memory at %s (vs %s+0x%x). Nothing written"),
core_addr_to_string (region_address),
core_addr_to_string (region_start),
- (unsigned)region_length);
+ (unsigned) region_length);
return res_length;
}
@@ -2211,8 +2199,8 @@ darwin_read_write_inferior (task_t task, CORE_ADDR addr,
{
vm_prot_t prot = VM_PROT_READ | VM_PROT_WRITE;
- kret = mach_vm_protect (task, region_address, region_length,
- FALSE, prot);
+ kret = mach_vm_protect (task, region_address, region_length, FALSE,
+ prot);
if (kret != KERN_SUCCESS)
{
prot |= VM_PROT_COPY;
@@ -2221,9 +2209,9 @@ darwin_read_write_inferior (task_t task, CORE_ADDR addr,
}
if (kret != KERN_SUCCESS)
{
- warning (_("darwin_read_write_inferior: "
- "mach_vm_protect failed at %s "
- "(len=0x%lx, prot=0x%x): %s"),
+ warning (_ ("darwin_read_write_inferior: "
+ "mach_vm_protect failed at %s "
+ "(len=0x%lx, prot=0x%x): %s"),
core_addr_to_string (region_address),
(unsigned long) region_length, (unsigned) prot,
mach_error_string (kret));
@@ -2240,7 +2228,7 @@ darwin_read_write_inferior (task_t task, CORE_ADDR addr,
kret = mach_vm_write (task, addr, (vm_offset_t) wraddr, write_length);
if (kret != KERN_SUCCESS)
{
- warning (_("darwin_read_write_inferior: mach_vm_write failed: %s"),
+ warning (_ ("darwin_read_write_inferior: mach_vm_write failed: %s"),
mach_error_string (kret));
return res_length;
}
@@ -2248,13 +2236,13 @@ darwin_read_write_inferior (task_t task, CORE_ADDR addr,
/* Restore page rights. */
if (!(info.protection & VM_PROT_WRITE))
{
- kret = mach_vm_protect (task, region_address, region_length,
- FALSE, info.protection);
+ kret = mach_vm_protect (task, region_address, region_length, FALSE,
+ info.protection);
if (kret != KERN_SUCCESS)
{
- warning (_("darwin_read_write_inferior: "
- "mach_vm_protect restore failed at %s "
- "(len=0x%lx): %s"),
+ warning (_ ("darwin_read_write_inferior: "
+ "mach_vm_protect restore failed at %s "
+ "(len=0x%lx): %s"),
core_addr_to_string (region_address),
(unsigned long) region_length,
mach_error_string (kret));
@@ -2287,8 +2275,8 @@ darwin_read_dyld_info (task_t task, CORE_ADDR addr, gdb_byte *rdaddr,
if (addr != 0 || length > sizeof (mach_vm_address_t))
return TARGET_XFER_EOF;
- kret = task_info (task, TASK_DYLD_INFO,
- (task_info_t) &task_dyld_info, &count);
+ kret
+ = task_info (task, TASK_DYLD_INFO, (task_info_t) &task_dyld_info, &count);
MACH_CHECK_ERROR (kret);
if (kret != KERN_SUCCESS)
return TARGET_XFER_E_IO;
@@ -2300,8 +2288,6 @@ darwin_read_dyld_info (task_t task, CORE_ADDR addr, gdb_byte *rdaddr,
}
#endif
-
-
enum target_xfer_status
darwin_nat_target::xfer_partial (enum target_object object, const char *annex,
gdb_byte *readbuf, const gdb_byte *writebuf,
@@ -2311,18 +2297,18 @@ darwin_nat_target::xfer_partial (enum target_object object, const char *annex,
struct inferior *inf = current_inferior ();
darwin_inferior *priv = get_darwin_inferior (inf);
- inferior_debug
- (8, _("darwin_xfer_partial(%s, %s, rbuf=%s, wbuf=%s) pid=%u\n"),
- core_addr_to_string (offset), pulongest (len),
- host_address_to_string (readbuf), host_address_to_string (writebuf),
- inf->pid);
+ inferior_debug (8,
+ _ ("darwin_xfer_partial(%s, %s, rbuf=%s, wbuf=%s) pid=%u\n"),
+ core_addr_to_string (offset), pulongest (len),
+ host_address_to_string (readbuf),
+ host_address_to_string (writebuf), inf->pid);
switch (object)
{
case TARGET_OBJECT_MEMORY:
{
- int l = darwin_read_write_inferior (priv->task, offset,
- readbuf, writebuf, len);
+ int l = darwin_read_write_inferior (priv->task, offset, readbuf,
+ writebuf, len);
if (l == 0)
return TARGET_XFER_EOF;
@@ -2346,7 +2332,6 @@ darwin_nat_target::xfer_partial (enum target_object object, const char *annex,
default:
return TARGET_XFER_E_IO;
}
-
}
static void
@@ -2408,8 +2393,8 @@ darwin_nat_target::get_ada_task_ptid (long lwp, ULONGEST thread)
/* Maybe the port was never extract. Do it now. */
/* First get inferior port names. */
- kret = mach_port_names (priv->task, &names, &names_count, &types,
- &types_count);
+ kret
+ = mach_port_names (priv->task, &names, &names_count, &types, &types_count);
MACH_CHECK_ERROR (kret);
if (kret != KERN_SUCCESS)
return null_ptid;
@@ -2425,8 +2410,8 @@ darwin_nat_target::get_ada_task_ptid (long lwp, ULONGEST thread)
/* We just need to know the corresponding name in gdb name space.
So extract and deallocate the right. */
kret = mach_port_extract_right (priv->task, names[i],
- MACH_MSG_TYPE_COPY_SEND,
- &local_name, &local_type);
+ MACH_MSG_TYPE_COPY_SEND, &local_name,
+ &local_type);
if (kret != KERN_SUCCESS)
continue;
mach_port_deallocate (gdb_task, local_name);
@@ -2458,6 +2443,7 @@ darwin_nat_target::supports_multi_process ()
}
void _initialize_darwin_nat ();
+
void
_initialize_darwin_nat ()
{
@@ -2474,22 +2460,23 @@ _initialize_darwin_nat ()
MACH_CHECK_ERROR (kret);
}
- inferior_debug (2, _("GDB task: 0x%lx, pid: %d\n"),
+ inferior_debug (2, _ ("GDB task: 0x%lx, pid: %d\n"),
(unsigned long) mach_task_self (), getpid ());
- add_setshow_zuinteger_cmd ("darwin", class_obscure,
- &darwin_debug_flag, _("\
-Set if printing inferior communication debugging statements."), _("\
-Show if printing inferior communication debugging statements."), NULL,
- NULL, NULL,
- &setdebuglist, &showdebuglist);
+ add_setshow_zuinteger_cmd ("darwin", class_obscure, &darwin_debug_flag, _ ("\
+Set if printing inferior communication debugging statements."),
+ _ ("\
+Show if printing inferior communication debugging statements."),
+ NULL, NULL, NULL, &setdebuglist, &showdebuglist);
add_setshow_boolean_cmd ("mach-exceptions", class_support,
- &enable_mach_exceptions, _("\
-Set if mach exceptions are caught."), _("\
-Show if mach exceptions are caught."), _("\
+ &enable_mach_exceptions, _ ("\
+Set if mach exceptions are caught."),
+ _ ("\
+Show if mach exceptions are caught."),
+ _ ("\
When this mode is on, all low level exceptions are reported before being\n\
reported by the kernel."),
- &set_enable_mach_exceptions, NULL,
- &setlist, &showlist);
+ &set_enable_mach_exceptions, NULL, &setlist,
+ &showlist);
}