OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [stop-gdb.c] - Blame information for rev 1772

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* A client to make GDB return to command level in Mach 3.
2
   Copyright (C) 1992, 1993 Free Software Foundation, Inc.
3
 
4
   This file is part of GDB.
5
 
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.
10
 
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.
15
 
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,
19
   Boston, MA 02111-1307, USA.  */
20
 
21
/* Authors: Jukka Virtanen <jtv@hut.fi> and Peter Stout <pds@cs.cmu.edu>.
22
 
23
   A simple client to make GDB (versions 4.4 and later) on Mach 3 return
24
   to the command level when it is waiting for the inferior to stop.
25
 
26
   Actions: Lookup the send right to the GDB message port from the
27
   NetMsgServer.
28
 
29
   Send an asynchronous message with msgh_id
30
   GDB_MESSAGE_ID_STOP to that port.
31
 */
32
 
33
#include <stdio.h>
34
 
35
#include "defs.h"
36
 
37
#include <mach.h>
38
#include <mach/message.h>
39
#include <mach_error.h>
40
#include <servers/netname.h>
41
#include <servers/netname_defs.h>
42
 
43
void
44
main (argc, argv)
45
     int argc;
46
     char **argv;
47
{
48
  kern_return_t kr;
49
  mach_msg_header_t msg;
50
  mach_port_t gdb_port;
51
  char *host;
52
  char *name;
53
 
54
  if (argc == 1)
55
    argv[argc++] = GDB_DEF_NAME;
56
 
57
  if (argc != 2)
58
    {
59
      fprintf (stderr, "Usage : %s <GDB name>\n", argv[0]);
60
      exit (1);
61
    }
62
 
63
  /* Allow the user to specify a remote host.  */
64
  host = strchr (argv[1], '@');
65
  if (host)
66
    *(host++) = '\0';
67
  else
68
    host = (char *) "";
69
 
70
  name = malloc (strlen (argv[1]) + sizeof (GDB_NAME_PREFIX));
71
  if (name == NULL)
72
    {
73
      fprintf (stderr, "Unable to allocate memory for name.");
74
      exit (1);
75
    }
76
 
77
  strcpy (name, GDB_NAME_PREFIX);
78
  strcat (name, argv[1]);
79
 
80
  /* Look up the GDB service port.  For convenience, add the
81
     GDB_NAME_PREFIX the argument before looking up the name.
82
     For backwards compatibility, do it without.  */
83
 
84
  kr = netname_look_up (name_server_port, host, name, &gdb_port);
85
  if (kr == NETNAME_NOT_CHECKED_IN)
86
    kr = netname_look_up (name_server_port, host, argv[1], &gdb_port);
87
  if (kr != KERN_SUCCESS)
88
    {
89
      fprintf (stderr, "Unable to lookup the GDB service port: %s.\n",
90
               mach_error_string (kr));
91
      exit (1);
92
    }
93
 
94
  /* Code generated by mig stub generator, with minor cleanups :-)
95
 
96
     simpleroutine stop_inferior(gdb_port : mach_port_t);  */
97
 
98
  msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, 0);
99
  msg.msgh_remote_port = gdb_port;
100
  msg.msgh_local_port = MACH_PORT_NULL;
101
  msg.msgh_size = sizeof (msg);
102
  msg.msgh_seqno = 0;
103
  msg.msgh_id = GDB_MESSAGE_ID_STOP;
104
 
105
  kr = mach_msg_send (&msg);
106
  if (kr != KERN_SUCCESS)
107
    fprintf (stderr, "Message not sent, return code %d : %s\n", kr,
108
             mach_error_string (kr));
109
 
110
  exit (kr != KERN_SUCCESS);
111
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.