Go to main content
Oracle® Developer Studio 12.6: dbxtool Tutorial

Exit Print View

Updated: June 2017
 
 

Example Program

This tutorial uses a simplified and somewhat artificial simulation of the dbx debugger. The source code for this C++ program is available in the sample applications zip file on the Oracle Developer Studio 12.6 downloads web page at http://www.oracle.com/technetwork/server-storage/developerstudio/downloads/index.html.

After accepting the license and downloading, you can extract the zip file in a directory of your choice.

  1. If you have not already done so, download the sample applications zip file, and unpack the file in a location of your choice. The debug_tutorial application is located in the Debugger subdirectory of the OracleDeveloperStudio12.5-Samples directory.

  2. Build the program.

    $ make
    CC -g   -c  main.cc
    CC -g   -c  interp.cc
    CC -g   -c  cmd.cc
    CC -g   -c  debugger.cc
    CC -g   -c  cmds.cc
    CC -g   main.o interp.o cmd.o debugger.o cmds.o -o a.out

The program is made up of the following modules:

cmd.h
cmd.cc
Class Cmd, a base for implementing debugger commands
interp.h
interp.cc
Class Interp, a simple command interpreter
debugger.h
debugger.cc
Class Debugger, mimics the main semantics of a debugger
cmds.h
cmds.cc
Implementations of various debugging commands
main.h
main.cc
The main() function and error handling. Sets up an Interp, creates various commands and assigns them to the Interp. Runs the Interp.

Run the program and try a few dbx commands.

$ a.out
> display var
will display 'var'
> stop in X
> run running ...
stopped in X
var = {
        a = '100'
        b = '101'
        c = '<error>'
        d = '102'
        e = '103'
        f = '104'
}
> quit
Goodby
$