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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [gdbserver/] [utils.c] - Diff between revs 107 and 1765

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

Rev 107 Rev 1765
/* General utility routines for the remote server for GDB.
/* General utility routines for the remote server for GDB.
   Copyright (C) 1986, 1989, 1993 Free Software Foundation, Inc.
   Copyright (C) 1986, 1989, 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.  */
 
 
#include "server.h"
#include "server.h"
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
 
 
/* Generally useful subroutines used throughout the program.  */
/* Generally useful subroutines used throughout the program.  */
 
 
/* Print the system error message for errno, and also mention STRING
/* Print the system error message for errno, and also mention STRING
   as the file name for which the error was encountered.
   as the file name for which the error was encountered.
   Then return to command level.  */
   Then return to command level.  */
 
 
void
void
perror_with_name (string)
perror_with_name (string)
     char *string;
     char *string;
{
{
#ifndef STDC_HEADERS
#ifndef STDC_HEADERS
  extern int sys_nerr;
  extern int sys_nerr;
  extern char *sys_errlist[];
  extern char *sys_errlist[];
  extern int errno;
  extern int errno;
#endif
#endif
  const char *err;
  const char *err;
  char *combined;
  char *combined;
 
 
  if (errno < sys_nerr)
  if (errno < sys_nerr)
    err = sys_errlist[errno];
    err = sys_errlist[errno];
  else
  else
    err = "unknown error";
    err = "unknown error";
 
 
  combined = (char *) alloca (strlen (err) + strlen (string) + 3);
  combined = (char *) alloca (strlen (err) + strlen (string) + 3);
  strcpy (combined, string);
  strcpy (combined, string);
  strcat (combined, ": ");
  strcat (combined, ": ");
  strcat (combined, err);
  strcat (combined, err);
 
 
  error ("%s.", combined);
  error ("%s.", combined);
}
}
 
 
/* Print an error message and return to command level.
/* Print an error message and return to command level.
   STRING is the error message, used as a fprintf string,
   STRING is the error message, used as a fprintf string,
   and ARG is passed as an argument to it.  */
   and ARG is passed as an argument to it.  */
 
 
#ifdef ANSI_PROTOTYPES
#ifdef ANSI_PROTOTYPES
NORETURN void
NORETURN void
error (const char *string,...)
error (const char *string,...)
#else
#else
void
void
error (va_alist)
error (va_alist)
     va_dcl
     va_dcl
#endif
#endif
{
{
  extern jmp_buf toplevel;
  extern jmp_buf toplevel;
  va_list args;
  va_list args;
#ifdef ANSI_PROTOTYPES
#ifdef ANSI_PROTOTYPES
  va_start (args, string);
  va_start (args, string);
#else
#else
  va_start (args);
  va_start (args);
#endif
#endif
  fflush (stdout);
  fflush (stdout);
#ifdef ANSI_PROTOTYPES
#ifdef ANSI_PROTOTYPES
  vfprintf (stderr, string, args);
  vfprintf (stderr, string, args);
#else
#else
  {
  {
    char *string1;
    char *string1;
 
 
    string1 = va_arg (args, char *);
    string1 = va_arg (args, char *);
    vfprintf (stderr, string1, args);
    vfprintf (stderr, string1, args);
  }
  }
#endif
#endif
  fprintf (stderr, "\n");
  fprintf (stderr, "\n");
  longjmp (toplevel, 1);
  longjmp (toplevel, 1);
}
}
 
 
/* Print an error message and exit reporting failure.
/* Print an error message and exit reporting failure.
   This is for a error that we cannot continue from.
   This is for a error that we cannot continue from.
   STRING and ARG are passed to fprintf.  */
   STRING and ARG are passed to fprintf.  */
 
 
/* VARARGS */
/* VARARGS */
NORETURN void
NORETURN void
#ifdef ANSI_PROTOTYPES
#ifdef ANSI_PROTOTYPES
fatal (char *string,...)
fatal (char *string,...)
#else
#else
fatal (va_alist)
fatal (va_alist)
     va_dcl
     va_dcl
#endif
#endif
{
{
  va_list args;
  va_list args;
#ifdef ANSI_PROTOTYPES
#ifdef ANSI_PROTOTYPES
  va_start (args, string);
  va_start (args, string);
#else
#else
  char *string;
  char *string;
  va_start (args);
  va_start (args);
  string = va_arg (args, char *);
  string = va_arg (args, char *);
#endif
#endif
  fprintf (stderr, "gdb: ");
  fprintf (stderr, "gdb: ");
  vfprintf (stderr, string, args);
  vfprintf (stderr, string, args);
  fprintf (stderr, "\n");
  fprintf (stderr, "\n");
  va_end (args);
  va_end (args);
  exit (1);
  exit (1);
}
}
 
 

powered by: WebSVN 2.1.0

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