(ddd.info)Commands with Other Debuggers


Prev: GDB Argument Commands Up: Defining Commands
Enter node , (file) or (file)node

10.5.3 Defining Commands using Other Debuggers
----------------------------------------------

If your inferior debugger allows you to define own command sequences,
you can also use these user-defined commands within DDD; just enter
them at the debugger prompt.

   However, you may encounter some problems:

   * In contrast to the well-documented commands of the inferior
     debugger, DDD does not know what a user-defined command does.
     This may lead to inconsistencies between DDD and the inferior
     debugger.  For instance, if your the user-defined command `bp'
     sets a breakpoint, DDD may not display it immediately, because DDD
     does not know that `bp' changes the breakpoint state.

   * You cannot use DDD `graph' commands within user-defined commands.
     This is only natural, because user-defined commands are
     interpreted by the inferior debugger, which does not know about
     DDD commands.

   As a solution, DDD provides a simple facility called
"auto-commands".  If DDD receives any output from the inferior debugger
in the form `PREFIX COMMAND', it will interpret COMMAND as if it had
been entered at the debugger prompt.  PREFIX is a user-defined string,
for example `ddd: '.

   Suppose you want to define a command `gd' that serves as
abbreviation for `graph display'.  All the command `gd' has to do is to
issue a string

     ddd: graph display ARGUMENT

   where ARGUMENT is the argument given to `gd'.  Using GDB, this can
be achieved using the `echo' command.  In your `~/.gdbinit' file,
insert the lines

     define gd
       echo ddd: graph display $arg0\n
     end

   To complete the setting, you must also set the `autoCommandPrefix'
resource to the `ddd: ' prefix you gave in your command.  In
`~/.ddd/init', write:

     Ddd*autoCommandPrefix: ddd:\

(Be sure to leave a space after the trailing backslash.)

   Entering `gd foo' will now have the same effect as entering `graph
display foo' at the debugger prompt.

   Please note: In your commands, you should choose some other prefix
than `ddd: '.  This is because auto-commands raise a security problem,
since arbitrary commands can be executed.  Just imagine some malicious
program issuing a string like `PREFIX shell rm -fr ~' when being
debugged!  As a consequence, be sure to choose your own PREFIX; it must
be at least three characters long.


automatically generated by info2www version 1.2.2.9