Esempio n. 1
0
int a2_get_current_location(void *ctx, int on_startup)
{
    struct annotate_two *a2 = (struct annotate_two *) ctx;
    int ret;

    if (on_startup) {
        ret = commands_issue_command(a2->c, a2->client_command_list,
                ANNOTATE_LIST, NULL, 0);
        if (ret == -1) {
            logger_write_pos(logger, __FILE__, __LINE__,
                    "commands_issue_command error");
            return -1;
        }
    }

    ret = commands_issue_command(a2->c, a2->client_command_list,
            ANNOTATE_INFO_LINE, NULL, 0);
    if (ret == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    return 0;
}
Esempio n. 2
0
int a2_initialize(void *ctx,
        int *debugger_stdin, int *debugger_stdout,
        int *inferior_stdin, int *inferior_stdout)
{
    struct annotate_two *a2 = (struct annotate_two *) ctx;

    *debugger_stdin = a2->debugger_stdin;
    *debugger_stdout = a2->debugger_out;

    a2->data = data_initialize();
    a2->sm = state_machine_initialize();
    a2->c = commands_initialize();
    a2->g = globals_initialize();
    a2->client_command_list = tgdb_list_init();

    a2_open_new_tty(a2, inferior_stdin, inferior_stdout);

    /* 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.
     */
    if (commands_issue_command(a2->c,
                    a2->client_command_list,
                    ANNOTATE_INFO_BREAKPOINTS, NULL, 0) == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    a2->tgdb_initialized = 1;

    return 0;
}
Esempio n. 3
0
int a2_completion_callback(struct annotate_two *a2, const char *command)
{
    if (commands_issue_command(a2->c,
                    a2->client_command_list,
                    ANNOTATE_COMPLETE, command, 4) == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    return 0;
}
Esempio n. 4
0
int a2_get_inferior_sources(struct annotate_two *a2)
{
    if (commands_issue_command(a2->c,
                    a2->client_command_list,
                    ANNOTATE_INFO_SOURCES, NULL, 0) == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    return 0;
}
Esempio n. 5
0
int a2_initialize(struct annotate_two *a2,
        int *debugger_stdin, int *debugger_stdout,
        int *inferior_stdin, int *inferior_stdout)
{
    *debugger_stdin = a2->debugger_stdin;
    *debugger_stdout = a2->debugger_out;

    a2->sm = state_machine_initialize();
    a2->c = commands_initialize(a2);
    a2->client_commands = NULL;

    a2_open_new_tty(a2, inferior_stdin, 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.
     */
    a2_get_current_location(a2);

    /* 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.
     */
    if (commands_issue_command(a2,
                    ANNOTATE_INFO_BREAKPOINTS, NULL, 0) == -1) {
        return -1;
    }

    /**
     * Query if disassemble supports the /s flag
     */
    if (commands_issue_command(a2,
                    ANNOTATE_DATA_DISASSEMBLE_MODE_QUERY, NULL, 1) == -1) {
        return -1;
    }

    a2->tgdb_initialized = 1;

    return 0;
}
Esempio n. 6
0
int a2_get_source_filename_pair(struct annotate_two *a2, const char *file)
{
    int ret;

    ret = commands_issue_command(a2->c, a2->client_command_list, ANNOTATE_LIST,
            file, 0);
    if (ret == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    ret = commands_issue_command(a2->c, a2->client_command_list,
            ANNOTATE_INFO_SOURCE_FILENAME_PAIR, file, 0);
    if (ret == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    return 0;
}
Esempio n. 7
0
int a2_open_new_tty(struct annotate_two *a2, int *inferior_stdin, int *inferior_stdout)
{
    if (a2->pty_pair)
        pty_pair_destroy(a2->pty_pair);

    a2->pty_pair = pty_pair_create();
    if (!a2->pty_pair) {
        logger_write_pos(logger, __FILE__, __LINE__, "pty_pair_create failed");
        return -1;
    }

    *inferior_stdin = pty_pair_get_masterfd(a2->pty_pair);
    *inferior_stdout = pty_pair_get_masterfd(a2->pty_pair);

    commands_issue_command(a2, ANNOTATE_TTY,
        pty_pair_get_slavename(a2->pty_pair), 1);

    return 0;
}
Esempio n. 8
0
static int a2_set_inferior_tty(void *ctx)
{
    struct annotate_two *a2 = (struct annotate_two *) ctx;

    if (!a2) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "a2_set_inferior_tty error");
        return -1;
    }

    if (commands_issue_command(a2->c,
                    a2->client_command_list,
                    ANNOTATE_TTY,
                    pty_pair_get_slavename(a2->pty_pair), 0) == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    return 0;
}
Esempio n. 9
0
int a2_initialize(struct annotate_two *a2,
        int *debugger_stdin, int *debugger_stdout,
        int *inferior_stdin, int *inferior_stdout)
{
    *debugger_stdin = a2->debugger_stdin;
    *debugger_stdout = a2->debugger_out;

    a2->data = data_initialize();
    a2->sm = state_machine_initialize();
    a2->c = commands_initialize();
    a2->g = globals_initialize();
    a2->client_command_list = tgdb_list_init();

    a2_open_new_tty(a2, inferior_stdin, 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.
     */
    a2_get_current_location(a2, 1);

    /* 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.
     */
    if (commands_issue_command(a2->c,
                    a2->client_command_list,
                    ANNOTATE_INFO_BREAKPOINTS, NULL, 0) == -1) {
        logger_write_pos(logger, __FILE__, __LINE__,
                "commands_issue_command error");
        return -1;
    }

    a2->tgdb_initialized = 1;

    return 0;
}
Esempio n. 10
0
int a2_get_current_location(struct annotate_two *a2)
{
    return commands_issue_command(a2, ANNOTATE_INFO_FRAME, NULL, 1);
}