5 Notes Feb 10, 2002 - Karl Bongers
7 SDCDB is a debugger for SDCC compiler. It works as a front
8 end to the ucSim simulator/disassembler program.
10 WARNING: SDCDB is EXPERIMENTAL and NOT A FULLY FUNCTIONING TOOL.
12 SDCDB does hold out promise for a nice debugger tool that
13 could integrate well with ucSim and other SDCC tools. It has
14 some nice functionality that could augment ucSim nicely.
15 It reads in a lot of symbolic information from the .CDB
16 debug files as well as the source code and assembly
17 listings referred to in these CDB files.
18 This can be used to display your program data, list
19 c or asm source code and set breakpoints.
21 Unfortunately, SDCDB is not quite finished and does not
22 function well enough yet to recommend for general use.
26 ======================
27 Compile with --debug option:
29 This should generate .cdb symbolic debug files.
31 Load sdcdb, like this:
34 Then you need to do an initial "run" command. It should hopefully
35 stop somewhere at the main() entrypoint.
37 Now you should be able to list code, and set breakpoints. Type
38 "c" to continue running to a breakpoint, or type "s" to single
39 step or "n" to skip function calls. Tpye "help" for a summary
42 Use a preceeding bang("!") to do s51 simulator commands. So for
45 will send the "pc" command to ucSim and
46 give you the program counter and list the current line of assembly.
48 will give you the brief command line help listing of ucSim. But
49 this help will scroll of the screen. So to get a list, I redirect
50 stdout to a text file to examine like this:
51 sdcdb hi.ihx 2>&1 | tee sdcdb.log
53 Type '.' to toggle to a full time ucSim prompt.
57 ======================
59 Ok, so what are some of its problems? Lets try to itemize
60 them so we can fix them:
62 * It hangs sometimes when trying to do step or next.
64 This probably has something to do with the context
65 sdcdb tries to build dynamically. Sdcdb tries to
66 trace program operation by placing hidden breakpoints
67 and stepping threw the simulation between these.
69 * Does not print variables properly. Seems to use the
70 wrong address for the variable. (fixed)
72 * ASM listing not implemented.
73 This should be easy enough to add. This feature
74 really needs to be implemented before this is a useful
75 tool. That or addresses of code functions need to be
76 readily available for raw ucSim commands.
78 * No way to browse symbols, files names.
79 Preferably, it is easy to learn the addresses of variables
81 (working on this... see new ls,lm,lf commands)
83 * Does not allow listing, setting breakpoints or viewing variables
84 before starting the simulation.
85 (I am fixing now, partly fixed)
87 * p codestr - print on code char * broken, could be CDB info invalid.
91 ======================
93 Added a -z option. Any options after -z on sdcdb invocation line
94 are passed directly to ucSim.
96 Fixed print basic variable command(was not parsing or expecting
97 "0x" in data coming from ucSim). Dump bit command changed from
100 Add support for the following alternative ucSim binaries:
101 -mz80 - use "uz80" simulator.
102 -mavr - use "uavr" simulator.
103 -mxa - use "uxa" simulator.
105 Note that Z80(and probably avr/xa) does not produce enough
106 CDB debugging information to
107 make SDCDB useful. Hopefully CDB support will be
108 added to these other linkers and code generators.
110 Added lf,lm,ls commands(list functions, list modules, list symbols).
111 This allows browsing some the CDB information SDCDB pulls in
112 to do the wonderful things it does.
114 Added '.' prefix/command, used alone switches back and forth
115 from ucSim/SDCDB command mode). Also when at the (ucsim) prompt,
116 if a command is prefixed with '.' it will route the command to
117 the SDCDB command processor. (This could obsolete the '!' prefix).
120 ======================
122 Fix any remaining shortcomings above and make sdcdb integrate better with
125 Concerning the hanging on next/step instructions: This is critical
126 to fix. I beleive the problem is related to SDCDB's attempt to
127 dynamically track context. To do this, it sets many temporary break
128 points and uses these to progress step by step through the source code.
129 It does not seem reliable. It might be an idea to offer a simplified
130 mode of stepping and breakpoints. Need to study this more.
132 Make SDCDB integrate better with ucSim.
133 I think if sdcdb can act more transparently in regard to ucSim
134 it would be used more. So stress adding value and enhancing
135 ucSim operation, and not block or hide the functionality of ucSim.
137 * combine print "p" & "pt" together. We have room on the screen,
138 might as well print its type, address and value in one command.
140 * "fr" command prints the current position in the C code.
141 Should also print the raw code address for dumping ucSim code.
146 ======================
147 To debug, it might be helpful to turn on verbose debug dumps
148 by uncommenting #define SDCDB_DEBUG in sdcdb.h.
151 sdcdb.c - main shell of the program.
152 cmd.c - process user commands typed in.
153 simi.c - handle talking to the simulator via a socket connection.
154 symtab.c - Misc. functions to translate and process linked list
155 structures(modules, functions, symbols, etc) and CDB file
157 break.c - track and implement break points.
159 Understanding the structures and access mechanisms of SDCDB
160 is a bit of work. The structures include generic linked list
161 and function access. These lists are accessed in part by the
162 functions from ../../src/SDCCset.c and SDCChash.c. See the
163 cmd.c:infoSymbols() routine to gain some insight into these
164 main program structures. Or type "info symbols" to dump
165 out some of these. The new ls,lm,lf commands are also based
166 on showing information about these lists of structures.
168 Generic functions are used to act on these linked lists of
169 structures. For example, in cmd.c, DEFSETFUNC(funcWithName)
170 function will find a function structure with a given name.
171 So the linked list of function structures(with the head
172 "functions") is traversed and when one is found with a matching
173 name, a pointer to the function structure is returned.
175 The src/SDCCset.c,SDCCset.h contain much of the core helper
176 routines to allowed to implement these linked list access
179 The dynamic context tracking is difficult to understand.
180 It has some concept of stack use, as in
181 cmd.c:printSymValue(), where it can print variables relative
182 to the stack pointer.