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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [gdbserver/] [utils.c] - Diff between revs 827 and 840

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

Rev 827 Rev 840
/* General utility routines for the remote server for GDB.
/* General utility routines for the remote server for GDB.
   Copyright (C) 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002, 2003,
   Copyright (C) 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002, 2003,
   2007, 2008 Free Software Foundation, Inc.
   2007, 2008 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 3 of the License, or
   the Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.  */
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
#include "server.h"
#include "server.h"
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#if HAVE_ERRNO_H
#if HAVE_ERRNO_H
#include <errno.h>
#include <errno.h>
#endif
#endif
#if HAVE_MALLOC_H
#if HAVE_MALLOC_H
#include <malloc.h>
#include <malloc.h>
#endif
#endif
 
 
/* 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 (char *string)
perror_with_name (char *string)
{
{
  const char *err;
  const char *err;
  char *combined;
  char *combined;
 
 
  err = strerror (errno);
  err = strerror (errno);
  if (err == NULL)
  if (err == NULL)
    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.  */
 
 
void
void
error (const char *string,...)
error (const char *string,...)
{
{
  extern jmp_buf toplevel;
  extern jmp_buf toplevel;
  va_list args;
  va_list args;
  va_start (args, string);
  va_start (args, string);
  fflush (stdout);
  fflush (stdout);
  vfprintf (stderr, string, args);
  vfprintf (stderr, string, args);
  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 */
void
void
fatal (const char *string,...)
fatal (const char *string,...)
{
{
  va_list args;
  va_list args;
  va_start (args, string);
  va_start (args, string);
  fprintf (stderr, "gdbserver: ");
  fprintf (stderr, "gdbserver: ");
  vfprintf (stderr, string, args);
  vfprintf (stderr, string, args);
  fprintf (stderr, "\n");
  fprintf (stderr, "\n");
  va_end (args);
  va_end (args);
  exit (1);
  exit (1);
}
}
 
 
/* VARARGS */
/* VARARGS */
void
void
warning (const char *string,...)
warning (const char *string,...)
{
{
  va_list args;
  va_list args;
  va_start (args, string);
  va_start (args, string);
  fprintf (stderr, "gdbserver: ");
  fprintf (stderr, "gdbserver: ");
  vfprintf (stderr, string, args);
  vfprintf (stderr, string, args);
  fprintf (stderr, "\n");
  fprintf (stderr, "\n");
  va_end (args);
  va_end (args);
}
}
 
 

powered by: WebSVN 2.1.0

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