Exemplo n.º 1
0
static void variable_changed_cb(struct ConfigVariable *variable)
{
    /* User switched source/disasm mode. Request a frame update
       so the appropriate data is displayed in the source window. */
    if (!strcmp(variable->name, "disasm"))
        tgdb_request_current_location(tgdb);
}
Exemplo n.º 2
0
Arquivo: tgdb.cpp Projeto: lizh06/cgdb
struct tgdb *tgdb_initialize(const char *debugger,
        int argc, char **argv, int *debugger_fd, tgdb_callbacks callbacks)
{
    /* Initialize the libtgdb context */
    struct tgdb *tgdb = initialize_tgdb_context(callbacks);
    static struct annotations_parser_callbacks annotations_callbacks = {
        tgdb,
        tgdb_breakpoints_changed,
        tgdb_source_location_changed,
        tgdb_prompt_changed,
        tgdb_console_output,
        tgdb_command_error,
        tgdb_console_at_prompt  
    };

    tgdb->debugger_pid = invoke_debugger(debugger, argc, argv,
            &tgdb->debugger_stdin, &tgdb->debugger_stdout, 0);

    /* Couldn't invoke process */
    if (tgdb->debugger_pid == -1)
        return NULL;

    tgdb->c = commands_initialize(tgdb);

    tgdb->parser = annotations_parser_initialize(annotations_callbacks);

    tgdb_open_new_tty(tgdb, &tgdb->inferior_stdin, &tgdb->inferior_stdout);

    /* Need to get source information before breakpoint information otherwise
     * the TGDB_UPDATE_BREAKPOINTS event will be ignored in process_commands()
     * because there are no source files to add the breakpoints to.
     */
    tgdb_request_current_location(tgdb);

    /* gdb may already have some breakpoints when it starts. This could happen
     * if the user puts breakpoints in there .gdbinit.
     * This makes sure that TGDB asks for the breakpoints on start up.
     */
    tgdb_issue_request(tgdb, TGDB_REQUEST_BREAKPOINTS, true);

    /**
     * Query if disassemble supports the /s flag
     */
    tgdb_issue_request(tgdb, TGDB_REQUEST_DATA_DISASSEMBLE_MODE_QUERY, true);

    *debugger_fd = tgdb->debugger_stdout;

    return tgdb;
}
Exemplo n.º 3
0
Arquivo: cgdb.c Projeto: i4fumi/cgdb
/* start_gdb: Starts up libtgdb
 *  Returns:  -1 on error, 0 on success
 */
static int start_gdb(int argc, char *argv[])
{
    tgdb_request_ptr request_ptr;

    tgdb = tgdb_initialize(debugger_path, argc, argv, &gdb_fd, &tty_fd);
    if (tgdb == NULL)
        return -1;

    /* Run some initialize commands */

    /* gdb may already have some breakpoints when it starts. This could happen
     * if the user puts breakpoints in there .gdbinit.
     * This makes sure that TGDB asks for the breakpoints on start up.
     */

  /**
   * Get the filename GDB defaults to. 
   */
    request_ptr = tgdb_request_current_location(tgdb, 1);
    if (handle_request(tgdb, request_ptr) == -1)
        return -1;

    return 0;
}
Exemplo n.º 4
0
static void tgdb_source_location_changed(void *context)
{
    struct tgdb *tgdb = (struct tgdb*)context;
    tgdb_request_current_location(tgdb);
}