/* Dispatch the correct tui function based upon the control character. */ unsigned int tui_dispatch_ctrl_char (unsigned int ch) { struct tui_win_info *win_info = tui_win_with_focus (); /* Handle the CTRL-L refresh for each window. */ if (ch == '\f') tui_refresh_all_win (); /* If the command window has the logical focus, or no-one does assume it is the command window; in this case, pass the character on through and do nothing here. */ if (win_info == NULL || win_info == TUI_CMD_WIN) return ch; switch (ch) { case KEY_NPAGE: tui_scroll_forward (win_info, 0); break; case KEY_PPAGE: tui_scroll_backward (win_info, 0); break; case KEY_DOWN: case KEY_SF: tui_scroll_forward (win_info, 1); break; case KEY_UP: case KEY_SR: tui_scroll_backward (win_info, 1); break; case KEY_RIGHT: tui_scroll_left (win_info, 1); break; case KEY_LEFT: tui_scroll_right (win_info, 1); break; case '\f': break; default: /* We didn't recognize the character as a control character, so pass it through. */ return ch; } /* We intercepted the control character, so return 0 (which readline will interpret as a no-op). */ return 0; }
/* Function to display source in the source/asm window. This function shows the source as specified by the horizontal offset. */ void tui_update_source_window_as_is (struct tui_win_info *win_info, struct gdbarch *gdbarch, struct symtab *s, struct tui_line_or_address line_or_addr, int noerror) { enum tui_status ret; if (win_info->generic.type == SRC_WIN) ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror); else ret = tui_set_disassem_content (gdbarch, line_or_addr.u.addr); if (ret == TUI_FAILURE) { tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT); tui_clear_exec_info_content (win_info); } else { tui_update_breakpoint_info (win_info, 0); tui_show_source_content (win_info); tui_update_exec_info (win_info); if (win_info->generic.type == SRC_WIN) { struct symtab_and_line sal; init_sal (&sal); sal.line = line_or_addr.u.line_no + (win_info->generic.content_size - 2); sal.symtab = s; sal.pspace = SYMTAB_PSPACE (s); set_current_source_symtab_and_line (&sal); /* If the focus was in the asm win, put it in the src win if we don't have a split layout. */ if (tui_win_with_focus () == TUI_DISASM_WIN && tui_current_layout () != SRC_DISASSEM_COMMAND) tui_set_win_focus_to (TUI_SRC_WIN); } } return; }
/* TUI readline command. Switch the active window to give the focus to a next window. */ static int tui_rl_other_window (int count, int key) { struct tui_win_info * win_info; if (!tui_active) tui_rl_switch_mode (0/*notused*/, 0/*notused*/); win_info = tui_next_win (tui_win_with_focus ()); if (win_info) { tui_set_win_focus_to (win_info); if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible) tui_refresh_data_win (); keypad (TUI_CMD_WIN->generic.handle, (win_info != TUI_CMD_WIN)); } return 0; }
/* Function to display the disassembly window with disassembled code. */ void tui_show_disassem (CORE_ADDR start_addr) { struct symtab *s = find_pc_symtab (start_addr); struct tui_win_info * win_with_focus = tui_win_with_focus (); union tui_line_or_address val; val.addr = start_addr; tui_add_win_to_layout (DISASSEM_WIN); tui_update_source_window (TUI_DISASM_WIN, s, val, FALSE); /* ** if the focus was in the src win, put it in the asm win, if the ** source view isn't split */ if (tui_current_layout () != SRC_DISASSEM_COMMAND && win_with_focus == TUI_SRC_WIN) tui_set_win_focus_to (TUI_DISASM_WIN); return; }
/* Dispatch the correct tui function based upon the control character. */ unsigned int tui_dispatch_ctrl_char (unsigned int ch) { struct tui_win_info *win_info = tui_win_with_focus (); /* Handle the CTRL-L refresh for each window. */ if (ch == '\f') tui_refresh_all_win (); /* If the command window has the logical focus, or no-one does assume it is the command window; in this case, pass the character on through and do nothing here. */ if (win_info == NULL || win_info == TUI_CMD_WIN) return ch; else { unsigned int c = 0, ch_copy = ch; int i; char *term; /* If this is an xterm, page next/prev keys aren't returned by keypad as a single char, so we must handle them here. Seems like a bug in the curses library? */ term = (char *) getenv ("TERM"); if (term) { for (i = 0; term[i]; i++) term[i] = toupper (term[i]); if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch)) { unsigned int page_ch = 0; unsigned int tmp_char; WINDOW *w = TUI_CMD_WIN->generic.handle; tmp_char = 0; while (!key_is_end_sequence (tmp_char)) { tmp_char = (int) wgetch (w); if (tmp_char == ERR) { return ch; } if (!tmp_char) break; if (tmp_char == 53) page_ch = KEY_PPAGE; else if (tmp_char == 54) page_ch = KEY_NPAGE; else { return 0; } } ch_copy = page_ch; } } switch (ch_copy) { case KEY_NPAGE: tui_scroll_forward (win_info, 0); break; case KEY_PPAGE: tui_scroll_backward (win_info, 0); break; case KEY_DOWN: case KEY_SF: tui_scroll_forward (win_info, 1); break; case KEY_UP: case KEY_SR: tui_scroll_backward (win_info, 1); break; case KEY_RIGHT: tui_scroll_left (win_info, 1); break; case KEY_LEFT: tui_scroll_right (win_info, 1); break; case '\f': break; default: c = ch_copy; break; } return c; } }
/* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND, SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND. If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or UNDEFINED_LAYOUT, then the data window is populated according to regs_display_type. */ enum tui_status tui_set_layout (enum tui_layout_type layout_type, enum tui_register_display_type regs_display_type) { enum tui_status status = TUI_SUCCESS; if (layout_type != UNDEFINED_LAYOUT || regs_display_type != TUI_UNDEFINED_REGS) { enum tui_layout_type cur_layout = tui_current_layout (), new_layout = UNDEFINED_LAYOUT; int regs_populate = FALSE; struct gdbarch *gdbarch; CORE_ADDR addr; struct tui_win_info *win_with_focus = tui_win_with_focus (); struct tui_layout_def *layout_def = tui_layout_def (); extract_display_start_addr (&gdbarch, &addr); if (layout_type == UNDEFINED_LAYOUT && regs_display_type != TUI_UNDEFINED_REGS) { if (cur_layout == SRC_DISASSEM_COMMAND) new_layout = DISASSEM_DATA_COMMAND; else if (cur_layout == SRC_COMMAND || cur_layout == SRC_DATA_COMMAND) new_layout = SRC_DATA_COMMAND; else if (cur_layout == DISASSEM_COMMAND || cur_layout == DISASSEM_DATA_COMMAND) new_layout = DISASSEM_DATA_COMMAND; } else new_layout = layout_type; regs_populate = (new_layout == SRC_DATA_COMMAND || new_layout == DISASSEM_DATA_COMMAND || regs_display_type != TUI_UNDEFINED_REGS); if (new_layout != cur_layout || regs_display_type != TUI_UNDEFINED_REGS) { if (new_layout != cur_layout) { show_layout (new_layout); /* Now determine where focus should be. */ if (win_with_focus != TUI_CMD_WIN) { switch (new_layout) { case SRC_COMMAND: tui_set_win_focus_to (TUI_SRC_WIN); layout_def->display_mode = SRC_WIN; layout_def->split = FALSE; break; case DISASSEM_COMMAND: /* The previous layout was not showing code. This can happen if there is no source available: 1. if the source file is in another dir OR 2. if target was compiled without -g We still want to show the assembly though! */ tui_get_begin_asm_address (&gdbarch, &addr); tui_set_win_focus_to (TUI_DISASM_WIN); layout_def->display_mode = DISASSEM_WIN; layout_def->split = FALSE; break; case SRC_DISASSEM_COMMAND: /* The previous layout was not showing code. This can happen if there is no source available: 1. if the source file is in another dir OR 2. if target was compiled without -g We still want to show the assembly though! */ tui_get_begin_asm_address (&gdbarch, &addr); if (win_with_focus == TUI_SRC_WIN) tui_set_win_focus_to (TUI_SRC_WIN); else tui_set_win_focus_to (TUI_DISASM_WIN); layout_def->split = TRUE; break; case SRC_DATA_COMMAND: if (win_with_focus != TUI_DATA_WIN) tui_set_win_focus_to (TUI_SRC_WIN); else tui_set_win_focus_to (TUI_DATA_WIN); layout_def->display_mode = SRC_WIN; layout_def->split = FALSE; break; case DISASSEM_DATA_COMMAND: /* The previous layout was not showing code. This can happen if there is no source available: 1. if the source file is in another dir OR 2. if target was compiled without -g We still want to show the assembly though! */ tui_get_begin_asm_address (&gdbarch, &addr); if (win_with_focus != TUI_DATA_WIN) tui_set_win_focus_to (TUI_DISASM_WIN); else tui_set_win_focus_to (TUI_DATA_WIN); layout_def->display_mode = DISASSEM_WIN; layout_def->split = FALSE; break; default: break; } } /* * Now update the window content. */ if (!regs_populate && (new_layout == SRC_DATA_COMMAND || new_layout == DISASSEM_DATA_COMMAND)) tui_display_all_data (); tui_update_source_windows_with_addr (gdbarch, addr); } if (regs_populate) { tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group); } } } else status = TUI_FAILURE; return status; }