3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: ntoskrnl/dbg/rdebug.c
24 * PURPOSE: Runtime debugging support
25 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
27 * 01-05-2001 CSH Created
30 /* INCLUDES *****************************************************************/
34 #include <internal/debug.h>
36 /* GLOBALS ******************************************************************/
38 typedef struct _RDEBUG_ENTRY
{
40 CHAR Filename
[MAX_PATH
];
41 } RDEBUG_ENTRY
, *PRDEBUG_ENTRY
;
43 LIST_ENTRY RDebugListHead
;
44 BOOLEAN RDebugInitialized
= FALSE
;
46 /* FUNCTIONS ****************************************************************/
49 DbgpFind(PCH Filename
)
54 Current
= RDebugListHead
.Flink
;
55 while (Current
!= &RDebugListHead
)
57 Entry
= CONTAINING_RECORD(Current
, RDEBUG_ENTRY
, ListEntry
);
59 if (strcmp(Filename
, Entry
->Filename
) == 0)
63 Current
= Current
->Flink
;
72 if (RDebugInitialized
)
75 InitializeListHead(&RDebugListHead
);
76 RDebugInitialized
= TRUE
;
86 if (!RDebugInitialized
)
90 Current
= RDebugListHead
.Flink
;
91 while (Current
!= &RDebugListHead
)
93 Entry
= CONTAINING_RECORD(Current
, RDEBUG_ENTRY
, ListEntry
);
95 DbgPrint(" %s\n", Entry
->Filename
);
98 Current
= Current
->Flink
;
103 DbgPrint(" 1 file listed\n");
107 DbgPrint(" %d files listed\n", Count
);
112 DbgEnableFile(PCH Filename
)
116 if (!RDebugInitialized
)
119 if (!DbgpFind(Filename
))
121 Entry
= ExAllocatePool(NonPagedPool
, sizeof(RDEBUG_ENTRY
));
123 RtlMoveMemory(Entry
->Filename
, Filename
, strlen(Filename
) + 1);
124 InsertTailList(&RDebugListHead
, &Entry
->ListEntry
);
129 DbgDisableFile(PCH Filename
)
133 if (!RDebugInitialized
)
136 Entry
= DbgpFind(Filename
);
140 RemoveEntryList(&Entry
->ListEntry
);
145 DbgShouldPrint(PCH Filename
)
147 if (!RDebugInitialized
)
150 return(DbgpFind(Filename
) != NULL
);