Go to single file .html
[fw/sdcc] / doc / SDCCUdoc-28.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4  <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
5  <TITLE>SDCC Compiler User Guide: SDCDB - Source level debugger.</TITLE>
6  <LINK HREF="SDCCUdoc-29.html" REL=next>
7  <LINK HREF="SDCCUdoc-27.html" REL=previous>
8  <LINK HREF="SDCCUdoc.html#toc28" REL=contents>
9 </HEAD>
10 <BODY>
11 <A HREF="SDCCUdoc-29.html">Next</A>
12 <A HREF="SDCCUdoc-27.html">Previous</A>
13 <A HREF="SDCCUdoc.html#toc28">Contents</A>
14 <HR>
15 <H2><A NAME="s28">28. SDCDB - Source level debugger.</A> </H2>
16
17 <P>SDCC is distributed with a source level debugger. The debugger uses a command
18 line interface, the command repertoire of the debugger has been kept as close
19 to gdb ( the GNU debugger) as possible. The configuration and build process
20 of the compiler see Installation 
21 <A HREF="SDCCUdoc-2.html#Installation"></A> also builds and installs the debugger in
22 the target directory specified during configuration. The debugger allows you
23 debug BOTH at the C source and at the ASM source level.
24 <H2><A NAME="ss28.1">28.1 Compiling for debugging.</A>
25  </H2>
26
27 <P>The --debug option must be specified for all files for which debug information
28 is to be generated. The complier generates a .cdb file for each of these files.
29 The linker updates the .cdb file with the address information. This .cdb is
30 used by the debugger .
31 <H2><A NAME="ss28.2">28.2 How the debugger works.</A>
32  </H2>
33
34 <P>When the --debug option is specified the compiler generates extra symbol
35 information some of which are put into the the assembler source and some are
36 put into the .cdb file, the linker updates the .cdb file with the address information
37 for the symbols. The debugger reads the symbolic information generated by the
38 compiler &amp; the address information generated by the linker. It uses the
39 SIMULATOR (Daniel's S51) to execute the program, the program execution is controlled
40 by the debugger. When a command is issued for the debugger, it translates it
41 into appropriate commands for the simulator .
42 <H2><A NAME="ss28.3">28.3 Starting the debugger.</A>
43  </H2>
44
45 <P>The debugger can be started using the following command line. (Assume the
46 file you are debugging has
47 <P>the file name foo).
48 <P>
49 <PRE>
50 &gt;sdcdb foo
51  
52 </PRE>
53 <P>The debugger will look for the following files.
54 <P>
55 <OL>
56 <LI>foo.c - the source file.</LI>
57 <LI>foo.cdb - the debugger symbol information file.</LI>
58 <LI>foo.ihx - the intel hex format object file.</LI>
59 </OL>
60 <H2><A NAME="ss28.4">28.4 Command line options.</A>
61  </H2>
62
63 <P>
64 <UL>
65 <LI>--directory=&lt;source file directory&gt; this option can used to specify
66 the directory search list. The debugger will look into the directory list specified
67 for source , cdb &amp; ihx files. The items in the directory list must be separated
68 by ':' , e.g. if the source files can be in the directories /home/src1 and
69 /home/src2, the --directory option should be --directory=/home/src1:/home/src2
70 . Note there can be no spaces in the option. </LI>
71 <LI>-cd &lt;directory&gt; - change to the &lt;directory&gt;.</LI>
72 <LI>-fullname - used by GUI front ends.</LI>
73 <LI>-cpu &lt;cpu-type&gt; - this argument is passed to the simulator please
74 see the simulator docs for details.</LI>
75 <LI>-X &lt;Clock frequency &gt; this options is passed to the simulator please
76 see simulator docs for details.</LI>
77 <LI>-s &lt;serial port file&gt; passed to simulator see simulator docs for
78 details.</LI>
79 <LI>-S &lt;serial in,out&gt; passed to simulator see simulator docs for details.</LI>
80 </UL>
81 <H2><A NAME="ss28.5">28.5 Debugger Commands.</A>
82  </H2>
83
84 <P>As mention earlier the command interface for the debugger has been deliberately
85 kept as close the GNU debugger gdb , as possible, this will help int integration
86 with existing graphical user interfaces (like ddd, xxgdb or xemacs) existing
87 for the GNU debugger.
88 <H3>break [line | file:line | function | file:function] </H3>
89
90 <P>Set breakpoint at specified line or function.
91 <P>
92 <PRE>
93 sdcdb&gt;break 100 
94 sdcdb&gt;break foo.c:100
95 sdcdb&gt;break funcfoo
96 sdcdb&gt;break
97  foo.c:funcfoo
98  
99 </PRE>
100 <H3>clear [line | file:line | function | file:function ] </H3>
101
102 <P>Clear breakpoint at specified line or function.
103 <P>
104 <PRE>
105 sdcdb&gt;clear 100
106 sdcdb&gt;clear foo.c:100
107 sdcdb&gt;clear funcfoo
108 sdcdb&gt;clear
109  foo.c:funcfoo
110  
111 </PRE>
112 <H3>continue </H3>
113
114 <P>Continue program being debugged, after breakpoint.
115 <H3>finish </H3>
116
117 <P>Execute till the end of the current function.
118 <H3>delete [n] </H3>
119
120 <P>Delete breakpoint number 'n'. If used without any option clear ALL user
121 defined break points.
122 <H3>info [break | stack | frame | registers ] </H3>
123
124 <P>
125 <UL>
126 <LI>info break - list all breakpoints</LI>
127 <LI>info stack - show the function call stack.</LI>
128 <LI>info frame - show information about the current execution frame.</LI>
129 <LI>info registers - show content of all registers.</LI>
130 </UL>
131 <H3>step </H3>
132
133 <P>Step program until it reaches a different source line.
134 <H3>next </H3>
135
136 <P>Step program, proceeding through subroutine calls.
137 <H3>run </H3>
138
139 <P>Start debugged program.
140 <H3>ptype variable  </H3>
141
142 <P>Print type information of the variable.
143 <H3>print variable </H3>
144
145 <P>print value of variable.
146 <H3>file filename </H3>
147
148 <P>load the given file name. Note this is an alternate method of loading file
149 for debugging.
150 <H3>frame </H3>
151
152 <P>print information about current frame.
153 <H3>set srcmode </H3>
154
155 <P>Toggle between C source &amp; assembly source.
156 <H3>! simulator command </H3>
157
158 <P>Send the string following '!' to the simulator, the simulator response
159 is displayed. Note the debugger does not interpret the command being sent to
160 the simulator, so if a command like 'go' is sent the debugger can loose its
161 execution context and may display incorrect values.
162 <H3>quit. </H3>
163
164 <P>&quot;Watch me now. Iam going Down. My name is Bobby Brown&quot;
165 <H2><A NAME="ss28.6">28.6 Interfacing with XEmacs.</A>
166  </H2>
167
168 <P>Two files are (in emacs lisp) are provided for the interfacing with XEmacs,
169 sdcdb.el and sdcdbsrc.el. These two files can be found in the $(prefix)/bin
170 directory after the installation is complete. These files need to be loaded
171 into XEmacs for the interface to work, this can be done at XEmacs startup time
172 by inserting the following into your '.xemacs' file (which can be found in
173 your HOME directory) (load-file sdcdbsrc.el) [ .xemacs is a lisp file
174 so the () around the command is REQUIRED), the files can also be loaded dynamically
175 while XEmacs is running, set the environment variable 'EMACSLOADPATH' to the
176 installation bin directory [$(prefix)/bin], then enter the
177 following command ESC-x load-file sdcdbsrc . To start the interface enter the
178 following command ESC-x sdcdbsrc , you will prompted to enter the file name
179 to be debugged. 
180 <P>The command line options that are passed to the simulator directly are
181 bound to default values in the file sdcdbsrc.el the variables are listed below
182 these values maybe changed as required.
183 <P>
184 <UL>
185 <LI>sdcdbsrc-cpu-type '51</LI>
186 <LI>sdcdbsrc-frequency '11059200</LI>
187 <LI>sdcdbsrc-serial nil</LI>
188 </UL>
189 <P>The following is a list of key mapping for the debugger interface.
190 <P>
191 <PRE>
192  
193 ;; Current Listing :: 
194 ;;key               binding                      Comment
195  
196 ;;---               -------                      ------- 
197 ;; 
198 ;; n              
199  sdcdb-next-from-src          SDCDB next command 
200 ;; b               sdcdb-back-from-src          SDCDB
201  back command 
202 ;; c               sdcdb-cont-from-src          SDCDB continue
203  command
204 ;; s               sdcdb-step-from-src          SDCDB step command
205  
206 ;; ?               sdcdb-whatis-c-sexp          SDCDB ptypecommand for data
207  at 
208 ;;                                           buffer point 
209 ;; x              
210  sdcdbsrc-delete              SDCDB Delete all breakpoints if no arg 
211 ;;                                              given
212  or delete arg (C-u arg x) 
213 ;; m               sdcdbsrc-frame               SDCDB
214  Display current frame if no arg, 
215 ;;                                              given
216  or display frame arg 
217 ;;                                             buffer
218  point 
219 ;; !               sdcdbsrc-goto-sdcdb          Goto the SDCDB output
220  buffer 
221 ;; p               sdcdb-print-c-sexp           SDCDB print command
222  for data at 
223 ;;                                           buffer point 
224 ;;
225  g               sdcdbsrc-goto-sdcdb          Goto the SDCDB output buffer 
226 ;;
227  t               sdcdbsrc-mode                Toggles Sdcdbsrc mode (turns it
228  off) 
229 ;; 
230 ;; C-c C-f         sdcdb-finish-from-src        SDCDB finish command
231  
232 ;; 
233 ;; C-x SPC         sdcdb-break                  Set break for line with
234  point 
235 ;; ESC t           sdcdbsrc-mode                Toggle Sdcdbsrc mode
236  
237 ;; ESC m           sdcdbsrc-srcmode             Toggle list mode 
238 ;; 
239
240  
241 </PRE>
242 <HR>
243 <A HREF="SDCCUdoc-29.html">Next</A>
244 <A HREF="SDCCUdoc-27.html">Previous</A>
245 <A HREF="SDCCUdoc.html#toc28">Contents</A>
246 </BODY>
247 </HTML>