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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [gdbserver/] [utils.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* General utility routines for the remote server for GDB.
2
   Copyright (C) 1986, 1989, 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
#include "server.h"
22
#include <stdio.h>
23
#include <string.h>
24
 
25
/* Generally useful subroutines used throughout the program.  */
26
 
27
/* Print the system error message for errno, and also mention STRING
28
   as the file name for which the error was encountered.
29
   Then return to command level.  */
30
 
31
void
32
perror_with_name (string)
33
     char *string;
34
{
35
#ifndef STDC_HEADERS
36
  extern int sys_nerr;
37
  extern char *sys_errlist[];
38
  extern int errno;
39
#endif
40
  const char *err;
41
  char *combined;
42
 
43
  if (errno < sys_nerr)
44
    err = sys_errlist[errno];
45
  else
46
    err = "unknown error";
47
 
48
  combined = (char *) alloca (strlen (err) + strlen (string) + 3);
49
  strcpy (combined, string);
50
  strcat (combined, ": ");
51
  strcat (combined, err);
52
 
53
  error ("%s.", combined);
54
}
55
 
56
/* Print an error message and return to command level.
57
   STRING is the error message, used as a fprintf string,
58
   and ARG is passed as an argument to it.  */
59
 
60
#ifdef ANSI_PROTOTYPES
61
NORETURN void
62
error (const char *string,...)
63
#else
64
void
65
error (va_alist)
66
     va_dcl
67
#endif
68
{
69
  extern jmp_buf toplevel;
70
  va_list args;
71
#ifdef ANSI_PROTOTYPES
72
  va_start (args, string);
73
#else
74
  va_start (args);
75
#endif
76
  fflush (stdout);
77
#ifdef ANSI_PROTOTYPES
78
  vfprintf (stderr, string, args);
79
#else
80
  {
81
    char *string1;
82
 
83
    string1 = va_arg (args, char *);
84
    vfprintf (stderr, string1, args);
85
  }
86
#endif
87
  fprintf (stderr, "\n");
88
  longjmp (toplevel, 1);
89
}
90
 
91
/* Print an error message and exit reporting failure.
92
   This is for a error that we cannot continue from.
93
   STRING and ARG are passed to fprintf.  */
94
 
95
/* VARARGS */
96
NORETURN void
97
#ifdef ANSI_PROTOTYPES
98
fatal (char *string,...)
99
#else
100
fatal (va_alist)
101
     va_dcl
102
#endif
103
{
104
  va_list args;
105
#ifdef ANSI_PROTOTYPES
106
  va_start (args, string);
107
#else
108
  char *string;
109
  va_start (args);
110
  string = va_arg (args, char *);
111
#endif
112
  fprintf (stderr, "gdb: ");
113
  vfprintf (stderr, string, args);
114
  fprintf (stderr, "\n");
115
  va_end (args);
116
  exit (1);
117
}

powered by: WebSVN 2.1.0

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