Esempio n. 1
0
static char *
tui_register_format (struct frame_info *frame, int regnum)
{
    struct gdbarch *gdbarch = get_frame_arch (frame);
    struct ui_file *stream;
    struct ui_file *old_stdout;
    struct cleanup *cleanups;
    char *p, *s;
    char *ret;

    pagination_enabled = 0;
    old_stdout = gdb_stdout;
    stream = tui_sfileopen (256);
    gdb_stdout = stream;
    cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout);
    gdbarch_print_registers_info (gdbarch, stream, frame, regnum, 1);

    /* Save formatted output in the buffer.  */
    p = tui_file_get_strbuf (stream);

    /* Remove the possible \n.  */
    s = strrchr (p, '\n');
    if (s && s[1] == 0)
        *s = 0;

    ret = xstrdup (p);
    do_cleanups (cleanups);

    return ret;
}
Esempio n. 2
0
/* Get the register from the frame and make a printable representation
   of it in the data element.  */
static void
tui_register_format (struct gdbarch *gdbarch, struct frame_info *frame,
                     struct tui_data_element *data_element, int regnum)
{
    struct ui_file *stream;
    struct ui_file *old_stdout;
    const char *name;
    struct cleanup *cleanups;
    char *p, *s;
    int pos;
    struct type *type = gdbarch_register_type (gdbarch, regnum);

    name = gdbarch_register_name (gdbarch, regnum);
    if (name == 0)
    {
        return;
    }

    pagination_enabled = 0;
    old_stdout = gdb_stdout;
    stream = tui_sfileopen (256);
    gdb_stdout = stream;
    cleanups = make_cleanup (tui_restore_gdbout, (void*) old_stdout);
    if (TYPE_VECTOR (type) != 0 && 0)
    {
        gdb_byte buf[MAX_REGISTER_SIZE];
        int len;

        len = register_size (current_gdbarch, regnum);
        fprintf_filtered (stream, "%-14s ", name);
        get_frame_register (frame, regnum, buf);
        print_scalar_formatted (buf, type, 'f', len, stream);
    }
    else
    {
        gdbarch_print_registers_info (current_gdbarch, stream,
                                      frame, regnum, 1);
    }

    /* Save formatted output in the buffer.  */
    p = tui_file_get_strbuf (stream);

    /* Remove the possible \n.  */
    s = strrchr (p, '\n');
    if (s && s[1] == 0)
        *s = 0;

    xfree (data_element->content);
    data_element->content = xstrdup (p);
    do_cleanups (cleanups);
}