Skip to content

Commit 654e7b7

Browse files
committed
debug macro adjustments to separate what is printed in DEBUG mode
1 parent 7fd6a6b commit 654e7b7

File tree

3 files changed

+47
-46
lines changed

3 files changed

+47
-46
lines changed

hdr/debug.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ VOID panic(BYTE * s);
7676
/* #define DEBUGIRQ */
7777

7878
/* show output related to moving kernel into HMA */
79-
#ifdef DEBUG
79+
#ifdef DEBUGHMA
8080
#define HMAInitPrintf(x) DebugPrintf(x)
8181
#else
8282
#define HMAInitPrintf(x)
@@ -128,14 +128,23 @@ VOID panic(BYTE * s);
128128

129129
/* debug truename */
130130
#ifdef DEBUG
131+
#ifndef DEBUG_TRUENAME
131132
#define DEBUG_TRUENAME
132133
#endif
134+
#endif
133135
#ifdef DEBUG_TRUENAME
134136
#define tn_printf(x) DebugPrintf(x)
135137
#else
136138
#define tn_printf(x)
137139
#endif
138140

141+
/* debug task/process creation */
142+
#ifdef DEBUGTASK
143+
#define ProcDbgPrintf(x) DebugPrintf(x)
144+
#else
145+
#define ProcDbgPrintf(x)
146+
#endif
147+
139148

140149
/* ensure printf is prototyped */
141150
#if defined(DEBUG) || defined(DEBUGIRQ) || defined(DEBUGCFG) || \

kernel/config.c

+27-31
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@
3030
#include "portab.h"
3131
#include "init-mod.h"
3232
#include "dyndata.h"
33+
#include "debug.h"
3334

3435

35-
#ifdef DEBUG
36-
#define DebugPrintf(x) printf x
37-
#else
38-
#define DebugPrintf(x)
39-
#endif
4036
#define para2far(seg) ((mcb FAR *)MK_FP((seg), 0))
4137

4238
/**
@@ -338,7 +334,7 @@ void PreConfig(void)
338334
{
339335
/* Initialize the base memory pointers */
340336

341-
DebugPrintf(("SDA located at 0x%p\n", internal_data));
337+
CfgDbgPrintf(("SDA located at 0x%p\n", internal_data));
342338
/* Begin by initializing our system buffers */
343339
/* DebugPrintf(("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers));*/
344340

@@ -352,14 +348,14 @@ void PreConfig(void)
352348

353349
LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0);
354350

355-
/* DebugPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
356-
DebugPrintf((" sft table 0x%p\n", LoL->sfthead));
357-
DebugPrintf((" CDS table 0x%p\n", LoL->CDSp));
358-
DebugPrintf((" DPB table 0x%p\n", LoL->DPBp));
351+
/* CfgDbgPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
352+
CfgDbgPrintf((" sft table 0x%p\n", LoL->sfthead));
353+
CfgDbgPrintf((" CDS table 0x%p\n", LoL->CDSp));
354+
CfgDbgPrintf((" DPB table 0x%p\n", LoL->DPBp));
359355

360356
/* Done. Now initialize the MCB structure */
361357
/* This next line is 8086 and 80x86 real mode specific */
362-
DebugPrintf(("Preliminary allocation completed: top at %p\n", lpTop));
358+
CfgDbgPrintf(("Preliminary allocation completed: top at %p\n", lpTop));
363359
}
364360

365361
/* Do second pass initialization: near allocation and MCBs */
@@ -425,7 +421,7 @@ void PostConfig(void)
425421
if (LoL->lastdrive < LoL->nblkdev)
426422
LoL->lastdrive = LoL->nblkdev;
427423

428-
DebugPrintf(("starting FAR allocations at %x\n", base_seg));
424+
CfgDbgPrintf(("starting FAR allocations at %x\n", base_seg));
429425

430426
/* Begin by initializing our system buffers */
431427
/* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */
@@ -446,10 +442,10 @@ void PostConfig(void)
446442

447443
LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh);
448444

449-
/* DebugPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
450-
DebugPrintf((" sft table 0x%p\n", LoL->sfthead->sftt_next));
451-
DebugPrintf((" CDS table 0x%p\n", LoL->CDSp));
452-
DebugPrintf((" DPB table 0x%p\n", LoL->DPBp));
445+
/* CfgDbgPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
446+
CfgDbgPrintf((" sft table 0x%p\n", LoL->sfthead->sftt_next));
447+
CfgDbgPrintf((" CDS table 0x%p\n", LoL->CDSp));
448+
CfgDbgPrintf((" DPB table 0x%p\n", LoL->DPBp));
453449

454450
if (Config.cfgStacks)
455451
{
@@ -458,9 +454,9 @@ void PostConfig(void)
458454
Config.cfgStacksHigh);
459455
init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize);
460456

461-
DebugPrintf(("Stacks allocated at %p\n", stackBase));
457+
CfgDbgPrintf(("Stacks allocated at %p\n", stackBase));
462458
}
463-
DebugPrintf(("Allocation completed: top at 0x%x\n", base_seg));
459+
CfgDbgPrintf(("Allocation completed: top at 0x%x\n", base_seg));
464460

465461
}
466462

@@ -483,12 +479,12 @@ VOID configDone(VOID)
483479
p->m_name[1] = 'C';
484480
p->m_psp = 8;
485481

486-
DebugPrintf(("HMA not available, moving text to %x\n", kernel_seg));
482+
CfgDbgPrintf(("HMA not available, moving text to %x\n", kernel_seg));
487483
MoveKernel(kernel_seg);
488484

489485
kernel_seg += hma_paras + 1;
490486

491-
DebugPrintf(("kernel is low, start alloc at %x", kernel_seg));
487+
CfgDbgPrintf(("kernel is low, start alloc at %x\n", kernel_seg));
492488
}
493489

494490
/* The standard handles should be reopened here, because
@@ -590,7 +586,7 @@ STATIC void umb_init(void)
590586
}
591587
para2far(umb_max)->m_size++;
592588
para2far(umb_max)->m_type = MCB_LAST;
593-
DebugPrintf(("UMB Allocation completed: start at 0x%x\n", umb_base_seg));
589+
CfgDbgPrintf(("UMB Allocation completed: start at 0x%x\n", umb_base_seg));
594590
}
595591
}
596592

@@ -830,11 +826,11 @@ VOID DoConfig(int nPass)
830826
if (mdsk != NULL)
831827
{
832828
printf("MEMDISK version %u.%02u (%lu sectors)\n", mdsk->version, mdsk->version_minor, mdsk->size);
833-
DebugPrintf(("MEMDISK args:{%S}\n", mdsk->cmdline));
829+
CfgDbgPrintf(("MEMDISK args:{%S}\n", mdsk->cmdline));
834830
}
835831
else
836832
{
837-
DebugPrintf(("MEMDISK not detected!\n"));
833+
CfgDbgPrintf(("MEMDISK not detected!\n"));
838834
}
839835
#endif
840836
}
@@ -871,10 +867,10 @@ VOID DoConfig(int nPass)
871867
for (ii = 0; configcommands[ii].pointer != NULL; ++ii) {
872868
if (**configcommands[ii].pointer != '\0') {
873869
if ((nFileDesc = open(*configcommands[ii].pointer, 0)) >= 0) {
874-
DebugPrintf(("Reading \"%s\"...\n", *configcommands[ii].pointer));
870+
CfgDbgPrintf(("Reading \"%s\"...\n", *configcommands[ii].pointer));
875871
break;
876872
} else {
877-
DebugPrintf(("\"%s\" not found\n", *configcommands[ii].pointer));
873+
CfgDbgPrintf(("\"%s\" not found\n", *configcommands[ii].pointer));
878874
}
879875
}
880876
}
@@ -955,7 +951,7 @@ VOID DoConfig(int nPass)
955951
continue;
956952
}
957953

958-
DebugPrintf(("CONFIG=[%s]\n", szLine));
954+
CfgDbgPrintf(("CONFIG=[%s]\n", szLine));
959955

960956
/* Skip leading white space and get verb. */
961957
pLine = scan(szLine, szBuf, 1);
@@ -1828,7 +1824,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode)
18281824
/* The device driver is paragraph aligned. */
18291825
eb.load.reloc = eb.load.load_seg = base;
18301826

1831-
DebugPrintf(("Loading device driver %s at segment %04x\n", szBuf, base));
1827+
CfgDbgPrintf(("Loading device driver %s at segment %04x\n", szBuf, base));
18321828

18331829
if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS)
18341830
{
@@ -1923,7 +1919,7 @@ void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode)
19231919
}
19241920

19251921
/* create the special DOS data MCB if it doesn't exist yet */
1926-
DebugPrintf(("kernelallocpara: %x %x %x %c %d\n", start, base, nPara, type, mode));
1922+
CfgDbgPrintf(("kernelallocpara: %x %x %x %c %d\n", start, base, nPara, type, mode));
19271923

19281924
if (base == start)
19291925
{
@@ -2178,8 +2174,8 @@ STATIC void config_init_buffers(int wantedbuffers)
21782174
LoL->deblock_buf = DiskTransferBuffer;
21792175
LoL->firstbuf = pbuffer;
21802176

2181-
DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer)));
2182-
DebugPrintf((" (%p)", LoL->firstbuf));
2177+
CfgDbgPrintf(("init_buffers (size %u) at", sizeof(struct buffer)));
2178+
CfgDbgPrintf((" (%p)", LoL->firstbuf));
21832179

21842180
buffers--;
21852181
pbuffer->b_prev = FP_OFF(pbuffer + buffers);
@@ -2201,7 +2197,7 @@ STATIC void config_init_buffers(int wantedbuffers)
22012197
but not if the BUFFERS count is negative ;-)
22022198
*/
22032199

2204-
DebugPrintf((" done\n"));
2200+
CfgDbgPrintf((" done\n"));
22052201

22062202
if (FP_SEG(pbuffer) == 0xffff)
22072203
{

kernel/task.c

+10-14
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
144144
/* create a new environment for the process */
145145
/* copy parent's environment if exec.env_seg == 0 */
146146

147-
DebugPrintf(("ChildEnv: environment block is %u, using %s\n", exp->exec.env_seg, (exp->exec.env_seg)?"exec_blk":"parent_blk"));
147+
ProcDbgPrintf(("ChildEnv: environment block is %u, using %s\n", exp->exec.env_seg, (exp->exec.env_seg)?"exec_blk":"parent_blk"));
148148
pSrc = exp->exec.env_seg ?
149149
MK_FP(exp->exec.env_seg, 0) : MK_FP(ppsp->ps_environ, 0);
150150

@@ -181,13 +181,13 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
181181
Note: we must allocate at least 1 paragraph (16 bytes) for empty environment
182182
+ ENV_KEEPFREE for argv[0] (program name)
183183
*/
184-
DebugPrintf(("PriPathName is %lu bytes\n", sizeof(PriPathName)));
184+
/* ProcDbgPrintf(("PriPathName is %lu bytes\n", sizeof(PriPathName))); */
185185
assert(sizeof(PriPathName)+3==ENV_KEEPFREE);
186186
if ((RetCode = DosMemAlloc((nEnvSize + ENV_KEEPFREE + 15)/16,
187187
mem_access_mode, pChildEnvSeg,
188188
NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0)
189189
{
190-
DebugPrintf(("Error alloc Env space\n"));
190+
ProcDbgPrintf(("Error alloc Env space\n"));
191191
return RetCode;
192192
}
193193
pDest = MK_FP(*pChildEnvSeg + 1, 0); /* skip past MCB and set pDest to start of env block */
@@ -211,10 +211,10 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
211211
/* copy complete pathname */
212212
if ((RetCode = truename(pathname, PriPathName, CDS_MODE_SKIP_PHYSICAL)) < SUCCESS)
213213
{
214-
DebugPrintf(("Failed to get truename for env argv0\n"));
214+
ProcDbgPrintf(("Failed to get truename for env argv0\n"));
215215
return RetCode;
216216
}
217-
DebugPrintf(("ChildEnv for [%s]\n", PriPathName));
217+
ProcDbgPrintf(("ChildEnv for [%s]\n", PriPathName));
218218
fstrcpy(pDest, PriPathName);
219219

220220
/* Theoretically one could either:
@@ -487,7 +487,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
487487

488488
rc = ChildEnv(exp, &env, namep);
489489
#if DEBUG
490-
if (rc != SUCCESS) DebugPrintf(("Failed to create ChildEnv\n"));
490+
if (rc != SUCCESS) { ProcDbgPrintf(("Failed to create ChildEnv\n")); }
491491
#endif
492492

493493
/* COMFILES will always be loaded in largest area. is that true TE */
@@ -519,9 +519,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
519519
mem = exp->load.load_seg;
520520
}
521521

522-
#ifdef DEBUG
523-
printf("DosComLoader. Loading '%S' at %04x\n", namep, mem);
524-
#endif
522+
ProcDbgPrintf(("DosComLoader. Loading '%S' at %04x\n", namep, mem));
525523
/* Now load the executable */
526524
{
527525
BYTE FAR *sp;
@@ -670,7 +668,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
670668

671669
rc = ChildEnv(exp, &env, namep);
672670
#if DEBUG
673-
if (rc != SUCCESS) DebugPrintf(("Failed to create ChildEnv\n"));
671+
if (rc != SUCCESS) { ProcDbgPrintf(("Failed to create ChildEnv\n")); }
674672
#endif
675673

676674
if (rc == SUCCESS)
@@ -708,9 +706,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
708706

709707
mode &= 0x7f; /* forget about high loading from now on */
710708

711-
#ifdef DEBUG
712-
printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem);
713-
#endif
709+
ProcDbgPrintf(("DosExeLoader. Loading '%S' at %04x\n", namep, mem));
714710

715711
/* memory found large enough - continue processing */
716712
++mem;
@@ -909,7 +905,7 @@ VOID ASMCFUNC P_0(struct config FAR *Config)
909905
exb.exec.cmd_line = (CommandTail *)(tailp + 1);
910906
exb.exec.cmd_line->ctCount = endp - tailp - 2;
911907
#ifdef DEBUG
912-
printf("Process 0 starting: %s%s\n\n", Shell, tailp + 2);
908+
DebugPrintf(("Process 0 starting: %s%s\n\n", Shell, tailp + 2));
913909
#endif
914910
res_DosExec(mode, &exb, Shell);
915911
put_string("Bad or missing Command Interpreter: "); /* failure _or_ exit */

0 commit comments

Comments
 (0)