Go to the first, previous, next, last section, table of contents.

# Invoking the Interpreter, Executing Commands

This section introduces the libgdb functions which invoke the command interpreter.

Function: void gdb_execute_command (command)

      char * command;

  Interpret the argument debugger command. An error handler must be set when this function is called. (See section You Provide the Top Level for the Libgdb Command Interpreter.)

It is possible to override the current I/O vectors for the duration of a single command:

Function: void gdb_execute_with_io (command, vecs)

      char * command;
      struct gdb_io_vecs * vecs;

      struct gdb_io_vecs
      {
        struct gdb_input_vector * input;
        struct gdb_output_vector * error;
        struct gdb_output_vector * info;
        struct gdb_output_vector * value;
      }

  Execute command, temporarily using the i/o vectors in vecs.

  Any of the vectors may be NULL, indicating that the current value should be used. An error handler must be in place when this function is used.

Function: struct gdb_str_output gdb_execute_for_strings (cmd)

      char * cmd;

Function: struct gdb_str_output gdb_execute_for_strings2 (cmd, input)

      char * cmd;
      struct gdb_input_vector * input;

      struct gdb_str_output
      {
        char * error;
        char * info;
        char * value;
      };

  Execute cmd, collecting its output as strings. If no error occurs, all three strings will be present in the structure, the empty-string rather than NULL standing for no output of a particular kind.

  If the command aborts with an error, then the `value` field will be NULL, though the other two strings will be present.

  In all cases, the strings returned are allocated by malloc and should be freed by the caller.

  The first form listed uses the current input vector, but overrides the current output vector. The second form additionally allows the input vector to be overridden.

  This function does not require that an error handler be installed.

Function: void execute_catching_errors (command)

      char * command;

  Like `execute_command` except that no error handler is required.

Function: void execute_with_text (command, text)

      char * command;
      char ** text;

  Like `execute_catching_errors`, except that the input vector is overridden. The new input vector handles only calls to `query` (by returning 'y') and calls to `read_strings` by returning a copy of text and the strings it points to.

  This form of execute_command is useful for commands like `define`, `document`, and `commands`.

Go to the first, previous, next, last section, table of contents.