* mdebugread.c (parse_symbol): Use new variable
[deliverable/binutils-gdb.git] / gdb / gdbserver / utils.c
CommitLineData
e20520b8
SG
1/* General utility routines for the remote server for GDB.
2 Copyright (C) 1986, 1989, 1993 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
41e170e2 20#include "server.h"
e20520b8 21#include <stdio.h>
e20520b8 22
e20520b8
SG
23/* Generally useful subroutines used throughout the program. */
24
e20520b8
SG
25/* Print the system error message for errno, and also mention STRING
26 as the file name for which the error was encountered.
27 Then return to command level. */
28
29void
30perror_with_name (string)
31 char *string;
32{
33 extern int sys_nerr;
34 extern char *sys_errlist[];
35 extern int errno;
36 char *err;
37 char *combined;
38
39 if (errno < sys_nerr)
40 err = sys_errlist[errno];
41 else
42 err = "unknown error";
43
44 combined = (char *) alloca (strlen (err) + strlen (string) + 3);
45 strcpy (combined, string);
46 strcat (combined, ": ");
47 strcat (combined, err);
48
49 error ("%s.", combined);
50}
51
e20520b8
SG
52/* Print an error message and return to command level.
53 STRING is the error message, used as a fprintf string,
54 and ARG is passed as an argument to it. */
55
56NORETURN void
57error (string, arg1, arg2, arg3)
58 char *string;
59 int arg1, arg2, arg3;
60{
61 extern jmp_buf toplevel;
62
63 fflush (stdout);
64 fprintf (stderr, string, arg1, arg2, arg3);
65 fprintf (stderr, "\n");
66 longjmp(toplevel, 1);
67}
68
69/* Print an error message and exit reporting failure.
70 This is for a error that we cannot continue from.
71 STRING and ARG are passed to fprintf. */
72
73void
74fatal (string, arg)
75 char *string;
76 int arg;
77{
78 fprintf (stderr, "gdb: ");
79 fprintf (stderr, string, arg);
80 fprintf (stderr, "\n");
81 exit (1);
82}
This page took 0.117226 seconds and 4 git commands to generate.