1 /* A client to make GDB return to command level in Mach 3.
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* Authors: Jukka Virtanen <jtv@hut.fi> and Peter Stout <pds@cs.cmu.edu>.
22 A simple client to make GDB (versions 4.4 and later) on Mach 3 return
23 to the command level when it is waiting for the inferior to stop.
25 Actions: Lookup the send right to the GDB message port from the
28 Send an asynchronous message with msgh_id
29 GDB_MESSAGE_ID_STOP to that port.
37 #include <mach/message.h>
38 #include <mach_error.h>
39 #include <servers/netname.h>
40 #include <servers/netname_defs.h>
48 mach_msg_header_t msg
;
54 argv
[argc
++] = GDB_DEF_NAME
;
58 fprintf (stderr
, "Usage : %s <GDB name>\n", argv
[0]);
62 /* Allow the user to specify a remote host. */
63 host
= strchr (argv
[1], '@');
69 name
= malloc (strlen (argv
[1]) + sizeof(GDB_NAME_PREFIX
));
72 fprintf (stderr
, "Unable to allocate memory for name.");
76 strcpy (name
, GDB_NAME_PREFIX
);
77 strcat (name
, argv
[1]);
79 /* Look up the GDB service port. For convenience, add the
80 GDB_NAME_PREFIX the argument before looking up the name.
81 For backwards compatibility, do it without. */
83 kr
= netname_look_up (name_server_port
, host
, name
, &gdb_port
);
84 if (kr
== NETNAME_NOT_CHECKED_IN
)
85 kr
= netname_look_up (name_server_port
, host
, argv
[1], &gdb_port
);
86 if (kr
!= KERN_SUCCESS
)
88 fprintf (stderr
, "Unable to lookup the GDB service port: %s.\n",
89 mach_error_string(kr
));
93 /* Code generated by mig stub generator, with minor cleanups :-)
95 simpleroutine stop_inferior(gdb_port : mach_port_t); */
97 msg
.msgh_bits
= MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND
, 0);
98 msg
.msgh_remote_port
= gdb_port
;
99 msg
.msgh_local_port
= MACH_PORT_NULL
;
100 msg
.msgh_size
= sizeof(msg
);
102 msg
.msgh_id
= GDB_MESSAGE_ID_STOP
;
104 kr
= mach_msg_send (&msg
);
105 if (kr
!= KERN_SUCCESS
)
106 fprintf (stderr
, "Message not sent, return code %d : %s\n", kr
,
107 mach_error_string (kr
));
109 exit (kr
!= KERN_SUCCESS
);
This page took 0.038137 seconds and 4 git commands to generate.