7 Martin Helmling added support for ddd GUI debugger.
8 Code added to display assembly, set variables, and other commands
13 in the attachment is my actual patch.
15 The 'up' and 'down' stack commands are not implemented.
16 But the features for 'ddd' to see bopth the c source and the assembler
18 also the display of variables.
19 Set variables are only implemented for basic types.
20 Register variables can also displayed, but here I think a problem in the
22 Sometimes the register name not exists:
24 S:LcacheTxAnalogValue$offset$1$1({1}SC:U),E,0,0
25 S:LcacheTxAnalogValue$i$1$1({1}SC:S),R,0,0,[]
26 S:LcacheTxAnalogValue$val$1$1({4}ST__00020000:S),E,0,0
27 S:LcacheTxAnalogValue$value$1$1({1}SC:U),R,0,0,[]
28 S:LcacheTxAnalogValue$sloc0$1$0({4}SL:U),E,0,0
29 S:LsetRelays$addr$1$1({1}SC:U),R,0,0,[r2]
30 S:LsetRelays$state$1$1({1}SC:U),R,0,0,[r3]
31 S:LsetRelays$value$1$1({1}SC:U),R,0,0,[r5]
32 S:L_main$i$1$1({1}SC:U),R,0,0,[]
33 S:L_main$j$1$1({1}SC:U),R,0,0,[r3]
34 S:L_main$ok$1$1({1}SC:U),R,0,0,[r3]
36 the empty [] I mean !!
38 Is this a known bug in sdcc ?
40 Also sometimes not the correct breakpoints for stepping found in sdcdb.
41 I try to fix this tomorrow.
45 Notes Feb 10, 2002 - Karl Bongers
47 SDCDB is a debugger for SDCC compiler. It works as a front
48 end to the ucSim simulator/disassembler program.
50 WARNING: SDCDB is EXPERIMENTAL and NOT A FULLY FUNCTIONING TOOL.
52 SDCDB does hold out promise for a nice debugger tool that
53 could integrate well with ucSim and other SDCC tools. It has
54 some nice functionality that could augment ucSim nicely.
55 It reads in a lot of symbolic information from the .CDB
56 debug files as well as the source code and assembly
57 listings referred to in these CDB files.
58 This can be used to display your program data, list
59 c or asm source code and set breakpoints.
61 Unfortunately, SDCDB is not quite finished and does not
62 function well enough yet to recommend for general use.
66 ======================
67 Compile with --debug option:
69 This should generate .cdb symbolic debug files.
71 Load sdcdb, like this:
74 Then you need to do an initial "run" command. It should hopefully
75 stop somewhere at the main() entrypoint.
77 Now you should be able to list code, and set breakpoints. Type
78 "c" to continue running to a breakpoint, or type "s" to single
79 step or "n" to skip function calls. Tpye "help" for a summary
82 Use a preceeding bang("!") to do s51 simulator commands. So for
85 will send the "pc" command to ucSim and
86 give you the program counter and list the current line of assembly.
88 will give you the brief command line help listing of ucSim. But
89 this help will scroll of the screen. So to get a list, I redirect
90 stdout to a text file to examine like this:
91 sdcdb hi.ihx 2>&1 | tee sdcdb.log
93 Type '.' to toggle to a full time ucSim prompt.
97 ======================
99 Ok, so what are some of its problems? Lets try to itemize
100 them so we can fix them:
102 * It hangs sometimes when trying to do step or next.
104 This probably has something to do with the context
105 sdcdb tries to build dynamically. Sdcdb tries to
106 trace program operation by placing hidden breakpoints
107 and stepping threw the simulation between these.
109 * Does not print variables properly. Seems to use the
110 wrong address for the variable. (fixed)
112 * ASM listing not implemented.
113 This should be easy enough to add. This feature
114 really needs to be implemented before this is a useful
115 tool. That or addresses of code functions need to be
116 readily available for raw ucSim commands.
118 * No way to browse symbols, files names.
119 Preferably, it is easy to learn the addresses of variables
121 (working on this... see new ls,lm,lf commands)
123 * Does not allow listing, setting breakpoints or viewing variables
124 before starting the simulation.
125 (I am fixing now, partly fixed)
127 * p codestr - print on code char * broken, could be CDB info invalid.
131 ======================
133 Added a -z option. Any options after -z on sdcdb invocation line
134 are passed directly to ucSim.
136 Fixed print basic variable command(was not parsing or expecting
137 "0x" in data coming from ucSim). Dump bit command changed from
140 Add support for the following alternative ucSim binaries:
141 -mz80 - use "uz80" simulator.
142 -mavr - use "uavr" simulator.
143 -mxa - use "uxa" simulator.
145 Note that Z80(and probably avr/xa) does not produce enough
146 CDB debugging information to
147 make SDCDB useful. Hopefully CDB support will be
148 added to these other linkers and code generators.
150 Added lf,lm,ls commands(list functions, list modules, list symbols).
151 This allows browsing some the CDB information SDCDB pulls in
152 to do the wonderful things it does.
154 Added '.' prefix/command, used alone switches back and forth
155 from ucSim/SDCDB command mode). Also when at the (ucsim) prompt,
156 if a command is prefixed with '.' it will route the command to
157 the SDCDB command processor. (This could obsolete the '!' prefix).
160 ======================
162 Fix any remaining shortcomings above and make sdcdb integrate better with
165 Concerning the hanging on next/step instructions: This is critical
166 to fix. I beleive the problem is related to SDCDB's attempt to
167 dynamically track context. To do this, it sets many temporary break
168 points and uses these to progress step by step through the source code.
169 It does not seem reliable. It might be an idea to offer a simplified
170 mode of stepping and breakpoints. Need to study this more.
172 Make SDCDB integrate better with ucSim.
173 I think if sdcdb can act more transparently in regard to ucSim
174 it would be used more. So stress adding value and enhancing
175 ucSim operation, and not block or hide the functionality of ucSim.
177 * combine print "p" & "pt" together. We have room on the screen,
178 might as well print its type, address and value in one command.
180 * "fr" command prints the current position in the C code.
181 Should also print the raw code address for dumping ucSim code.
186 ======================
187 To debug, it might be helpful to turn on verbose debug dumps
188 by uncommenting #define SDCDB_DEBUG in sdcdb.h.
191 sdcdb.c - main shell of the program.
192 cmd.c - process user commands typed in.
193 simi.c - handle talking to the simulator via a socket connection.
194 symtab.c - Misc. functions to translate and process linked list
195 structures(modules, functions, symbols, etc) and CDB file
197 break.c - track and implement break points.
199 Understanding the structures and access mechanisms of SDCDB
200 is a bit of work. The structures include generic linked list
201 and function access. These lists are accessed in part by the
202 functions from ../../src/SDCCset.c and SDCChash.c. See the
203 cmd.c:infoSymbols() routine to gain some insight into these
204 main program structures. Or type "info symbols" to dump
205 out some of these. The new ls,lm,lf commands are also based
206 on showing information about these lists of structures.
208 Generic functions are used to act on these linked lists of
209 structures. For example, in cmd.c, DEFSETFUNC(funcWithName)
210 function will find a function structure with a given name.
211 So the linked list of function structures(with the head
212 "functions") is traversed and when one is found with a matching
213 name, a pointer to the function structure is returned.
215 The src/SDCCset.c,SDCCset.h contain much of the core helper
216 routines to allowed to implement these linked list access
219 The dynamic context tracking is difficult to understand.
220 It has some concept of stack use, as in
221 cmd.c:printSymValue(), where it can print variables relative
222 to the stack pointer.