File: debug.c

package info (click to toggle)
anjuta 1.2.2-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 24,732 kB
  • ctags: 12,398
  • sloc: ansic: 82,587; cpp: 35,104; sh: 8,591; xml: 7,210; makefile: 981; python: 157
file content (115 lines) | stat: -rw-r--r-- 2,665 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
*
*   Copyright (c) 1996-2001, Darren Hiebert
*
*   This source code is released for free distribution under the terms of the
*   GNU General Public License.
*
*   This module contains debugging functions.
*/

/*
*   INCLUDE FILES
*/
#include "general.h"	/* must always come first */

#include <ctype.h>
#include <stdarg.h>

#include "debug.h"
#include "options.h"
#include "read.h"

/*
*   FUNCTION DEFINITIONS
*/

#ifdef TM_DEBUG

extern void lineBreak (void) {}	/* provides a line-specified break point */

extern void debugPrintf ( const enum eDebugLevels level,
			 const char *const format, ... )
{
    va_list ap;

    va_start (ap, format);
    if (debug (level))
	vprintf (format, ap);
    fflush (stdout);
    va_end (ap);
}

extern void debugPutc (const int level, const int c)
{
    if (debug (level)  &&  c != EOF)
    {
    	     if (c == STRING_SYMBOL)	printf ("\"string\"");
    	else if (c == CHAR_SYMBOL)	printf ("'c'");
	else				putchar (c);

	fflush (stdout);
    }
}

extern void debugParseNest (const boolean increase, const unsigned int level)
{
    debugPrintf (DEBUG_PARSE, "<*%snesting:%d*>", increase ? "++" : "--", level);
}

extern void debugCppNest (const boolean begin, const unsigned int level)
{
    debugPrintf (DEBUG_CPP, "<*cpp:%s level %d*>", begin ? "begin":"end", level);
}

extern void debugCppIgnore (const boolean ignore)
{
    debugPrintf (DEBUG_CPP, "<*cpp:%s ignore*>", ignore ? "begin":"end");
}

extern void clearString (char *const string, const int length)
{
    int i;

    for (i = 0 ; i < length ; ++i)
	string [i] = '\0';
}

extern void debugEntry (const tagEntryInfo *const tag)
{
    const char *const scope = tag->isFileScope ? "{fs}" : "";

    if (debug (DEBUG_PARSE))
    {
	printf ("<#%s%s:%s", scope, tag->kindName, tag->name);

	if (Option.extensionFields.access  &&
		tag->extensionFields.scope [0] != NULL  &&
		tag->extensionFields.scope [1] != NULL)
	    printf (" [%s:%s]", tag->extensionFields.scope [0],
		    tag->extensionFields.scope [1]);

	if (Option.extensionFields.inheritance  &&
		tag->extensionFields.inheritance != NULL)
	    printf (" [inherits:%s]", tag->extensionFields.inheritance);

	if (Option.extensionFields.fileScope &&
		tag->isFileScope && ! isHeaderFile ())
	    printf (" [file:]");

	if (Option.extensionFields.access  &&
		tag->extensionFields.access != NULL)
	    printf (" [access:%s]", tag->extensionFields.access);

	if (Option.extensionFields.implementation  &&
		tag->extensionFields.implementation != NULL)
	    printf (" [imp:%s]", tag->extensionFields.implementation);

	printf ("#>");
	fflush (stdout);
    }
}

#endif

/* vi:set tabstop=8 shiftwidth=4: */