1 /* General utility routines for the remote server for GDB.
2 Copyright (C) 1986, 1989, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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, Boston, MA 02111-1307, USA. */
24 /* Generally useful subroutines used throughout the program. */
26 /* Print the system error message for errno, and also mention STRING
27 as the file name for which the error was encountered.
28 Then return to command level. */
31 perror_with_name (string)
38 err = sys_errlist[errno];
40 err = "unknown error";
42 combined = (char *) alloca (strlen (err) + strlen (string) + 3);
43 strcpy (combined, string);
44 strcat (combined, ": ");
45 strcat (combined, err);
47 error ("%s.", combined);
50 /* Print an error message and return to command level.
51 STRING is the error message, used as a fprintf string,
52 and ARG is passed as an argument to it. */
54 #ifdef ANSI_PROTOTYPES
56 error (const char *string, ...)
63 extern jmp_buf toplevel;
65 #ifdef ANSI_PROTOTYPES
66 va_start (args, string);
71 #ifdef ANSI_PROTOTYPES
72 vfprintf (stderr, string, args);
77 string1 = va_arg (args, char *);
78 vfprintf (stderr, string1, args);
81 fprintf (stderr, "\n");
85 /* Print an error message and exit reporting failure.
86 This is for a error that we cannot continue from.
87 STRING and ARG are passed to fprintf. */
91 #ifdef ANSI_PROTOTYPES
92 fatal (char *string, ...)
99 #ifdef ANSI_PROTOTYPES
100 va_start (args, string);
104 string = va_arg (args, char *);
106 fprintf (stderr, "gdb: ");
107 vfprintf (stderr, string, args);
108 fprintf (stderr, "\n");