* sunos.c (sunos_create_dynamic_sections): We need the dynamic
[deliverable/binutils-gdb.git] / gdb / debugify.c
CommitLineData
4659e3b3
DP
1
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <stdarg.h>
6
7#define DEBUGIFY
8#include "debugify.h"
9
10#define REDIRECT
11
12static FILE *fout=NULL;
13static char fname[128];
14static int file_cnt=0; /* count number of open files */
15
16void puts_dbg(const char *data)
17{
18 FILE *fdbg;
19
20 fdbg=fopen("dbg.log","a+");
21 if (fdbg==NULL)
22 return;
23 fprintf(fdbg,data);
24 fclose(fdbg);
25}
26
27/* Can't easily get the message back to gdb... write to a log instead. */
28void fputs_dbg (const char *data, FILE * fakestream)
29{
30#ifdef REDIRECT
31 puts_dbg(data);
32#else /* REDIRECT */
33
34 //CIOLogView_output (s);
35 if (fakestream==stdout || fakestream==stderr || fakestream==NULL)
36 {
37 if (fout==NULL)
38 {
39 for (file_cnt=0; file_cnt<20; file_cnt++)
40 {
41 sprintf(fname,"dbg%d.log",file_cnt);
42 if ((fout=fopen(fname),"r")!=NULL)
43 fclose(fout);
44 else
45 break;
46 }
47 fout=fopen(fname,"w");
48 if (fout==NULL)
49 return;
50 }
51 fakestream=fout;
52 }
53 fprintf(fakestream,data);
54 fflush(fakestream);
55#endif /* REDIRECT */
56}
57
58void printf_dbg(const char* format,...)
59{
60 va_list args;
61 char buf[256];
62 va_start (args, format);
63 vsprintf (buf, format, args);
64 puts_dbg(buf);
65 va_end (args);
66}
This page took 0.024729 seconds and 4 git commands to generate.