1 /* General utility routines for the remote server for GDB.
2 Copyright (C) 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002, 2003,
3 2007 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., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
33 /* Generally useful subroutines used throughout the program. */
35 /* Print the system error message for errno, and also mention STRING
36 as the file name for which the error was encountered.
37 Then return to command level. */
40 perror_with_name (char *string)
45 err = strerror (errno);
47 err = "unknown error";
49 combined = (char *) alloca (strlen (err) + strlen (string) + 3);
50 strcpy (combined, string);
51 strcat (combined, ": ");
52 strcat (combined, err);
54 error ("%s.", combined);
57 /* Print an error message and return to command level.
58 STRING is the error message, used as a fprintf string,
59 and ARG is passed as an argument to it. */
62 error (const char *string,...)
64 extern jmp_buf toplevel;
66 va_start (args, string);
68 vfprintf (stderr, string, args);
69 fprintf (stderr, "\n");
70 longjmp (toplevel, 1);
73 /* Print an error message and exit reporting failure.
74 This is for a error that we cannot continue from.
75 STRING and ARG are passed to fprintf. */
79 fatal (const char *string,...)
82 va_start (args, string);
83 fprintf (stderr, "gdb: ");
84 vfprintf (stderr, string, args);
85 fprintf (stderr, "\n");
92 warning (const char *string,...)
95 va_start (args, string);
96 fprintf (stderr, "gdb: ");
97 vfprintf (stderr, string, args);
98 fprintf (stderr, "\n");