1 /* General utility routines for the remote server for GDB.
2 Copyright 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 /* Generally useful subroutines used throughout the program. */
28 /* Print the system error message for errno, and also mention STRING
29 as the file name for which the error was encountered.
30 Then return to command level. */
33 perror_with_name (char *string
)
37 extern char *sys_errlist
[];
44 err
= sys_errlist
[errno
];
46 err
= "unknown error";
48 combined
= (char *) alloca (strlen (err
) + strlen (string
) + 3);
49 strcpy (combined
, string
);
50 strcat (combined
, ": ");
51 strcat (combined
, err
);
53 error ("%s.", combined
);
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. */
61 error (const char *string
,...)
63 extern jmp_buf toplevel
;
65 va_start (args
, string
);
67 vfprintf (stderr
, string
, args
);
68 fprintf (stderr
, "\n");
69 longjmp (toplevel
, 1);
72 /* Print an error message and exit reporting failure.
73 This is for a error that we cannot continue from.
74 STRING and ARG are passed to fprintf. */
78 fatal (const char *string
,...)
81 va_start (args
, string
);
82 fprintf (stderr
, "gdb: ");
83 vfprintf (stderr
, string
, args
);
84 fprintf (stderr
, "\n");
91 warning (const char *string
,...)
94 va_start (args
, string
);
95 fprintf (stderr
, "gdb: ");
96 vfprintf (stderr
, string
, args
);
97 fprintf (stderr
, "\n");