* debugify.c, debugify.h: Fix for general gnu use. Remove C++
comment, add PARAMS, add license info and fix indentation.
This commit is contained in:
parent
62332d05fd
commit
27e81a4e1b
3 changed files with 100 additions and 42 deletions
|
@ -1,7 +1,12 @@
|
||||||
|
|
||||||
|
Wed Feb 12 15:08:47 1997 Dawn Perchik <dawn@cygnus.com>
|
||||||
|
|
||||||
|
* debugify.c, debugify.h: Fix for general gnu use. Remove C++
|
||||||
|
comment, add PARAMS, add license info and fix indentation.
|
||||||
|
|
||||||
Wed Feb 12 14:42:47 1997 Dawn Perchik <dawn@cygnus.com>
|
Wed Feb 12 14:42:47 1997 Dawn Perchik <dawn@cygnus.com>
|
||||||
|
|
||||||
* debugify.c, debugify.h: New files. Provide common macros
|
* debugify.c, debugify.h: New files. Provide common macros
|
||||||
for writing debug info to a log file or stdio.
|
for writing debug info to a log file or stdio.
|
||||||
|
|
||||||
Wed Feb 12 02:44:39 1997 Dawn Perchik <dawn@cygnus.com>
|
Wed Feb 12 02:44:39 1997 Dawn Perchik <dawn@cygnus.com>
|
||||||
|
|
103
gdb/debugify.c
103
gdb/debugify.c
|
@ -1,66 +1,99 @@
|
||||||
|
|
||||||
|
/* Debug macros for developemnt.
|
||||||
|
Copyright 1997
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GDB.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#else
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
#ifdef ANSI_PROTOTYPES
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
|
#include <varargs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define DEBUGIFY
|
#define DEBUGIFY
|
||||||
#include "debugify.h"
|
#include "debugify.h"
|
||||||
|
|
||||||
#define REDIRECT
|
#define REDIRECT
|
||||||
|
|
||||||
static FILE *fout=NULL;
|
static FILE *fout = NULL;
|
||||||
static char fname[128];
|
static char fname[128];
|
||||||
static int file_cnt=0; /* count number of open files */
|
static int file_cnt = 0; /* count number of open files */
|
||||||
|
|
||||||
void puts_dbg(const char *data)
|
void
|
||||||
|
puts_dbg (const char *data)
|
||||||
{
|
{
|
||||||
FILE *fdbg;
|
FILE *fdbg;
|
||||||
|
|
||||||
fdbg=fopen("dbg.log","a+");
|
fdbg = fopen ("dbg.log", "a+");
|
||||||
if (fdbg==NULL)
|
if (fdbg == NULL)
|
||||||
return;
|
return;
|
||||||
fprintf(fdbg,data);
|
fprintf (fdbg, data);
|
||||||
fclose(fdbg);
|
fclose (fdbg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can't easily get the message back to gdb... write to a log instead. */
|
/* Can't easily get the message back to gdb... write to a log instead. */
|
||||||
void fputs_dbg (const char *data, FILE * fakestream)
|
void
|
||||||
|
fputs_dbg (const char *data, FILE * fakestream)
|
||||||
{
|
{
|
||||||
#ifdef REDIRECT
|
#ifdef REDIRECT
|
||||||
puts_dbg(data);
|
puts_dbg (data);
|
||||||
#else /* REDIRECT */
|
#else /* REDIRECT */
|
||||||
|
|
||||||
//CIOLogView_output (s);
|
if (fakestream == stdout || fakestream == stderr || fakestream == NULL)
|
||||||
if (fakestream==stdout || fakestream==stderr || fakestream==NULL)
|
{
|
||||||
{
|
if (fout == NULL)
|
||||||
if (fout==NULL)
|
{
|
||||||
{
|
for (file_cnt = 0; file_cnt < 20; file_cnt++)
|
||||||
for (file_cnt=0; file_cnt<20; file_cnt++)
|
{
|
||||||
{
|
sprintf (fname, "dbg%d.log", file_cnt);
|
||||||
sprintf(fname,"dbg%d.log",file_cnt);
|
if ((fout = fopen (fname), "r") != NULL)
|
||||||
if ((fout=fopen(fname),"r")!=NULL)
|
fclose (fout);
|
||||||
fclose(fout);
|
else
|
||||||
else
|
break;
|
||||||
break;
|
}
|
||||||
}
|
fout = fopen (fname, "w");
|
||||||
fout=fopen(fname,"w");
|
if (fout == NULL)
|
||||||
if (fout==NULL)
|
return;
|
||||||
return;
|
}
|
||||||
}
|
fakestream = fout;
|
||||||
fakestream=fout;
|
}
|
||||||
}
|
fprintf (fakestream, data);
|
||||||
fprintf(fakestream,data);
|
fflush (fakestream);
|
||||||
fflush(fakestream);
|
|
||||||
#endif /* REDIRECT */
|
#endif /* REDIRECT */
|
||||||
}
|
}
|
||||||
|
|
||||||
void printf_dbg(const char* format,...)
|
void
|
||||||
|
printf_dbg (const char *format,...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
vsprintf (buf, format, args);
|
vsprintf (buf, format, args);
|
||||||
puts_dbg(buf);
|
puts_dbg (buf);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,24 @@
|
||||||
|
|
||||||
|
/* Debug macros for development.
|
||||||
|
Copyright 1997
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GDB.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#ifndef _DEBUGIFY_H_
|
#ifndef _DEBUGIFY_H_
|
||||||
#define _DEBUGIFY_H_
|
#define _DEBUGIFY_H_
|
||||||
|
|
||||||
|
@ -12,7 +32,7 @@
|
||||||
#define DBG(x) MessageBox x
|
#define DBG(x) MessageBox x
|
||||||
#else /* default: TO_FILE "gdb.log" */
|
#else /* default: TO_FILE "gdb.log" */
|
||||||
#define DBG(x) printf_dbg x
|
#define DBG(x) printf_dbg x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ASSERT(x) assert(x)
|
#define ASSERT(x) assert(x)
|
||||||
|
|
||||||
|
@ -22,21 +42,21 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef REDIRECT
|
#ifdef REDIRECT
|
||||||
#define printf_unfiltered printf_dbg
|
#define printf_unfiltered printf_dbg
|
||||||
#define fputs_unfiltered fputs_dbg
|
#define fputs_unfiltered fputs_dbg
|
||||||
void fputs_dbg (const char *fmt, FILE *fakestream);
|
extern void fputs_dbg PARAMS ((const char *fmt, FILE * fakestream));
|
||||||
#endif /* REDIRECT */
|
#endif /* REDIRECT */
|
||||||
|
|
||||||
void puts_dbg(const char *fmt);
|
extern void puts_dbg PARAMS ((const char *fmt));
|
||||||
void printf_dbg(const char *fmt,...);
|
extern void printf_dbg PARAMS ((const char *fmt,...));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _DEBUGIFY_H_ */
|
#endif /* _DEBUGIFY_H_ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue