go to single .html
[fw/sdcc] / doc / SDCCUdoc-28.html
index cb2e167bf855839958c873a88fb74e25e19de423..f5247e320400334e1737937b2006d8ec6f041466 100644 (file)
@@ -1,8 +1,8 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <HTML>
 <HEAD>
- <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
- <TITLE>SDCC Compiler User Guide: Conclusion</TITLE>
+ <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7">
+ <TITLE>SDCC Compiler User Guide: SDCDB - Source level debugger.</TITLE>
  <LINK HREF="SDCCUdoc-29.html" REL=next>
  <LINK HREF="SDCCUdoc-27.html" REL=previous>
  <LINK HREF="SDCCUdoc.html#toc28" REL=contents>
 <A HREF="SDCCUdoc-27.html">Previous</A>
 <A HREF="SDCCUdoc.html#toc28">Contents</A>
 <HR>
-<H2><A NAME="Conclusion"></A> <A NAME="s28">28. Conclusion</A> </H2>
-
-<P>SDCC is a large project , the compiler alone (without the Assembler Package
-, Preprocessor &amp; garbage collector) is about 40,000 lines of code (blank
-stripped). As with any project of this size there are bound to be bugs, I am
-more than willing to work to fix these bugs , of course all the source code
-is included with the package. 
-<P>Where does it go from here ? I am planning to target the Atmel AVR 8-bit
-MCUs which seems to have a lot of users. I am also planning to include an alias
-analysis system with this compiler (it does not currently have one).
+<H2><A NAME="s28">28. SDCDB - Source level debugger.</A> </H2>
+
+<P>SDCC is distributed with a source level debugger. The debugger uses a command
+line interface, the command repertoire of the debugger has been kept as close
+to gdb ( the GNU debugger) as possible. The configuration and build process
+of the compiler see Installation 
+<A HREF="SDCCUdoc-2.html#Installation"></A> also builds and installs the debugger in
+the target directory specified during configuration. The debugger allows you
+debug BOTH at the C source and at the ASM source level.
+<H2><A NAME="ss28.1">28.1 Compiling for debugging.</A>
+ </H2>
+
+<P>The --debug option must be specified for all files for which debug information
+is to be generated. The complier generates a .cdb file for each of these files.
+The linker updates the .cdb file with the address information. This .cdb is
+used by the debugger .
+<H2><A NAME="ss28.2">28.2 How the debugger works.</A>
+ </H2>
+
+<P>When the --debug option is specified the compiler generates extra symbol
+information some of which are put into the the assembler source and some are
+put into the .cdb file, the linker updates the .cdb file with the address information
+for the symbols. The debugger reads the symbolic information generated by the
+compiler &amp; the address information generated by the linker. It uses the
+SIMULATOR (Daniel's S51) to execute the program, the program execution is controlled
+by the debugger. When a command is issued for the debugger, it translates it
+into appropriate commands for the simulator .
+<H2><A NAME="ss28.3">28.3 Starting the debugger.</A>
+ </H2>
+
+<P>The debugger can be started using the following command line. (Assume the
+file you are debugging has
+<P>the file name foo).
+<P>
+<PRE>
+&gt;sdcdb foo
+</PRE>
+<P>The debugger will look for the following files.
+<P>
+<OL>
+<LI>foo.c - the source file.</LI>
+<LI>foo.cdb - the debugger symbol information file.</LI>
+<LI>foo.ihx - the intel hex format object file.</LI>
+</OL>
+<H2><A NAME="ss28.4">28.4 Command line options.</A>
+ </H2>
+
+<P>
+<UL>
+<LI>--directory=&lt;source file directory&gt; this option can used to specify
+the directory search list. The debugger will look into the directory list specified
+for source , cdb &amp; ihx files. The items in the directory list must be separated
+by ':' , e.g. if the source files can be in the directories /home/src1 and
+/home/src2, the --directory option should be --directory=/home/src1:/home/src2
+. Note there can be no spaces in the option. </LI>
+<LI>-cd &lt;directory&gt; - change to the &lt;directory&gt;.</LI>
+<LI>-fullname - used by GUI front ends.</LI>
+<LI>-cpu &lt;cpu-type&gt; - this argument is passed to the simulator please
+see the simulator docs for details.</LI>
+<LI>-X &lt;Clock frequency &gt; this options is passed to the simulator please
+see simulator docs for details.</LI>
+<LI>-s &lt;serial port file&gt; passed to simulator see simulator docs for
+details.</LI>
+<LI>-S &lt;serial in,out&gt; passed to simulator see simulator docs for details.</LI>
+</UL>
+<H2><A NAME="ss28.5">28.5 Debugger Commands.</A>
+ </H2>
+
+<P>As mention earlier the command interface for the debugger has been deliberately
+kept as close the GNU debugger gdb , as possible, this will help int integration
+with existing graphical user interfaces (like ddd, xxgdb or xemacs) existing
+for the GNU debugger.
+<H3>break [line | file:line | function | file:function] </H3>
+
+<P>Set breakpoint at specified line or function.
+<P>
+<PRE>
+sdcdb&gt;break 100 
+sdcdb&gt;break foo.c:100
+sdcdb&gt;break funcfoo
+sdcdb&gt;break
+ foo.c:funcfoo
+</PRE>
+<H3>clear [line | file:line | function | file:function ] </H3>
+
+<P>Clear breakpoint at specified line or function.
+<P>
+<PRE>
+sdcdb&gt;clear 100
+sdcdb&gt;clear foo.c:100
+sdcdb&gt;clear funcfoo
+sdcdb&gt;clear
+ foo.c:funcfoo
+</PRE>
+<H3>continue </H3>
+
+<P>Continue program being debugged, after breakpoint.
+<H3>finish </H3>
+
+<P>Execute till the end of the current function.
+<H3>delete [n] </H3>
+
+<P>Delete breakpoint number 'n'. If used without any option clear ALL user
+defined break points.
+<H3>info [break | stack | frame | registers ] </H3>
+
+<P>
+<UL>
+<LI>info break - list all breakpoints</LI>
+<LI>info stack - show the function call stack.</LI>
+<LI>info frame - show information about the current execution frame.</LI>
+<LI>info registers - show content of all registers.</LI>
+</UL>
+<H3>step </H3>
+
+<P>Step program until it reaches a different source line.
+<H3>next </H3>
+
+<P>Step program, proceeding through subroutine calls.
+<H3>run </H3>
+
+<P>Start debugged program.
+<H3>ptype variable  </H3>
+
+<P>Print type information of the variable.
+<H3>print variable </H3>
+
+<P>print value of variable.
+<H3>file filename </H3>
+
+<P>load the given file name. Note this is an alternate method of loading file
+for debugging.
+<H3>frame </H3>
+
+<P>print information about current frame.
+<H3>set srcmode </H3>
+
+<P>Toggle between C source &amp; assembly source.
+<H3>! simulator command </H3>
+
+<P>Send the string following '!' to the simulator, the simulator response
+is displayed. Note the debugger does not interpret the command being sent to
+the simulator, so if a command like 'go' is sent the debugger can loose its
+execution context and may display incorrect values.
+<H3>quit. </H3>
+
+<P>&quot;Watch me now. Iam going Down. My name is Bobby Brown&quot;
+<H2><A NAME="ss28.6">28.6 Interfacing with XEmacs.</A>
+ </H2>
+
+<P>Two files are (in emacs lisp) are provided for the interfacing with XEmacs,
+sdcdb.el and sdcdbsrc.el. These two files can be found in the $(prefix)/bin
+directory after the installation is complete. These files need to be loaded
+into XEmacs for the interface to work, this can be done at XEmacs startup time
+by inserting the following into your '.xemacs' file (which can be found in
+your HOME directory) (load-file sdcdbsrc.el) [ .xemacs is a lisp file
+so the () around the command is REQUIRED), the files can also be loaded dynamically
+while XEmacs is running, set the environment variable 'EMACSLOADPATH' to the
+installation bin directory [$(prefix)/bin], then enter the
+following command ESC-x load-file sdcdbsrc . To start the interface enter the
+following command ESC-x sdcdbsrc , you will prompted to enter the file name
+to be debugged. 
+<P>The command line options that are passed to the simulator directly are
+bound to default values in the file sdcdbsrc.el the variables are listed below
+these values maybe changed as required.
+<P>
+<UL>
+<LI>sdcdbsrc-cpu-type '51</LI>
+<LI>sdcdbsrc-frequency '11059200</LI>
+<LI>sdcdbsrc-serial nil</LI>
+</UL>
+<P>The following is a list of key mapping for the debugger interface.
+<P>
+<PRE>
+;; Current Listing :: 
+;;key               binding                      Comment
+;;---               -------                      ------- 
+;; 
+;; n              
+ sdcdb-next-from-src          SDCDB next command 
+;; b               sdcdb-back-from-src          SDCDB
+ back command 
+;; c               sdcdb-cont-from-src          SDCDB continue
+ command
+;; s               sdcdb-step-from-src          SDCDB step command
+;; ?               sdcdb-whatis-c-sexp          SDCDB ptypecommand for data
+ at 
+;;                                           buffer point 
+;; x              
+ sdcdbsrc-delete              SDCDB Delete all breakpoints if no arg 
+;;                                              given
+ or delete arg (C-u arg x) 
+;; m               sdcdbsrc-frame               SDCDB
+ Display current frame if no arg, 
+;;                                              given
+ or display frame arg 
+;;                                             buffer
+ point 
+;; !               sdcdbsrc-goto-sdcdb          Goto the SDCDB output
+ buffer 
+;; p               sdcdb-print-c-sexp           SDCDB print command
+ for data at 
+;;                                           buffer point 
+;;
+ g               sdcdbsrc-goto-sdcdb          Goto the SDCDB output buffer 
+;;
+ t               sdcdbsrc-mode                Toggles Sdcdbsrc mode (turns it
+ off) 
+;; 
+;; C-c C-f         sdcdb-finish-from-src        SDCDB finish command
+;; 
+;; C-x SPC         sdcdb-break                  Set break for line with
+ point 
+;; ESC t           sdcdbsrc-mode                Toggle Sdcdbsrc mode
+;; ESC m           sdcdbsrc-srcmode             Toggle list mode 
+;; 
+
+</PRE>
 <HR>
 <A HREF="SDCCUdoc-29.html">Next</A>
 <A HREF="SDCCUdoc-27.html">Previous</A>