1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
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>
11 <A HREF="SDCCUdoc-29.html">Next</A>
12 <A HREF="SDCCUdoc-27.html">Previous</A>
13 <A HREF="SDCCUdoc.html#toc28">Contents</A>
15 <H2><A NAME="s28">28. SDCDB - Source level debugger.</A> </H2>
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>
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>
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 & 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>
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).
53 <P>The debugger will look for the following files.
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>
60 <H2><A NAME="ss28.4">28.4 Command line options.</A>
65 <LI>--directory=<source file directory> this option can used to specify
66 the directory search list. The debugger will look into the directory list specified
67 for source , cdb & 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 <directory> - change to the <directory>.</LI>
72 <LI>-fullname - used by GUI front ends.</LI>
73 <LI>-cpu <cpu-type> - this argument is passed to the simulator please
74 see the simulator docs for details.</LI>
75 <LI>-X <Clock frequency > this options is passed to the simulator please
76 see simulator docs for details.</LI>
77 <LI>-s <serial port file> passed to simulator see simulator docs for
79 <LI>-S <serial in,out> passed to simulator see simulator docs for details.</LI>
81 <H2><A NAME="ss28.5">28.5 Debugger Commands.</A>
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
88 <H3>break [line | file:line | function | file:function] </H3>
90 <P>Set breakpoint at specified line or function.
94 sdcdb>break foo.c:100
95 sdcdb>break funcfoo
100 <H3>clear [line | file:line | function | file:function ] </H3>
102 <P>Clear breakpoint at specified line or function.
106 sdcdb>clear foo.c:100
107 sdcdb>clear funcfoo
114 <P>Continue program being debugged, after breakpoint.
117 <P>Execute till the end of the current function.
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>
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>
133 <P>Step program until it reaches a different source line.
136 <P>Step program, proceeding through subroutine calls.
139 <P>Start debugged program.
140 <H3>ptype variable </H3>
142 <P>Print type information of the variable.
143 <H3>print variable </H3>
145 <P>print value of variable.
146 <H3>file filename </H3>
148 <P>load the given file name. Note this is an alternate method of loading file
152 <P>print information about current frame.
153 <H3>set srcmode </H3>
155 <P>Toggle between C source & assembly source.
156 <H3>! simulator command </H3>
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.
164 <P>"Watch me now. Iam going Down. My name is Bobby Brown"
165 <H2><A NAME="ss28.6">28.6 Interfacing with XEmacs.</A>
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
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.
185 <LI>sdcdbsrc-cpu-type '51</LI>
186 <LI>sdcdbsrc-frequency '11059200</LI>
187 <LI>sdcdbsrc-serial nil</LI>
189 <P>The following is a list of key mapping for the debugger interface.
193 ;; Current Listing ::
194 ;;key binding Comment
196 ;;--- ------- -------
199 sdcdb-next-from-src SDCDB next command
200 ;; b sdcdb-back-from-src SDCDB
202 ;; c sdcdb-cont-from-src SDCDB continue
204 ;; s sdcdb-step-from-src SDCDB step command
206 ;; ? sdcdb-whatis-c-sexp SDCDB ptypecommand for data
210 sdcdbsrc-delete SDCDB Delete all breakpoints if no arg
212 or delete arg (C-u arg x)
213 ;; m sdcdbsrc-frame SDCDB
214 Display current frame if no arg,
219 ;; ! sdcdbsrc-goto-sdcdb Goto the SDCDB output
221 ;; p sdcdb-print-c-sexp SDCDB print command
225 g sdcdbsrc-goto-sdcdb Goto the SDCDB output buffer
227 t sdcdbsrc-mode Toggles Sdcdbsrc mode (turns it
230 ;; C-c C-f sdcdb-finish-from-src SDCDB finish command
233 ;; C-x SPC sdcdb-break Set break for line with
235 ;; ESC t sdcdbsrc-mode Toggle Sdcdbsrc mode
237 ;; ESC m sdcdbsrc-srcmode Toggle list mode
243 <A HREF="SDCCUdoc-29.html">Next</A>
244 <A HREF="SDCCUdoc-27.html">Previous</A>
245 <A HREF="SDCCUdoc.html#toc28">Contents</A>