OSDN Git Service

* tracepoint.c (trace_status_command): Add some status output.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / darwin-nat.c
index 2b45689..8be0ec2 100644 (file)
@@ -147,6 +147,34 @@ static struct inferior *darwin_inf_fake_stop;
 /* This controls output of inferior debugging.  */
 static int darwin_debug_flag = 0;
 
+/* Create a __TEXT __info_plist section in the executable so that gdb could
+   be signed.  This is required to get an authorization for task_for_pid.
+
+   Once gdb is built, you can either:
+   * make it setgid procmod
+   * or 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";
+
 static void
 inferior_debug (int level, const char *fmt, ...)
 {
@@ -967,7 +995,7 @@ cancel_breakpoint (ptid_t ptid)
   CORE_ADDR pc;
 
   pc = regcache_read_pc (regcache) - gdbarch_decr_pc_after_break (gdbarch);
-  if (breakpoint_inserted_here_p (pc))
+  if (breakpoint_inserted_here_p (get_regcache_aspace (regcache), pc))
     {
       inferior_debug (4, "cancel_breakpoint for thread %x\n",
                      ptid_get_tid (ptid));
@@ -1323,7 +1351,7 @@ darwin_attach_pid (struct inferior *inf)
        }
 
       error (_("Unable to find Mach task port for process-id %d: %s (0x%lx).\n"
-              " (please check gdb is setgid procmod)"),
+              " (please check gdb is codesigned - see taskgated(8))"),
              inf->pid, mach_error_string (kret), (unsigned long) kret);
     }
 
@@ -1515,8 +1543,10 @@ darwin_attach (struct target_ops *ops, char *args, int from_tty)
            pid, safe_strerror (errno), errno);
 
   inferior_ptid = pid_to_ptid (pid);
-  inf = add_inferior (pid);
+  inf = current_inferior ();
+  inferior_appeared (inf, pid);
   inf->attach_flag = 1;
+
   /* Always add a main thread.  */
   add_thread_silent (inferior_ptid);
 
@@ -1772,8 +1802,10 @@ darwin_xfer_partial (struct target_ops *ops,
   struct inferior *inf = current_inferior ();
 
   inferior_debug
-    (8, _("darwin_xfer_partial(%s, %d, rbuf=%p, wbuf=%p) pid=%u\n"),
-     core_addr_to_string (offset), (int)len, readbuf, writebuf, inf->pid);
+    (8, _("darwin_xfer_partial(%s, %d, rbuf=%s, wbuf=%s) pid=%u\n"),
+     core_addr_to_string (offset), (int)len,
+     host_address_to_string (readbuf), host_address_to_string (writebuf),
+     inf->pid);
 
   if (object != TARGET_OBJECT_MEMORY)
     return -1;
@@ -1934,7 +1966,6 @@ _initialize_darwin_inferior (void)
   darwin_ops->to_xfer_partial = darwin_xfer_partial;
   darwin_ops->to_supports_multi_process = darwin_supports_multi_process;
   darwin_ops->to_get_ada_task_ptid = darwin_get_ada_task_ptid;
-  /* darwin_ops->to_has_thread_control = tc_schedlock | tc_switch */;
 
   darwin_complete_target (darwin_ops);