Next Previous Contents

28. SDCDB - Source level debugger.

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 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.

28.1 Compiling for debugging.

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 .

28.2 How the debugger works.

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 & 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 .

28.3 Starting the debugger.

The debugger can be started using the following command line. (Assume the file you are debugging has

the file name foo).

>sdcdb foo
 

The debugger will look for the following files.

  1. foo.c - the source file.
  2. foo.cdb - the debugger symbol information file.
  3. foo.ihx - the intel hex format object file.

28.4 Command line options.

28.5 Debugger Commands.

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.

break [line | file:line | function | file:function]

Set breakpoint at specified line or function.

sdcdb>break 100 
sdcdb>break foo.c:100
sdcdb>break funcfoo
sdcdb>break
 foo.c:funcfoo
 

clear [line | file:line | function | file:function ]

Clear breakpoint at specified line or function.

sdcdb>clear 100
sdcdb>clear foo.c:100
sdcdb>clear funcfoo
sdcdb>clear
 foo.c:funcfoo
 

continue

Continue program being debugged, after breakpoint.

finish

Execute till the end of the current function.

delete [n]

Delete breakpoint number 'n'. If used without any option clear ALL user defined break points.

info [break | stack | frame | registers ]

step

Step program until it reaches a different source line.

next

Step program, proceeding through subroutine calls.

run

Start debugged program.

ptype variable

Print type information of the variable.

print variable

print value of variable.

file filename

load the given file name. Note this is an alternate method of loading file for debugging.

frame

print information about current frame.

set srcmode

Toggle between C source & assembly source.

! simulator command

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.

quit.

"Watch me now. Iam going Down. My name is Bobby Brown"

28.6 Interfacing with XEmacs.

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.

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.

The following is a list of key mapping for the debugger interface.

 
;; 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 
;; 

 

Next Previous Contents