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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [stop-gdb.c] - Diff between revs 105 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 105 Rev 1765
/* A client to make GDB return to command level in Mach 3.
/* A client to make GDB return to command level in Mach 3.
   Copyright (C) 1992, 1993 Free Software Foundation, Inc.
   Copyright (C) 1992, 1993 Free Software Foundation, Inc.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */
   Boston, MA 02111-1307, USA.  */
 
 
/* Authors: Jukka Virtanen <jtv@hut.fi> and Peter Stout <pds@cs.cmu.edu>.
/* Authors: Jukka Virtanen <jtv@hut.fi> and Peter Stout <pds@cs.cmu.edu>.
 
 
   A simple client to make GDB (versions 4.4 and later) on Mach 3 return
   A simple client to make GDB (versions 4.4 and later) on Mach 3 return
   to the command level when it is waiting for the inferior to stop.
   to the command level when it is waiting for the inferior to stop.
 
 
   Actions: Lookup the send right to the GDB message port from the
   Actions: Lookup the send right to the GDB message port from the
   NetMsgServer.
   NetMsgServer.
 
 
   Send an asynchronous message with msgh_id
   Send an asynchronous message with msgh_id
   GDB_MESSAGE_ID_STOP to that port.
   GDB_MESSAGE_ID_STOP to that port.
 */
 */
 
 
#include <stdio.h>
#include <stdio.h>
 
 
#include "defs.h"
#include "defs.h"
 
 
#include <mach.h>
#include <mach.h>
#include <mach/message.h>
#include <mach/message.h>
#include <mach_error.h>
#include <mach_error.h>
#include <servers/netname.h>
#include <servers/netname.h>
#include <servers/netname_defs.h>
#include <servers/netname_defs.h>
 
 
void
void
main (argc, argv)
main (argc, argv)
     int argc;
     int argc;
     char **argv;
     char **argv;
{
{
  kern_return_t kr;
  kern_return_t kr;
  mach_msg_header_t msg;
  mach_msg_header_t msg;
  mach_port_t gdb_port;
  mach_port_t gdb_port;
  char *host;
  char *host;
  char *name;
  char *name;
 
 
  if (argc == 1)
  if (argc == 1)
    argv[argc++] = GDB_DEF_NAME;
    argv[argc++] = GDB_DEF_NAME;
 
 
  if (argc != 2)
  if (argc != 2)
    {
    {
      fprintf (stderr, "Usage : %s <GDB name>\n", argv[0]);
      fprintf (stderr, "Usage : %s <GDB name>\n", argv[0]);
      exit (1);
      exit (1);
    }
    }
 
 
  /* Allow the user to specify a remote host.  */
  /* Allow the user to specify a remote host.  */
  host = strchr (argv[1], '@');
  host = strchr (argv[1], '@');
  if (host)
  if (host)
    *(host++) = '\0';
    *(host++) = '\0';
  else
  else
    host = (char *) "";
    host = (char *) "";
 
 
  name = malloc (strlen (argv[1]) + sizeof (GDB_NAME_PREFIX));
  name = malloc (strlen (argv[1]) + sizeof (GDB_NAME_PREFIX));
  if (name == NULL)
  if (name == NULL)
    {
    {
      fprintf (stderr, "Unable to allocate memory for name.");
      fprintf (stderr, "Unable to allocate memory for name.");
      exit (1);
      exit (1);
    }
    }
 
 
  strcpy (name, GDB_NAME_PREFIX);
  strcpy (name, GDB_NAME_PREFIX);
  strcat (name, argv[1]);
  strcat (name, argv[1]);
 
 
  /* Look up the GDB service port.  For convenience, add the
  /* Look up the GDB service port.  For convenience, add the
     GDB_NAME_PREFIX the argument before looking up the name.
     GDB_NAME_PREFIX the argument before looking up the name.
     For backwards compatibility, do it without.  */
     For backwards compatibility, do it without.  */
 
 
  kr = netname_look_up (name_server_port, host, name, &gdb_port);
  kr = netname_look_up (name_server_port, host, name, &gdb_port);
  if (kr == NETNAME_NOT_CHECKED_IN)
  if (kr == NETNAME_NOT_CHECKED_IN)
    kr = netname_look_up (name_server_port, host, argv[1], &gdb_port);
    kr = netname_look_up (name_server_port, host, argv[1], &gdb_port);
  if (kr != KERN_SUCCESS)
  if (kr != KERN_SUCCESS)
    {
    {
      fprintf (stderr, "Unable to lookup the GDB service port: %s.\n",
      fprintf (stderr, "Unable to lookup the GDB service port: %s.\n",
               mach_error_string (kr));
               mach_error_string (kr));
      exit (1);
      exit (1);
    }
    }
 
 
  /* Code generated by mig stub generator, with minor cleanups :-)
  /* Code generated by mig stub generator, with minor cleanups :-)
 
 
     simpleroutine stop_inferior(gdb_port : mach_port_t);  */
     simpleroutine stop_inferior(gdb_port : mach_port_t);  */
 
 
  msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, 0);
  msg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, 0);
  msg.msgh_remote_port = gdb_port;
  msg.msgh_remote_port = gdb_port;
  msg.msgh_local_port = MACH_PORT_NULL;
  msg.msgh_local_port = MACH_PORT_NULL;
  msg.msgh_size = sizeof (msg);
  msg.msgh_size = sizeof (msg);
  msg.msgh_seqno = 0;
  msg.msgh_seqno = 0;
  msg.msgh_id = GDB_MESSAGE_ID_STOP;
  msg.msgh_id = GDB_MESSAGE_ID_STOP;
 
 
  kr = mach_msg_send (&msg);
  kr = mach_msg_send (&msg);
  if (kr != KERN_SUCCESS)
  if (kr != KERN_SUCCESS)
    fprintf (stderr, "Message not sent, return code %d : %s\n", kr,
    fprintf (stderr, "Message not sent, return code %d : %s\n", kr,
             mach_error_string (kr));
             mach_error_string (kr));
 
 
  exit (kr != KERN_SUCCESS);
  exit (kr != KERN_SUCCESS);
}
}
 
 

powered by: WebSVN 2.1.0

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