|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 12928 (0x3280) Types: TextFile Names: »CDB.DOC«
└─⟦1275f6521⟧ Bits:30005823 BD Software C Compiler v1.50a └─ ⟦this⟧ »CDB.DOC« └─⟦b35f94715⟧ Bits:30003295 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo └─⟦b35f94715⟧ Bits:30005324 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo └─ ⟦this⟧ »CDB.DOC«
CDB: A Debugger for BDS C page 1 CDB: A Debugger for BDS C Version 1.2 4 November 1982 David Kirkland 5915 Yale Station New Haven, Connecticut 06520 (203) 787-9764 Copyright (c) 1982 by David Kirkland This document is a continuation of the CDB Appendix from the BDS C User's Guide. It is supplied on disk instead of on paper because of the large number of characters that are unprintable on the daisy wheel currently being used to run off the User's Guide. Note that all really useful reference material is in the CDB Appendix of the User's Guide; the main items given here are a file listing and a sample CDB session. Files Supplied The following CDB-related files are supplied on the CDB distribution disk: L2.C ø source code for L2 linker CHARIO.C ø L2.COM executable form of L2 linker CDB.DOC this file CDB.H header file for CDB.COM and CDB2.OVL CDB.COM prepared for BDOS at or above D000 CDB1.H ø CDB.C ø source code for CDB.COM BUILD.C ø CDB2.OVL prepared for BDOS at or above D300 CDB: A Debugger for BDS C page 2 CDB2.H ø CDB2.C ø ATBREAK.C ø BREAK.C ø source code for CDB2.OVL COMMAND.C ø PRINT.C ø PARSE.C ø UTIL.C ø DASM.CSM ø DASM.CRL CRL version of DASM.CSM CDB.SUB command file to simplify compilation and linkage of CDB.COM CDB2.SUB command file to simplify compilation of CDB2 components LCDB2.SUB command file to simplify linkage of CDB2.OVL An Example -- A CDB Debugging Session This section contains a transcript of a debugging session to demonstrate the use of CDB. The target program, which is contained in the file TARGET.C, is as follows: /* * /.C David Kirkland, 20 October 1982 * * This is a short submit program. It is designed to be used * when the user wants to batch a few commands, but it's too * much trouble to edit a SUB file to do the work. It can be * used in two forms: * * B>/ command line 1; command line 2; ... command line n * * or * * B>/ * åcommand 1 * åcommand 2 * . * . * åcommand n * å * * In the first form, the / command is entered with arguments. * group of characters delimited by a semicolon (or the end of * the line) is treated as a separate command. * CDB: A Debugger for BDS C page 3 * In the second form, / is entered without arguments. * / then prompts with a "å", and the user enters commands, one * per line. A null line terminates command entry. * (To enter a null line, enter a singe ^ on the line.) * * In either form, control characters can be entered either * directly or via a sequence beginning with a "^" and followed * by a letter or one of the characters: Æ Ø Å ^ _ * */ #include <bdscio.h> #define OPEN 15 /* BDOS function codes */ #define CLOSE 16 #define DELETE 19 #define CREATE 22 #define SET_DMA 26 #define RAND_WRITE 34 #define COMPUTE_SIZE 35 struct fcb æ /* define fcb format */ char drivecode; char fnameÆ8Å; char ftypeÆ3Å; char extent; char padÆ2Å; char rc; int blkÆ8Å; char cr; int rand_rec; char overflow; å; #define CPMEOF 0x1a #define MAXBLK 256 #define SUBNAME "A:$$$.SUB" struct fcb ffcb; /* the way a record from the $$$.SUB */ struct subrec æ /* file looks: */ char reclen; /* number of characters in command */ char alineÆ127Å; /* command line */ å ; struct subrec outÆ128Å; storeline(block,line) int block; char *line; æ /* storeline takes the line pointed to by "line" and * converts it to $$$.SUB representation and stores * it in outÆblockÅ. CDB: A Debugger for BDS C page 4 * This routine handles control characters (the ^ * escape sequence). * */ char *p; struct subrec *b; int i, len; b = outÆblockÅ; /* copy line into out.aline, processing control chars */ for (p = b->aline; *p = *line; p++, line++) if (*line=='^') if ('@' <= toupper(*++line) && toupper(*line) <= '_') *p = 0x1f&*line; else if (*p = *line) break; /* set up length byte */ b->reclen = len = strlen(b->aline); if (len>127) æ printf("Line %d is too long (%d > %d)Øn",block,len,127); bdos(DELETE,ffcb); exit(); å /* pad block with CPMEOFs (not needed?) */ for (i=len+2;i<128;i++) *++p = CPMEOF; å main (argc, argv) int argc; char *argvÆÅ; æ char *p, /* points to ; that ended current command */ *b, /* current character in command */ done; /* loop control */ char lineÆ256Å, *gets(); int block; /* index into out array */ block = 0; if (argc<2) /* prompt user format */ while (1) æ putchar('å'); if (!*gets(line)) break; storeline(block++, line); å else æ /* scan command line in low memory */ CDB: A Debugger for BDS C page 5 b = p = 0x80; for (done=0; !done; p = b) æ /* skip leading whitespace */ while (isspace(*++b)) p = b; while (*b && *b!=';') b++; done = !*b; *b = 0; storeline(block++, p+1); å å setfcb(ffcb,SUBNAME); if (255==bdos(OPEN,ffcb) && 255==bdos(CREATE,ffcb)) æ printf("Can't create %sØn",SUBNAME); exit(); å /* find end of $$$.SUB so submits can nest */ bdos(COMPUTE_SIZE,ffcb); /* write blocks in REVERSE order for CCP */ for(--block; block >= 0; block--) æ bdos(SET_DMA, outÆblockÅ); bdos(RAND_WRITE, ffcb); ffcb.rand_rec++; å /* all done! */ if (255==bdos(CLOSE,ffcb)) printf("Could not close %sØn",SUBNAME); å The debugging session follows. Text typed by the user is in boldface. ----- Start of Session ----- B> B>cc target.c -k BD Software C Compiler v1.50 (part I) 35K Unused BD Software C Compiler v1.50 (part II) 32K to spare B>l2 target -d Mark of the Unicorn Linker ver. 2.2.2 Loading TARGET.CRL Scanning A:DEFF.CRL Scanning A:DEFF2.CRL Link statistics: Number of functions: 17 Code ends at: 0x133B CDB: A Debugger for BDS C page 6 Externals begin at: 0x133B Externals end at: 0x535F End of current TPA: 0xE406 Jump table bytes saved: 0x5D Link space remaining: 26K B>cdb target c debugger ver 1.2 top of target stack is 8C94, cdb2 is at 9000 globals use 0160 bytes, locals use 00D9 bytes break at MAIN 0 Æ0A54Å >list map STORELIN 08A1 MAIN 0A51 TOUPPER 0CDA STRLEN 0D11 PRINTF 0D51 ISSPACE 0D79 ISLOWER 0DAF _SPR2 0DDE PUTS 113E _USPR 116A ISDIGIT 120C _GV2 123B BDOS 1298 EXIT 12AC GETS 12B2 PUTCHAR 12E6 SETFCB 1318 >list args argc Æ8C90Å = 0001 = 1 '..' argv Æ8C92Å = 0863 >break storeline >l breaks MAIN -1 STORELIN 0 >go ådir a: break at STORELIN 0 Æ08A4Å >list args block Æ8B81Å = 0000 = 0 '..' line Æ8B83Å = 8B8A >d *line string 8B8A (len 6): "dir a:" >trace 5 trace: STORELIN 15 Æ08AFÅ trace: STORELIN 18 Æ08CEÅ trace: STORELIN 18.1 Æ08DCÅ trace: STORELIN 19 Æ08F1Å break at STORELIN 27 Æ096DÅ >break 28 >go break at STORELIN 28 Æ09A6Å >dump *b a struct subrec reclen Æ135FÅ = 06 = '.' aline a 127 element array of char 1360 Æ 0Å 64 69 72 20 61 3a 00 00 00 00 00 00 00 00 00 00 'dir a:..........' 1370 Æ 16Å 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................' 1380 Æ 32Å 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................' CDB: A Debugger for BDS C page 7 1390 Æ 48Å 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................' 13A0 Æ 64Å 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................' 13B0 Æ 80Å 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................' 13C0 Æ 96Å 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................' 13D0 Æ112Å 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '...............' >d len Æ8B7BÅ = 0006 = 6 '..' >,b->reclen Æ135FÅ = 06 = '.' >b setfcb >go å break at SETFCB 0 Æ131BÅ >list args first argument address is 8B81 Æ1Å = 133B = 4923, Æ2Å = 0C97 = 3223, Æ3Å =01FE = 510 Æ4Å = 22Ca = 8906, Æ5Å = 0030 = 48, Æ6Å = 7269 = 29289 >t break at MAIN 33 Æ0BA1Å >dump ffcb a struct fcb drivecod Æ133BÅ = 01 = '.' fname a 8 element array of char 133C Æ 0Å 24 24 24 20 20 20 20 20 '$$$ ' ftype a 3 element array of char 1344 Æ 0Å 53 55 42 'SUB' extent Æ1347Å = 00 = '.' pad a 2 element array of char 1348 Æ 0Å 00 00 '..' rc Æ134AÅ = 00 = '.' blk a 8 element array of int 134B Æ 0Å 0000 0000 0000 0000 = 0 0 0 0 '........' 1353 Æ 4Å 0000 0000 0000 0000 = 0 0 0 0 '........' cr Æ135BÅ = 00 = '.' rand_rec Æ135CÅ = 0000 = 0 '..' overflow Æ135EÅ = 00 = '.' >t 5 trace: BDOS 0 Æ129BÅ trace: BDOS returning 00FF = 255 = '..' trace: BDOS 0 Æ129BÅ trace: BDOS returning 0001 = 1 = '..' break at MAIN 39 Æ0BE6Å >t break at BDOS 0 Æ129BÅ >t BDOS returning 00FF = 255 = '..' >t CDB: A Debugger for BDS C page 8 break at MAIN 42 Æ0BF6Å >go MAIN returning FF02 = -254 = '..' >quit B> ----- End of Session ----- «eof»