* elf32-v850.c (v850_elf_relocate_section): Make sure r_symndx
[deliverable/binutils-gdb.git] / gdb / debugify.c
CommitLineData
4659e3b3 1
27e81a4e
DP
2/* Debug macros for developemnt.
3 Copyright 1997
4 Free Software Foundation, Inc.
5
6This file is part of GDB.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
4659e3b3 22#include <stdio.h>
27e81a4e 23#ifdef HAVE_STDLIB_H
4659e3b3 24#include <stdlib.h>
27e81a4e
DP
25#endif
26#ifdef HAVE_STRING_H
4659e3b3 27#include <string.h>
27e81a4e
DP
28#else
29#include <strings.h>
30#endif
4659e3b3
DP
31
32#define DEBUGIFY
33#include "debugify.h"
34
35#define REDIRECT
36
27e81a4e 37static FILE *fout = NULL;
4659e3b3 38static char fname[128];
27e81a4e 39static int file_cnt = 0; /* count number of open files */
4659e3b3 40
27e81a4e 41void
8662603f
DP
42puts_dbg (data)
43 const char *data;
4659e3b3 44{
27e81a4e 45 FILE *fdbg;
4659e3b3 46
27e81a4e
DP
47 fdbg = fopen ("dbg.log", "a+");
48 if (fdbg == NULL)
49 return;
50 fprintf (fdbg, data);
51 fclose (fdbg);
4659e3b3
DP
52}
53
54/* Can't easily get the message back to gdb... write to a log instead. */
27e81a4e 55void
8662603f
DP
56fputs_dbg (data, fakestream)
57 const char *data;
58 FILE *fakestream;
4659e3b3
DP
59{
60#ifdef REDIRECT
27e81a4e 61 puts_dbg (data);
4659e3b3 62#else /* REDIRECT */
27e81a4e
DP
63
64 if (fakestream == stdout || fakestream == stderr || fakestream == NULL)
65 {
66 if (fout == NULL)
67 {
68 for (file_cnt = 0; file_cnt < 20; file_cnt++)
69 {
70 sprintf (fname, "dbg%d.log", file_cnt);
71 if ((fout = fopen (fname), "r") != NULL)
72 fclose (fout);
73 else
74 break;
75 }
76 fout = fopen (fname, "w");
77 if (fout == NULL)
78 return;
79 }
80 fakestream = fout;
81 }
82 fprintf (fakestream, data);
83 fflush (fakestream);
4659e3b3
DP
84#endif /* REDIRECT */
85}
86
27e81a4e 87void
8662603f 88#ifdef ANSI_PROTOTYPES
27e81a4e 89printf_dbg (const char *format,...)
8662603f
DP
90#else
91printf_dbg (va_alist)
92 va_dcl
93#endif
4659e3b3
DP
94{
95 va_list args;
96 char buf[256];
8662603f 97#ifdef ANSI_PROTOTYPES
4659e3b3 98 va_start (args, format);
8662603f
DP
99#else
100 char *format;
101
102 va_start (args);
103 format = va_arg (args, char *);
104#endif
4659e3b3 105 vsprintf (buf, format, args);
27e81a4e 106 puts_dbg (buf);
4659e3b3
DP
107 va_end (args);
108}
This page took 0.027625 seconds and 4 git commands to generate.