URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/trunk/gnu-src/gdb-6.8/gdb/tui
- from Rev 24 to Rev 157
- ↔ Reverse comparison
Rev 24 → Rev 157
/tui-regs.c
0,0 → 1,769
/* TUI display registers in window. |
|
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008 |
Free Software Foundation, Inc. |
|
Contributed by Hewlett-Packard Company. |
|
This file is part of GDB. |
|
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 3 of the License, or |
(at your option) any later version. |
|
This program is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
|
You should have received a copy of the GNU General Public License |
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
|
#include "defs.h" |
#include "tui/tui.h" |
#include "tui/tui-data.h" |
#include "symtab.h" |
#include "gdbtypes.h" |
#include "gdbcmd.h" |
#include "frame.h" |
#include "regcache.h" |
#include "inferior.h" |
#include "target.h" |
#include "gdb_string.h" |
#include "tui/tui-layout.h" |
#include "tui/tui-win.h" |
#include "tui/tui-windata.h" |
#include "tui/tui-wingeneral.h" |
#include "tui/tui-file.h" |
#include "reggroups.h" |
|
#include "gdb_curses.h" |
|
|
/***************************************** |
** STATIC LOCAL FUNCTIONS FORWARD DECLS ** |
******************************************/ |
static void |
tui_display_register (struct tui_data_element *data, |
struct tui_gen_win_info *win_info); |
|
static enum tui_status |
tui_show_register_group (struct gdbarch *gdbarch, |
struct reggroup *group, |
struct frame_info *frame, |
int refresh_values_only); |
|
static enum tui_status |
tui_get_register (struct gdbarch *gdbarch, |
struct frame_info *frame, |
struct tui_data_element *data, |
int regnum, int *changedp); |
static void tui_register_format (struct gdbarch *, |
struct frame_info *, |
struct tui_data_element*, |
int); |
static void tui_scroll_regs_forward_command (char *, int); |
static void tui_scroll_regs_backward_command (char *, int); |
|
|
|
/***************************************** |
** PUBLIC FUNCTIONS ** |
******************************************/ |
|
/* Answer the number of the last line in the regs display. If there |
are no registers (-1) is returned. */ |
int |
tui_last_regs_line_no (void) |
{ |
int num_lines = (-1); |
|
if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0) |
{ |
num_lines = (TUI_DATA_WIN->detail.data_display_info.regs_content_count / |
TUI_DATA_WIN->detail.data_display_info.regs_column_count); |
if (TUI_DATA_WIN->detail.data_display_info.regs_content_count % |
TUI_DATA_WIN->detail.data_display_info.regs_column_count) |
num_lines++; |
} |
return num_lines; |
} |
|
|
/* Answer the line number that the register element at element_no is |
on. If element_no is greater than the number of register elements |
there are, -1 is returned. */ |
int |
tui_line_from_reg_element_no (int element_no) |
{ |
if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count) |
{ |
int i, line = (-1); |
|
i = 1; |
while (line == (-1)) |
{ |
if (element_no < |
(TUI_DATA_WIN->detail.data_display_info.regs_column_count * i)) |
line = i - 1; |
else |
i++; |
} |
|
return line; |
} |
else |
return (-1); |
} |
|
|
/* Answer the index of the first element in line_no. If line_no is |
past the register area (-1) is returned. */ |
int |
tui_first_reg_element_no_inline (int line_no) |
{ |
if ((line_no * TUI_DATA_WIN->detail.data_display_info.regs_column_count) |
<= TUI_DATA_WIN->detail.data_display_info.regs_content_count) |
return ((line_no + 1) * |
TUI_DATA_WIN->detail.data_display_info.regs_column_count) - |
TUI_DATA_WIN->detail.data_display_info.regs_column_count; |
else |
return (-1); |
} |
|
|
/* Answer the index of the last element in line_no. If line_no is |
past the register area (-1) is returned. */ |
int |
tui_last_reg_element_no_in_line (int line_no) |
{ |
if ((line_no * TUI_DATA_WIN->detail.data_display_info.regs_column_count) <= |
TUI_DATA_WIN->detail.data_display_info.regs_content_count) |
return ((line_no + 1) * |
TUI_DATA_WIN->detail.data_display_info.regs_column_count) - 1; |
else |
return (-1); |
} |
|
/* Show the registers of the given group in the data window |
and refresh the window. */ |
void |
tui_show_registers (struct reggroup *group) |
{ |
enum tui_status ret = TUI_FAILURE; |
struct tui_data_info *display_info; |
|
/* Make sure the curses mode is enabled. */ |
tui_enable (); |
|
/* Make sure the register window is visible. If not, select an |
appropriate layout. */ |
if (TUI_DATA_WIN == NULL || !TUI_DATA_WIN->generic.is_visible) |
tui_set_layout_for_display_command (DATA_NAME); |
|
display_info = &TUI_DATA_WIN->detail.data_display_info; |
if (group == 0) |
group = general_reggroup; |
|
/* Say that registers should be displayed, even if there is a |
problem. */ |
display_info->display_regs = TRUE; |
|
if (target_has_registers && target_has_stack && target_has_memory) |
{ |
ret = tui_show_register_group (current_gdbarch, group, |
get_current_frame (), |
group == display_info->current_group); |
} |
if (ret == TUI_FAILURE) |
{ |
display_info->current_group = 0; |
tui_erase_data_content (NO_REGS_STRING); |
} |
else |
{ |
int i; |
|
/* Clear all notation of changed values. */ |
for (i = 0; i < display_info->regs_content_count; i++) |
{ |
struct tui_gen_win_info *data_item_win; |
struct tui_win_element *win; |
|
data_item_win = &display_info->regs_content[i] |
->which_element.data_window; |
win = (struct tui_win_element *) data_item_win->content[0]; |
win->which_element.data.highlight = FALSE; |
} |
display_info->current_group = group; |
tui_display_all_data (); |
} |
} |
|
|
/* Set the data window to display the registers of the register group |
using the given frame. Values are refreshed only when |
refresh_values_only is TRUE. */ |
|
static enum tui_status |
tui_show_register_group (struct gdbarch *gdbarch, |
struct reggroup *group, |
struct frame_info *frame, |
int refresh_values_only) |
{ |
enum tui_status ret = TUI_FAILURE; |
int nr_regs; |
int allocated_here = FALSE; |
int regnum, pos; |
char title[80]; |
struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info; |
|
/* Make a new title showing which group we display. */ |
snprintf (title, sizeof (title) - 1, "Register group: %s", |
reggroup_name (group)); |
xfree (TUI_DATA_WIN->generic.title); |
TUI_DATA_WIN->generic.title = xstrdup (title); |
|
/* See how many registers must be displayed. */ |
nr_regs = 0; |
for (regnum = 0; |
regnum < gdbarch_num_regs (current_gdbarch) |
+ gdbarch_num_pseudo_regs (current_gdbarch); |
regnum++) |
{ |
/* Must be in the group and have a name. */ |
if (gdbarch_register_reggroup_p (gdbarch, regnum, group) |
&& gdbarch_register_name (gdbarch, regnum) != 0) |
nr_regs++; |
} |
|
if (display_info->regs_content_count > 0 && !refresh_values_only) |
{ |
tui_free_data_content (display_info->regs_content, |
display_info->regs_content_count); |
display_info->regs_content_count = 0; |
} |
|
if (display_info->regs_content_count <= 0) |
{ |
display_info->regs_content = tui_alloc_content (nr_regs, DATA_WIN); |
allocated_here = TRUE; |
refresh_values_only = FALSE; |
} |
|
if (display_info->regs_content != (tui_win_content) NULL) |
{ |
if (!refresh_values_only || allocated_here) |
{ |
TUI_DATA_WIN->generic.content = (void*) NULL; |
TUI_DATA_WIN->generic.content_size = 0; |
tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs); |
display_info->regs_content |
= (tui_win_content) TUI_DATA_WIN->generic.content; |
display_info->regs_content_count = nr_regs; |
} |
|
/* Now set the register names and values. */ |
pos = 0; |
for (regnum = 0; |
regnum < gdbarch_num_regs (current_gdbarch) |
+ gdbarch_num_pseudo_regs (current_gdbarch); |
regnum++) |
{ |
struct tui_gen_win_info *data_item_win; |
struct tui_data_element *data; |
const char *name; |
|
if (!gdbarch_register_reggroup_p (gdbarch, regnum, group)) |
continue; |
|
name = gdbarch_register_name (gdbarch, regnum); |
if (name == 0) |
continue; |
|
data_item_win = |
&display_info->regs_content[pos]->which_element.data_window; |
data = |
&((struct tui_win_element *) data_item_win->content[0])->which_element.data; |
if (data) |
{ |
if (!refresh_values_only) |
{ |
data->item_no = regnum; |
data->name = name; |
data->highlight = FALSE; |
} |
if (data->value == (void*) NULL) |
data->value = (void*) xmalloc (MAX_REGISTER_SIZE); |
|
tui_get_register (gdbarch, frame, data, regnum, 0); |
} |
pos++; |
} |
|
TUI_DATA_WIN->generic.content_size = |
display_info->regs_content_count + display_info->data_content_count; |
ret = TUI_SUCCESS; |
} |
|
return ret; |
} |
|
/* Function to display the registers in the content from |
'start_element_no' until the end of the register content or the end |
of the display height. No checking for displaying past the end of |
the registers is done here. */ |
void |
tui_display_registers_from (int start_element_no) |
{ |
struct tui_data_info *display_info = &TUI_DATA_WIN->detail.data_display_info; |
|
if (display_info->regs_content != (tui_win_content) NULL |
&& display_info->regs_content_count > 0) |
{ |
int i = start_element_no; |
int j, value_chars_wide, item_win_width, cur_y; |
|
int max_len = 0; |
for (i = 0; i < display_info->regs_content_count; i++) |
{ |
struct tui_data_element *data; |
struct tui_gen_win_info *data_item_win; |
char *p; |
int len; |
|
data_item_win = &display_info->regs_content[i]->which_element.data_window; |
data = &((struct tui_win_element *) |
data_item_win->content[0])->which_element.data; |
len = 0; |
p = data->content; |
if (p != 0) |
while (*p) |
{ |
if (*p++ == '\t') |
len = 8 * ((len / 8) + 1); |
else |
len++; |
} |
|
if (len > max_len) |
max_len = len; |
} |
item_win_width = max_len + 1; |
i = start_element_no; |
|
display_info->regs_column_count = |
(TUI_DATA_WIN->generic.width - 2) / item_win_width; |
if (display_info->regs_column_count == 0) |
display_info->regs_column_count = 1; |
item_win_width = |
(TUI_DATA_WIN->generic.width - 2) / display_info->regs_column_count; |
|
/* Now create each data "sub" window, and write the display into |
it. */ |
cur_y = 1; |
while (i < display_info->regs_content_count |
&& cur_y <= TUI_DATA_WIN->generic.viewport_height) |
{ |
for (j = 0; |
j < display_info->regs_column_count |
&& i < display_info->regs_content_count; |
j++) |
{ |
struct tui_gen_win_info *data_item_win; |
struct tui_data_element *data_element_ptr; |
|
/* Create the window if necessary. */ |
data_item_win = &display_info->regs_content[i] |
->which_element.data_window; |
data_element_ptr = &((struct tui_win_element *) |
data_item_win->content[0])->which_element.data; |
if (data_item_win->handle != (WINDOW*) NULL |
&& (data_item_win->height != 1 |
|| data_item_win->width != item_win_width |
|| data_item_win->origin.x != (item_win_width * j) + 1 |
|| data_item_win->origin.y != cur_y)) |
{ |
tui_delete_win (data_item_win->handle); |
data_item_win->handle = 0; |
} |
|
if (data_item_win->handle == (WINDOW *) NULL) |
{ |
data_item_win->height = 1; |
data_item_win->width = item_win_width; |
data_item_win->origin.x = (item_win_width * j) + 1; |
data_item_win->origin.y = cur_y; |
tui_make_window (data_item_win, DONT_BOX_WINDOW); |
scrollok (data_item_win->handle, FALSE); |
} |
touchwin (data_item_win->handle); |
|
/* Get the printable representation of the register |
and display it. */ |
tui_display_register (data_element_ptr, data_item_win); |
i++; /* Next register. */ |
} |
cur_y++; /* Next row. */ |
} |
} |
} |
|
|
/* Function to display the registers in the content from |
'start_element_no' on 'start_line_no' until the end of the register |
content or the end of the display height. This function checks |
that we won't display off the end of the register display. */ |
void |
tui_display_reg_element_at_line (int start_element_no, |
int start_line_no) |
{ |
if (TUI_DATA_WIN->detail.data_display_info.regs_content != (tui_win_content) NULL |
&& TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0) |
{ |
int element_no = start_element_no; |
|
if (start_element_no != 0 && start_line_no != 0) |
{ |
int last_line_no, first_line_on_last_page; |
|
last_line_no = tui_last_regs_line_no (); |
first_line_on_last_page = last_line_no - (TUI_DATA_WIN->generic.height - 2); |
if (first_line_on_last_page < 0) |
first_line_on_last_page = 0; |
|
/* If there is no other data displayed except registers, and |
the element_no causes us to scroll past the end of the |
registers, adjust what element to really start the |
display at. */ |
if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0 |
&& start_line_no > first_line_on_last_page) |
element_no = tui_first_reg_element_no_inline (first_line_on_last_page); |
} |
tui_display_registers_from (element_no); |
} |
} |
|
|
|
/* Function to display the registers starting at line line_no in the |
data window. Answers the line number that the display actually |
started from. If nothing is displayed (-1) is returned. */ |
int |
tui_display_registers_from_line (int line_no, |
int force_display) |
{ |
if (TUI_DATA_WIN->detail.data_display_info.regs_content_count > 0) |
{ |
int line, element_no; |
|
if (line_no < 0) |
line = 0; |
else if (force_display) |
{ /* If we must display regs (force_display is true), then |
make sure that we don't display off the end of the |
registers. */ |
if (line_no >= tui_last_regs_line_no ()) |
{ |
if ((line = tui_line_from_reg_element_no ( |
TUI_DATA_WIN->detail.data_display_info.regs_content_count - 1)) < 0) |
line = 0; |
} |
else |
line = line_no; |
} |
else |
line = line_no; |
|
element_no = tui_first_reg_element_no_inline (line); |
if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count) |
tui_display_reg_element_at_line (element_no, line); |
else |
line = (-1); |
|
return line; |
} |
|
return (-1); /* Nothing was displayed. */ |
} |
|
|
/* This function check all displayed registers for changes in values, |
given a particular frame. If the values have changed, they are |
updated with the new value and highlighted. */ |
void |
tui_check_register_values (struct frame_info *frame) |
{ |
if (TUI_DATA_WIN != NULL |
&& TUI_DATA_WIN->generic.is_visible) |
{ |
struct tui_data_info *display_info |
= &TUI_DATA_WIN->detail.data_display_info; |
|
if (display_info->regs_content_count <= 0 |
&& display_info->display_regs) |
tui_show_registers (display_info->current_group); |
else |
{ |
int i, j; |
|
for (i = 0; (i < display_info->regs_content_count); i++) |
{ |
struct tui_data_element *data; |
struct tui_gen_win_info *data_item_win_ptr; |
int was_hilighted; |
|
data_item_win_ptr = &display_info->regs_content[i]-> |
which_element.data_window; |
data = &((struct tui_win_element *) |
data_item_win_ptr->content[0])->which_element.data; |
was_hilighted = data->highlight; |
|
tui_get_register (current_gdbarch, frame, data, |
data->item_no, &data->highlight); |
|
if (data->highlight || was_hilighted) |
{ |
tui_display_register (data, data_item_win_ptr); |
} |
} |
} |
} |
} |
|
/* Display a register in a window. If hilite is TRUE, then the value |
will be displayed in reverse video. */ |
static void |
tui_display_register (struct tui_data_element *data, |
struct tui_gen_win_info *win_info) |
{ |
if (win_info->handle != (WINDOW *) NULL) |
{ |
int i; |
|
if (data->highlight) |
wstandout (win_info->handle); |
|
wmove (win_info->handle, 0, 0); |
for (i = 1; i < win_info->width; i++) |
waddch (win_info->handle, ' '); |
wmove (win_info->handle, 0, 0); |
if (data->content) |
waddstr (win_info->handle, data->content); |
|
if (data->highlight) |
wstandend (win_info->handle); |
tui_refresh_win (win_info); |
} |
} |
|
static void |
tui_reg_next_command (char *arg, int from_tty) |
{ |
if (TUI_DATA_WIN != 0) |
{ |
struct reggroup *group |
= TUI_DATA_WIN->detail.data_display_info.current_group; |
|
group = reggroup_next (current_gdbarch, group); |
if (group == 0) |
group = reggroup_next (current_gdbarch, 0); |
|
if (group) |
tui_show_registers (group); |
} |
} |
|
static void |
tui_reg_float_command (char *arg, int from_tty) |
{ |
tui_show_registers (float_reggroup); |
} |
|
static void |
tui_reg_general_command (char *arg, int from_tty) |
{ |
tui_show_registers (general_reggroup); |
} |
|
static void |
tui_reg_system_command (char *arg, int from_tty) |
{ |
tui_show_registers (system_reggroup); |
} |
|
static struct cmd_list_element *tuireglist; |
|
static void |
tui_reg_command (char *args, int from_tty) |
{ |
printf_unfiltered (_("\"tui reg\" must be followed by the name of a " |
"tui reg command.\n")); |
help_list (tuireglist, "tui reg ", -1, gdb_stdout); |
} |
|
void |
_initialize_tui_regs (void) |
{ |
struct cmd_list_element **tuicmd; |
|
tuicmd = tui_get_cmd_list (); |
|
add_prefix_cmd ("reg", class_tui, tui_reg_command, |
_("TUI commands to control the register window."), |
&tuireglist, "tui reg ", 0, |
tuicmd); |
|
add_cmd ("float", class_tui, tui_reg_float_command, |
_("Display only floating point registers."), |
&tuireglist); |
add_cmd ("general", class_tui, tui_reg_general_command, |
_("Display only general registers."), |
&tuireglist); |
add_cmd ("system", class_tui, tui_reg_system_command, |
_("Display only system registers."), |
&tuireglist); |
add_cmd ("next", class_tui, tui_reg_next_command, |
_("Display next register group."), |
&tuireglist); |
|
if (xdb_commands) |
{ |
add_com ("fr", class_tui, tui_reg_float_command, |
_("Display only floating point registers\n")); |
add_com ("gr", class_tui, tui_reg_general_command, |
_("Display only general registers\n")); |
add_com ("sr", class_tui, tui_reg_system_command, |
_("Display only special registers\n")); |
add_com ("+r", class_tui, tui_scroll_regs_forward_command, |
_("Scroll the registers window forward\n")); |
add_com ("-r", class_tui, tui_scroll_regs_backward_command, |
_("Scroll the register window backward\n")); |
} |
} |
|
|
/***************************************** |
** STATIC LOCAL FUNCTIONS ** |
******************************************/ |
|
extern int pagination_enabled; |
|
static void |
tui_restore_gdbout (void *ui) |
{ |
ui_file_delete (gdb_stdout); |
gdb_stdout = (struct ui_file*) ui; |
pagination_enabled = 1; |
} |
|
/* 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 = 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); |
} |
|
/* Get the register value from the given frame and format it for the |
display. When changep is set, check if the new register value has |
changed with respect to the previous call. */ |
static enum tui_status |
tui_get_register (struct gdbarch *gdbarch, |
struct frame_info *frame, |
struct tui_data_element *data, |
int regnum, int *changedp) |
{ |
enum tui_status ret = TUI_FAILURE; |
|
if (changedp) |
*changedp = FALSE; |
if (target_has_registers) |
{ |
gdb_byte buf[MAX_REGISTER_SIZE]; |
get_frame_register (frame, regnum, buf); |
|
if (changedp) |
{ |
int size = register_size (gdbarch, regnum); |
char *old = (char*) data->value; |
int i; |
|
for (i = 0; i < size; i++) |
if (buf[i] != old[i]) |
{ |
*changedp = TRUE; |
old[i] = buf[i]; |
} |
} |
|
/* Reformat the data content if the value changed. */ |
if (changedp == 0 || *changedp == TRUE) |
tui_register_format (gdbarch, frame, data, regnum); |
|
ret = TUI_SUCCESS; |
} |
return ret; |
} |
|
static void |
tui_scroll_regs_forward_command (char *arg, int from_tty) |
{ |
tui_scroll (FORWARD_SCROLL, TUI_DATA_WIN, 1); |
} |
|
|
static void |
tui_scroll_regs_backward_command (char *arg, int from_tty) |
{ |
tui_scroll (BACKWARD_SCROLL, TUI_DATA_WIN, 1); |
} |
tui-regs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui.c
===================================================================
--- tui.c (nonexistent)
+++ tui.c (revision 157)
@@ -0,0 +1,568 @@
+/* General functions for the WDB TUI.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "gdbcmd.h"
+#include "tui/tui.h"
+#include "tui/tui-hooks.h"
+#include "tui/tui-data.h"
+#include "tui/tui-layout.h"
+#include "tui/tui-io.h"
+#include "tui/tui-regs.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-win.h"
+#include "tui/tui-winsource.h"
+#include "tui/tui-windata.h"
+#include "target.h"
+#include "frame.h"
+#include "breakpoint.h"
+#include "inferior.h"
+#include "symtab.h"
+#include "source.h"
+
+#include
+#include
+#include
+#include
+#include
+#if 0
+#include
+#endif
+#include
+
+#include "gdb_curses.h"
+
+/* This redefines CTRL if it is not already defined, so it must come
+ after terminal state releated include files like and
+ "gdb_curses.h". */
+#include "readline/readline.h"
+
+/* Tells whether the TUI is active or not. */
+int tui_active = 0;
+static int tui_finish_init = 1;
+
+enum tui_key_mode tui_current_key_mode = TUI_COMMAND_MODE;
+
+struct tui_char_command
+{
+ unsigned char key;
+ const char *cmd;
+};
+
+/* Key mapping to gdb commands when the TUI is using the single key
+ mode. */
+static const struct tui_char_command tui_commands[] = {
+ { 'c', "continue" },
+ { 'd', "down" },
+ { 'f', "finish" },
+ { 'n', "next" },
+ { 'r', "run" },
+ { 's', "step" },
+ { 'u', "up" },
+ { 'v', "info locals" },
+ { 'w', "where" },
+ { 0, 0 },
+};
+
+static Keymap tui_keymap;
+static Keymap tui_readline_standard_keymap;
+
+/* TUI readline command.
+ Switch the output mode between TUI/standard gdb. */
+static int
+tui_rl_switch_mode (int notused1, int notused2)
+{
+ if (tui_active)
+ {
+ tui_disable ();
+ rl_prep_terminal (0);
+ }
+ else
+ {
+ rl_deprep_terminal ();
+ tui_enable ();
+ }
+
+ /* Clear the readline in case switching occurred in middle of
+ something. */
+ if (rl_end)
+ rl_kill_text (0, rl_end);
+
+ /* Since we left the curses mode, the terminal mode is restored to
+ some previous state. That state may not be suitable for readline
+ to work correctly (it may be restored in line mode). We force an
+ exit of the current readline so that readline is re-entered and
+ it will be able to setup the terminal for its needs. By
+ re-entering in readline, we also redisplay its prompt in the
+ non-curses mode. */
+ rl_newline (1, '\n');
+
+ /* Make sure the \n we are returning does not repeat the last
+ command. */
+ dont_repeat ();
+ return 0;
+}
+
+/* TUI readline command.
+ Change the TUI layout to show a next layout.
+ This function is bound to CTRL-X 2. It is intended to provide
+ a functionality close to the Emacs split-window command. We
+ always show two windows (src+asm), (src+regs) or (asm+regs). */
+static int
+tui_rl_change_windows (int notused1, int notused2)
+{
+ if (!tui_active)
+ tui_rl_switch_mode (0 /* notused */, 0 /* notused */);
+
+ if (tui_active)
+ {
+ enum tui_layout_type new_layout;
+ enum tui_register_display_type regs_type = TUI_UNDEFINED_REGS;
+
+ new_layout = tui_current_layout ();
+
+ /* Select a new layout to have a rolling layout behavior with
+ always two windows (except when undefined). */
+ switch (new_layout)
+ {
+ case SRC_COMMAND:
+ new_layout = SRC_DISASSEM_COMMAND;
+ break;
+
+ case DISASSEM_COMMAND:
+ new_layout = SRC_DISASSEM_COMMAND;
+ break;
+
+ case SRC_DATA_COMMAND:
+ new_layout = SRC_DISASSEM_COMMAND;
+ break;
+
+ case SRC_DISASSEM_COMMAND:
+ new_layout = DISASSEM_DATA_COMMAND;
+ break;
+
+ case DISASSEM_DATA_COMMAND:
+ new_layout = SRC_DATA_COMMAND;
+ break;
+
+ default:
+ new_layout = SRC_COMMAND;
+ break;
+ }
+ tui_set_layout (new_layout, regs_type);
+ }
+ return 0;
+}
+
+/* TUI readline command.
+ Delete the second TUI window to only show one. */
+static int
+tui_rl_delete_other_windows (int notused1, int notused2)
+{
+ if (!tui_active)
+ tui_rl_switch_mode (0 /* notused */, 0 /* notused */);
+
+ if (tui_active)
+ {
+ enum tui_layout_type new_layout;
+ enum tui_register_display_type regs_type = TUI_UNDEFINED_REGS;
+
+ new_layout = tui_current_layout ();
+
+ /* Kill one window. */
+ switch (new_layout)
+ {
+ case SRC_COMMAND:
+ case SRC_DATA_COMMAND:
+ case SRC_DISASSEM_COMMAND:
+ default:
+ new_layout = SRC_COMMAND;
+ break;
+
+ case DISASSEM_COMMAND:
+ case DISASSEM_DATA_COMMAND:
+ new_layout = DISASSEM_COMMAND;
+ break;
+ }
+ tui_set_layout (new_layout, regs_type);
+ }
+ return 0;
+}
+
+/* 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;
+}
+
+/* TUI readline command.
+ Execute the gdb command bound to the specified key. */
+static int
+tui_rl_command_key (int count, int key)
+{
+ int i;
+
+ reinitialize_more_filter ();
+ for (i = 0; tui_commands[i].cmd; i++)
+ {
+ if (tui_commands[i].key == key)
+ {
+ /* Must save the command because it can be modified by
+ execute_command. */
+ char *cmd = alloca (strlen (tui_commands[i].cmd) + 1);
+ strcpy (cmd, tui_commands[i].cmd);
+ execute_command (cmd, TRUE);
+ return 0;
+ }
+ }
+ return 0;
+}
+
+/* TUI readline command.
+ Temporarily leave the TUI SingleKey mode to allow editing
+ a gdb command with the normal readline. Once the command
+ is executed, the TUI SingleKey mode is installed back. */
+static int
+tui_rl_command_mode (int count, int key)
+{
+ tui_set_key_mode (TUI_ONE_COMMAND_MODE);
+ return rl_insert (count, key);
+}
+
+/* TUI readline command.
+ Switch between TUI SingleKey mode and gdb readline editing. */
+static int
+tui_rl_next_keymap (int notused1, int notused2)
+{
+ if (!tui_active)
+ tui_rl_switch_mode (0 /* notused */, 0 /* notused */);
+
+ tui_set_key_mode (tui_current_key_mode == TUI_COMMAND_MODE
+ ? TUI_SINGLE_KEY_MODE : TUI_COMMAND_MODE);
+ return 0;
+}
+
+/* Readline hook to redisplay ourself the gdb prompt.
+ In the SingleKey mode, the prompt is not printed so that
+ the command window is cleaner. It will be displayed if
+ we temporarily leave the SingleKey mode. */
+static int
+tui_rl_startup_hook (void)
+{
+ rl_already_prompted = 1;
+ if (tui_current_key_mode != TUI_COMMAND_MODE)
+ tui_set_key_mode (TUI_SINGLE_KEY_MODE);
+ tui_redisplay_readline ();
+ return 0;
+}
+
+/* Change the TUI key mode by installing the appropriate readline
+ keymap. */
+void
+tui_set_key_mode (enum tui_key_mode mode)
+{
+ tui_current_key_mode = mode;
+ rl_set_keymap (mode == TUI_SINGLE_KEY_MODE
+ ? tui_keymap : tui_readline_standard_keymap);
+ tui_show_locator_content ();
+}
+
+/* Initialize readline and configure the keymap for the switching
+ key shortcut. */
+void
+tui_initialize_readline (void)
+{
+ int i;
+ Keymap tui_ctlx_keymap;
+
+ rl_initialize ();
+
+ rl_add_defun ("tui-switch-mode", tui_rl_switch_mode, -1);
+ rl_add_defun ("gdb-command", tui_rl_command_key, -1);
+ rl_add_defun ("next-keymap", tui_rl_next_keymap, -1);
+
+ tui_keymap = rl_make_bare_keymap ();
+ tui_ctlx_keymap = rl_make_bare_keymap ();
+ tui_readline_standard_keymap = rl_get_keymap ();
+
+ for (i = 0; tui_commands[i].cmd; i++)
+ rl_bind_key_in_map (tui_commands[i].key, tui_rl_command_key, tui_keymap);
+
+ rl_generic_bind (ISKMAP, "\\C-x", (char*) tui_ctlx_keymap, tui_keymap);
+
+ /* Bind all other keys to tui_rl_command_mode so that we switch
+ temporarily from SingleKey mode and can enter a gdb command. */
+ for (i = ' '; i < 0x7f; i++)
+ {
+ int j;
+
+ for (j = 0; tui_commands[j].cmd; j++)
+ if (tui_commands[j].key == i)
+ break;
+
+ if (tui_commands[j].cmd)
+ continue;
+
+ rl_bind_key_in_map (i, tui_rl_command_mode, tui_keymap);
+ }
+
+ rl_bind_key_in_map ('a', tui_rl_switch_mode, emacs_ctlx_keymap);
+ rl_bind_key_in_map ('a', tui_rl_switch_mode, tui_ctlx_keymap);
+ rl_bind_key_in_map ('A', tui_rl_switch_mode, emacs_ctlx_keymap);
+ rl_bind_key_in_map ('A', tui_rl_switch_mode, tui_ctlx_keymap);
+ rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, emacs_ctlx_keymap);
+ rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, tui_ctlx_keymap);
+ rl_bind_key_in_map ('1', tui_rl_delete_other_windows, emacs_ctlx_keymap);
+ rl_bind_key_in_map ('1', tui_rl_delete_other_windows, tui_ctlx_keymap);
+ rl_bind_key_in_map ('2', tui_rl_change_windows, emacs_ctlx_keymap);
+ rl_bind_key_in_map ('2', tui_rl_change_windows, tui_ctlx_keymap);
+ rl_bind_key_in_map ('o', tui_rl_other_window, emacs_ctlx_keymap);
+ rl_bind_key_in_map ('o', tui_rl_other_window, tui_ctlx_keymap);
+ rl_bind_key_in_map ('q', tui_rl_next_keymap, tui_keymap);
+ rl_bind_key_in_map ('s', tui_rl_next_keymap, emacs_ctlx_keymap);
+ rl_bind_key_in_map ('s', tui_rl_next_keymap, tui_ctlx_keymap);
+}
+
+/* Enter in the tui mode (curses).
+ When in normal mode, it installs the tui hooks in gdb, redirects
+ the gdb output, configures the readline to work in tui mode.
+ When in curses mode, it does nothing. */
+void
+tui_enable (void)
+{
+ if (tui_active)
+ return;
+
+ /* To avoid to initialize curses when gdb starts, there is a defered
+ curses initialization. This initialization is made only once
+ and the first time the curses mode is entered. */
+ if (tui_finish_init)
+ {
+ WINDOW *w;
+
+ w = initscr ();
+
+ cbreak ();
+ noecho ();
+ /* timeout (1); */
+ nodelay(w, FALSE);
+ nl();
+ keypad (w, TRUE);
+ rl_initialize ();
+ tui_set_term_height_to (LINES);
+ tui_set_term_width_to (COLS);
+ def_prog_mode ();
+
+ tui_show_frame_info (0);
+ tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
+ tui_set_win_focus_to (TUI_SRC_WIN);
+ keypad (TUI_CMD_WIN->generic.handle, TRUE);
+ wrefresh (TUI_CMD_WIN->generic.handle);
+ tui_finish_init = 0;
+ }
+ else
+ {
+ /* Save the current gdb setting of the terminal.
+ Curses will restore this state when endwin() is called. */
+ def_shell_mode ();
+ clearok (stdscr, TRUE);
+ }
+
+ /* Install the TUI specific hooks. */
+ tui_install_hooks ();
+ rl_startup_hook = tui_rl_startup_hook;
+
+ tui_update_variables ();
+
+ tui_setup_io (1);
+
+ tui_active = 1;
+ if (deprecated_safe_get_selected_frame ())
+ tui_show_frame_info (deprecated_safe_get_selected_frame ());
+
+ /* Restore TUI keymap. */
+ tui_set_key_mode (tui_current_key_mode);
+ tui_refresh_all_win ();
+
+ /* Update gdb's knowledge of its terminal. */
+ target_terminal_save_ours ();
+ tui_update_gdb_sizes ();
+}
+
+/* Leave the tui mode.
+ Remove the tui hooks and configure the gdb output and readline
+ back to their original state. The curses mode is left so that
+ the terminal setting is restored to the point when we entered. */
+void
+tui_disable (void)
+{
+ if (!tui_active)
+ return;
+
+ /* Restore initial readline keymap. */
+ rl_set_keymap (tui_readline_standard_keymap);
+
+ /* Remove TUI hooks. */
+ tui_remove_hooks ();
+ rl_startup_hook = 0;
+ rl_already_prompted = 0;
+
+ /* Leave curses and restore previous gdb terminal setting. */
+ endwin ();
+
+ /* gdb terminal has changed, update gdb internal copy of it
+ so that terminal management with the inferior works. */
+ tui_setup_io (0);
+
+ /* Update gdb's knowledge of its terminal. */
+ target_terminal_save_ours ();
+
+ tui_active = 0;
+ tui_update_gdb_sizes ();
+}
+
+void
+strcat_to_buf (char *buf, int buflen,
+ const char *item_to_add)
+{
+ if (item_to_add != (char *) NULL && buf != (char *) NULL)
+ {
+ if ((strlen (buf) + strlen (item_to_add)) <= buflen)
+ strcat (buf, item_to_add);
+ else
+ strncat (buf, item_to_add, (buflen - strlen (buf)));
+ }
+}
+
+#if 0
+/* Solaris defines CTRL. */
+#ifndef CTRL
+#define CTRL(x) (x & ~0140)
+#endif
+
+#define FILEDES 2
+#define CHK(val, dft) (val<=0 ? dft : val)
+
+static void
+tui_reset (void)
+{
+ struct termio mode;
+
+ /* Reset the teletype mode bits to a sensible state.
+ Copied tset.c. */
+#if defined (TIOCGETC)
+ struct tchars tbuf;
+#endif /* TIOCGETC */
+#ifdef UCB_NTTY
+ struct ltchars ltc;
+
+ if (ldisc == NTTYDISC)
+ {
+ ioctl (FILEDES, TIOCGLTC, <c);
+ ltc.t_suspc = CHK (ltc.t_suspc, CTRL ('Z'));
+ ltc.t_dsuspc = CHK (ltc.t_dsuspc, CTRL ('Y'));
+ ltc.t_rprntc = CHK (ltc.t_rprntc, CTRL ('R'));
+ ltc.t_flushc = CHK (ltc.t_flushc, CTRL ('O'));
+ ltc.t_werasc = CHK (ltc.t_werasc, CTRL ('W'));
+ ltc.t_lnextc = CHK (ltc.t_lnextc, CTRL ('V'));
+ ioctl (FILEDES, TIOCSLTC, <c);
+ }
+#endif /* UCB_NTTY */
+#ifdef TIOCGETC
+ ioctl (FILEDES, TIOCGETC, &tbuf);
+ tbuf.t_intrc = CHK (tbuf.t_intrc, CTRL ('?'));
+ tbuf.t_quitc = CHK (tbuf.t_quitc, CTRL ('\\'));
+ tbuf.t_startc = CHK (tbuf.t_startc, CTRL ('Q'));
+ tbuf.t_stopc = CHK (tbuf.t_stopc, CTRL ('S'));
+ tbuf.t_eofc = CHK (tbuf.t_eofc, CTRL ('D'));
+ /* brkc is left alone. */
+ ioctl (FILEDES, TIOCSETC, &tbuf);
+#endif /* TIOCGETC */
+ mode.sg_flags &= ~(RAW
+#ifdef CBREAK
+ | CBREAK
+#endif /* CBREAK */
+ | VTDELAY | ALLDELAY);
+ mode.sg_flags |= XTABS | ECHO | CRMOD | ANYP;
+
+ return;
+}
+#endif
+
+void
+tui_show_source (const char *file, int line)
+{
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ /* Make sure that the source window is displayed. */
+ tui_add_win_to_layout (SRC_WIN);
+
+ tui_update_source_windows_with_line (cursal.symtab, line);
+ tui_update_locator_filename (file);
+}
+
+void
+tui_show_assembly (CORE_ADDR addr)
+{
+ tui_add_win_to_layout (DISASSEM_WIN);
+ tui_update_source_windows_with_addr (addr);
+}
+
+int
+tui_is_window_visible (enum tui_win_type type)
+{
+ if (tui_active == 0)
+ return 0;
+
+ if (tui_win_list[type] == 0)
+ return 0;
+
+ return tui_win_list[type]->generic.is_visible;
+}
+
+int
+tui_get_command_dimension (unsigned int *width,
+ unsigned int *height)
+{
+ if (!tui_active || (TUI_CMD_WIN == NULL))
+ {
+ return 0;
+ }
+
+ *width = TUI_CMD_WIN->generic.width;
+ *height = TUI_CMD_WIN->generic.height;
+ return 1;
+}
tui.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-win.h
===================================================================
--- tui-win.h (nonexistent)
+++ tui-win.h (revision 157)
@@ -0,0 +1,60 @@
+/* TUI window generic functions.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_WIN_H
+#define TUI_WIN_H
+
+#include "tui/tui-data.h"
+
+struct tui_win_info;
+
+extern void tui_scroll_forward (struct tui_win_info *, int);
+extern void tui_scroll_backward (struct tui_win_info *, int);
+extern void tui_scroll_left (struct tui_win_info *, int);
+extern void tui_scroll_right (struct tui_win_info *, int);
+extern void tui_scroll (enum tui_scroll_direction,
+ struct tui_win_info *, int);
+extern void tui_set_win_focus_to (struct tui_win_info *);
+extern void tui_resize_all (void);
+extern void tui_refresh_all_win (void);
+extern void tui_sigwinch_handler (int);
+
+extern chtype tui_border_ulcorner;
+extern chtype tui_border_urcorner;
+extern chtype tui_border_lrcorner;
+extern chtype tui_border_llcorner;
+extern chtype tui_border_vline;
+extern chtype tui_border_hline;
+extern int tui_border_attrs;
+extern int tui_active_border_attrs;
+
+extern int tui_update_variables (void);
+
+extern void tui_initialize_win (void);
+
+/* Update gdb's knowledge of the terminal size. */
+extern void tui_update_gdb_sizes (void);
+
+/* Create or get the TUI command list. */
+struct cmd_list_element **tui_get_cmd_list ();
+
+#endif
tui-win.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-stack.c
===================================================================
--- tui-stack.c (nonexistent)
+++ tui-stack.c (revision 157)
@@ -0,0 +1,429 @@
+/* TUI display locator.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "symtab.h"
+#include "breakpoint.h"
+#include "frame.h"
+#include "command.h"
+#include "inferior.h"
+#include "target.h"
+#include "top.h"
+#include "gdb_string.h"
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-wingeneral.h"
+#include "tui/tui-source.h"
+#include "tui/tui-winsource.h"
+#include "tui/tui-file.h"
+
+#include "gdb_curses.h"
+
+/* Get a printable name for the function at the address.
+ The symbol name is demangled if demangling is turned on.
+ Returns a pointer to a static area holding the result. */
+static char *tui_get_function_from_frame (struct frame_info *fi);
+
+/* Set the filename portion of the locator. */
+static void tui_set_locator_filename (const char *filename);
+
+/* Update the locator, with the provided arguments. */
+static void tui_set_locator_info (const char *filename,
+ const char *procname,
+ int lineno, CORE_ADDR addr);
+
+static void tui_update_command (char *, int);
+
+
+/* Create the status line to display as much information as we can on
+ this single line: target name, process number, current function,
+ current line, current PC, SingleKey mode. */
+static char*
+tui_make_status_line (struct tui_locator_element *loc)
+{
+ char *string;
+ char line_buf[50], *pname;
+ char *buf;
+ int status_size;
+ int i, proc_width;
+ const char *pid_name;
+ const char *pc_buf;
+ int target_width;
+ int pid_width;
+ int line_width;
+ int pc_width;
+ struct ui_file *pc_out;
+
+ if (ptid_equal (inferior_ptid, null_ptid))
+ pid_name = "No process";
+ else
+ pid_name = target_pid_to_str (inferior_ptid);
+
+ target_width = strlen (target_shortname);
+ if (target_width > MAX_TARGET_WIDTH)
+ target_width = MAX_TARGET_WIDTH;
+
+ pid_width = strlen (pid_name);
+ if (pid_width > MAX_PID_WIDTH)
+ pid_width = MAX_PID_WIDTH;
+
+ status_size = tui_term_width ();
+ string = (char *) xmalloc (status_size + 1);
+ buf = (char*) alloca (status_size + 1);
+
+ /* Translate line number and obtain its size. */
+ if (loc->line_no > 0)
+ sprintf (line_buf, "%d", loc->line_no);
+ else
+ strcpy (line_buf, "??");
+ line_width = strlen (line_buf);
+ if (line_width < MIN_LINE_WIDTH)
+ line_width = MIN_LINE_WIDTH;
+
+ /* Translate PC address. */
+ pc_out = tui_sfileopen (128);
+ deprecated_print_address_numeric (loc->addr, 1, pc_out);
+ pc_buf = tui_file_get_strbuf (pc_out);
+ pc_width = strlen (pc_buf);
+
+ /* First determine the amount of proc name width we have available.
+ The +1 are for a space separator between fields.
+ The -1 are to take into account the \0 counted by sizeof. */
+ proc_width = (status_size
+ - (target_width + 1)
+ - (pid_width + 1)
+ - (sizeof (PROC_PREFIX) - 1 + 1)
+ - (sizeof (LINE_PREFIX) - 1 + line_width + 1)
+ - (sizeof (PC_PREFIX) - 1 + pc_width + 1)
+ - (tui_current_key_mode == TUI_SINGLE_KEY_MODE
+ ? (sizeof (SINGLE_KEY) - 1 + 1)
+ : 0));
+
+ /* If there is no room to print the function name, try by removing
+ some fields. */
+ if (proc_width < MIN_PROC_WIDTH)
+ {
+ proc_width += target_width + 1;
+ target_width = 0;
+ if (proc_width < MIN_PROC_WIDTH)
+ {
+ proc_width += pid_width + 1;
+ pid_width = 0;
+ if (proc_width <= MIN_PROC_WIDTH)
+ {
+ proc_width += pc_width + sizeof (PC_PREFIX) - 1 + 1;
+ pc_width = 0;
+ if (proc_width < 0)
+ {
+ proc_width += line_width + sizeof (LINE_PREFIX) - 1 + 1;
+ line_width = 0;
+ if (proc_width < 0)
+ proc_width = 0;
+ }
+ }
+ }
+ }
+
+ /* Now convert elements to string form. */
+ pname = loc->proc_name;
+
+ /* Now create the locator line from the string version of the
+ elements. We could use sprintf() here but that wouldn't ensure
+ that we don't overrun the size of the allocated buffer.
+ strcat_to_buf() will. */
+ *string = (char) 0;
+
+ if (target_width > 0)
+ {
+ sprintf (buf, "%*.*s ",
+ -target_width, target_width, target_shortname);
+ strcat_to_buf (string, status_size, buf);
+ }
+ if (pid_width > 0)
+ {
+ sprintf (buf, "%*.*s ",
+ -pid_width, pid_width, pid_name);
+ strcat_to_buf (string, status_size, buf);
+ }
+
+ /* Show whether we are in SingleKey mode. */
+ if (tui_current_key_mode == TUI_SINGLE_KEY_MODE)
+ {
+ strcat_to_buf (string, status_size, SINGLE_KEY);
+ strcat_to_buf (string, status_size, " ");
+ }
+
+ /* Procedure/class name. */
+ if (proc_width > 0)
+ {
+ if (strlen (pname) > proc_width)
+ sprintf (buf, "%s%*.*s* ", PROC_PREFIX,
+ 1 - proc_width, proc_width - 1, pname);
+ else
+ sprintf (buf, "%s%*.*s ", PROC_PREFIX,
+ -proc_width, proc_width, pname);
+ strcat_to_buf (string, status_size, buf);
+ }
+
+ if (line_width > 0)
+ {
+ sprintf (buf, "%s%*.*s ", LINE_PREFIX,
+ -line_width, line_width, line_buf);
+ strcat_to_buf (string, status_size, buf);
+ }
+ if (pc_width > 0)
+ {
+ strcat_to_buf (string, status_size, PC_PREFIX);
+ strcat_to_buf (string, status_size, pc_buf);
+ }
+
+
+ for (i = strlen (string); i < status_size; i++)
+ string[i] = ' ';
+ string[status_size] = (char) 0;
+
+ ui_file_delete (pc_out);
+ return string;
+}
+
+/* Get a printable name for the function at the address. The symbol
+ name is demangled if demangling is turned on. Returns a pointer to
+ a static area holding the result. */
+static char*
+tui_get_function_from_frame (struct frame_info *fi)
+{
+ static char name[256];
+ struct ui_file *stream = tui_sfileopen (256);
+ char *p;
+
+ print_address_symbolic (get_frame_pc (fi), stream, demangle, "");
+ p = tui_file_get_strbuf (stream);
+
+ /* Use simple heuristics to isolate the function name. The symbol
+ can be demangled and we can have function parameters. Remove
+ them because the status line is too short to display them. */
+ if (*p == '<')
+ p++;
+ strncpy (name, p, sizeof (name));
+ p = strchr (name, '(');
+ if (!p)
+ p = strchr (name, '>');
+ if (p)
+ *p = 0;
+ p = strchr (name, '+');
+ if (p)
+ *p = 0;
+ ui_file_delete (stream);
+ return name;
+}
+
+void
+tui_show_locator_content (void)
+{
+ char *string;
+ struct tui_gen_win_info *locator;
+
+ locator = tui_locator_win_info_ptr ();
+
+ if (locator != NULL && locator->handle != (WINDOW *) NULL)
+ {
+ struct tui_win_element *element;
+
+ element = (struct tui_win_element *) locator->content[0];
+
+ string = tui_make_status_line (&element->which_element.locator);
+ wmove (locator->handle, 0, 0);
+ wstandout (locator->handle);
+ waddstr (locator->handle, string);
+ wclrtoeol (locator->handle);
+ wstandend (locator->handle);
+ tui_refresh_win (locator);
+ wmove (locator->handle, 0, 0);
+ xfree (string);
+ locator->content_in_use = TRUE;
+ }
+}
+
+
+/* Set the filename portion of the locator. */
+static void
+tui_set_locator_filename (const char *filename)
+{
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+ struct tui_locator_element *element;
+
+ if (locator->content[0] == NULL)
+ {
+ tui_set_locator_info (filename, NULL, 0, 0);
+ return;
+ }
+
+ element = &((struct tui_win_element *) locator->content[0])->which_element.locator;
+ element->file_name[0] = 0;
+ strcat_to_buf (element->file_name, MAX_LOCATOR_ELEMENT_LEN, filename);
+}
+
+/* Update the locator, with the provided arguments. */
+static void
+tui_set_locator_info (const char *filename,
+ const char *procname,
+ int lineno,
+ CORE_ADDR addr)
+{
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+ struct tui_locator_element *element;
+
+ /* Allocate the locator content if necessary. */
+ if (locator->content_size <= 0)
+ {
+ locator->content = (void **) tui_alloc_content (1, locator->type);
+ locator->content_size = 1;
+ }
+
+ element = &((struct tui_win_element *) locator->content[0])->which_element.locator;
+ element->proc_name[0] = (char) 0;
+ strcat_to_buf (element->proc_name, MAX_LOCATOR_ELEMENT_LEN, procname);
+ element->line_no = lineno;
+ element->addr = addr;
+ tui_set_locator_filename (filename);
+}
+
+/* Update only the filename portion of the locator. */
+void
+tui_update_locator_filename (const char *filename)
+{
+ tui_set_locator_filename (filename);
+ tui_show_locator_content ();
+}
+
+/* Function to print the frame information for the TUI. */
+void
+tui_show_frame_info (struct frame_info *fi)
+{
+ struct tui_win_info *win_info;
+ int i;
+
+ if (fi)
+ {
+ int start_line, i;
+ CORE_ADDR low;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+ int source_already_displayed;
+ struct symtab_and_line sal;
+
+ find_frame_sal (fi, &sal);
+
+ source_already_displayed = sal.symtab != 0
+ && tui_source_is_displayed (sal.symtab->filename);
+ tui_set_locator_info (sal.symtab == 0 ? "??" : sal.symtab->filename,
+ tui_get_function_from_frame (fi),
+ sal.line,
+ get_frame_pc (fi));
+ tui_show_locator_content ();
+ start_line = 0;
+ for (i = 0; i < (tui_source_windows ())->count; i++)
+ {
+ union tui_which_element *item;
+ win_info = (tui_source_windows ())->list[i];
+
+ item = &((struct tui_win_element *) locator->content[0])->which_element;
+ if (win_info == TUI_SRC_WIN)
+ {
+ start_line = (item->locator.line_no -
+ (win_info->generic.viewport_height / 2)) + 1;
+ if (start_line <= 0)
+ start_line = 1;
+ }
+ else
+ {
+ if (find_pc_partial_function (get_frame_pc (fi), (char **) NULL,
+ &low, (CORE_ADDR) 0) == 0)
+ error (_("No function contains program counter for selected frame."));
+ else
+ low = tui_get_low_disassembly_address (low, get_frame_pc (fi));
+ }
+
+ if (win_info == TUI_SRC_WIN)
+ {
+ struct tui_line_or_address l;
+ l.loa = LOA_LINE;
+ l.u.line_no = start_line;
+ if (!(source_already_displayed
+ && tui_line_is_displayed (item->locator.line_no, win_info, TRUE)))
+ tui_update_source_window (win_info, sal.symtab, l, TRUE);
+ else
+ {
+ l.u.line_no = item->locator.line_no;
+ tui_set_is_exec_point_at (l, win_info);
+ }
+ }
+ else
+ {
+ if (win_info == TUI_DISASM_WIN)
+ {
+ struct tui_line_or_address a;
+ a.loa = LOA_ADDRESS;
+ a.u.addr = low;
+ if (!tui_addr_is_displayed (item->locator.addr, win_info, TRUE))
+ tui_update_source_window (win_info, sal.symtab, a, TRUE);
+ else
+ {
+ a.u.addr = item->locator.addr;
+ tui_set_is_exec_point_at (a, win_info);
+ }
+ }
+ }
+ tui_update_exec_info (win_info);
+ }
+ }
+ else
+ {
+ tui_set_locator_info (NULL, NULL, 0, (CORE_ADDR) 0);
+ tui_show_locator_content ();
+ for (i = 0; i < (tui_source_windows ())->count; i++)
+ {
+ win_info = (tui_source_windows ())->list[i];
+ tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
+ tui_update_exec_info (win_info);
+ }
+ }
+}
+
+/* Function to initialize gdb commands, for tui window stack
+ manipulation. */
+void
+_initialize_tui_stack (void)
+{
+ add_com ("update", class_tui, tui_update_command, _("\
+Update the source window and locator to display the current execution point.\n"));
+}
+
+/* Command to update the display with the current execution point. */
+static void
+tui_update_command (char *arg, int from_tty)
+{
+ char cmd[sizeof("frame 0")];
+
+ strcpy (cmd, "frame 0");
+ execute_command (cmd, from_tty);
+}
tui-stack.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-regs.h
===================================================================
--- tui-regs.h (nonexistent)
+++ tui-regs.h (revision 157)
@@ -0,0 +1,37 @@
+/* TUI display registers in window.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_REGS_H
+#define TUI_REGS_H
+
+#include "tui/tui-data.h" /* For struct tui_register_display_type. */
+
+extern void tui_check_register_values (struct frame_info *);
+extern void tui_show_registers (struct reggroup *group);
+extern void tui_display_registers_from (int);
+extern int tui_display_registers_from_line (int, int);
+extern int tui_last_regs_line_no (void);
+extern int tui_first_reg_element_inline (int);
+extern int tui_line_from_reg_element_no (int);
+extern int tui_first_reg_element_no_inline (int lineno);
+
+#endif
tui-regs.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui.h
===================================================================
--- tui.h (nonexistent)
+++ tui.h (revision 157)
@@ -0,0 +1,102 @@
+/* External/Public TUI Header File.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_H
+#define TUI_H
+
+struct ui_file;
+
+extern void strcat_to_buf (char *, int, const char *);
+
+/* Types of error returns. */
+enum tui_status
+{
+ TUI_SUCCESS,
+ TUI_FAILURE
+};
+
+/* Types of windows. */
+enum tui_win_type
+{
+ SRC_WIN = 0,
+ DISASSEM_WIN,
+ DATA_WIN,
+ CMD_WIN,
+ /* This must ALWAYS be AFTER the major windows last. */
+ MAX_MAJOR_WINDOWS,
+ /* Auxillary windows. */
+ LOCATOR_WIN,
+ EXEC_INFO_WIN,
+ DATA_ITEM_WIN,
+ /* This must ALWAYS be next to last. */
+ MAX_WINDOWS,
+ UNDEFINED_WIN /* LAST */
+};
+
+/* GENERAL TUI FUNCTIONS */
+/* tui.c */
+extern CORE_ADDR tui_get_low_disassembly_address (CORE_ADDR,
+ CORE_ADDR);
+extern void tui_show_assembly (CORE_ADDR addr);
+extern int tui_is_window_visible (enum tui_win_type type);
+extern int tui_get_command_dimension (unsigned int *width,
+ unsigned int *height);
+
+/* Initialize readline and configure the keymap for the switching
+ key shortcut. */
+extern void tui_initialize_readline (void);
+
+/* Enter in the tui mode (curses). */
+extern void tui_enable (void);
+
+/* Leave the tui mode. */
+extern void tui_disable (void);
+
+enum tui_key_mode
+{
+ /* Plain command mode to enter gdb commands. */
+ TUI_COMMAND_MODE,
+
+ /* SingleKey mode with some keys bound to gdb commands. */
+ TUI_SINGLE_KEY_MODE,
+
+ /* Read/edit one command and return to SingleKey after it's
+ processed. */
+ TUI_ONE_COMMAND_MODE
+};
+
+extern enum tui_key_mode tui_current_key_mode;
+
+/* Change the TUI key mode by installing the appropriate readline
+ keymap. */
+extern void tui_set_key_mode (enum tui_key_mode mode);
+
+extern int tui_active;
+
+extern void tui_show_source (const char *file, int line);
+
+extern struct ui_out *tui_out_new (struct ui_file *stream);
+
+/* tui-layout.c */
+extern enum tui_status tui_set_layout_for_display_command (const char *);
+
+#endif
tui.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-out.c
===================================================================
--- tui-out.c (nonexistent)
+++ tui-out.c (revision 157)
@@ -0,0 +1,434 @@
+/* Output generating routines for GDB CLI.
+
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Cygnus Solutions.
+ Written by Fernando Nasser for Cygnus.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "ui-out.h"
+#include "tui.h"
+#include "gdb_string.h"
+#include "gdb_assert.h"
+
+struct ui_out_data
+ {
+ struct ui_file *stream;
+ int suppress_output;
+ int line;
+ int start_of_line;
+ };
+typedef struct ui_out_data tui_out_data;
+
+/* These are the CLI output functions. */
+
+static void tui_table_begin (struct ui_out *uiout,
+ int nbrofcols, int nr_rows,
+ const char *tblid);
+static void tui_table_body (struct ui_out *uiout);
+static void tui_table_end (struct ui_out *uiout);
+static void tui_table_header (struct ui_out *uiout,
+ int width, enum ui_align alig,
+ const char *col_name,
+ const char *colhdr);
+static void tui_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level, const char *lstid);
+static void tui_end (struct ui_out *uiout,
+ enum ui_out_type type, int level);
+static void tui_field_int (struct ui_out *uiout,
+ int fldno, int width,
+ enum ui_align alig,
+ const char *fldname, int value);
+static void tui_field_skip (struct ui_out *uiout,
+ int fldno, int width,
+ enum ui_align alig,
+ const char *fldname);
+static void tui_field_string (struct ui_out *uiout,
+ int fldno, int width,
+ enum ui_align alig,
+ const char *fldname,
+ const char *string);
+static void tui_field_fmt (struct ui_out *uiout, int fldno,
+ int width, enum ui_align align,
+ const char *fldname,
+ const char *format,
+ va_list args)
+ ATTR_FORMAT (printf, 6, 0);
+static void tui_spaces (struct ui_out *uiout, int numspaces);
+static void tui_text (struct ui_out *uiout, const char *string);
+static void tui_message (struct ui_out *uiout, int verbosity,
+ const char *format, va_list args)
+ ATTR_FORMAT (printf, 3, 0);
+static void tui_wrap_hint (struct ui_out *uiout,
+ char *identstring);
+static void tui_flush (struct ui_out *uiout);
+
+/* This is the CLI ui-out implementation functions vector. */
+
+/* FIXME: This can be initialized dynamically after default is set to
+ handle initial output in main.c. */
+
+static struct ui_out_impl tui_ui_out_impl = {
+ tui_table_begin,
+ tui_table_body,
+ tui_table_end,
+ tui_table_header,
+ tui_begin,
+ tui_end,
+ tui_field_int,
+ tui_field_skip,
+ tui_field_string,
+ tui_field_fmt,
+ tui_spaces,
+ tui_text,
+ tui_message,
+ tui_wrap_hint,
+ tui_flush,
+ NULL,
+ 0, /* Does not need MI hacks (i.e. needs CLI hacks). */
+};
+
+/* Prototypes for local functions. */
+
+extern void _initialize_tui_out (void);
+
+static void field_separator (void);
+
+static void out_field_fmt (struct ui_out *uiout,
+ int fldno,
+ const char *fldname,
+ const char *format,...)
+ ATTR_FORMAT (printf, 4, 5);
+
+/* local variables */
+
+/* (none yet) */
+
+/* Mark beginning of a table. */
+
+void
+tui_table_begin (struct ui_out *uiout,
+ int nbrofcols,
+ int nr_rows,
+ const char *tblid)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (nr_rows == 0)
+ data->suppress_output = 1;
+ else
+ /* Only the table suppresses the output and, fortunately, a table
+ is not a recursive data structure. */
+ gdb_assert (data->suppress_output == 0);
+}
+
+/* Mark beginning of a table body. */
+
+void
+tui_table_body (struct ui_out *uiout)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+ /* First, close the table header line. */
+ tui_text (uiout, "\n");
+}
+
+/* Mark end of a table. */
+
+void
+tui_table_end (struct ui_out *uiout)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ data->suppress_output = 0;
+}
+
+/* Specify table header. */
+
+void
+tui_table_header (struct ui_out *uiout,
+ int width,
+ enum ui_align alignment,
+ const char *col_name,
+ const char *colhdr)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+ tui_field_string (uiout, 0, width, alignment, 0, colhdr);
+}
+
+/* Mark beginning of a list. */
+
+void
+tui_begin (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level,
+ const char *id)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+}
+
+/* Mark end of a list. */
+
+void
+tui_end (struct ui_out *uiout,
+ enum ui_out_type type,
+ int level)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+}
+
+/* Output an int field. */
+
+void
+tui_field_int (struct ui_out *uiout,
+ int fldno, int width,
+ enum ui_align alignment,
+ const char *fldname,
+ int value)
+{
+ char buffer[20]; /* FIXME: how many chars long a %d can become? */
+
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+
+ /* Don't print line number, keep it for later. */
+ if (data->start_of_line == 0 && strcmp (fldname, "line") == 0)
+ {
+ data->start_of_line ++;
+ data->line = value;
+ return;
+ }
+ data->start_of_line ++;
+ sprintf (buffer, "%d", value);
+ tui_field_string (uiout, fldno, width, alignment, fldname, buffer);
+}
+
+/* Used to ommit a field. */
+
+void
+tui_field_skip (struct ui_out *uiout,
+ int fldno, int width,
+ enum ui_align alignment,
+ const char *fldname)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+ tui_field_string (uiout, fldno, width, alignment, fldname, "");
+}
+
+/* Other specific tui_field_* end up here so alignment and field
+ separators are both handled by tui_field_string. */
+
+void
+tui_field_string (struct ui_out *uiout,
+ int fldno, int width,
+ enum ui_align align,
+ const char *fldname,
+ const char *string)
+{
+ int before = 0;
+ int after = 0;
+
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+
+ if (fldname && data->line > 0 && strcmp (fldname, "file") == 0)
+ {
+ data->start_of_line ++;
+ if (data->line > 0)
+ {
+ tui_show_source (string, data->line);
+ }
+ return;
+ }
+
+ data->start_of_line ++;
+ if ((align != ui_noalign) && string)
+ {
+ before = width - strlen (string);
+ if (before <= 0)
+ before = 0;
+ else
+ {
+ if (align == ui_right)
+ after = 0;
+ else if (align == ui_left)
+ {
+ after = before;
+ before = 0;
+ }
+ else
+ /* ui_center */
+ {
+ after = before / 2;
+ before -= after;
+ }
+ }
+ }
+
+ if (before)
+ ui_out_spaces (uiout, before);
+ if (string)
+ out_field_fmt (uiout, fldno, fldname, "%s", string);
+ if (after)
+ ui_out_spaces (uiout, after);
+
+ if (align != ui_noalign)
+ field_separator ();
+}
+
+/* This is the only field function that does not align. */
+
+void
+tui_field_fmt (struct ui_out *uiout, int fldno,
+ int width, enum ui_align align,
+ const char *fldname,
+ const char *format,
+ va_list args)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+
+ data->start_of_line ++;
+ vfprintf_filtered (data->stream, format, args);
+
+ if (align != ui_noalign)
+ field_separator ();
+}
+
+void
+tui_spaces (struct ui_out *uiout, int numspaces)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+ print_spaces_filtered (numspaces, data->stream);
+}
+
+void
+tui_text (struct ui_out *uiout, const char *string)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+ data->start_of_line ++;
+ if (data->line > 0)
+ {
+ if (strchr (string, '\n') != 0)
+ {
+ data->line = -1;
+ data->start_of_line = 0;
+ }
+ return;
+ }
+ if (strchr (string, '\n'))
+ data->start_of_line = 0;
+ fputs_filtered (string, data->stream);
+}
+
+void
+tui_message (struct ui_out *uiout,
+ int verbosity,
+ const char *format,
+ va_list args)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+ if (ui_out_get_verblvl (uiout) >= verbosity)
+ vfprintf_unfiltered (data->stream, format, args);
+}
+
+void
+tui_wrap_hint (struct ui_out *uiout, char *identstring)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ if (data->suppress_output)
+ return;
+ wrap_here (identstring);
+}
+
+void
+tui_flush (struct ui_out *uiout)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ gdb_flush (data->stream);
+}
+
+/* Local functions. */
+
+/* Like tui_field_fmt, but takes a variable number of args and makes a
+ va_list and does not insert a separator. */
+
+/* VARARGS */
+static void
+out_field_fmt (struct ui_out *uiout,
+ int fldno,
+ const char *fldname,
+ const char *format,...)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ va_list args;
+
+ va_start (args, format);
+ vfprintf_filtered (data->stream, format, args);
+
+ va_end (args);
+}
+
+/* Access to ui_out format private members. */
+
+static void
+field_separator (void)
+{
+ tui_out_data *data = ui_out_data (uiout);
+ fputc_filtered (' ', data->stream);
+}
+
+/* Initalize private members at startup. */
+
+struct ui_out *
+tui_out_new (struct ui_file *stream)
+{
+ int flags = 0;
+
+ tui_out_data *data = XMALLOC (tui_out_data);
+ data->stream = stream;
+ data->suppress_output = 0;
+ data->line = -1;
+ data->start_of_line = 0;
+ return ui_out_new (&tui_ui_out_impl, data, flags);
+}
+
+/* Standard gdb initialization hook. */
+void
+_initialize_tui_out (void)
+{
+ /* Nothing needs to be done. */
+}
tui-out.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-data.c
===================================================================
--- tui-data.c (nonexistent)
+++ tui-data.c (revision 157)
@@ -0,0 +1,939 @@
+/* TUI data manipulation routines.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "symtab.h"
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-wingeneral.h"
+
+#include "gdb_string.h"
+#include "gdb_curses.h"
+
+/****************************
+** GLOBAL DECLARATIONS
+****************************/
+struct tui_win_info *(tui_win_list[MAX_MAJOR_WINDOWS]);
+
+/***************************
+** Private data
+****************************/
+static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
+static int term_height, term_width;
+static struct tui_gen_win_info _locator;
+static struct tui_gen_win_info exec_info[2];
+static struct tui_win_info *src_win_list[2];
+static struct tui_list source_windows = {src_win_list, 0};
+static int default_tab_len = DEFAULT_TAB_LEN;
+static struct tui_win_info *win_with_focus = (struct tui_win_info *) NULL;
+static struct tui_layout_def layout_def = {
+ SRC_WIN, /* DISPLAY_MODE */
+ FALSE, /* SPLIT */
+ TUI_UNDEFINED_REGS, /* REGS_DISPLAY_TYPE */
+ TUI_SFLOAT_REGS}; /* FLOAT_REGS_DISPLAY_TYPE */
+
+static int win_resized = FALSE;
+
+
+/*********************************
+** Static function forward decls
+**********************************/
+static void free_content (tui_win_content,
+ int,
+ enum tui_win_type);
+static void free_content_elements (tui_win_content,
+ int,
+ enum tui_win_type);
+
+
+
+/*********************************
+** PUBLIC FUNCTIONS
+**********************************/
+
+int
+tui_win_is_source_type (enum tui_win_type win_type)
+{
+ return (win_type == SRC_WIN || win_type == DISASSEM_WIN);
+}
+
+int
+tui_win_is_auxillary (enum tui_win_type win_type)
+{
+ return (win_type > MAX_MAJOR_WINDOWS);
+}
+
+int
+tui_win_has_locator (struct tui_win_info *win_info)
+{
+ return (win_info != NULL
+ && win_info->detail.source_info.has_locator);
+}
+
+void
+tui_set_win_highlight (struct tui_win_info *win_info,
+ int highlight)
+{
+ if (win_info != NULL)
+ win_info->is_highlighted = highlight;
+}
+
+/******************************************
+** ACCESSORS & MUTATORS FOR PRIVATE DATA
+******************************************/
+
+/* Answer a whether the terminal window has been resized or not. */
+int
+tui_win_resized (void)
+{
+ return win_resized;
+}
+
+
+/* Set a whether the terminal window has been resized or not. */
+void
+tui_set_win_resized_to (int resized)
+{
+ win_resized = resized;
+}
+
+
+/* Answer a pointer to the current layout definition. */
+struct tui_layout_def *
+tui_layout_def (void)
+{
+ return &layout_def;
+}
+
+
+/* Answer the window with the logical focus. */
+struct tui_win_info *
+tui_win_with_focus (void)
+{
+ return win_with_focus;
+}
+
+
+/* Set the window that has the logical focus. */
+void
+tui_set_win_with_focus (struct tui_win_info *win_info)
+{
+ win_with_focus = win_info;
+}
+
+
+/* Answer the length in chars, of tabs. */
+int
+tui_default_tab_len (void)
+{
+ return default_tab_len;
+}
+
+
+/* Set the length in chars, of tabs. */
+void
+tui_set_default_tab_len (int len)
+{
+ default_tab_len = len;
+}
+
+
+/* Accessor for the current source window. Usually there is only one
+ source window (either source or disassembly), but both can be
+ displayed at the same time. */
+struct tui_list *
+tui_source_windows (void)
+{
+ return &source_windows;
+}
+
+
+/* Clear the list of source windows. Usually there is only one source
+ window (either source or disassembly), but both can be displayed at
+ the same time. */
+void
+tui_clear_source_windows (void)
+{
+ source_windows.list[0] = NULL;
+ source_windows.list[1] = NULL;
+ source_windows.count = 0;
+}
+
+
+/* Clear the pertinant detail in the source windows. */
+void
+tui_clear_source_windows_detail (void)
+{
+ int i;
+
+ for (i = 0; i < (tui_source_windows ())->count; i++)
+ tui_clear_win_detail ((tui_source_windows ())->list[i]);
+}
+
+
+/* Add a window to the list of source windows. Usually there is only
+ one source window (either source or disassembly), but both can be
+ displayed at the same time. */
+void
+tui_add_to_source_windows (struct tui_win_info *win_info)
+{
+ if (source_windows.count < 2)
+ source_windows.list[source_windows.count++] = (void *) win_info;
+}
+
+
+/* Clear the pertinant detail in the windows. */
+void
+tui_clear_win_detail (struct tui_win_info *win_info)
+{
+ if (win_info != NULL)
+ {
+ switch (win_info->generic.type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
+ win_info->detail.source_info.start_line_or_addr.u.addr = 0;
+ win_info->detail.source_info.horizontal_offset = 0;
+ break;
+ case CMD_WIN:
+ win_info->detail.command_info.cur_line =
+ win_info->detail.command_info.curch = 0;
+ break;
+ case DATA_WIN:
+ win_info->detail.data_display_info.data_content =
+ (tui_win_content) NULL;
+ win_info->detail.data_display_info.data_content_count = 0;
+ win_info->detail.data_display_info.regs_content =
+ (tui_win_content) NULL;
+ win_info->detail.data_display_info.regs_content_count = 0;
+ win_info->detail.data_display_info.regs_display_type =
+ TUI_UNDEFINED_REGS;
+ win_info->detail.data_display_info.regs_column_count = 1;
+ win_info->detail.data_display_info.display_regs = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+
+/* Accessor for the source execution info ptr. */
+struct tui_gen_win_info *
+tui_source_exec_info_win_ptr (void)
+{
+ return &exec_info[0];
+}
+
+
+/* Accessor for the disassem execution info ptr. */
+struct tui_gen_win_info *
+tui_disassem_exec_info_win_ptr (void)
+{
+ return &exec_info[1];
+}
+
+
+/* Accessor for the locator win info. Answers a pointer to the static
+ locator win info struct. */
+struct tui_gen_win_info *
+tui_locator_win_info_ptr (void)
+{
+ return &_locator;
+}
+
+
+/* Accessor for the term_height. */
+int
+tui_term_height (void)
+{
+ return term_height;
+}
+
+
+/* Mutator for the term height. */
+void
+tui_set_term_height_to (int h)
+{
+ term_height = h;
+}
+
+
+/* Accessor for the term_width. */
+int
+tui_term_width (void)
+{
+ return term_width;
+}
+
+
+/* Mutator for the term_width. */
+void
+tui_set_term_width_to (int w)
+{
+ term_width = w;
+}
+
+
+/* Accessor for the current layout. */
+enum tui_layout_type
+tui_current_layout (void)
+{
+ return current_layout;
+}
+
+
+/* Mutator for the current layout. */
+void
+tui_set_current_layout_to (enum tui_layout_type new_layout)
+{
+ current_layout = new_layout;
+}
+
+
+/* Set the origin of the window. */
+void
+set_gen_win_origin (struct tui_gen_win_info *win_info,
+ int x, int y)
+{
+ win_info->origin.x = x;
+ win_info->origin.y = y;
+}
+
+
+/*****************************
+** OTHER PUBLIC FUNCTIONS
+*****************************/
+
+
+/* Answer the next window in the list, cycling back to the top if
+ necessary. */
+struct tui_win_info *
+tui_next_win (struct tui_win_info *cur_win)
+{
+ enum tui_win_type type = cur_win->generic.type;
+ struct tui_win_info *next_win = (struct tui_win_info *) NULL;
+
+ if (cur_win->generic.type == CMD_WIN)
+ type = SRC_WIN;
+ else
+ type = cur_win->generic.type + 1;
+ while (type != cur_win->generic.type && (next_win == NULL))
+ {
+ if (tui_win_list[type]
+ && tui_win_list[type]->generic.is_visible)
+ next_win = tui_win_list[type];
+ else
+ {
+ if (type == CMD_WIN)
+ type = SRC_WIN;
+ else
+ type++;
+ }
+ }
+
+ return next_win;
+}
+
+
+/* Answer the prev window in the list, cycling back to the bottom if
+ necessary. */
+struct tui_win_info *
+tui_prev_win (struct tui_win_info *cur_win)
+{
+ enum tui_win_type type = cur_win->generic.type;
+ struct tui_win_info *prev = (struct tui_win_info *) NULL;
+
+ if (cur_win->generic.type == SRC_WIN)
+ type = CMD_WIN;
+ else
+ type = cur_win->generic.type - 1;
+ while (type != cur_win->generic.type && (prev == NULL))
+ {
+ if (tui_win_list[type]
+ && tui_win_list[type]->generic.is_visible)
+ prev = tui_win_list[type];
+ else
+ {
+ if (type == SRC_WIN)
+ type = CMD_WIN;
+ else
+ type--;
+ }
+ }
+
+ return prev;
+}
+
+
+/* Answer the window represented by name. */
+struct tui_win_info *
+tui_partial_win_by_name (char *name)
+{
+ struct tui_win_info *win_info = (struct tui_win_info *) NULL;
+
+ if (name != (char *) NULL)
+ {
+ int i = 0;
+
+ while (i < MAX_MAJOR_WINDOWS && win_info == NULL)
+ {
+ if (tui_win_list[i] != 0)
+ {
+ char *cur_name = tui_win_name (&tui_win_list[i]->generic);
+ if (strlen (name) <= strlen (cur_name)
+ && strncmp (name, cur_name, strlen (name)) == 0)
+ win_info = tui_win_list[i];
+ }
+ i++;
+ }
+ }
+
+ return win_info;
+}
+
+
+/* Answer the name of the window. */
+char *
+tui_win_name (struct tui_gen_win_info *win_info)
+{
+ char *name = (char *) NULL;
+
+ switch (win_info->type)
+ {
+ case SRC_WIN:
+ name = SRC_NAME;
+ break;
+ case CMD_WIN:
+ name = CMD_NAME;
+ break;
+ case DISASSEM_WIN:
+ name = DISASSEM_NAME;
+ break;
+ case DATA_WIN:
+ name = DATA_NAME;
+ break;
+ default:
+ name = "";
+ break;
+ }
+
+ return name;
+}
+
+
+void
+tui_initialize_static_data (void)
+{
+ tui_init_generic_part (tui_source_exec_info_win_ptr ());
+ tui_init_generic_part (tui_disassem_exec_info_win_ptr ());
+ tui_init_generic_part (tui_locator_win_info_ptr ());
+}
+
+
+struct tui_gen_win_info *
+tui_alloc_generic_win_info (void)
+{
+ struct tui_gen_win_info *win;
+
+ if ((win = XMALLOC (struct tui_gen_win_info)) != NULL)
+ tui_init_generic_part (win);
+
+ return win;
+}
+
+
+void
+tui_init_generic_part (struct tui_gen_win_info *win)
+{
+ win->width =
+ win->height =
+ win->origin.x =
+ win->origin.y =
+ win->viewport_height =
+ win->content_size =
+ win->last_visible_line = 0;
+ win->handle = (WINDOW *) NULL;
+ win->content = NULL;
+ win->content_in_use =
+ win->is_visible = FALSE;
+ win->title = 0;
+}
+
+
+/* init_content_element().
+ */
+void
+init_content_element (struct tui_win_element *element,
+ enum tui_win_type type)
+{
+ element->highlight = FALSE;
+ switch (type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ element->which_element.source.line = (char *) NULL;
+ element->which_element.source.line_or_addr.loa = LOA_LINE;
+ element->which_element.source.line_or_addr.u.line_no = 0;
+ element->which_element.source.is_exec_point = FALSE;
+ element->which_element.source.has_break = FALSE;
+ break;
+ case DATA_WIN:
+ tui_init_generic_part (&element->which_element.data_window);
+ element->which_element.data_window.type = DATA_ITEM_WIN;
+ ((struct tui_gen_win_info *) & element->which_element.data_window)->content =
+ (void **) tui_alloc_content (1, DATA_ITEM_WIN);
+ ((struct tui_gen_win_info *)
+ & element->which_element.data_window)->content_size = 1;
+ break;
+ case CMD_WIN:
+ element->which_element.command.line = (char *) NULL;
+ break;
+ case DATA_ITEM_WIN:
+ element->which_element.data.name = (char *) NULL;
+ element->which_element.data.type = TUI_REGISTER;
+ element->which_element.data.item_no = UNDEFINED_ITEM;
+ element->which_element.data.value = NULL;
+ element->which_element.data.highlight = FALSE;
+ element->which_element.data.content = (char*) NULL;
+ break;
+ case LOCATOR_WIN:
+ element->which_element.locator.file_name[0] =
+ element->which_element.locator.proc_name[0] = (char) 0;
+ element->which_element.locator.line_no = 0;
+ element->which_element.locator.addr = 0;
+ break;
+ case EXEC_INFO_WIN:
+ memset(element->which_element.simple_string, ' ',
+ sizeof(element->which_element.simple_string));
+ break;
+ default:
+ break;
+ }
+}
+
+void
+init_win_info (struct tui_win_info *win_info)
+{
+ tui_init_generic_part (&win_info->generic);
+ win_info->can_highlight =
+ win_info->is_highlighted = FALSE;
+ switch (win_info->generic.type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ win_info->detail.source_info.execution_info = (struct tui_gen_win_info *) NULL;
+ win_info->detail.source_info.has_locator = FALSE;
+ win_info->detail.source_info.horizontal_offset = 0;
+ win_info->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
+ win_info->detail.source_info.start_line_or_addr.u.addr = 0;
+ win_info->detail.source_info.filename = 0;
+ break;
+ case DATA_WIN:
+ win_info->detail.data_display_info.data_content = (tui_win_content) NULL;
+ win_info->detail.data_display_info.data_content_count = 0;
+ win_info->detail.data_display_info.regs_content = (tui_win_content) NULL;
+ win_info->detail.data_display_info.regs_content_count = 0;
+ win_info->detail.data_display_info.regs_display_type =
+ TUI_UNDEFINED_REGS;
+ win_info->detail.data_display_info.regs_column_count = 1;
+ win_info->detail.data_display_info.display_regs = FALSE;
+ win_info->detail.data_display_info.current_group = 0;
+ break;
+ case CMD_WIN:
+ win_info->detail.command_info.cur_line = 0;
+ win_info->detail.command_info.curch = 0;
+ break;
+ default:
+ win_info->detail.opaque = NULL;
+ break;
+ }
+}
+
+
+struct tui_win_info *
+tui_alloc_win_info (enum tui_win_type type)
+{
+ struct tui_win_info *win_info;
+
+ win_info = XMALLOC (struct tui_win_info);
+ if (win_info != NULL)
+ {
+ win_info->generic.type = type;
+ init_win_info (win_info);
+ }
+
+ return win_info;
+}
+
+
+/* Allocates the content and elements in a block. */
+tui_win_content
+tui_alloc_content (int num_elements, enum tui_win_type type)
+{
+ tui_win_content content;
+ char *element_block_ptr;
+ int i;
+
+ content = xmalloc (sizeof (struct tui_win_element *) *num_elements);
+ if (content != NULL)
+ {
+ /*
+ * All windows, except the data window, can allocate the
+ * elements in a chunk. The data window cannot because items
+ * can be added/removed from the data display by the user at any
+ * time.
+ */
+ if (type != DATA_WIN)
+ {
+ element_block_ptr =
+ xmalloc (sizeof (struct tui_win_element) * num_elements);
+ if (element_block_ptr != NULL)
+ {
+ for (i = 0; i < num_elements; i++)
+ {
+ content[i] = (struct tui_win_element *) element_block_ptr;
+ init_content_element (content[i], type);
+ element_block_ptr += sizeof (struct tui_win_element);
+ }
+ }
+ else
+ {
+ xfree (content);
+ content = (tui_win_content) NULL;
+ }
+ }
+ }
+
+ return content;
+}
+
+
+/* Adds the input number of elements to the windows's content. If no
+ content has been allocated yet, alloc_content() is called to do
+ this. The index of the first element added is returned, unless
+ there is a memory allocation error, in which case, (-1) is
+ returned. */
+int
+tui_add_content_elements (struct tui_gen_win_info *win_info,
+ int num_elements)
+{
+ struct tui_win_element *element_ptr;
+ int i, index_start;
+
+ if (win_info->content == NULL)
+ {
+ win_info->content = (void **) tui_alloc_content (num_elements, win_info->type);
+ index_start = 0;
+ }
+ else
+ index_start = win_info->content_size;
+ if (win_info->content != NULL)
+ {
+ for (i = index_start; (i < num_elements + index_start); i++)
+ {
+ if ((element_ptr = XMALLOC (struct tui_win_element)) != NULL)
+ {
+ win_info->content[i] = (void *) element_ptr;
+ init_content_element (element_ptr, win_info->type);
+ win_info->content_size++;
+ }
+ else /* Things must be really hosed now! We ran out of
+ memory!? */
+ return (-1);
+ }
+ }
+
+ return index_start;
+}
+
+
+/* Delete all curses windows associated with win_info, leaving
+ everything else intact. */
+void
+tui_del_window (struct tui_win_info *win_info)
+{
+ struct tui_gen_win_info *generic_win;
+
+ switch (win_info->generic.type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ generic_win = tui_locator_win_info_ptr ();
+ if (generic_win != (struct tui_gen_win_info *) NULL)
+ {
+ tui_delete_win (generic_win->handle);
+ generic_win->handle = (WINDOW *) NULL;
+ generic_win->is_visible = FALSE;
+ }
+ if (win_info->detail.source_info.filename)
+ {
+ xfree (win_info->detail.source_info.filename);
+ win_info->detail.source_info.filename = 0;
+ }
+ generic_win = win_info->detail.source_info.execution_info;
+ if (generic_win != (struct tui_gen_win_info *) NULL)
+ {
+ tui_delete_win (generic_win->handle);
+ generic_win->handle = (WINDOW *) NULL;
+ generic_win->is_visible = FALSE;
+ }
+ break;
+ case DATA_WIN:
+ if (win_info->generic.content != NULL)
+ {
+ tui_del_data_windows (win_info->detail.data_display_info.regs_content,
+ win_info->detail.data_display_info.regs_content_count);
+ tui_del_data_windows (win_info->detail.data_display_info.data_content,
+ win_info->detail.data_display_info.data_content_count);
+ }
+ break;
+ default:
+ break;
+ }
+ if (win_info->generic.handle != (WINDOW *) NULL)
+ {
+ tui_delete_win (win_info->generic.handle);
+ win_info->generic.handle = (WINDOW *) NULL;
+ win_info->generic.is_visible = FALSE;
+ }
+}
+
+
+void
+tui_free_window (struct tui_win_info *win_info)
+{
+ struct tui_gen_win_info *generic_win;
+
+ switch (win_info->generic.type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ generic_win = tui_locator_win_info_ptr ();
+ if (generic_win != (struct tui_gen_win_info *) NULL)
+ {
+ tui_delete_win (generic_win->handle);
+ generic_win->handle = (WINDOW *) NULL;
+ }
+ tui_free_win_content (generic_win);
+ if (win_info->detail.source_info.filename)
+ {
+ xfree (win_info->detail.source_info.filename);
+ win_info->detail.source_info.filename = 0;
+ }
+ generic_win = win_info->detail.source_info.execution_info;
+ if (generic_win != (struct tui_gen_win_info *) NULL)
+ {
+ tui_delete_win (generic_win->handle);
+ generic_win->handle = (WINDOW *) NULL;
+ tui_free_win_content (generic_win);
+ }
+ break;
+ case DATA_WIN:
+ if (win_info->generic.content != NULL)
+ {
+ tui_free_data_content (win_info->detail.data_display_info.regs_content,
+ win_info->detail.data_display_info.regs_content_count);
+ win_info->detail.data_display_info.regs_content =
+ (tui_win_content) NULL;
+ win_info->detail.data_display_info.regs_content_count = 0;
+ tui_free_data_content (win_info->detail.data_display_info.data_content,
+ win_info->detail.data_display_info.data_content_count);
+ win_info->detail.data_display_info.data_content =
+ (tui_win_content) NULL;
+ win_info->detail.data_display_info.data_content_count = 0;
+ win_info->detail.data_display_info.regs_display_type =
+ TUI_UNDEFINED_REGS;
+ win_info->detail.data_display_info.regs_column_count = 1;
+ win_info->detail.data_display_info.display_regs = FALSE;
+ win_info->generic.content = NULL;
+ win_info->generic.content_size = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ if (win_info->generic.handle != (WINDOW *) NULL)
+ {
+ tui_delete_win (win_info->generic.handle);
+ win_info->generic.handle = (WINDOW *) NULL;
+ tui_free_win_content (&win_info->generic);
+ }
+ if (win_info->generic.title)
+ xfree (win_info->generic.title);
+ xfree (win_info);
+}
+
+
+void
+tui_free_all_source_wins_content (void)
+{
+ int i;
+
+ for (i = 0; i < (tui_source_windows ())->count; i++)
+ {
+ struct tui_win_info *win_info = (tui_source_windows ())->list[i];
+
+ if (win_info != NULL)
+ {
+ tui_free_win_content (&(win_info->generic));
+ tui_free_win_content (win_info->detail.source_info.execution_info);
+ }
+ }
+}
+
+
+void
+tui_free_win_content (struct tui_gen_win_info *win_info)
+{
+ if (win_info->content != NULL)
+ {
+ free_content ((tui_win_content) win_info->content,
+ win_info->content_size,
+ win_info->type);
+ win_info->content = NULL;
+ }
+ win_info->content_size = 0;
+}
+
+
+void
+tui_del_data_windows (tui_win_content content,
+ int content_size)
+{
+ int i;
+
+ /* Remember that data window content elements are of type struct
+ tui_gen_win_info *, each of which whose single element is a data
+ element. */
+ for (i = 0; i < content_size; i++)
+ {
+ struct tui_gen_win_info *generic_win = &content[i]->which_element.data_window;
+
+ if (generic_win != (struct tui_gen_win_info *) NULL)
+ {
+ tui_delete_win (generic_win->handle);
+ generic_win->handle = (WINDOW *) NULL;
+ generic_win->is_visible = FALSE;
+ }
+ }
+}
+
+
+void
+tui_free_data_content (tui_win_content content,
+ int content_size)
+{
+ int i;
+
+ /* Remember that data window content elements are of type struct
+ tui_gen_win_info *, each of which whose single element is a data
+ element. */
+ for (i = 0; i < content_size; i++)
+ {
+ struct tui_gen_win_info *generic_win = &content[i]->which_element.data_window;
+
+ if (generic_win != (struct tui_gen_win_info *) NULL)
+ {
+ tui_delete_win (generic_win->handle);
+ generic_win->handle = (WINDOW *) NULL;
+ tui_free_win_content (generic_win);
+ }
+ }
+ free_content (content,
+ content_size,
+ DATA_WIN);
+}
+
+
+/**********************************
+** LOCAL STATIC FUNCTIONS **
+**********************************/
+
+
+static void
+free_content (tui_win_content content,
+ int content_size,
+ enum tui_win_type win_type)
+{
+ if (content != (tui_win_content) NULL)
+ {
+ free_content_elements (content, content_size, win_type);
+ xfree (content);
+ }
+}
+
+
+/* free_content_elements().
+ */
+static void
+free_content_elements (tui_win_content content,
+ int content_size,
+ enum tui_win_type type)
+{
+ if (content != (tui_win_content) NULL)
+ {
+ int i;
+
+ if (type == SRC_WIN || type == DISASSEM_WIN)
+ {
+ /* Free whole source block. */
+ xfree (content[0]->which_element.source.line);
+ }
+ else
+ {
+ for (i = 0; i < content_size; i++)
+ {
+ struct tui_win_element *element;
+
+ element = content[i];
+ if (element != (struct tui_win_element *) NULL)
+ {
+ switch (type)
+ {
+ case DATA_WIN:
+ xfree (element);
+ break;
+ case DATA_ITEM_WIN:
+ /* Note that data elements are not allocated in
+ a single block, but individually, as
+ needed. */
+ if (element->which_element.data.type != TUI_REGISTER)
+ xfree ((void *)element->which_element.data.name);
+ xfree (element->which_element.data.value);
+ xfree (element->which_element.data.content);
+ xfree (element);
+ break;
+ case CMD_WIN:
+ xfree (element->which_element.command.line);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ if (type != DATA_WIN && type != DATA_ITEM_WIN)
+ xfree (content[0]); /* Free the element block. */
+ }
+}
tui-data.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-stack.h
===================================================================
--- tui-stack.h (nonexistent)
+++ tui-stack.h (revision 157)
@@ -0,0 +1,32 @@
+/* TUI display locator.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_STACK_H
+#define TUI_STACK_H
+
+struct frame_info;
+
+extern void tui_update_locator_filename (const char *);
+extern void tui_show_locator_content (void);
+extern void tui_show_frame_info (struct frame_info *);
+
+#endif
tui-stack.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-layout.c
===================================================================
--- tui-layout.c (nonexistent)
+++ tui-layout.c (revision 157)
@@ -0,0 +1,1076 @@
+/* TUI layout window management.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "command.h"
+#include "symtab.h"
+#include "frame.h"
+#include "source.h"
+#include
+
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-windata.h"
+#include "tui/tui-wingeneral.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-regs.h"
+#include "tui/tui-win.h"
+#include "tui/tui-winsource.h"
+#include "tui/tui-disasm.h"
+
+#include "gdb_string.h"
+#include "gdb_curses.h"
+
+/*******************************
+** Static Local Decls
+********************************/
+static void show_layout (enum tui_layout_type);
+static void init_gen_win_info (struct tui_gen_win_info *,
+ enum tui_win_type,
+ int, int, int, int);
+static void *init_and_make_win (void *, enum tui_win_type,
+ int, int, int, int, int);
+static void show_source_or_disasm_and_command (enum tui_layout_type);
+static void make_source_or_disasm_window (struct tui_win_info **,
+ enum tui_win_type,
+ int, int);
+static void make_command_window (struct tui_win_info **, int, int);
+static void make_source_window (struct tui_win_info **, int, int);
+static void make_disasm_window (struct tui_win_info **, int, int);
+static void make_data_window (struct tui_win_info **, int, int);
+static void show_source_command (void);
+static void show_disasm_command (void);
+static void show_source_disasm_command (void);
+static void show_data (enum tui_layout_type);
+static enum tui_layout_type next_layout (void);
+static enum tui_layout_type prev_layout (void);
+static void tui_layout_command (char *, int);
+static void tui_toggle_layout_command (char *, int);
+static void tui_toggle_split_layout_command (char *, int);
+static CORE_ADDR extract_display_start_addr (void);
+static void tui_handle_xdb_layout (struct tui_layout_def *);
+
+
+/***************************************
+** DEFINITIONS
+***************************************/
+
+#define LAYOUT_USAGE "Usage: layout prev | next | \n"
+
+/* Show the screen layout defined. */
+static void
+show_layout (enum tui_layout_type layout)
+{
+ enum tui_layout_type cur_layout = tui_current_layout ();
+
+ if (layout != cur_layout)
+ {
+ /* Since the new layout may cause changes in window size, we
+ should free the content and reallocate on next display of
+ source/asm. */
+ tui_free_all_source_wins_content ();
+ tui_clear_source_windows ();
+ if (layout == SRC_DATA_COMMAND
+ || layout == DISASSEM_DATA_COMMAND)
+ {
+ show_data (layout);
+ tui_refresh_all (tui_win_list);
+ }
+ else
+ {
+ /* First make the current layout be invisible. */
+ tui_make_all_invisible ();
+ tui_make_invisible (tui_locator_win_info_ptr ());
+
+ switch (layout)
+ {
+ /* Now show the new layout. */
+ case SRC_COMMAND:
+ show_source_command ();
+ tui_add_to_source_windows (TUI_SRC_WIN);
+ break;
+ case DISASSEM_COMMAND:
+ show_disasm_command ();
+ tui_add_to_source_windows (TUI_DISASM_WIN);
+ break;
+ case SRC_DISASSEM_COMMAND:
+ show_source_disasm_command ();
+ tui_add_to_source_windows (TUI_SRC_WIN);
+ tui_add_to_source_windows (TUI_DISASM_WIN);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
+
+/* 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;
+ CORE_ADDR addr = extract_display_start_addr ();
+ struct tui_win_info *win_with_focus = tui_win_with_focus ();
+ struct tui_layout_def *layout_def = tui_layout_def ();
+
+
+ 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! */
+
+ addr = tui_get_begin_asm_address ();
+ 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! */
+
+ addr = tui_get_begin_asm_address ();
+ 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! */
+
+ addr = tui_get_begin_asm_address ();
+ 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 (addr);
+ }
+ if (regs_populate)
+ {
+ tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group);
+ }
+ }
+ }
+ else
+ status = TUI_FAILURE;
+
+ return status;
+}
+
+/* Add the specified window to the layout in a logical way. This
+ means setting up the most logical layout given the window to be
+ added. */
+void
+tui_add_win_to_layout (enum tui_win_type type)
+{
+ enum tui_layout_type cur_layout = tui_current_layout ();
+
+ switch (type)
+ {
+ case SRC_WIN:
+ if (cur_layout != SRC_COMMAND
+ && cur_layout != SRC_DISASSEM_COMMAND
+ && cur_layout != SRC_DATA_COMMAND)
+ {
+ tui_clear_source_windows_detail ();
+ if (cur_layout == DISASSEM_DATA_COMMAND)
+ show_layout (SRC_DATA_COMMAND);
+ else
+ show_layout (SRC_COMMAND);
+ }
+ break;
+ case DISASSEM_WIN:
+ if (cur_layout != DISASSEM_COMMAND
+ && cur_layout != SRC_DISASSEM_COMMAND
+ && cur_layout != DISASSEM_DATA_COMMAND)
+ {
+ tui_clear_source_windows_detail ();
+ if (cur_layout == SRC_DATA_COMMAND)
+ show_layout (DISASSEM_DATA_COMMAND);
+ else
+ show_layout (DISASSEM_COMMAND);
+ }
+ break;
+ case DATA_WIN:
+ if (cur_layout != SRC_DATA_COMMAND
+ && cur_layout != DISASSEM_DATA_COMMAND)
+ {
+ if (cur_layout == DISASSEM_COMMAND)
+ show_layout (DISASSEM_DATA_COMMAND);
+ else
+ show_layout (SRC_DATA_COMMAND);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+
+/* Answer the height of a window. If it hasn't been created yet,
+ answer what the height of a window would be based upon its type and
+ the layout. */
+int
+tui_default_win_height (enum tui_win_type type,
+ enum tui_layout_type layout)
+{
+ int h;
+
+ if (tui_win_list[type] != (struct tui_win_info *) NULL)
+ h = tui_win_list[type]->generic.height;
+ else
+ {
+ switch (layout)
+ {
+ case SRC_COMMAND:
+ case DISASSEM_COMMAND:
+ if (TUI_CMD_WIN == NULL)
+ h = tui_term_height () / 2;
+ else
+ h = tui_term_height () - TUI_CMD_WIN->generic.height;
+ break;
+ case SRC_DISASSEM_COMMAND:
+ case SRC_DATA_COMMAND:
+ case DISASSEM_DATA_COMMAND:
+ if (TUI_CMD_WIN == NULL)
+ h = tui_term_height () / 3;
+ else
+ h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
+ break;
+ default:
+ h = 0;
+ break;
+ }
+ }
+
+ return h;
+}
+
+
+/* Answer the height of a window. If it hasn't been created yet,
+ answer what the height of a window would be based upon its type and
+ the layout. */
+int
+tui_default_win_viewport_height (enum tui_win_type type,
+ enum tui_layout_type layout)
+{
+ int h;
+
+ h = tui_default_win_height (type, layout);
+
+ if (tui_win_list[type] == TUI_CMD_WIN)
+ h -= 1;
+ else
+ h -= 2;
+
+ return h;
+}
+
+
+/* Function to initialize gdb commands, for tui window layout
+ manipulation. */
+void
+_initialize_tui_layout (void)
+{
+ add_com ("layout", class_tui, tui_layout_command, _("\
+Change the layout of windows.\n\
+Usage: layout prev | next | \n\
+Layout names are:\n\
+ src : Displays source and command windows.\n\
+ asm : Displays disassembly and command windows.\n\
+ split : Displays source, disassembly and command windows.\n\
+ regs : Displays register window. If existing layout\n\
+ is source/command or assembly/command, the \n\
+ register window is displayed. If the\n\
+ source/assembly/command (split) is displayed, \n\
+ the register window is displayed with \n\
+ the window that has current logical focus.\n"));
+ if (xdb_commands)
+ {
+ add_com ("td", class_tui, tui_toggle_layout_command, _("\
+Toggle between Source/Command and Disassembly/Command layouts.\n"));
+ add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\
+Toggle between Source/Command or Disassembly/Command and \n\
+Source/Disassembly/Command layouts.\n"));
+ }
+}
+
+
+/*************************
+** STATIC LOCAL FUNCTIONS
+**************************/
+
+
+/* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
+ REGS, $REGS, $GREGS, $FREGS, $SREGS. */
+enum tui_status
+tui_set_layout_for_display_command (const char *layout_name)
+{
+ enum tui_status status = TUI_SUCCESS;
+
+ if (layout_name != (char *) NULL)
+ {
+ int i;
+ char *buf_ptr;
+ enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
+ enum tui_register_display_type dpy_type = TUI_UNDEFINED_REGS;
+ enum tui_layout_type cur_layout = tui_current_layout ();
+
+ buf_ptr = (char *) xstrdup (layout_name);
+ for (i = 0; (i < strlen (layout_name)); i++)
+ buf_ptr[i] = toupper (buf_ptr[i]);
+
+ /* First check for ambiguous input. */
+ if (strlen (buf_ptr) <= 1
+ && (*buf_ptr == 'S' || *buf_ptr == '$'))
+ {
+ warning (_("Ambiguous command input."));
+ status = TUI_FAILURE;
+ }
+ else
+ {
+ if (subset_compare (buf_ptr, "SRC"))
+ new_layout = SRC_COMMAND;
+ else if (subset_compare (buf_ptr, "ASM"))
+ new_layout = DISASSEM_COMMAND;
+ else if (subset_compare (buf_ptr, "SPLIT"))
+ new_layout = SRC_DISASSEM_COMMAND;
+ else if (subset_compare (buf_ptr, "REGS")
+ || subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME)
+ || subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME)
+ || subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME)
+ || subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
+ {
+ if (cur_layout == SRC_COMMAND
+ || cur_layout == SRC_DATA_COMMAND)
+ new_layout = SRC_DATA_COMMAND;
+ else
+ new_layout = DISASSEM_DATA_COMMAND;
+
+ /* Could ifdef out the following code. when compile with
+ -z, there are null pointer references that cause a
+ core dump if 'layout regs' is the first layout
+ command issued by the user. HP has asked us to hook
+ up this code. - edie epstein */
+ if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME))
+ {
+ if (TUI_DATA_WIN->detail.data_display_info.regs_display_type != TUI_SFLOAT_REGS
+ && TUI_DATA_WIN->detail.data_display_info.regs_display_type != TUI_DFLOAT_REGS)
+ dpy_type = TUI_SFLOAT_REGS;
+ else
+ dpy_type =
+ TUI_DATA_WIN->detail.data_display_info.regs_display_type;
+ }
+ else if (subset_compare (buf_ptr,
+ TUI_GENERAL_SPECIAL_REGS_NAME))
+ dpy_type = TUI_GENERAL_AND_SPECIAL_REGS;
+ else if (subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME))
+ dpy_type = TUI_GENERAL_REGS;
+ else if (subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
+ dpy_type = TUI_SPECIAL_REGS;
+ else if (TUI_DATA_WIN)
+ {
+ if (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
+ TUI_UNDEFINED_REGS)
+ dpy_type =
+ TUI_DATA_WIN->detail.data_display_info.regs_display_type;
+ else
+ dpy_type = TUI_GENERAL_REGS;
+ }
+
+ /* End of potential ifdef.
+ */
+
+ /* If ifdefed out code above, then assume that the user
+ wishes to display the general purpose registers .
+ */
+
+ /* dpy_type = TUI_GENERAL_REGS; */
+ }
+ else if (subset_compare (buf_ptr, "NEXT"))
+ new_layout = next_layout ();
+ else if (subset_compare (buf_ptr, "PREV"))
+ new_layout = prev_layout ();
+ else
+ status = TUI_FAILURE;
+
+ tui_set_layout (new_layout, dpy_type);
+ }
+ xfree (buf_ptr);
+ }
+ else
+ status = TUI_FAILURE;
+
+ return status;
+}
+
+
+static CORE_ADDR
+extract_display_start_addr (void)
+{
+ enum tui_layout_type cur_layout = tui_current_layout ();
+ CORE_ADDR addr;
+ CORE_ADDR pc;
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
+ switch (cur_layout)
+ {
+ case SRC_COMMAND:
+ case SRC_DATA_COMMAND:
+ find_line_pc (cursal.symtab,
+ TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
+ &pc);
+ addr = pc;
+ break;
+ case DISASSEM_COMMAND:
+ case SRC_DISASSEM_COMMAND:
+ case DISASSEM_DATA_COMMAND:
+ addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
+ break;
+ default:
+ addr = 0;
+ break;
+ }
+
+ return addr;
+}
+
+
+static void
+tui_handle_xdb_layout (struct tui_layout_def *layout_def)
+{
+ if (layout_def->split)
+ {
+ tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
+ tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
+ }
+ else
+ {
+ if (layout_def->display_mode == SRC_WIN)
+ tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
+ else
+ tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
+ }
+}
+
+
+static void
+tui_toggle_layout_command (char *arg, int from_tty)
+{
+ struct tui_layout_def *layout_def = tui_layout_def ();
+
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ if (layout_def->display_mode == SRC_WIN)
+ layout_def->display_mode = DISASSEM_WIN;
+ else
+ layout_def->display_mode = SRC_WIN;
+
+ if (!layout_def->split)
+ tui_handle_xdb_layout (layout_def);
+}
+
+
+static void
+tui_toggle_split_layout_command (char *arg, int from_tty)
+{
+ struct tui_layout_def *layout_def = tui_layout_def ();
+
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ layout_def->split = (!layout_def->split);
+ tui_handle_xdb_layout (layout_def);
+}
+
+
+static void
+tui_layout_command (char *arg, int from_tty)
+{
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+
+ /* Switch to the selected layout. */
+ if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS)
+ warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
+
+}
+
+/* Answer the previous layout to cycle to. */
+static enum tui_layout_type
+next_layout (void)
+{
+ enum tui_layout_type new_layout;
+
+ new_layout = tui_current_layout ();
+ if (new_layout == UNDEFINED_LAYOUT)
+ new_layout = SRC_COMMAND;
+ else
+ {
+ new_layout++;
+ if (new_layout == UNDEFINED_LAYOUT)
+ new_layout = SRC_COMMAND;
+ }
+
+ return new_layout;
+}
+
+
+/* Answer the next layout to cycle to. */
+static enum tui_layout_type
+prev_layout (void)
+{
+ enum tui_layout_type new_layout;
+
+ new_layout = tui_current_layout ();
+ if (new_layout == SRC_COMMAND)
+ new_layout = DISASSEM_DATA_COMMAND;
+ else
+ {
+ new_layout--;
+ if (new_layout == UNDEFINED_LAYOUT)
+ new_layout = DISASSEM_DATA_COMMAND;
+ }
+
+ return new_layout;
+}
+
+
+
+static void
+make_command_window (struct tui_win_info **win_info_ptr,
+ int height, int origin_y)
+{
+ *win_info_ptr = init_and_make_win (*win_info_ptr,
+ CMD_WIN,
+ height,
+ tui_term_width (),
+ 0,
+ origin_y,
+ DONT_BOX_WINDOW);
+
+ (*win_info_ptr)->can_highlight = FALSE;
+}
+
+
+/* make_source_window().
+ */
+static void
+make_source_window (struct tui_win_info **win_info_ptr,
+ int height, int origin_y)
+{
+ make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
+
+ return;
+} /* make_source_window */
+
+
+/* make_disasm_window().
+ */
+static void
+make_disasm_window (struct tui_win_info **win_info_ptr,
+ int height, int origin_y)
+{
+ make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
+
+ return;
+} /* make_disasm_window */
+
+
+static void
+make_data_window (struct tui_win_info **win_info_ptr,
+ int height, int origin_y)
+{
+ *win_info_ptr = init_and_make_win (*win_info_ptr,
+ DATA_WIN,
+ height,
+ tui_term_width (),
+ 0,
+ origin_y,
+ BOX_WINDOW);
+}
+
+
+
+/* Show the Source/Command layout. */
+static void
+show_source_command (void)
+{
+ show_source_or_disasm_and_command (SRC_COMMAND);
+}
+
+
+/* Show the Dissassem/Command layout. */
+static void
+show_disasm_command (void)
+{
+ show_source_or_disasm_and_command (DISASSEM_COMMAND);
+}
+
+
+/* Show the Source/Disassem/Command layout. */
+static void
+show_source_disasm_command (void)
+{
+ if (tui_current_layout () != SRC_DISASSEM_COMMAND)
+ {
+ int cmd_height, src_height, asm_height;
+
+ if (TUI_CMD_WIN != NULL)
+ cmd_height = TUI_CMD_WIN->generic.height;
+ else
+ cmd_height = tui_term_height () / 3;
+
+ src_height = (tui_term_height () - cmd_height) / 2;
+ asm_height = tui_term_height () - (src_height + cmd_height);
+
+ if (TUI_SRC_WIN == NULL)
+ make_source_window (&TUI_SRC_WIN, src_height, 0);
+ else
+ {
+ init_gen_win_info (&TUI_SRC_WIN->generic,
+ TUI_SRC_WIN->generic.type,
+ src_height,
+ TUI_SRC_WIN->generic.width,
+ TUI_SRC_WIN->detail.source_info.execution_info->width,
+ 0);
+ TUI_SRC_WIN->can_highlight = TRUE;
+ init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
+ EXEC_INFO_WIN,
+ src_height,
+ 3,
+ 0,
+ 0);
+ tui_make_visible (&TUI_SRC_WIN->generic);
+ tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
+ TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
+ }
+ if (TUI_SRC_WIN != NULL)
+ {
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+
+ tui_show_source_content (TUI_SRC_WIN);
+ if (TUI_DISASM_WIN == NULL)
+ {
+ make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
+ locator = init_and_make_win (locator,
+ LOCATOR_WIN,
+ 2 /* 1 */ ,
+ tui_term_width (),
+ 0,
+ (src_height + asm_height) - 1,
+ DONT_BOX_WINDOW);
+ }
+ else
+ {
+ init_gen_win_info (locator,
+ LOCATOR_WIN,
+ 2 /* 1 */ ,
+ tui_term_width (),
+ 0,
+ (src_height + asm_height) - 1);
+ TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
+ init_gen_win_info (&TUI_DISASM_WIN->generic,
+ TUI_DISASM_WIN->generic.type,
+ asm_height,
+ TUI_DISASM_WIN->generic.width,
+ TUI_DISASM_WIN->detail.source_info.execution_info->width,
+ src_height - 1);
+ init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
+ EXEC_INFO_WIN,
+ asm_height,
+ 3,
+ 0,
+ src_height - 1);
+ TUI_DISASM_WIN->can_highlight = TRUE;
+ tui_make_visible (&TUI_DISASM_WIN->generic);
+ tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
+ }
+ if (TUI_DISASM_WIN != NULL)
+ {
+ TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
+ TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
+ tui_make_visible (locator);
+ tui_show_locator_content ();
+ tui_show_source_content (TUI_DISASM_WIN);
+
+ if (TUI_CMD_WIN == NULL)
+ make_command_window (&TUI_CMD_WIN,
+ cmd_height,
+ tui_term_height () - cmd_height);
+ else
+ {
+ init_gen_win_info (&TUI_CMD_WIN->generic,
+ TUI_CMD_WIN->generic.type,
+ TUI_CMD_WIN->generic.height,
+ TUI_CMD_WIN->generic.width,
+ 0,
+ TUI_CMD_WIN->generic.origin.y);
+ TUI_CMD_WIN->can_highlight = FALSE;
+ tui_make_visible (&TUI_CMD_WIN->generic);
+ }
+ if (TUI_CMD_WIN != NULL)
+ tui_refresh_win (&TUI_CMD_WIN->generic);
+ }
+ }
+ tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
+ }
+}
+
+
+/* Show the Source/Data/Command or the Dissassembly/Data/Command
+ layout. */
+static void
+show_data (enum tui_layout_type new_layout)
+{
+ int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
+ int src_height, data_height;
+ enum tui_win_type win_type;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+
+
+ data_height = total_height / 2;
+ src_height = total_height - data_height;
+ tui_make_all_invisible ();
+ tui_make_invisible (locator);
+ make_data_window (&TUI_DATA_WIN, data_height, 0);
+ TUI_DATA_WIN->can_highlight = TRUE;
+ if (new_layout == SRC_DATA_COMMAND)
+ win_type = SRC_WIN;
+ else
+ win_type = DISASSEM_WIN;
+ if (tui_win_list[win_type] == NULL)
+ {
+ if (win_type == SRC_WIN)
+ make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
+ else
+ make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
+ locator = init_and_make_win (locator,
+ LOCATOR_WIN,
+ 2 /* 1 */ ,
+ tui_term_width (),
+ 0,
+ total_height - 1,
+ DONT_BOX_WINDOW);
+ }
+ else
+ {
+ init_gen_win_info (&tui_win_list[win_type]->generic,
+ tui_win_list[win_type]->generic.type,
+ src_height,
+ tui_win_list[win_type]->generic.width,
+ tui_win_list[win_type]->detail.source_info.execution_info->width,
+ data_height - 1);
+ init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
+ EXEC_INFO_WIN,
+ src_height,
+ 3,
+ 0,
+ data_height - 1);
+ tui_make_visible (&tui_win_list[win_type]->generic);
+ tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
+ init_gen_win_info (locator,
+ LOCATOR_WIN,
+ 2 /* 1 */ ,
+ tui_term_width (),
+ 0,
+ total_height - 1);
+ }
+ tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
+ tui_make_visible (locator);
+ tui_show_locator_content ();
+ tui_add_to_source_windows (tui_win_list[win_type]);
+ tui_set_current_layout_to (new_layout);
+}
+
+/* init_gen_win_info().
+ */
+static void
+init_gen_win_info (struct tui_gen_win_info *win_info,
+ enum tui_win_type type,
+ int height, int width,
+ int origin_x, int origin_y)
+{
+ int h = height;
+
+ win_info->type = type;
+ win_info->width = width;
+ win_info->height = h;
+ if (h > 1)
+ {
+ win_info->viewport_height = h - 1;
+ if (win_info->type != CMD_WIN)
+ win_info->viewport_height--;
+ }
+ else
+ win_info->viewport_height = 1;
+ win_info->origin.x = origin_x;
+ win_info->origin.y = origin_y;
+
+ return;
+} /* init_gen_win_info */
+
+/* init_and_make_win().
+ */
+static void *
+init_and_make_win (void *opaque_win_info,
+ enum tui_win_type win_type,
+ int height, int width,
+ int origin_x, int origin_y,
+ int box_it)
+{
+ struct tui_gen_win_info *generic;
+
+ if (opaque_win_info == NULL)
+ {
+ if (tui_win_is_auxillary (win_type))
+ opaque_win_info = (void *) tui_alloc_generic_win_info ();
+ else
+ opaque_win_info = (void *) tui_alloc_win_info (win_type);
+ }
+ if (tui_win_is_auxillary (win_type))
+ generic = (struct tui_gen_win_info *) opaque_win_info;
+ else
+ generic = &((struct tui_win_info *) opaque_win_info)->generic;
+
+ if (opaque_win_info != NULL)
+ {
+ init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
+ if (!tui_win_is_auxillary (win_type))
+ {
+ if (generic->type == CMD_WIN)
+ ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
+ else
+ ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
+ }
+ tui_make_window (generic, box_it);
+ }
+ return opaque_win_info;
+}
+
+
+static void
+make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
+ enum tui_win_type type,
+ int height, int origin_y)
+{
+ struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL;
+
+ /* Create the exeuction info window. */
+ if (type == SRC_WIN)
+ execution_info = tui_source_exec_info_win_ptr ();
+ else
+ execution_info = tui_disassem_exec_info_win_ptr ();
+ execution_info = init_and_make_win (execution_info,
+ EXEC_INFO_WIN,
+ height,
+ 3,
+ 0,
+ origin_y,
+ DONT_BOX_WINDOW);
+
+ /* Now create the source window. */
+ *win_info_ptr = init_and_make_win (*win_info_ptr,
+ type,
+ height,
+ tui_term_width () - execution_info->width,
+ execution_info->width,
+ origin_y,
+ BOX_WINDOW);
+
+ (*win_info_ptr)->detail.source_info.execution_info = execution_info;
+}
+
+
+/* Show the Source/Command or the Disassem layout. */
+static void
+show_source_or_disasm_and_command (enum tui_layout_type layout_type)
+{
+ if (tui_current_layout () != layout_type)
+ {
+ struct tui_win_info **win_info_ptr;
+ int src_height, cmd_height;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+
+ if (TUI_CMD_WIN != NULL)
+ cmd_height = TUI_CMD_WIN->generic.height;
+ else
+ cmd_height = tui_term_height () / 3;
+ src_height = tui_term_height () - cmd_height;
+
+ if (layout_type == SRC_COMMAND)
+ win_info_ptr = &TUI_SRC_WIN;
+ else
+ win_info_ptr = &TUI_DISASM_WIN;
+
+ if ((*win_info_ptr) == NULL)
+ {
+ if (layout_type == SRC_COMMAND)
+ make_source_window (win_info_ptr, src_height - 1, 0);
+ else
+ make_disasm_window (win_info_ptr, src_height - 1, 0);
+ locator = init_and_make_win (locator,
+ LOCATOR_WIN,
+ 2 /* 1 */ ,
+ tui_term_width (),
+ 0,
+ src_height - 1,
+ DONT_BOX_WINDOW);
+ }
+ else
+ {
+ init_gen_win_info (locator,
+ LOCATOR_WIN,
+ 2 /* 1 */ ,
+ tui_term_width (),
+ 0,
+ src_height - 1);
+ (*win_info_ptr)->detail.source_info.has_locator = TRUE;
+ init_gen_win_info (&(*win_info_ptr)->generic,
+ (*win_info_ptr)->generic.type,
+ src_height - 1,
+ (*win_info_ptr)->generic.width,
+ (*win_info_ptr)->detail.source_info.execution_info->width,
+ 0);
+ init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
+ EXEC_INFO_WIN,
+ src_height - 1,
+ 3,
+ 0,
+ 0);
+ (*win_info_ptr)->can_highlight = TRUE;
+ tui_make_visible (&(*win_info_ptr)->generic);
+ tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
+ }
+ if ((*win_info_ptr) != NULL)
+ {
+ (*win_info_ptr)->detail.source_info.has_locator = TRUE;
+ tui_make_visible (locator);
+ tui_show_locator_content ();
+ tui_show_source_content (*win_info_ptr);
+
+ if (TUI_CMD_WIN == NULL)
+ {
+ make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
+ tui_refresh_win (&TUI_CMD_WIN->generic);
+ }
+ else
+ {
+ init_gen_win_info (&TUI_CMD_WIN->generic,
+ TUI_CMD_WIN->generic.type,
+ TUI_CMD_WIN->generic.height,
+ TUI_CMD_WIN->generic.width,
+ TUI_CMD_WIN->generic.origin.x,
+ TUI_CMD_WIN->generic.origin.y);
+ TUI_CMD_WIN->can_highlight = FALSE;
+ tui_make_visible (&TUI_CMD_WIN->generic);
+ }
+ }
+ tui_set_current_layout_to (layout_type);
+ }
+}
tui-layout.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-data.h
===================================================================
--- tui-data.h (nonexistent)
+++ tui-data.h (revision 157)
@@ -0,0 +1,363 @@
+/* TUI data manipulation routines.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_DATA_H
+#define TUI_DATA_H
+
+#include "tui/tui.h" /* For enum tui_win_type. */
+#include "gdb_curses.h" /* For WINDOW. */
+
+/* This is a point definition. */
+struct tui_point
+{
+ int x, y;
+};
+
+/* Generic window information. */
+struct tui_gen_win_info
+{
+ WINDOW *handle; /* Window handle. */
+ enum tui_win_type type; /* Type of window. */
+ int width; /* Window width. */
+ int height; /* Window height. */
+ struct tui_point origin; /* Origin of window. */
+ void **content; /* Content of window. */
+ int content_size; /* Size of content (# of elements). */
+ int content_in_use; /* Can it be used, or is it already used? */
+ int viewport_height; /* Viewport height. */
+ int last_visible_line; /* Index of last visible line. */
+ int is_visible; /* Whether the window is visible or not. */
+ char *title; /* Window title to display. */
+};
+
+/* Constant definitions. */
+#define DEFAULT_TAB_LEN 8
+#define NO_SRC_STRING "[ No Source Available ]"
+#define NO_DISASSEM_STRING "[ No Assembly Available ]"
+#define NO_REGS_STRING "[ Register Values Unavailable ]"
+#define NO_DATA_STRING "[ No Data Values Displayed ]"
+#define MAX_CONTENT_COUNT 100
+#define SRC_NAME "SRC"
+#define CMD_NAME "CMD"
+#define DATA_NAME "REGS"
+#define DISASSEM_NAME "ASM"
+#define TUI_NULL_STR ""
+#define DEFAULT_HISTORY_COUNT 25
+#define BOX_WINDOW TRUE
+#define DONT_BOX_WINDOW FALSE
+#define HILITE TRUE
+#define NO_HILITE FALSE
+#define WITH_LOCATOR TRUE
+#define NO_LOCATOR FALSE
+#define EMPTY_SOURCE_PROMPT TRUE
+#define NO_EMPTY_SOURCE_PROMPT FALSE
+#define UNDEFINED_ITEM -1
+#define MIN_WIN_HEIGHT 3
+#define MIN_CMD_WIN_HEIGHT 3
+
+/* Strings to display in the TUI status line. */
+#define PROC_PREFIX "In: "
+#define LINE_PREFIX "Line: "
+#define PC_PREFIX "PC: "
+#define SINGLE_KEY "(SingleKey)"
+
+/* Minimum/Maximum length of some fields displayed in the TUI status
+ line. */
+#define MIN_LINE_WIDTH 4 /* Use at least 4 digits for line
+ numbers. */
+#define MIN_PROC_WIDTH 12
+#define MAX_TARGET_WIDTH 10
+#define MAX_PID_WIDTH 14
+
+#define TUI_FLOAT_REGS_NAME "$FREGS"
+#define TUI_FLOAT_REGS_NAME_LOWER "$fregs"
+#define TUI_GENERAL_REGS_NAME "$GREGS"
+#define TUI_GENERAL_REGS_NAME_LOWER "$gregs"
+#define TUI_SPECIAL_REGS_NAME "$SREGS"
+#define TUI_SPECIAL_REGS_NAME_LOWER "$sregs"
+#define TUI_GENERAL_SPECIAL_REGS_NAME "$REGS"
+#define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER "$regs"
+
+/* Scroll direction enum. */
+enum tui_scroll_direction
+{
+ FORWARD_SCROLL,
+ BACKWARD_SCROLL,
+ LEFT_SCROLL,
+ RIGHT_SCROLL
+};
+
+
+/* General list struct. */
+struct tui_list
+{
+ struct tui_win_info **list;
+ int count;
+};
+
+
+/* The kinds of layouts available. */
+enum tui_layout_type
+{
+ SRC_COMMAND,
+ DISASSEM_COMMAND,
+ SRC_DISASSEM_COMMAND,
+ SRC_DATA_COMMAND,
+ DISASSEM_DATA_COMMAND,
+ UNDEFINED_LAYOUT
+};
+
+/* Basic data types that can be displayed in the data window. */
+enum tui_data_type
+{
+ TUI_REGISTER,
+ TUI_SCALAR,
+ TUI_COMPLEX,
+ TUI_STRUCT
+};
+
+/* Types of register displays. */
+enum tui_register_display_type
+{
+ TUI_UNDEFINED_REGS,
+ TUI_GENERAL_REGS,
+ TUI_SFLOAT_REGS,
+ TUI_DFLOAT_REGS,
+ TUI_SPECIAL_REGS,
+ TUI_GENERAL_AND_SPECIAL_REGS
+};
+
+/* Structure describing source line or line address. */
+struct tui_line_or_address
+{
+ enum { LOA_LINE, LOA_ADDRESS } loa;
+ union
+ {
+ int line_no;
+ CORE_ADDR addr;
+ } u;
+};
+
+/* Current Layout definition. */
+struct tui_layout_def
+{
+ enum tui_win_type display_mode;
+ int split;
+ enum tui_register_display_type regs_display_type;
+ enum tui_register_display_type float_regs_display_type;
+};
+
+/* Elements in the Source/Disassembly Window. */
+struct tui_source_element
+{
+ char *line;
+ struct tui_line_or_address line_or_addr;
+ int is_exec_point;
+ int has_break;
+};
+
+
+/* Elements in the data display window content. */
+struct tui_data_element
+{
+ const char *name;
+ int item_no; /* The register number, or data display
+ number. */
+ enum tui_data_type type;
+ void *value;
+ int highlight;
+ char *content;
+};
+
+
+/* Elements in the command window content. */
+struct tui_command_element
+{
+ char *line;
+};
+
+#ifdef PATH_MAX
+# define MAX_LOCATOR_ELEMENT_LEN PATH_MAX
+#else
+# define MAX_LOCATOR_ELEMENT_LEN 1024
+#endif
+
+/* Elements in the locator window content. */
+struct tui_locator_element
+{
+ char file_name[MAX_LOCATOR_ELEMENT_LEN];
+ char proc_name[MAX_LOCATOR_ELEMENT_LEN];
+ int line_no;
+ CORE_ADDR addr;
+};
+
+/* Flags to tell what kind of breakpoint is at current line. */
+#define TUI_BP_ENABLED 0x01
+#define TUI_BP_DISABLED 0x02
+#define TUI_BP_HIT 0x04
+#define TUI_BP_CONDITIONAL 0x08
+#define TUI_BP_HARDWARE 0x10
+
+/* Position of breakpoint markers in the exec info string. */
+#define TUI_BP_HIT_POS 0
+#define TUI_BP_BREAK_POS 1
+#define TUI_EXEC_POS 2
+#define TUI_EXECINFO_SIZE 4
+
+typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
+
+/* An content element in a window. */
+union tui_which_element
+{
+ struct tui_source_element source; /* The source elements. */
+ struct tui_gen_win_info data_window; /* Data display elements. */
+ struct tui_data_element data; /* Elements of data_window. */
+ struct tui_command_element command; /* Command elements. */
+ struct tui_locator_element locator; /* Locator elements. */
+ tui_exec_info_content simple_string; /* Simple char based elements. */
+};
+
+struct tui_win_element
+{
+ int highlight;
+ union tui_which_element which_element;
+};
+
+
+/* This describes the content of the window. */
+typedef struct tui_win_element **tui_win_content;
+
+
+/* This struct defines the specific information about a data display
+ window. */
+struct tui_data_info
+{
+ tui_win_content data_content; /* Start of data display content. */
+ int data_content_count;
+ tui_win_content regs_content; /* Start of regs display content. */
+ int regs_content_count;
+ enum tui_register_display_type regs_display_type;
+ int regs_column_count;
+ int display_regs; /* Should regs be displayed at all? */
+ struct reggroup *current_group;
+};
+
+
+struct tui_source_info
+{
+ int has_locator; /* Does locator belongs to this window? */
+ /* Execution information window. */
+ struct tui_gen_win_info *execution_info;
+ int horizontal_offset; /* Used for horizontal scroll. */
+ struct tui_line_or_address start_line_or_addr;
+ char *filename;
+};
+
+
+struct tui_command_info
+{
+ int cur_line; /* The current line position. */
+ int curch; /* The current cursor position. */
+ int start_line;
+};
+
+
+/* This defines information about each logical window. */
+struct tui_win_info
+{
+ struct tui_gen_win_info generic; /* General window information. */
+ union
+ {
+ struct tui_source_info source_info;
+ struct tui_data_info data_display_info;
+ struct tui_command_info command_info;
+ void *opaque;
+ }
+ detail;
+ int can_highlight; /* Can this window ever be highlighted? */
+ int is_highlighted; /* Is this window highlighted? */
+};
+
+extern int tui_win_is_source_type (enum tui_win_type win_type);
+extern int tui_win_is_auxillary (enum tui_win_type win_type);
+extern int tui_win_has_locator (struct tui_win_info *win_info);
+extern void tui_set_win_highlight (struct tui_win_info *win_info,
+ int highlight);
+
+
+/* Global Data. */
+extern struct tui_win_info *(tui_win_list[MAX_MAJOR_WINDOWS]);
+
+#define TUI_SRC_WIN tui_win_list[SRC_WIN]
+#define TUI_DISASM_WIN tui_win_list[DISASSEM_WIN]
+#define TUI_DATA_WIN tui_win_list[DATA_WIN]
+#define TUI_CMD_WIN tui_win_list[CMD_WIN]
+
+/* Data Manipulation Functions. */
+extern void tui_initialize_static_data (void);
+extern struct tui_gen_win_info *tui_alloc_generic_win_info (void);
+extern struct tui_win_info *tui_alloc_win_info (enum tui_win_type);
+extern void tui_init_generic_part (struct tui_gen_win_info *);
+extern void tui_init_win_info (struct tui_win_info *);
+extern tui_win_content tui_alloc_content (int, enum tui_win_type);
+extern int tui_add_content_elements (struct tui_gen_win_info *,
+ int);
+extern void tui_init_content_element (struct tui_win_element *,
+ enum tui_win_type);
+extern void tui_free_window (struct tui_win_info *);
+extern void tui_free_win_content (struct tui_gen_win_info *);
+extern void tui_free_data_content (tui_win_content, int);
+extern void tui_free_all_source_wins_content (void);
+extern void tui_del_window (struct tui_win_info *);
+extern void tui_del_data_windows (tui_win_content, int);
+extern struct tui_win_info *tui_partial_win_by_name (char *);
+extern char *tui_win_name (struct tui_gen_win_info *);
+extern enum tui_layout_type tui_current_layout (void);
+extern void tui_set_current_layout_to (enum tui_layout_type);
+extern int tui_term_height (void);
+extern void tui_set_term_height_to (int);
+extern int tui_term_width (void);
+extern void tui_set_term_width_to (int);
+extern void tui_set_gen_win_origin (struct tui_gen_win_info *,
+ int, int);
+extern struct tui_gen_win_info *tui_locator_win_info_ptr (void);
+extern struct tui_gen_win_info *tui_source_exec_info_win_ptr (void);
+extern struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void);
+extern struct tui_list *tui_source_windows (void);
+extern void tui_clear_source_windows (void);
+extern void tui_clear_source_windows_detail (void);
+extern void tui_clear_win_detail (struct tui_win_info *);
+extern void tui_add_to_source_windows (struct tui_win_info *);
+extern int tui_default_tab_len (void);
+extern void tui_set_default_tab_len (int);
+extern struct tui_win_info *tui_win_with_focus (void);
+extern void tui_set_win_with_focus (struct tui_win_info *);
+extern struct tui_layout_def *tui_layout_def (void);
+extern int tui_win_resized (void);
+extern void tui_set_win_resized_to (int);
+
+extern struct tui_win_info *tui_next_win (struct tui_win_info *);
+extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
+
+extern void tui_add_to_source_windows (struct tui_win_info *);
+
+#endif /* TUI_DATA_H */
tui-data.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-file.c
===================================================================
--- tui-file.c (nonexistent)
+++ tui-file.c (revision 157)
@@ -0,0 +1,237 @@
+/* UI_FILE - a generic STDIO like output stream.
+ Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "ui-file.h"
+#include "tui/tui-file.h"
+#include "tui/tui-io.h"
+
+#include "tui.h"
+
+#include "gdb_string.h"
+
+/* A ``struct ui_file'' that is compatible with all the legacy
+ code. */
+
+/* new */
+enum streamtype
+{
+ afile,
+ astring
+};
+
+/* new */
+struct tui_stream
+{
+ int *ts_magic;
+ enum streamtype ts_streamtype;
+ FILE *ts_filestream;
+ char *ts_strbuf;
+ int ts_buflen;
+};
+
+static ui_file_flush_ftype tui_file_flush;
+extern ui_file_fputs_ftype tui_file_fputs;
+static ui_file_isatty_ftype tui_file_isatty;
+static ui_file_rewind_ftype tui_file_rewind;
+static ui_file_put_ftype tui_file_put;
+static ui_file_delete_ftype tui_file_delete;
+static struct ui_file *tui_file_new (void);
+static int tui_file_magic;
+
+static struct ui_file *
+tui_file_new (void)
+{
+ struct tui_stream *tui = XMALLOC (struct tui_stream);
+ struct ui_file *file = ui_file_new ();
+ set_ui_file_data (file, tui, tui_file_delete);
+ set_ui_file_flush (file, tui_file_flush);
+ set_ui_file_fputs (file, tui_file_fputs);
+ set_ui_file_isatty (file, tui_file_isatty);
+ set_ui_file_rewind (file, tui_file_rewind);
+ set_ui_file_put (file, tui_file_put);
+ tui->ts_magic = &tui_file_magic;
+ return file;
+}
+
+static void
+tui_file_delete (struct ui_file *file)
+{
+ struct tui_stream *tmpstream = ui_file_data (file);
+ if (tmpstream->ts_magic != &tui_file_magic)
+ internal_error (__FILE__, __LINE__,
+ _("tui_file_delete: bad magic number"));
+ if ((tmpstream->ts_streamtype == astring)
+ && (tmpstream->ts_strbuf != NULL))
+ {
+ xfree (tmpstream->ts_strbuf);
+ }
+ xfree (tmpstream);
+}
+
+struct ui_file *
+tui_fileopen (FILE *stream)
+{
+ struct ui_file *file = tui_file_new ();
+ struct tui_stream *tmpstream = ui_file_data (file);
+ tmpstream->ts_streamtype = afile;
+ tmpstream->ts_filestream = stream;
+ tmpstream->ts_strbuf = NULL;
+ tmpstream->ts_buflen = 0;
+ return file;
+}
+
+struct ui_file *
+tui_sfileopen (int n)
+{
+ struct ui_file *file = tui_file_new ();
+ struct tui_stream *tmpstream = ui_file_data (file);
+ tmpstream->ts_streamtype = astring;
+ tmpstream->ts_filestream = NULL;
+ if (n > 0)
+ {
+ tmpstream->ts_strbuf = xmalloc ((n + 1) * sizeof (char));
+ tmpstream->ts_strbuf[0] = '\0';
+ }
+ else
+ /* Do not allocate the buffer now. The first time something is
+ printed one will be allocated by tui_file_adjust_strbuf(). */
+ tmpstream->ts_strbuf = NULL;
+ tmpstream->ts_buflen = n;
+ return file;
+}
+
+static int
+tui_file_isatty (struct ui_file *file)
+{
+ struct tui_stream *stream = ui_file_data (file);
+ if (stream->ts_magic != &tui_file_magic)
+ internal_error (__FILE__, __LINE__,
+ _("tui_file_isatty: bad magic number"));
+ if (stream->ts_streamtype == afile)
+ return (isatty (fileno (stream->ts_filestream)));
+ else
+ return 0;
+}
+
+static void
+tui_file_rewind (struct ui_file *file)
+{
+ struct tui_stream *stream = ui_file_data (file);
+ if (stream->ts_magic != &tui_file_magic)
+ internal_error (__FILE__, __LINE__,
+ _("tui_file_rewind: bad magic number"));
+ stream->ts_strbuf[0] = '\0';
+}
+
+static void
+tui_file_put (struct ui_file *file,
+ ui_file_put_method_ftype *write,
+ void *dest)
+{
+ struct tui_stream *stream = ui_file_data (file);
+ if (stream->ts_magic != &tui_file_magic)
+ internal_error (__FILE__, __LINE__,
+ _("tui_file_put: bad magic number"));
+ if (stream->ts_streamtype == astring)
+ write (dest, stream->ts_strbuf, strlen (stream->ts_strbuf));
+}
+
+/* All TUI I/O sent to the *_filtered and *_unfiltered functions
+ eventually ends up here. The fputs_unfiltered_hook is primarily
+ used by GUIs to collect all output and send it to the GUI, instead
+ of the controlling terminal. Only output to gdb_stdout and
+ gdb_stderr are sent to the hook. Everything else is sent on to
+ fputs to allow file I/O to be handled appropriately. */
+
+/* FIXME: Should be broken up and moved to a TUI specific file. */
+
+void
+tui_file_fputs (const char *linebuffer, struct ui_file *file)
+{
+ struct tui_stream *stream = ui_file_data (file);
+
+ if (stream->ts_streamtype == astring)
+ {
+ tui_file_adjust_strbuf (strlen (linebuffer), file);
+ strcat (stream->ts_strbuf, linebuffer);
+ }
+ else
+ {
+ tui_puts (linebuffer);
+ }
+}
+
+char *
+tui_file_get_strbuf (struct ui_file *file)
+{
+ struct tui_stream *stream = ui_file_data (file);
+ if (stream->ts_magic != &tui_file_magic)
+ internal_error (__FILE__, __LINE__,
+ _("tui_file_get_strbuf: bad magic number"));
+ return (stream->ts_strbuf);
+}
+
+/* Adjust the length of the buffer by the amount necessary to
+ accomodate appending a string of length N to the buffer
+ contents. */
+void
+tui_file_adjust_strbuf (int n, struct ui_file *file)
+{
+ struct tui_stream *stream = ui_file_data (file);
+ int non_null_chars;
+ if (stream->ts_magic != &tui_file_magic)
+ internal_error (__FILE__, __LINE__,
+ _("tui_file_adjust_strbuf: bad magic number"));
+
+ if (stream->ts_streamtype != astring)
+ return;
+
+ if (stream->ts_strbuf)
+ {
+ /* There is already a buffer allocated. */
+ non_null_chars = strlen (stream->ts_strbuf);
+
+ if (n > (stream->ts_buflen - non_null_chars - 1))
+ {
+ stream->ts_buflen = n + non_null_chars + 1;
+ stream->ts_strbuf = xrealloc (stream->ts_strbuf, stream->ts_buflen);
+ }
+ }
+ else
+ /* No buffer yet, so allocate one of the desired size. */
+ stream->ts_strbuf = xmalloc ((n + 1) * sizeof (char));
+}
+
+static void
+tui_file_flush (struct ui_file *file)
+{
+ struct tui_stream *stream = ui_file_data (file);
+ if (stream->ts_magic != &tui_file_magic)
+ internal_error (__FILE__, __LINE__,
+ _("tui_file_flush: bad magic number"));
+
+ switch (stream->ts_streamtype)
+ {
+ case astring:
+ break;
+ case afile:
+ fflush (stream->ts_filestream);
+ break;
+ }
+}
tui-file.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-layout.h
===================================================================
--- tui-layout.h (nonexistent)
+++ tui-layout.h (revision 157)
@@ -0,0 +1,37 @@
+/* TUI layout window management.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_LAYOUT_H
+#define TUI_LAYOUT_H
+
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+
+extern void tui_add_win_to_layout (enum tui_win_type);
+extern int tui_default_win_height (enum tui_win_type,
+ enum tui_layout_type);
+extern int tui_default_win_viewport_height (enum tui_win_type,
+ enum tui_layout_type);
+extern enum tui_status tui_set_layout (enum tui_layout_type,
+ enum tui_register_display_type);
+
+#endif /*TUI_LAYOUT_H */
tui-layout.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-file.h
===================================================================
--- tui-file.h (nonexistent)
+++ tui-file.h (revision 157)
@@ -0,0 +1,27 @@
+/* UI_FILE - a generic STDIO like output stream.
+ Copyright (C) 1999, 2000, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_FILE_H
+#define TUI_FILE_H
+
+extern struct ui_file *tui_fileopen (FILE *);
+extern struct ui_file *tui_sfileopen (int);
+extern char *tui_file_get_strbuf (struct ui_file *);
+extern void tui_file_adjust_strbuf (int, struct ui_file *);
+
+#endif
tui-file.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-main.c
===================================================================
--- tui-main.c (nonexistent)
+++ tui-main.c (revision 157)
@@ -0,0 +1,35 @@
+/* Main function for TUI gdb.
+
+ Copyright (C) 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "main.h"
+#include "gdb_string.h"
+#include "interps.h"
+
+int
+main (int argc, char **argv)
+{
+ struct captured_main_args args;
+ memset (&args, 0, sizeof args);
+ args.argc = argc;
+ args.argv = argv;
+ args.use_windows = 0;
+ args.interpreter_p = INTERP_TUI;
+ return gdb_main (&args);
+}
tui-main.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-windata.c
===================================================================
--- tui-windata.c (nonexistent)
+++ tui-windata.c (revision 157)
@@ -0,0 +1,300 @@
+/* Data/register window display.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-wingeneral.h"
+#include "tui/tui-regs.h"
+
+#include "gdb_string.h"
+#include "gdb_curses.h"
+
+
+/*****************************************
+** STATIC LOCAL FUNCTIONS FORWARD DECLS **
+******************************************/
+
+
+
+/*****************************************
+** PUBLIC FUNCTIONS **
+******************************************/
+
+
+/* Answer the index first element displayed. If none are displayed,
+ then return (-1). */
+int
+tui_first_data_item_displayed (void)
+{
+ int element_no = (-1);
+ int i;
+
+ for (i = 0;
+ i < TUI_DATA_WIN->generic.content_size && element_no < 0;
+ i++)
+ {
+ struct tui_gen_win_info *data_item_win;
+
+ data_item_win = &((tui_win_content)
+ TUI_DATA_WIN->generic.content)[i]->which_element.data_window;
+ if (data_item_win->handle != (WINDOW *) NULL
+ && data_item_win->is_visible)
+ element_no = i;
+ }
+
+ return element_no;
+}
+
+
+/* Answer the index of the first element in line_no. If line_no is
+ past the data area (-1) is returned. */
+int
+tui_first_data_element_no_in_line (int line_no)
+{
+ int first_element_no = (-1);
+
+ /* First see if there is a register on line_no, and if so, set the
+ first element number. */
+ if ((first_element_no = tui_first_reg_element_no_inline (line_no)) == -1)
+ { /* Looking at the general data, the 1st element on line_no. */
+ }
+
+ return first_element_no;
+}
+
+
+/* Function to delete all the item windows in the data window. This
+ is usually done when the data window is scrolled. */
+void
+tui_delete_data_content_windows (void)
+{
+ int i;
+ struct tui_gen_win_info *data_item_win_ptr;
+
+ for (i = 0; (i < TUI_DATA_WIN->generic.content_size); i++)
+ {
+ data_item_win_ptr = &((tui_win_content)
+ TUI_DATA_WIN->generic.content)[i]->which_element.data_window;
+ tui_delete_win (data_item_win_ptr->handle);
+ data_item_win_ptr->handle = (WINDOW *) NULL;
+ data_item_win_ptr->is_visible = FALSE;
+ }
+}
+
+
+void
+tui_erase_data_content (char *prompt)
+{
+ werase (TUI_DATA_WIN->generic.handle);
+ tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
+ if (prompt != (char *) NULL)
+ {
+ int half_width = (TUI_DATA_WIN->generic.width - 2) / 2;
+ int x_pos;
+
+ if (strlen (prompt) >= half_width)
+ x_pos = 1;
+ else
+ x_pos = half_width - strlen (prompt);
+ mvwaddstr (TUI_DATA_WIN->generic.handle,
+ (TUI_DATA_WIN->generic.height / 2),
+ x_pos,
+ prompt);
+ }
+ wrefresh (TUI_DATA_WIN->generic.handle);
+}
+
+
+/* This function displays the data that is in the data window's
+ content. It does not set the content. */
+void
+tui_display_all_data (void)
+{
+ if (TUI_DATA_WIN->generic.content_size <= 0)
+ tui_erase_data_content (NO_DATA_STRING);
+ else
+ {
+ tui_erase_data_content ((char *) NULL);
+ tui_delete_data_content_windows ();
+ tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
+ tui_display_registers_from (0);
+
+ /* Then display the other data. */
+ if (TUI_DATA_WIN->detail.data_display_info.data_content !=
+ (tui_win_content) NULL
+ && TUI_DATA_WIN->detail.data_display_info.data_content_count > 0)
+ {
+ }
+ }
+}
+
+
+/* Function to display the data starting at line, line_no, in the data
+ window. */
+void
+tui_display_data_from_line (int line_no)
+{
+ int _line_no = line_no;
+
+ if (line_no < 0)
+ _line_no = 0;
+
+ tui_check_and_display_highlight_if_needed (TUI_DATA_WIN);
+
+ /* There is no general data, force regs to display (if there are
+ any). */
+ if (TUI_DATA_WIN->detail.data_display_info.data_content_count <= 0)
+ tui_display_registers_from_line (_line_no, TRUE);
+ else
+ {
+ int element_no, start_line_no;
+ int regs_last_line = tui_last_regs_line_no ();
+
+
+ /* Display regs if we can. */
+ if (tui_display_registers_from_line (_line_no, FALSE) < 0)
+ { /* _line_no is past the regs display, so calc where the
+ start data element is. */
+ if (regs_last_line < _line_no)
+ { /* Figure out how many lines each element is to obtain
+ the start element_no. */
+ }
+ }
+ else
+ { /* Calculate the starting element of the data display, given
+ regs_last_line and how many lines each element is, up to
+ _line_no. */
+ }
+ /* Now display the data , starting at element_no. */
+ }
+}
+
+
+/* Display data starting at element element_no. */
+void
+tui_display_data_from (int element_no, int reuse_windows)
+{
+ int first_line = (-1);
+
+ if (element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+ first_line = tui_line_from_reg_element_no (element_no);
+ else
+ { /* Calculate the first_line from the element number. */
+ }
+
+ if (first_line >= 0)
+ {
+ tui_erase_data_content ((char *) NULL);
+ if (!reuse_windows)
+ tui_delete_data_content_windows ();
+ tui_display_data_from_line (first_line);
+ }
+}
+
+
+/* Function to redisplay the contents of the data window. */
+void
+tui_refresh_data_win (void)
+{
+ tui_erase_data_content ((char *) NULL);
+ if (TUI_DATA_WIN->generic.content_size > 0)
+ {
+ int first_element = tui_first_data_item_displayed ();
+
+ if (first_element >= 0) /* Re-use existing windows. */
+ tui_display_data_from (first_element, TRUE);
+ }
+}
+
+
+/* Function to check the data values and hilite any that have
+ changed. */
+void
+tui_check_data_values (struct frame_info *frame)
+{
+ tui_check_register_values (frame);
+
+ /* Now check any other data values that there are. */
+ if (TUI_DATA_WIN != NULL && TUI_DATA_WIN->generic.is_visible)
+ {
+ int i;
+
+ for (i = 0;
+ TUI_DATA_WIN->detail.data_display_info.data_content_count;
+ i++)
+ {
+#ifdef LATER
+ tui_data_element_ptr data_element_ptr;
+ struct tui_gen_win_info *data_item_win_ptr;
+ Opaque new_value;
+
+ data_item_ptr = &TUI_DATA_WIN->detail.data_display_info.
+ data_content[i]->which_element.data_window;
+ data_element_ptr = &((tui_win_content)
+ data_item_win_ptr->content)[0]->which_element.data;
+ if value
+ has changed (data_element_ptr, frame, &new_value)
+ {
+ data_element_ptr->value = new_value;
+ update the display with the new value, hiliting it.
+ }
+#endif
+ }
+ }
+}
+
+
+/* Scroll the data window vertically forward or backward. */
+void
+tui_vertical_data_scroll (enum tui_scroll_direction scroll_direction,
+ int num_to_scroll)
+{
+ int first_element_no;
+ int first_line = (-1);
+
+ first_element_no = tui_first_data_item_displayed ();
+ if (first_element_no < TUI_DATA_WIN->detail.data_display_info.regs_content_count)
+ first_line = tui_line_from_reg_element_no (first_element_no);
+ else
+ { /* Calculate the first line from the element number which is in
+ the general data content. */
+ }
+
+ if (first_line >= 0)
+ {
+ int last_element_no, last_line;
+
+ if (scroll_direction == FORWARD_SCROLL)
+ first_line += num_to_scroll;
+ else
+ first_line -= num_to_scroll;
+ tui_erase_data_content ((char *) NULL);
+ tui_delete_data_content_windows ();
+ tui_display_data_from_line (first_line);
+ }
+}
+
+
+/*****************************************
+** STATIC LOCAL FUNCTIONS **
+******************************************/
tui-windata.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-wingeneral.c
===================================================================
--- tui-wingeneral.c (nonexistent)
+++ tui-wingeneral.c (revision 157)
@@ -0,0 +1,282 @@
+/* General window behavior.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-wingeneral.h"
+#include "tui/tui-win.h"
+
+#include "gdb_curses.h"
+
+/***********************
+** PUBLIC FUNCTIONS
+***********************/
+
+/* Refresh the window. */
+void
+tui_refresh_win (struct tui_gen_win_info *win_info)
+{
+ if (win_info->type == DATA_WIN && win_info->content_size > 0)
+ {
+ int i;
+
+ for (i = 0; (i < win_info->content_size); i++)
+ {
+ struct tui_gen_win_info *data_item_win_ptr;
+
+ data_item_win_ptr = &((tui_win_content)
+ win_info->content)[i]->which_element.data_window;
+ if (data_item_win_ptr != NULL
+ && data_item_win_ptr->handle != (WINDOW *) NULL)
+ wrefresh (data_item_win_ptr->handle);
+ }
+ }
+ else if (win_info->type == CMD_WIN)
+ {
+ /* Do nothing. */
+ }
+ else
+ {
+ if (win_info->handle != (WINDOW *) NULL)
+ wrefresh (win_info->handle);
+ }
+
+ return;
+}
+
+
+/* Function to delete the curses window, checking for NULL. */
+void
+tui_delete_win (WINDOW *window)
+{
+ if (window != (WINDOW *) NULL)
+ delwin (window);
+
+ return;
+}
+
+
+/* Draw a border arround the window. */
+void
+box_win (struct tui_gen_win_info *win_info,
+ int highlight_flag)
+{
+ if (win_info && win_info->handle)
+ {
+ WINDOW *win;
+ int attrs;
+
+ win = win_info->handle;
+ if (highlight_flag == HILITE)
+ attrs = tui_active_border_attrs;
+ else
+ attrs = tui_border_attrs;
+
+ wattron (win, attrs);
+#ifdef HAVE_WBORDER
+ wborder (win, tui_border_vline, tui_border_vline,
+ tui_border_hline, tui_border_hline,
+ tui_border_ulcorner, tui_border_urcorner,
+ tui_border_llcorner, tui_border_lrcorner);
+#else
+ box (win, tui_border_vline, tui_border_hline);
+#endif
+ if (win_info->title)
+ mvwaddstr (win, 0, 3, win_info->title);
+ wattroff (win, attrs);
+ }
+}
+
+
+void
+tui_unhighlight_win (struct tui_win_info *win_info)
+{
+ if (win_info != NULL
+ && win_info->generic.handle != (WINDOW *) NULL)
+ {
+ box_win ((struct tui_gen_win_info *) win_info, NO_HILITE);
+ wrefresh (win_info->generic.handle);
+ tui_set_win_highlight (win_info, 0);
+ }
+}
+
+
+void
+tui_highlight_win (struct tui_win_info *win_info)
+{
+ if (win_info != NULL
+ && win_info->can_highlight
+ && win_info->generic.handle != (WINDOW *) NULL)
+ {
+ box_win ((struct tui_gen_win_info *) win_info, HILITE);
+ wrefresh (win_info->generic.handle);
+ tui_set_win_highlight (win_info, 1);
+ }
+}
+
+void
+tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
+{
+ if (win_info != NULL && win_info->generic.type != CMD_WIN)
+ {
+ if (win_info->is_highlighted)
+ tui_highlight_win (win_info);
+ else
+ tui_unhighlight_win (win_info);
+
+ }
+ return;
+}
+
+
+void
+tui_make_window (struct tui_gen_win_info *win_info, int box_it)
+{
+ WINDOW *handle;
+
+ handle = newwin (win_info->height,
+ win_info->width,
+ win_info->origin.y,
+ win_info->origin.x);
+ win_info->handle = handle;
+ if (handle != (WINDOW *) NULL)
+ {
+ if (box_it == BOX_WINDOW)
+ box_win (win_info, NO_HILITE);
+ win_info->is_visible = TRUE;
+ scrollok (handle, TRUE);
+ }
+}
+
+
+/* We can't really make windows visible, or invisible. So we have to
+ delete the entire window when making it visible, and create it
+ again when making it visible. */
+static void
+make_visible (struct tui_gen_win_info *win_info, int visible)
+{
+ /* Don't tear down/recreate command window. */
+ if (win_info->type == CMD_WIN)
+ return;
+
+ if (visible)
+ {
+ if (!win_info->is_visible)
+ {
+ tui_make_window (win_info,
+ (win_info->type != CMD_WIN
+ && !tui_win_is_auxillary (win_info->type)));
+ win_info->is_visible = TRUE;
+ }
+ }
+ else if (!visible
+ && win_info->is_visible
+ && win_info->handle != (WINDOW *) NULL)
+ {
+ win_info->is_visible = FALSE;
+ tui_delete_win (win_info->handle);
+ win_info->handle = (WINDOW *) NULL;
+ }
+
+ return;
+}
+
+void
+tui_make_visible (struct tui_gen_win_info *win_info)
+{
+ make_visible (win_info, 1);
+}
+
+void
+tui_make_invisible (struct tui_gen_win_info *win_info)
+{
+ make_visible (win_info, 0);
+}
+
+
+/* Makes all windows invisible (except the command and locator
+ windows). */
+static void
+make_all_visible (int visible)
+{
+ int i;
+
+ for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
+ {
+ if (tui_win_list[i] != NULL
+ && ((tui_win_list[i])->generic.type) != CMD_WIN)
+ {
+ if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
+ make_visible ((tui_win_list[i])->detail.source_info.execution_info,
+ visible);
+ make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible);
+ }
+ }
+
+ return;
+}
+
+void
+tui_make_all_visible (void)
+{
+ make_all_visible (1);
+}
+
+void
+tui_make_all_invisible (void)
+{
+ make_all_visible (0);
+}
+
+/* Function to refresh all the windows currently displayed. */
+
+void
+tui_refresh_all (struct tui_win_info **list)
+{
+ enum tui_win_type type;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+
+ for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
+ {
+ if (list[type] && list[type]->generic.is_visible)
+ {
+ if (type == SRC_WIN || type == DISASSEM_WIN)
+ {
+ touchwin (list[type]->detail.source_info.execution_info->handle);
+ tui_refresh_win (list[type]->detail.source_info.execution_info);
+ }
+ touchwin (list[type]->generic.handle);
+ tui_refresh_win (&list[type]->generic);
+ }
+ }
+ if (locator->is_visible)
+ {
+ touchwin (locator->handle);
+ tui_refresh_win (locator);
+ }
+}
+
+
+/*********************************
+** Local Static Functions
+*********************************/
tui-wingeneral.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-windata.h
===================================================================
--- tui-windata.h (nonexistent)
+++ tui-windata.h (revision 157)
@@ -0,0 +1,40 @@
+/* Data/register window display.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_WINDATA_H
+#define TUI_WINDATA_H
+
+#include "tui/tui-data.h"
+
+extern void tui_erase_data_content (char *);
+extern void tui_display_all_data (void);
+extern void tui_check_data_values (struct frame_info *);
+extern void tui_display_data_from_line (int);
+extern int tui_first_data_item_displayed (void);
+extern int tui_first_data_element_no_in_line (int);
+extern void tui_delete_data_content_windows (void);
+extern void tui_refresh_data_win (void);
+extern void tui_display_data_from (int, int);
+extern void tui_vertical_data_scroll (enum tui_scroll_direction,
+ int);
+
+#endif
tui-windata.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-wingeneral.h
===================================================================
--- tui-wingeneral.h (nonexistent)
+++ tui-wingeneral.h (revision 157)
@@ -0,0 +1,43 @@
+/* General window behavior.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_WINGENERAL_H
+#define TUI_WINGENERAL_H
+
+struct tui_win_info;
+struct tui_gen_win_info;
+
+extern void tui_unhighlight_win (struct tui_win_info *);
+extern void tui_make_visible (struct tui_gen_win_info *);
+extern void tui_make_invisible (struct tui_gen_win_info *);
+extern void tui_make_all_visible (void);
+extern void tui_make_all_invisible (void);
+extern void tui_make_window (struct tui_gen_win_info *, int);
+extern struct tui_win_info *tui_copy_win (struct tui_win_info *);
+extern void tui_box_win (struct tui_gen_win_info *, int);
+extern void tui_highlight_win (struct tui_win_info *);
+extern void tui_check_and_display_highlight_if_needed (struct tui_win_info *);
+extern void tui_refresh_all (struct tui_win_info **);
+extern void tui_delete_win (WINDOW *window);
+extern void tui_refresh_win (struct tui_gen_win_info *);
+
+#endif
tui-wingeneral.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-source.c
===================================================================
--- tui-source.c (nonexistent)
+++ tui-source.c (revision 157)
@@ -0,0 +1,371 @@
+/* TUI display source window.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include
+#include "symtab.h"
+#include "frame.h"
+#include "breakpoint.h"
+#include "source.h"
+#include "symtab.h"
+
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-winsource.h"
+#include "tui/tui-source.h"
+
+#include "gdb_string.h"
+#include "gdb_curses.h"
+
+/* Function to display source in the source window. */
+enum tui_status
+tui_set_source_content (struct symtab *s,
+ int line_no,
+ int noerror)
+{
+ enum tui_status ret = TUI_FAILURE;
+
+ if (s != (struct symtab *) NULL && s->filename != (char *) NULL)
+ {
+ FILE *stream;
+ int i, desc, c, line_width, nlines;
+ char *src_line = 0;
+
+ if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS)
+ {
+ line_width = TUI_SRC_WIN->generic.width - 1;
+ /* Take hilite (window border) into account, when
+ calculating the number of lines. */
+ nlines = (line_no + (TUI_SRC_WIN->generic.height - 2)) - line_no;
+ desc = open_source_file (s);
+ if (desc < 0)
+ {
+ if (!noerror)
+ {
+ char *name = alloca (strlen (s->filename) + 100);
+ sprintf (name, "%s:%d", s->filename, line_no);
+ print_sys_errmsg (name, errno);
+ }
+ ret = TUI_FAILURE;
+ }
+ else
+ {
+ if (s->line_charpos == 0)
+ find_source_lines (s, desc);
+
+ if (line_no < 1 || line_no > s->nlines)
+ {
+ close (desc);
+ printf_unfiltered (
+ "Line number %d out of range; %s has %d lines.\n",
+ line_no, s->filename, s->nlines);
+ }
+ else if (lseek (desc, s->line_charpos[line_no - 1], 0) < 0)
+ {
+ close (desc);
+ perror_with_name (s->filename);
+ }
+ else
+ {
+ int offset, cur_line_no, cur_line, cur_len, threshold;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+ struct tui_source_info *src = &TUI_SRC_WIN->detail.source_info;
+
+ if (TUI_SRC_WIN->generic.title)
+ xfree (TUI_SRC_WIN->generic.title);
+ TUI_SRC_WIN->generic.title = xstrdup (s->filename);
+
+ if (src->filename)
+ xfree (src->filename);
+ src->filename = xstrdup (s->filename);
+
+ /* Determine the threshold for the length of the
+ line and the offset to start the display. */
+ offset = src->horizontal_offset;
+ threshold = (line_width - 1) + offset;
+ stream = fdopen (desc, FOPEN_RT);
+ clearerr (stream);
+ cur_line = 0;
+ src->start_line_or_addr.loa = LOA_LINE;
+ cur_line_no = src->start_line_or_addr.u.line_no = line_no;
+ if (offset > 0)
+ src_line = (char *) xmalloc (
+ (threshold + 1) * sizeof (char));
+ while (cur_line < nlines)
+ {
+ struct tui_win_element *element = (struct tui_win_element *)
+ TUI_SRC_WIN->generic.content[cur_line];
+
+ /* Get the first character in the line. */
+ c = fgetc (stream);
+
+ if (offset == 0)
+ src_line = ((struct tui_win_element *)
+ TUI_SRC_WIN->generic.content[
+ cur_line])->which_element.source.line;
+ /* Init the line with the line number. */
+ sprintf (src_line, "%-6d", cur_line_no);
+ cur_len = strlen (src_line);
+ i = cur_len -
+ ((cur_len / tui_default_tab_len ()) * tui_default_tab_len ());
+ while (i < tui_default_tab_len ())
+ {
+ src_line[cur_len] = ' ';
+ i++;
+ cur_len++;
+ }
+ src_line[cur_len] = (char) 0;
+
+ /* Set whether element is the execution point
+ and whether there is a break point on it. */
+ element->which_element.source.line_or_addr.loa =
+ LOA_LINE;
+ element->which_element.source.line_or_addr.u.line_no =
+ cur_line_no;
+ element->which_element.source.is_exec_point =
+ (strcmp (((struct tui_win_element *)
+ locator->content[0])->which_element.locator.file_name,
+ s->filename) == 0
+ && cur_line_no == ((struct tui_win_element *)
+ locator->content[0])->which_element.locator.line_no);
+ if (c != EOF)
+ {
+ i = strlen (src_line) - 1;
+ do
+ {
+ if ((c != '\n') && (c != '\r')
+ && (++i < threshold))
+ {
+ if (c < 040 && c != '\t')
+ {
+ src_line[i++] = '^';
+ src_line[i] = c + 0100;
+ }
+ else if (c == 0177)
+ {
+ src_line[i++] = '^';
+ src_line[i] = '?';
+ }
+ else
+ { /* Store the charcter in the
+ line buffer. If it is a tab,
+ then translate to the correct
+ number of chars so we don't
+ overwrite our buffer. */
+ if (c == '\t')
+ {
+ int j, max_tab_len = tui_default_tab_len ();
+
+ for (j = i - ((i / max_tab_len) * max_tab_len);
+ j < max_tab_len
+ && i < threshold;
+ i++, j++)
+ src_line[i] = ' ';
+ i--;
+ }
+ else
+ src_line[i] = c;
+ }
+ src_line[i + 1] = 0;
+ }
+ else
+ { /* If we have not reached EOL, then
+ eat chars until we do. */
+ while (c != EOF && c != '\n' && c != '\r')
+ c = fgetc (stream);
+ /* Handle non-'\n' end-of-line. */
+ if (c == '\r'
+ && (c = fgetc (stream)) != '\n'
+ && c != EOF)
+ {
+ ungetc (c, stream);
+ c = '\r';
+ }
+
+ }
+ }
+ while (c != EOF && c != '\n' && c != '\r'
+ && i < threshold
+ && (c = fgetc (stream)));
+ }
+ /* Now copy the line taking the offset into
+ account. */
+ if (strlen (src_line) > offset)
+ strcpy (((struct tui_win_element *) TUI_SRC_WIN->generic.content[
+ cur_line])->which_element.source.line,
+ &src_line[offset]);
+ else
+ ((struct tui_win_element *)
+ TUI_SRC_WIN->generic.content[
+ cur_line])->which_element.source.line[0] = (char) 0;
+ cur_line++;
+ cur_line_no++;
+ }
+ if (offset > 0)
+ xfree (src_line);
+ fclose (stream);
+ TUI_SRC_WIN->generic.content_size = nlines;
+ ret = TUI_SUCCESS;
+ }
+ }
+ }
+ }
+ return ret;
+}
+
+
+/* elz: This function sets the contents of the source window to empty
+ except for a line in the middle with a warning message about the
+ source not being available. This function is called by
+ tui_erase_source_contents(), which in turn is invoked when the
+ source files cannot be accessed. */
+
+void
+tui_set_source_content_nil (struct tui_win_info *win_info,
+ char *warning_string)
+{
+ int line_width;
+ int n_lines;
+ int curr_line = 0;
+
+ line_width = win_info->generic.width - 1;
+ n_lines = win_info->generic.height - 2;
+
+ /* Set to empty each line in the window, except for the one which
+ contains the message. */
+ while (curr_line < win_info->generic.content_size)
+ {
+ /* Set the information related to each displayed line to null:
+ i.e. the line number is 0, there is no bp, it is not where
+ the program is stopped. */
+
+ struct tui_win_element *element =
+ (struct tui_win_element *) win_info->generic.content[curr_line];
+ element->which_element.source.line_or_addr.loa = LOA_LINE;
+ element->which_element.source.line_or_addr.u.line_no = 0;
+ element->which_element.source.is_exec_point = FALSE;
+ element->which_element.source.has_break = FALSE;
+
+ /* Set the contents of the line to blank. */
+ element->which_element.source.line[0] = (char) 0;
+
+ /* If the current line is in the middle of the screen, then we
+ want to display the 'no source available' message in it.
+ Note: the 'weird' arithmetic with the line width and height
+ comes from the function tui_erase_source_content(). We need
+ to keep the screen and the window's actual contents in
+ synch. */
+
+ if (curr_line == (n_lines / 2 + 1))
+ {
+ int i;
+ int xpos;
+ int warning_length = strlen (warning_string);
+ char *src_line;
+
+ src_line = element->which_element.source.line;
+
+ if (warning_length >= ((line_width - 1) / 2))
+ xpos = 1;
+ else
+ xpos = (line_width - 1) / 2 - warning_length;
+
+ for (i = 0; i < xpos; i++)
+ src_line[i] = ' ';
+
+ sprintf (src_line + i, "%s", warning_string);
+
+ for (i = xpos + warning_length; i < line_width; i++)
+ src_line[i] = ' ';
+
+ src_line[i] = '\n';
+
+ } /* end if */
+
+ curr_line++;
+
+ } /* end while */
+}
+
+
+/* Function to display source in the source window. This function
+ initializes the horizontal scroll to 0. */
+void
+tui_show_symtab_source (struct symtab *s,
+ struct tui_line_or_address line,
+ int noerror)
+{
+ TUI_SRC_WIN->detail.source_info.horizontal_offset = 0;
+ tui_update_source_window_as_is (TUI_SRC_WIN, s, line, noerror);
+}
+
+
+/* Answer whether the source is currently displayed in the source
+ window. */
+int
+tui_source_is_displayed (char *fname)
+{
+ return (TUI_SRC_WIN->generic.content_in_use
+ && (strcmp (((struct tui_win_element *) (tui_locator_win_info_ptr ())->
+ content[0])->which_element.locator.file_name, fname) == 0));
+}
+
+
+/* Scroll the source forward or backward vertically. */
+void
+tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction,
+ int num_to_scroll)
+{
+ if (TUI_SRC_WIN->generic.content != NULL)
+ {
+ struct tui_line_or_address l;
+ struct symtab *s;
+ tui_win_content content = (tui_win_content) TUI_SRC_WIN->generic.content;
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
+ if (cursal.symtab == (struct symtab *) NULL)
+ s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
+ else
+ s = cursal.symtab;
+
+ l.loa = LOA_LINE;
+ if (scroll_direction == FORWARD_SCROLL)
+ {
+ l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
+ + num_to_scroll;
+ if (l.u.line_no > s->nlines)
+ /* line = s->nlines - win_info->generic.content_size + 1; */
+ /* elz: fix for dts 23398. */
+ l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no;
+ }
+ else
+ {
+ l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
+ - num_to_scroll;
+ if (l.u.line_no <= 0)
+ l.u.line_no = 1;
+ }
+
+ print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
+ }
+}
tui-source.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-interp.c
===================================================================
--- tui-interp.c (nonexistent)
+++ tui-interp.c (revision 157)
@@ -0,0 +1,213 @@
+/* TUI Interpreter definitions for GDB, the GNU debugger.
+
+ Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "interps.h"
+#include "top.h"
+#include "event-top.h"
+#include "event-loop.h"
+#include "ui-out.h"
+#include "cli-out.h"
+#include "tui/tui-data.h"
+#include "readline/readline.h"
+#include "tui/tui-win.h"
+#include "tui/tui.h"
+#include "tui/tui-io.h"
+#include "exceptions.h"
+
+/* Set to 1 when the TUI mode must be activated when we first start
+ gdb. */
+static int tui_start_enabled = 0;
+
+/* Cleanup the tui before exiting. */
+
+static void
+tui_exit (void)
+{
+ /* Disable the tui. Curses mode is left leaving the screen in a
+ clean state (see endwin()). */
+ tui_disable ();
+}
+
+/* These implement the TUI interpreter. */
+
+static void *
+tui_init (void)
+{
+ /* Install exit handler to leave the screen in a good shape. */
+ atexit (tui_exit);
+
+ tui_initialize_static_data ();
+
+ tui_initialize_io ();
+ tui_initialize_win ();
+ tui_initialize_readline ();
+
+ return NULL;
+}
+
+static int
+tui_resume (void *data)
+{
+ struct ui_file *stream;
+
+ /* gdb_setup_readline will change gdb_stdout. If the TUI was
+ previously writing to gdb_stdout, then set it to the new
+ gdb_stdout afterwards. */
+
+ stream = cli_out_set_stream (tui_old_uiout, gdb_stdout);
+ if (stream != gdb_stdout)
+ {
+ cli_out_set_stream (tui_old_uiout, stream);
+ stream = NULL;
+ }
+
+ gdb_setup_readline ();
+
+ if (stream != NULL)
+ cli_out_set_stream (tui_old_uiout, gdb_stdout);
+
+ if (tui_start_enabled)
+ tui_enable ();
+ return 1;
+}
+
+static int
+tui_suspend (void *data)
+{
+ tui_start_enabled = tui_active;
+ tui_disable ();
+ return 1;
+}
+
+/* Display the prompt if we are silent. */
+
+static int
+tui_display_prompt_p (void *data)
+{
+ if (interp_quiet_p (NULL))
+ return 0;
+ else
+ return 1;
+}
+
+static struct gdb_exception
+tui_exec (void *data, const char *command_str)
+{
+ internal_error (__FILE__, __LINE__, _("tui_exec called"));
+}
+
+
+/* Initialize all the necessary variables, start the event loop,
+ register readline, and stdin, start the loop. */
+
+static void
+tui_command_loop (void *data)
+{
+ /* If we are using readline, set things up and display the first
+ prompt, otherwise just print the prompt. */
+ if (async_command_editing_p)
+ {
+ int length;
+ char *a_prompt;
+ char *gdb_prompt = get_prompt ();
+
+ /* Tell readline what the prompt to display is and what function
+ it will need to call after a whole line is read. This also
+ displays the first prompt. */
+ length = strlen (PREFIX (0))
+ + strlen (gdb_prompt) + strlen (SUFFIX (0)) + 1;
+ a_prompt = (char *) alloca (length);
+ strcpy (a_prompt, PREFIX (0));
+ strcat (a_prompt, gdb_prompt);
+ strcat (a_prompt, SUFFIX (0));
+ rl_callback_handler_install (a_prompt, input_handler);
+ }
+ else
+ display_gdb_prompt (0);
+
+ /* Loop until there is nothing to do. This is the entry point to the
+ event loop engine. gdb_do_one_event, called via catch_errors()
+ will process one event for each invocation. It blocks waits for
+ an event and then processes it. >0 when an event is processed, 0
+ when catch_errors() caught an error and <0 when there are no
+ longer any event sources registered. */
+ while (1)
+ {
+ int result = catch_errors (gdb_do_one_event, 0, "", RETURN_MASK_ALL);
+ if (result < 0)
+ break;
+
+ /* Update gdb output according to TUI mode. Since catch_errors
+ preserves the uiout from changing, this must be done at top
+ level of event loop. */
+ if (tui_active)
+ uiout = tui_out;
+ else
+ uiout = tui_old_uiout;
+
+ if (result == 0)
+ {
+ /* FIXME: this should really be a call to a hook that is
+ interface specific, because interfaces can display the
+ prompt in their own way. */
+ display_gdb_prompt (0);
+ /* This call looks bizarre, but it is required. If the user
+ entered a command that caused an error,
+ after_char_processing_hook won't be called from
+ rl_callback_read_char_wrapper. Using a cleanup there
+ won't work, since we want this function to be called
+ after a new prompt is printed. */
+ if (after_char_processing_hook)
+ (*after_char_processing_hook) ();
+ /* Maybe better to set a flag to be checked somewhere as to
+ whether display the prompt or not. */
+ }
+ }
+
+ /* We are done with the event loop. There are no more event sources
+ to listen to. So we exit GDB. */
+ return;
+}
+
+void
+_initialize_tui_interp (void)
+{
+ static const struct interp_procs procs = {
+ tui_init,
+ tui_resume,
+ tui_suspend,
+ tui_exec,
+ tui_display_prompt_p,
+ tui_command_loop,
+ };
+ struct interp *tui_interp;
+
+ /* Create a default uiout builder for the TUI. */
+ tui_out = tui_out_new (gdb_stdout);
+ interp_add (interp_new (INTERP_TUI, NULL, tui_out, &procs));
+ if (interpreter_p && strcmp (interpreter_p, INTERP_TUI) == 0)
+ tui_start_enabled = 1;
+
+ if (interpreter_p && strcmp (interpreter_p, INTERP_CONSOLE) == 0)
+ {
+ xfree (interpreter_p);
+ interpreter_p = xstrdup (INTERP_TUI);
+ }
+}
tui-interp.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: ChangeLog-1998-2003
===================================================================
--- ChangeLog-1998-2003 (nonexistent)
+++ ChangeLog-1998-2003 (revision 157)
@@ -0,0 +1,1217 @@
+2003-09-27 Andrew Cagney
+
+ * tuiRegs.c: Rename REGISTER_RAW_SIZE to
+ DEPRECATED_REGISTER_RAW_SIZE.
+
+2003-09-13 Andrew Cagney
+
+ * tui.h (struct ui_file): Add opaque declaration.
+
+2003-08-04 Daniel Jacobowitz
+
+ * tui-interp.c: Include "cli-out.h".
+ (tui_resume): Update tui_old_uiout's stream to gdb_stdout.
+
+2003-07-24 Stephane Carrez
+
+ * tui.c (tui_rl_other_window): New function to switch the TUI active
+ window and give focus to a next window.
+ (tui_initialize_readline): Bind it to c-x o.
+ (tui_rl_next_keymap): Activate TUI mode when entering SingleKey mode.
+
+2003-07-23 Stephane Carrez
+
+ * tui.c (tui_enable): Call tuiRefreshAll to make sure the window
+ is accurate.
+
+2003-07-23 Stephane Carrez
+
+ * tui-interp.c (tui_resume): Enable tui when we expected it.
+ (tui_suspend): Remember in which TUI mode we are.
+ (_initialize_tui_interp): Use the tui interpreter even when no
+ other interpreter was set and define in which TUI mode to start.
+
+2003-06-28 Daniel Jacobowitz
+
+ * tui-out.c (tui_ui_out_impl): Add NULL for redirect member.
+
+2003-06-22 Daniel Jacobowitz
+
+ * tui-hooks.c: Update include order.
+ * tui.c: Likewise.
+ * tuiCommand.c: Likewise.
+ * tuiData.c: Likewise.
+ * tuiDataWin.c: Likewise.
+ * tuiDisassem.c: Likewise.
+ * tuiGeneralWin.c: Likewise.
+ * tuiIO.c: Likewise.
+ * tuiLayout.c: Likewise.
+ * tuiRegs.c: Likewise.
+ * tuiSource.c: Likewise.
+ * tuiSourceWin.c: Likewise.
+ * tuiStack.c: Likewise.
+ * tuiWin.c: Likewise.
+
+2003-06-12 Andreas Schwab
+
+ * tuiSource.c (tuiVerticalSourceScroll): Use get_frame_pc.
+ * tuiSourceWin.c (tuiHorizontalSourceScroll): Likewise.
+ * tuiStack.c (tui_get_function_from_frame): Likewise.
+ (tuiShowFrameInfo): Likewise.
+ * tuiWin.c (_makeVisibleWithNewHeight): Likewise.
+ * tui-hooks.c (tui_selected_frame_level_changed_hook): Likewise.
+ * tuiDisassem.c (tuiVerticalDisassemScroll): Likewise.
+ Include "disasm.h".
+
+2003-05-08 Andrew Cagney
+
+ * tuiRegs.c: Use MAX_REGISTER_SIZE instead of
+ MAX_REGISTER_RAW_SIZE.
+
+2003-05-03 Andrew Cagney
+
+ * tuiDisassem.c (tui_disassemble): Call gdb_print_insn, instead of
+ TARGET_PRINT_INSN. Do not initialize a disassemble_info object.
+
+2003-04-30 Andrew Cagney
+
+ * tuiDisassem.c (tui_disassemble): Use
+ "deprecated_tm_print_insn_info" instead of TARGET_PRINT_INSN_INFO,
+ add comment.
+
+2003-03-14 Andrew Cagney
+
+ * tuiRegs.c (_tuiGetRegisterRawValue): Use frame_read_register,
+ instead of get_saved_register.
+
+2003-03-13 Stephane Carrez
+
+ * tui-out.c (tui_out_data): Fix typedef.
+
+2003-03-08 Andrew Cagney
+
+ * tui-out.c: Update copyright.
+ (tui_out_data): Define typedef. Use instead of ui_out_data.
+
+2003-02-14 Andrew Cagney
+
+ * tui.c (tui_enable, tui_disable): Don't modify tui_version.
+ (tui_is_window_visible, tui_get_command_dimension): Test
+ tui_active instead of tui_version.
+ * tuiData.h (tui_version): Delete declaration.
+ * tui-hooks.c (tui_init_hook, tui_event_loop): Delete function,
+ moved to "tui-interp.c".
+ (tui_exit, tui_command_loop): Ditto.
+ (_initialize_tui): Don't initialize init_ui_hook. Initialize
+ target_new_objfile_hook.
+ * tui-interp.c: New file.
+
+2003-02-12 Andrew Cagney
+
+ * tuiIO.c (tui_prep_terminal): Add one notused parameter.
+ * tui.c (tui_rl_switch_mode): Add two notused parameters.
+ (tui_rl_change_windows, tui_rl_next_keymap): Ditto.
+ (tui_rl_delete_other_windows): Ditto.
+ (tui_rl_change_windows, tui_rl_delete_other_windows): Update
+ calls.
+
+2002-12-08 Elena Zannoni
+
+ Import of readline 4.3.
+ Fix PR gdb/675
+ * tuiWin.c: Include readline/readline.h.
+ (tui_update_gdb_sizes): Use accessor function rl_get_screen_size.
+ (tuiResizeAll): Ditto.
+
+2002-12-06 Elena Zannoni
+
+ * tuiStack.c (tuiShowFrameInfo): Fix typo.
+
+2002-11-29 Andrew Cagney
+
+ * tui/tui-hooks.c: Update to use deprecated_selected_frame.
+ * tui/tui.c, tui/tuiDisassem.c, tui/tuiRegs.c: Ditto.
+ * tui/tuiSource.c, tui/tuiSourceWin.c, tui/tuiWin.c: Ditto.
+
+2002-11-28 Andrew Cagney
+
+ * tuiStack.c (tuiShowFrameInfo): Use find_frame_sal instead of
+ find_pc_line.
+
+2002-11-23 Andrew Cagney
+
+ * tuiStack.c (tuiShowFrameInfo): Use get_frame_type instead of
+ deprecated_frame_in_dummy. Fix coding style.
+
+2002-11-21 Stephane Carrez
+
+ * tui-hooks.c (tui_init_hook): Don't enable the TUI if a specific
+ interpreter is installed.
+
+2002-11-18 Andrew Cagney
+
+ * tuiStack.c (tuiShowFrameInfo): Use get_frame_type instead of
+ signal_handler_caller.
+
+2002-11-10 Andrew Cagney
+
+ * tuiStack.c (tuiShowFrameInfo): Replace frame_in_dummy with
+ deprecated_frame_in_dummy.
+
+2002-10-26 Stephane Carrez
+
+ * tuiIO.c (tui_prep_terminal): Save the prompt registered in readline.
+ (tui_redisplay_readline): Use the last saved prompt.
+ (tui_rl_saved_prompt): New.
+
+2002-10-25 Stephane Carrez
+
+ Fix PR gdb/787
+ * tuiWin.c (ACS_LRCORNER, ACS_LLCORNER, ACS_ULCORNER, ACS_URCORNER,
+ ACS_HLINE, ACS_VLINE): Define if they don't exist.
+
+2002-10-25 Stephane Carrez
+
+ Fix PR gdb/478
+ * tuiIO.c (tui_initialize_io): Use setvbuf since this is portable.
+
+2002-10-02 Elena Zannoni
+
+ * tui-hooks.c (selected_frame_level_changed_hook): Use the one
+ exported from frame.h.
+
+2002-09-29 Elena Zannoni
+
+ * tui.c (tui_show_source): Don't access current_source_symtab, use
+ accessor function instead. Include source.h and symtab.h
+ * tuiDisassem.c (tuiShowDisassemAndUpdateSource,
+ tuiVerticalDisassemScroll): Use accessor functions for current
+ source line and symtab. Include source.h.
+ * tuiLayout.c (_extractDisplayStartAddr): Use accessor functions
+ for current source line and symtab. Include source.h.
+ * tuiWin.c (_makeVisibleWithNewHeight): Ditto.
+ * tuiSourceWin.c (tuiUpdateSourceWindowAsIs,
+ tuiHorizontalSourceScroll): Ditto.
+ * tuiSource.c (tuiVerticalSourceScroll): Ditto.
+
+2002-09-13 Stephane Carrez
+
+ * tui.c (tui_rl_switch_mode): Remove unecessary TUI switch printfs.
+ (tui_initialize_readline): Allow to use space to leave SingleKey
+ to enter one gdb command.
+ (tui_enable): Restore the TUI keymap when we are back to TUI.
+ (tui_disable): Restore normal keymap when leaving TUI.
+ * tuiIO.c (tui_redisplay_readline): Restore the SingleKey mode
+ when the buffer becomes empty and we are in tui_one_command_mode.
+
+2002-09-13 Stephane Carrez
+
+ * tuiIO.c (tui_setup_io): rl_already_prompted must be cleared
+ when leaving TUI mode so that gdb prompt is displayed.
+
+2002-09-13 Stephane Carrez
+
+ * tuiStack.c (tui_make_status_line): Make sure the local buffer
+ is large enough to hold the complete line.
+
+2002-09-10 Stephane Carrez
+
+ * tui-hooks.c (tui_event_loop): New function.
+ (tui_command_loop): New function to override gdb loop and make sure
+ uiout is set according to TUI mode.
+ (tui_command_loop): Install the specific TUI command hook.
+ * tuiIO.c (tui_initialize_io): Initialize tui_old_uiout.
+ (tui_uiout, tui_old_uiout): Make public.
+ * tuiIO.h (tui_uiout, tui_old_uiout): Declare.
+
+2002-09-04 Stephane Carrez
+
+ * tuiIO.c (tui_putc): New function to print one character.
+ (printable_part): New function from readline/complete.c.
+ (PUTX): New macro, likewise.
+ (print_filename): New function, likewise.
+ (get_y_or_n): New function, likewise and adapted for TUI.
+ (tui_rl_display_match_list): New function from readline/complete.c
+ and writes on TUI command window.
+ (tui_setup_io): Install or remove the readline hook
+ rl_completion_display_matches_hook so that completion is written
+ directly in TUI command window instead of in the TUI pipe.
+ (tui_initialize_io): Use #ifdef TUI_USE_PIPE_FOR_READLINE for the
+ TUI redirection pipe.
+ (tui_getc): Likewise for call to tui_readline_output.
+ (tui_readline_output): Likewise for function.
+ * tui.c (tui_rl_startup_hook): Always take care of gdb prompt.
+
+2002-09-02 Stephane Carrez
+
+ * tuiWin.c (_newHeightOk): Fix compilation warnings.
+
+2002-09-01 Stephane Carrez
+
+ * tuiWin.c (_tuiAllWindowsInfo): Don't crash if the window
+ is not displayed.
+
+2002-09-01 Stephane Carrez
+
+ * tui-out.c (tui_out_new): Clear start_of_line.
+ * tuiSource.c (tuiVerticalSourceScroll): Use print_source_lines
+ to update the current source line.
+
+2002-09-01 Stephane Carrez
+
+ * tui-hooks.c (tui_detach_hook): New hook to know when a process dies.
+ (tui_install_hooks): Install it.
+ (tui_remove_hooks): Remove it.
+
+2002-09-01 Stephane Carrez
+
+ * tuiData.h (FILE_PREFIX): Don't define.
+ (blankStr, locationStr, breakStr): Don't declare.
+ (breakLocationStr, nullStr, historyLimit, setHistoryLimitTo): Likewise.
+ (displayableWinContentOf, displayableWinContentAt): Likewise.
+ (winElementHeight, winByName, freeAllWindows): Likewise.
+
+ * tuiData.c (blankStr, locationStr, breakStr): Remove.
+ (breakLocationStr, nullStr, historyLimit, setHistoryLimitTo): Remove.
+ (displayableWinContentOf, displayableWinContentAt): Remove.
+ (winElementHeight, winByName, freeAllWindows): Remove.
+
+2002-09-01 Stephane Carrez
+
+ * tuiStack.c (tui_make_status_line): New function to create the
+ status line.
+ (tuiShowLocatorContent): Use it instead of displayableWinContentAt.
+ * tuiData.h (PROC_PREFIX): Use "In:" to reduce length of prefix.
+ (PC_PREFIX): Use upper case.
+ (SINGLE_KEY, MIN_LINE_WIDTH, MIN_PROC_WIDTH): Define.
+ (MAX_TARGET_WIDTH, MAX_PID_WIDTH): Define.
+
+2002-08-31 Stephane Carrez
+
+ * tuiSourceWin.h (tuiUpdateAllExecInfos): Don't declare.
+ (tuiClearAllExecInfosContent): Likewise.
+ (tuiEraseAllExecInfosContent): Ditto.
+ (tuiUpdateSourceWindowsFromLocator): Ditto.
+ * tuiSourceWin.c (tuiUpdateAllExecInfos): Remove.
+ * tui.h (tui_vCheckDataValues): Don't declare.
+ (tui_vStartNewLines, tui_vAllSetHasBreakAt): Likewise.
+ (tui_vUpdateLocatorFilename, tui_vUpdateSourceWindowsWithAddr): Ditto.
+ (tui_vShowFrameInfo): Ditto.
+
+2002-08-31 Stephane Carrez
+
+ * tui.c (tui_commands): Table of single key commands.
+ (tui_rl_command_key): New function to execute gdb command.
+ (tui_rl_command_mode): New function to temporarily leave SingleKey.
+ (tui_rl_next_keymap): New function to enter/leave the SingleKey mode.
+ (tui_rl_startup_hook): New function to avoid prompt display by
+ readline functions.
+ (tui_set_key_mode): New function to set the key mode and install
+ the readline keymap.
+ (tui_initialize_readline): Create TUI SingleKey readline map.
+ (tui_enable): Install rl_startup_hook.
+ (tui_disable): Remove it.
+ * tui.h (enum tui_key_mode): Declare.
+ (tui_set_key_mode, tui_current_key_mode): Declare.
+ * tuiIO.c (tui_redisplay_readline): Don't display the prompt in
+ SingleKey mode.
+ * tuiIO.h (tui_redisplay_readline): Declare.
+
+2002-08-31 Stephane Carrez
+
+ * tuiSourceWin.c (tuiSetIsExecPointAt): Redraw the previous and
+ current line.
+
+2002-08-31 Stephane Carrez
+
+ * tuiSource.c (tuiSetSourceContent): Remove old breakpoint code.
+ (_hasBreak): Remove.
+ (tuiShowSource): Fix comment indentation.
+ (tuiSourceIsDisplayed): Likewise.
+ (tuiVerticalSourceScroll): Likewise.
+
+2002-08-30 Stephane Carrez
+
+ * tuiSourceWin.h (tui_update_all_breakpoint_info): Declare.
+ (tui_update_breakpoint_info): Declare.
+ (tuiSetHasBreakAt, tuiAllSetHasBreakAt): Remove.
+
+ * tuiSourceWin.c (tuiUpdateSourceWindowAsIs): Update breakpoint
+ information using tui_update_breakpoint_info.
+ (tui_update_all_breakpoint_info): New function to refresh all
+ execution windows.
+ (tui_update_breakpoint_info): New function to recompute the status
+ of exec info window from breakpoints.
+ (tuiSetHasBreakAt, tuiAllSetHasBreakAt): Remove.
+ (tuiSetExecInfoContent): Use the exec info flags computed by
+ tui_update_breakpoint_info to display a short status about breakpoints.
+
+ * tuiData.h (TuiExecInfoContent): New for exec info string.
+ (TuiWhichElement): Use it.
+ (TUI_BP_ENABLED, TUI_BP_DISABLED, TUI_BP_HIT): New defines.
+ (TUI_BP_CONDITIONAL, TUI_BP_HARDWARE): New defines.
+ (TUI_BP_HIT_POS, TUI_BP_BREAK_POS, TUI_EXEC_POS): Likewise.
+ (TUI_EXECINFO_SIZE): Likewise.
+ * tuiData.c (initContentElement): Clear exec info string.
+
+ * tui-hooks.c (get_breakpoint): Remove.
+ (tui_event_create_breakpoint): Call tui_update_all_breakpoint_info.
+ (tui_event_delete_breakpoint): Likewise.
+ (tui_event_modify_breakpoint): Likewise.
+
+2002-08-29 Stephane Carrez
+
+ * tui.c (tuiGetLowDisassemblyAddress): Moved from here.
+ * tuiDisassem.c (tuiGetLowDisassemblyAddress): To here, and use
+ tui_find_disassembly_address to find the starting address of
+ disassemble window.
+
+2002-08-28 Stephane Carrez
+
+ * tuiDisassem.c (tui_disassemble): New function to disassemble
+ several lines in a buffer.
+ (tui_find_disassembly_address): New function to search backward
+ or forward a disassembly line.
+ (tuiSetDisassemContent): Use tui_disassemble to obtain the real
+ content and format it in the window.
+ (tuiShowDisassemAndUpdateSource): Remove unused locals.
+ (tuiVerticalDisassemScroll): Use tui_find_disassembly_address to
+ obtain the address to disassemble for the scrolling.
+ * tuiDisassem.h (tuiGetBeginAsmAddress): Update.
+ * tuiSourceWin.c (tuiUpdateSourceWindowAsIs): Don't pass symtab.
+
+2002-08-28 Stephane Carrez
+
+ * tuiIO.c (CTRL_CHAR): Redefine and use readline 4.3 definition.
+
+2002-08-26 Stephane Carrez
+
+ Fix PR gdb/393:
+ * tui.c (tui_disable): Update gdb's knowledge of its terminal
+ using target_terminal_save_ours.
+ (tui_enable): Likewise.
+
+2002-08-25 Stephane Carrez
+
+ * tui.c (tui_rl_switch_mode): Renames tui_switch_mode.
+ (tui_rl_change_windows): Renames tui_change_windows.
+ (tui_rl_delete_other_windows): Renames tui_delete_other_windows.
+ (tui_initialize_readline): Update.
+
+2002-08-25 Stephane Carrez
+
+ * tuiDisassem.c (tuiSetDisassemContent): Use breakpoint_here_p.
+ (_hasBreak): Remove.
+
+2002-08-25 Stephane Carrez
+
+ * tuiDisassem.c (tuiGetBeginAsmAddress): Use lookup_minimal_symbol
+ to find symbol address.
+
+2002-08-25 Stephane Carrez
+
+ * tuiSourceWin.c (tui_display_main): Rename from tuiDisplayMainFunction
+ and use tuiGetBeginAsmAddress.
+ * tuiSourceWin.h (tui_display_main): Declare.
+ * tui.h (tuiDisplayMainFunction): Remove.
+ * tui-hooks.c (tui_new_objfile_hook): Update.
+
+2002-08-25 Stephane Carrez
+
+ * tuiSource.h (m_tuiShowSourceAsIs): Remove macro.
+ (tuiShowSourceAsIs): Don't declare.
+
+2002-08-25 Stephane Carrez
+
+ * tui-hooks.c (tui_selected_frame_level_changed_hook): Always update
+ the frame position.
+
+2002-08-25 Stephane Carrez
+
+ * tuiStack.c (tuiSetLocatorContent): Remove.
+ (tuiUpdateLocatorInfoFromFrame): Remove.
+ (tui_set_locator_info): Allocate the content buffer if necessary.
+ (tui_set_locator_filename): Call tui_set_locator_info directly.
+ (tuiShowFrameInfo): Likewise and use find_pc_line instead of
+ find_pc_symtab.
+
+2002-08-25 Stephane Carrez
+
+ * tuiSourceWin.c (tuiDisplayMainFunction): Update to use
+ tuiUpdateLocatorFilename.
+ * tuiStack.c (tuiSetLocatorInfo): Make it static.
+ (tuiSetLocatorContent): Likewise.
+ (tuiUpdateLocatorInfoFromFrame): Likewise.
+ (tuiSwitchFilename): Remove.
+ (tui_set_locator_filename): New function
+ (tui_set_locator_info): Rename from tuiSetLocatorInfo to GNU-ify;
+ use tui_set_locator_filename to record the filename.
+ (tuiUpdateLocatorFilename): Likewise.
+ (tuiUpdateLocatorInfoFromFrame): Update.
+ (tuiSetLocatorContent): Likewise.
+ * tuiStack.h (tuiClearLocatorContent): Don't declare.
+ (tuiSetLocatorInfo, tuiSetLocatorContent): Likewise.
+ (tuiUpdateLocatorInfoFromFrame, tuiSwitchFilename): Likewise.
+
+2002-08-25 Stephane Carrez
+
+ * tuiSourceWin.c (tuiSetHasBreakAt): Use filename for breakpoint
+ comparison; cleanup.
+ * tuiSource.c (tuiSetSourceContent): Set window title and filename.
+ * tuiGeneralWin.c (boxWin): Print optional title on top of window.
+ * tuiData.h (TuiSourceInfo): Add filename member.
+ (TuiGenWinInfo): Add title member.
+ * tuiData.c (initGenericPart): Clear title.
+ (freeWindow): Free title and filename; remove unused locals.
+ (initWinInfo): Clear filename.
+ (tuiDelWindow): Free it; remove unused locals.
+
+2002-08-25 Stephane Carrez
+
+ * tuiStack.h (tuiGetLocatorFilename): Don't declare.
+ (tuiUpdateLocatorDisplay): Likewise.
+ * tuiStack.c (tuiGetLocatorFilename): Remove.
+ (tuiShowFrameInfo): Use tuiSetLocatorContent and tuiShowLocatorContent
+ instead of tuiUpdateLocatorDisplay.
+ (tuiUpdateLocatorDisplay): Remove.
+
+2002-08-25 Stephane Carrez
+
+ * tuiStack.h (tuiClearLocatorDisplay): Don't declare.
+ * tuiStack.c (tuiClearLocatorDisplay): Remove.
+ (tuiShowLocatorContent): Use wclrtoeol to clear end of status line.
+ (tuiUpdateLocatorDisplay): Don't call tuiClearLocatorDisplay.
+
+2002-08-25 Stephane Carrez
+
+ * tuiStack.c (tui_get_function_from_frame): Rename from
+ _getFuncNameFromFrame; use print_address_symbolic to get symbolic
+ name of address.
+ (tuiUpdateLocatorInfoFromFrame): Update.
+
+2002-08-25 Stephane Carrez
+
+ * tuiRegs.c (tuiDisplayRegistersFrom): Remove unused locals.
+ (_tuiRegisterFormat, _tuiSetSpecialRegsContent): Likewise.
+ (_tuiSetGeneralAndSpecialRegsContent): Likewise.
+ (_tuiSetFloatRegsContent): Likewise.
+ (_tuiRegisterName): Return a const char*.
+ * tuiData.h (_TuiDataElement): Use const char* for name.
+
+2002-08-25 Stephane Carrez
+
+ * tuiSourceWin.h (tuiEraseAllSourceContent): Don't declare.
+ (tuiShowAllExecInfosContent): Likewise.
+ * tuiSourceWin.c (tuiEraseAllSourceContent): Remove.
+ (tuiShowAllExecInfosContent): Remove.
+ (tuiAllocSourceBuffer): Remove unused locals.
+
+2002-08-25 Stephane Carrez
+
+ * tuiStack.c (tui_update_command): Rename _tuiUpdateLocation_command
+ to follow other gdb's command names; use execute_command; cleanup.
+ (_initialize_tuiStack): Update.
+
+2002-08-25 Stephane Carrez
+
+ * tuiWin.h (tui_update_gdb_sizes): Declare.
+
+2002-08-24 Stephane Carrez
+
+ * tui.c (strcat_to_buf): Use const char* for source item.
+ (tui_enable): Update the windows if there is a selected frame.
+ * tui.h (strcat_to_buf): Update prototype.
+ (strcat_to_buf_with_fmt): Remove.
+
+2002-08-24 Stephane Carrez
+
+ * tuiWin.c (tui_update_gdb_sizes): New function to tell gdb what
+ is the size of command window.
+ (tuiResizeAll): Call it instead of init_page_info.
+ * tui.c (tui_enable): Call it to resize to TUI command window.
+ (tui_disable): Likewise for plain screen.
+
+2002-08-24 Stephane Carrez
+
+ * tui.c (tui_enable): Use tuiSetLayout instead of showLayout and
+ use tuiShowFrameInfo instead of tuiSetLocatorContent.
+ * tuiLayout.h (showLayout): Remove.
+ * tuiLayout.c (_showSourceOrDisassemAndCommand): Remove unused locals.
+ (_showSourceDisassemCommand): Likewise.
+ (showLayout): Make it static.
+ (lastLayout): Remove.
+
+2002-08-24 Stephane Carrez
+
+ * tuiSourceWin.c (tui_show_source_line): New function.
+ (tuiShowSourceContent): Call it and avoid clearing the window before
+ redrawing it.
+ (tuiClearAllSourceWinsContent): Remove.
+ * tuiSourceWin.h (tuiClearAllSourceWinsContent): Don't declare.
+ * tuiWin.h (tuiClearWinFocus, tuiClearWinFocusFrom): Don't declare.
+ * tuiWin.c (tuiClearWinFocus, tuiClearWinFocusFrom): Remove.
+ (tuiRefreshAll): Don't clear the window.
+ (_makeVisibleWithNewHeight): Don't clear locator line.
+ (tuiResizeAll): Remove unused locals.
+ (_tuiAdjustWinHeights): Likewise.
+ (_makeInvisibleAndSetNewHeight): Likewise.
+ (_newHeightOk): Likewise.
+ * tuiLayout.c (showLayout): Don't clear source windows.
+ (tuiSetLayout): Don't clear the window.
+ (_initAndMakeWin): Likewise for status line.
+ * tuiGeneralWin.c (makeVisible): Don't clear or refresh the window.
+ (makeWindow): Likewise.
+ (tuiClearWin): Remove.
+ * tuiGeneralWin.h (tuiClearWin): Don't declare.
+
+2002-08-24 Stephane Carrez
+
+ * tuiSourceWin.c (tuiSrcWinIsDisplayed): Remove.
+ (tuiAsmWinIsDisplayed): Remove.
+ (tuiShowAllSourceWinsContent): Remove.
+ (tuiUpdateOnEnd): Remove.
+ * tuiGeneralWin.c (scrollWinForward): Remove.
+ (scrollWinBackward): Remove.
+ (_winResize): Don't declare.
+ * tui.h (tuiUpdateOnEnd): Don't declare.
+ (vcatch_errors, va_catch_errors): Likewise.
+ * tuiSourceWin.h (tuiUpdateOnEnd): Likewise.
+ (tuiShowAllSourceWinsContent): Likewise.
+ * tuiGeneralWin.h (scrollWinForward): Likewise.
+ (scrollWinBackward): Likewise.
+
+2002-08-24 Stephane Carrez
+
+ * tuiRegs.c (_tuiRegisterFormat): Use gdbarch_print_registers_info.
+
+2002-08-18 Daniel Jacobowitz
+
+ Fix PR gdb/655
+ * tui.c: Disable include.
+
+2002-03-15 Andrew Cagney
+
+ * tui-out.c (XMALLOC): Delete macro. Update copyright.
+
+2002-03-01 Andrew Cagney
+
+ * tui-hooks.c: Add FIXME to explain true/false problem. Update
+ copyright.
+ * tui.c, tuiCommand.c, tuiData.c, tuiDataWin.c: Ditto.
+ * tuiDisassem.c, tuiGeneralWin.c, tuiIO.c, tuiLayout.c: Ditto.
+ * tuiRegs.c, tuiSource.c, tuiSourceWin.c, tuiStack.c: Ditto.
+ * tuiWin.c: Ditto.
+
+ 2002-02-08 Daniel Jacobowitz
+ * tui-hooks.c: Include before "bfd.h".
+ * tui.c: Likewise.
+ * tuiCommand.c: Likewise.
+ * tuiData.c: Likewise.
+ * tuiDataWin.c: Likewise.
+ * tuiDisassem.c: Likewise.
+ * tuiGeneralWin.c: Likewise.
+ * tuiIO.c: Likewise.
+ * tuiLayout.c: Likewise.
+ * tuiRegs.c: Likewise.
+ * tuiSource.c: Likewise.
+ * tuiSourceWin.c: Likewise.
+ * tuiStack.c: Likewise.
+ * tuiWin.c: Likewise.
+
+2002-02-01 Andrew Cagney
+
+ * tuiWin.c (_initialize_tuiWin): Replace NO_FUNCTION with NULL.
+
+2001-10-20 Andrew Cagney
+
+ * tuiDisassem.c: Include "value.h".
+ * tuiSourceWin.c: Ditto.
+
+2001-09-28 Tom Tromey
+
+ * tuiLayout.h (tui_set_layout): Don't declare.
+ * tui.h (tui_vAddWinToLayout): Don't declare.
+ (tui_vSetLayoutTo): Likewise.
+ (tui_set_layout): Declare.
+
+2001-08-02 Eli Zaretskii
+
+ * tuiSourceWin.c: Use disp_del instead of del.
+
+ * tuiSource.c: Use disp_del instead of del.
+
+ * tuiDisassem.c: Use disp_del instead of del.
+
+2001-07-31 Stephane Carrez
+
+ * tui.c (tui_enable): Remove call to terminal_save_ours().
+ (tui_disable): Likewise.
+
+2001-07-28 Stephane Carrez
+
+ * tuiWin.c (_initialize_tuiWin): Use specific tui prefix for
+ set/show configuration variables.
+ (show_tui_cmd): New function.
+ (set_tui_cmd): New function.
+
+2001-07-24 Stephane Carrez
+
+ * tui-hooks.c: New file, gdb hooks for tui.
+ * tui-out.c: New file, image copied from cli-out.c.
+ (tui_field_int): Identify "line" fields and keep track of them.
+ (tui_field_string): Likewise for "file".
+ (tui_out_new): Use flags = 0 to avoid printing the sources.
+
+2001-07-23 Stephane Carrez
+
+ * tuiIO.c (tui_cont_sig): Update cursor position on the screen to
+ leave it in the command window.
+ (tui_redisplay_readline): Save cursor position to restore the
+ cursor after we go back from background.
+ * tuiData.h (TuiCommandInfo): Add start_line member.
+
+2001-07-23 Stephane Carrez
+
+ * tuiStack.c (tuiUpdateLocatorFilename): Use const char*.
+ * tuiStack.h (tuiUpdateLocatorFilename): Update prototype.
+ * tuiWin.c (_initialize_tuiWin): Don't cast table of enum in calls
+ to add_set_enum_cmd.
+ * tui.c (tui_show_source): New function.
+ (tuiGetLowDisassemblyAddress): Use CORE_ADDR for newLow.
+ (tui_switch_mode): Prep or deprep readline terminal;
+ make sure the \n we return does not redo the last command.
+ * tui.h (tui_show_source): Declare.
+ (tui_out_new, tui_install_hooks, tui_remove_hooks): Likewise.
+ (tui_active, tui_initialize_io, tui_initialize_readline): Likewise.
+
+2001-07-22 Stephane Carrez
+
+ * tuiIO.c (tui_initialize_io): Install tui_cont_sig signal handler
+ if SIGCONT is defined.
+ (tui_cont_sig): New function when SIGCONT is defined.
+ (tui_setup_io): Save tty setting to restore by SIGCONT.
+
+2001-07-22 Stephane Carrez
+
+ * tui.h (tui_show_assembly): Declare.
+ (tui_is_window_visible): Declare.
+ * tui.c (tui_show_assembly): New function.
+ (tui_is_window_visible): New function.
+ (tui_get_command_dimension): New function.
+
+2001-07-21 Stephane Carrez
+
+ * tuiWin.c (tuiRefreshAll): Use clearok to force a refresh.
+
+2001-07-21 Stephane Carrez
+
+ * tui-file.c (tui_file_fputs): Use tui_puts.
+
+2001-07-21 Stephane Carrez
+
+ * tuiStack.c (tuiSetLocatorInfo): Cleanup.
+ * tuiStack.h (tuiGetLocatorFilename): Declare.
+ * tuiRegs.h (tuiFirstRegElementNoInLine): Declare.
+ * tuiData.h (addToSourceWindows): Declare.
+
+2001-07-21 Stephane Carrez
+
+ * tui.c (tui_change_windows): New function.
+ (tui_delete_other_windows): New function.
+ (tui_initialize_readline): Bind them to C-X 1 and C-X 2.
+ (tui_enable): Enable the keypad; call tui_update_variables.
+ (strcat_to_buf_with_fmt): Remove.
+
+2001-07-21 Stephane Carrez
+
+ * tui.h: Remove old declarations, add the new ones.
+ * tui.c (tui_switch_mode): New function.
+ (tui_initialize_readline): New function.
+ (tui_enable): New function.
+ (tui_disable): New function.
+ (tuiGetLowDisassemblyAddress): Use CORE_ADDR, cleanup.
+ (tui_vSelectSourceSymtab): Remove.
+ (tuiInitWindows): Remove.
+ (_initialize_tui): Remove.
+ (_tuiReset): Keep but put arround #if 0.
+
+2001-07-21 Stephane Carrez
+
+ * tuiIO.h: Remove old declarations and add the new ones.
+ * tuiIO.c: New management for curses and gdb terminal interactions.
+ (tui_tputs): Remove.
+ (tuiTermSetup, tuiTermUnsetup): Remove, must use normal curses ops.
+ (tuiBufferGetc, tui_vStartNewLines, _updateCommandInfo): Remove.
+ (tui_owns_terminal): Remove.
+ (tui_redisplay_readline): New function.
+ (tui_puts): New function.
+ (tui_prep_terminal): New function.
+ (tui_deprep_terminal): New function.
+ (tui_getc): Rename of tuiGetc, simplify and fix.
+ (tui_setup_io): New function.
+ (tui_initialize_io): New function.
+
+2001-07-21 Stephane Carrez
+
+ * tuiRegs.c (tuiDisplayRegistersFrom): Call touchwin.
+ (_tuiRegisterFormat): Reduce size of format result.
+
+2001-07-21 Stephane Carrez
+
+ * tuiGeneralWin.c (boxWin): Use the tui configuration variables.
+ * tuiWin.h: Declare the new variables.
+ * tuiWin.c (_initialize_tuiWin): Create TUI configuration variables.
+ (tui_update_variables): New function.
+ (translate): New function.
+ (tui_border_kind_enums, tui_border_mode_enums): New tables.
+ (tui_border_mode_translate): New table.
+ (tui_border_kind_translate_*): New tables.
+ (tui_active_border_mode): New variables.
+ (tui_border_*): New variables.
+
+2001-07-21 Stephane Carrez
+
+ * tuiWin.c (_parseScrollingArgs): Fix uninitialized variable.
+ (_makeVisibleWithNewHeight): Use TuiLineOrAddress type.
+
+ * tuiStack.c (tuiShowFrameInfo): Use TuiLineOrAddress type.
+ (tui_vUpdateLocatorFilename): Remove.
+ * tuiStack.h: Update prototypes.
+
+ * tuiSourceWin.c (tuiAddrIsDisplayed): New function.
+ (tuiLineIsDisplayed): Split for address and line.
+ (tuiUpdateSourceWindow): Use TuiLineOrAddress type.
+ (tuiUpdateSourceWindowAsIs): Likewise.
+ (tuiUpdateSourceWindowsWithAddr): Likewise.
+ (tuiUpdateSourceWindowsWithLine): Likewise.
+ (tuiHorizontalSourceScroll): Likewise.
+ (tuiSetIsExecPointAt): Likewise.
+ (tuiUpdateOnEnd): Likewise.
+ * tuiSourceWin.h: Update prototypes.
+
+ * tuiSource.c (tuiVerticalSourceScroll): Use TuiLineOrAddress type.
+ (tuiShowSource): Likewise.
+ (tuiVerticalSourceScroll): Likewise.
+ * tuiSource.h (tuiShowSource): Update prototype.
+
+ * tuiDisassem.c (tuiSetDisassemContent): Use CORE_ADDR for address.
+ (tuiShowDisassem): Use TuiLineOrAddress type.
+ (tuiShowDisassemAndUpdateSource): Likewise.
+ (tuiVerticalDisassemScroll): Likewise.
+ (tuiShowDisassemAsIs): Remove.
+ * tuiDisassem.h (tuiSetDisassemContent): Update prototype.
+
+ * tuiData.c (initWinInfo): Use CORE_ADDR for address.
+ (clearWinDetail): Likewise.
+ (displayableWinContentOf): Fix address conversion.
+ (tuiNextWin): Fix crash when the window is not yet created.
+ (partialWinByName): Likewise.
+
+2001-07-21 Stephane Carrez
+
+ * tuiSourceWin.h: Remove unused declarations.
+ * tuiSourceWin.c (tui_vUpdateSourceWindowsWithAddr): Remove.
+ (tui_vUpdateSourceWindowsWithLine): Remove.
+ (tui_vAllSetHasBreakAt): Remove.
+
+ * tuiLayout.h (tui_set_layout): Declare.
+ (tui_vSetLayoutTo): Remove.
+ (tui_vAddWinToLayout): Remove.
+ * tuiLayout.c (_tuiLayout_command): Call tui_enable() to force TUI.
+ (_tuiToggleLayout_command): Remove.
+ (_tuiToggleSplitLayout_command): Remove.
+ (_tuiLayout_command): Remove.
+ (tui_vSetLayoutTo): Remove.
+ (tui_vAddWinToLayout): Remove.
+
+ * tuiDataWin.h (tui_vCheckDataValues): Remove.
+ * tuiDataWin.c (tui_vCheckDataValues): Remove.
+
+2001-07-20 Stephane Carrez
+
+ * tuiWin.c (tuiStrDup): Remove, replaced by xstrdup.
+ (_parseScrollingArgs): Use xstrdup.
+ (_tuiScrollForward_command): Call tui_enable() to force TUI mode.
+ (_tuiScrollBackward_command): Likewise.
+ (_tuiScrollLeft_command): Likewise.
+ (_tuiScrollRight_command): Likewise.
+ (_tuiSetFocus): Likewise.
+ (_tuiSetFocus_command): Likewise.
+ (_tuiRefreshAll_command): Likewise.
+ (_tuiSetTabWidth_command): Likewise.
+ (_tuiSetWinHeight): Likewise.
+ (_tuiSetWinHeight_command): Likewise.
+ (_tuiXDBsetWinHeight): Likewise.
+ (_tui_vSetFocus): Remove.
+ (_tui_vSetWinHeight): Remove.
+ (_tui_vXDBsetWinHeight): Remove.
+
+2001-07-21 Stephane Carrez
+
+ * tuiCommand.h: Remove unused declarations.
+ * tuiCommand.c (tuiDispatchCtrlChar): Fix escape sequences.
+ (tuiIncrCommandCharCountBy): Remove.
+ (tuiDecrCommandCharCountBy): Remove.
+ (tuiSetCommandCharCountTo): Remove.
+ (tuiClearCommandCharCount): Remove.
+
+2001-07-20 Stephane Carrez
+
+ * tuiWin.c (_initialize_tuiWin): Always define the tui commands;
+ create the tui class help.
+ * tuiLayout.c (_initialize_tuiLayout): Always define the tui commands.
+ * tuiRegs.c (_initialize_tuiRegs): Likewise.
+ * tuiStack.c (_initialize_tuiStack): Likewise.
+
+2001-07-19 Stephane Carrez
+
+ * tuiDisassem.c (tuiVerticalDisassemScroll): Use CORE_ADDR.
+ (tuiVerticalDisassemScroll): Likewise.
+ (tuiShowDisassemAndUpdateSource): Check for null symtab to
+ prevent a crash.
+
+2001-07-18 Stephane Carrez
+
+ * tuiIO.c (_tuiHandleResizeDuringIO): Call tuiRefreshAll.
+ (tuiRead, tui_vread): Remove.
+
+ * tui.c (va_catch_errors, tuiDo, tuiDoAndReturnToTop): Remove.
+ (vcatch_errors, _tui_vDo): Remove.
+ * tui.h (tuiDo, tuiDoAndReturnToTop): Remove.
+
+ * tuiLayout.c (tuiSetLayout): Remove vcatch_errors.
+ (tui_set_layout): Rename of _tuiSetLayoutTo, public.
+ (_tuiToggleLayout_command): Merge with _tui_vToggleLayout_command.
+ (_tuiToggleSplitLayout_command): Merge with _tui_vToggleSplitLayout_command.
+ (_tuiLayout_command): Call tui_set_layout.
+
+ * tuiRegs.c (_tuiScrollRegsBackward_command): Call tui_scroll.
+ (_tuiScrollRegsForward_command): Likewise.
+ (_tuiShowFloat_command): Call _tui_vShowRegisters_commandSupport.
+ (_tuiShowGeneral_command): Likewise.
+ (_tuiShowSpecial_command): Likewise.
+ (_tuiToggleFloatRegs_command): Call tuiToggleFloatRegs.
+ * tuiWin.c (tui_scroll): Rename of tui_vScroll, update parameters.
+ (_tuiScrollForward_command): Call tui_scroll.
+ (_tuiScrollBackward_command): Likewise.
+ (_tuiScrollLeft_command): Likewise.
+ (_tuiScrollRight_command): Likewise.
+ (_tuiSetFocus_command): Call _tuiSetFocus.
+ (_tuiRefreshAll_command): Call tuiRefreshAll.
+ (_tuiSetWinHeight_command): Call _tuiSetWinHeight.
+ (_tuiXDBsetWinHeight_command): Call _tuiXDBsetWinHeight.
+ * tuiWin.h (tui_scroll): Rename of tui_vScroll, update parameters.
+
+2001-07-18 Stephane Carrez
+
+ * tuiData.h (TuiLocatorElement): Use CORE_ADDR for address member.
+ (TuiLineOrAddress): Likewise.
+ * tuiDisassem.c (tuiGetBeginAsmAddress): Use CORE_ADDR to specify
+ an address.
+ (tuiSetDisassemContent): Likewise.
+ (tuiShowDisassem, tuiShowDisassemAndUpdateSource): Likewise.
+ * tuiLayout.c (_extractDisplayStartAddr): Likewise.
+ (tuiSetLayout): Likewise.
+ * tuiSourceWin.c (tuiDisplayMainFunction): Likewise.
+ (tuiUpdateSourceWindowsWithAddr): Likewise.
+ (tuiUpdateSourceWindowsWithLine): Likewise.
+ (tuiSetHasBreakAt): Likewise.
+ * tuiStack.c (tuiSetLocatorInfo): Likewise.
+ (tuiSwitchFilename): Likewise.
+ (tuiUpdateLocatorInfoFromFrame): Likewise.
+ (tuiSetLocatorContent): Likewise.
+ (tuiShowFrameInfo): Likewise.
+ * tuiDisassem.h: Update prototypes to use CORE_ADDR.
+ * tuiSourceWin.h: Likewise.
+ * tuiStack.h: Likewise.
+
+2001-07-17 Stephane Carrez
+
+ * tuiWin.c: Add missing includes.
+ (_makeVisibleWithNewHeight): Fix call to find_line_pc.
+ * tuiLayout.c: Add missing includes.
+ (_initAndMakeWin): Don't put curses in echo mode.
+ (_extractDisplayStartAddr): Fix calls to find_line_pc.
+ (_tuiLayout_command): Missing ',' in warning call.
+ * tuiSourceWin.c (tuiUpdateSourceWindowsWithLine): Fix calls to
+ find_line_pc.
+ (tuiSetHasBreakAt): Check for null source file.
+
+2001-07-17 Stephane Carrez
+
+ * tuiWin.c (_tuiSetFocus): Replace subsetCompare with subset_compare.
+ * tuiLayout.c (_tuiSetLayoutTo): Likewise.
+ * tui.c (_tui_vToggle_command): Likewise.
+
+2001-07-17 Elena Zannoni
+
+ * tui-file.c: Add include of tuiIO.h, for tuiPuts_unfiltered.
+
+2001-07-16 Stephane Carrez
+
+ * tuiRegs.c (tuiDisplayRegistersFrom): Set scrollok to FALSE in
+ each register window.
+ (tuiCheckRegisterValues): Use REGISTER_RAW_SIZE to obtain the size
+ of the register to check.
+ (_tuiRegValueHasChanged): Likewise.
+ (_tuiRegisterName): Use REGISTER_NAME.
+ (tui_restore_gdbout): New function.
+ (_tuiRegisterFormat): Use do_registers_info with gdb_stdout redirected
+ to a string.
+ (START_SPECIAL_REGS): Define.
+ (_tuiGetRegisterRawValue): Use get_saved_register.
+ (_tuiDisplayRegister): Fix clearing of register window.
+
+2001-07-17 Stephane Carrez
+
+ * tui-file.h (fputs_unfiltered_hook): Remove.
+ * tui-file.c (tui_file_flush): Remove fputs_unfiltered_hook.
+ (tui_file_fputs): Likewise; simplify
+
+2001-07-16 Stephane Carrez
+
+ * tuiStack.c: Add missing includes.
+ (tuiShowFrameInfo): Don't crash when there is no symbol table
+ associated with the pc.
+ * tuiSource.c (_hasBreak): Check for null source file.
+ * tuiWin.c (tuiRefreshAll): Check for null winList[type].
+ (_tuiSetFocus): Check for null dataWin.
+ * tuiGeneralWin.c (refreshAll): Check for null list[type].
+
+2001-07-16 Stephane Carrez
+
+ * tuiDisassem.c (tuiSetDisassemContent): Use tm_print_insn_info
+ to disassemble in the curses window.
+
+2001-07-16 Stephane Carrez
+
+ * tui.h: Cleanup to avoid inclusion of curses includes.
+ (TuiGenWinInfo, TuiGenWinInfoPtr): Move from here.
+ * tuiData.h: To here; include curses includes here.
+ (setTermHeightTo): Rename of setTermHeight to follow reality.
+ (setTermWidthTo): Likewise with setTermWidth.
+
+2001-07-14 Stephane Carrez
+
+ * tuiWin.c, tui.c, tuiCommand.c: Use ansi prototype.
+ tuiIO.c, tuiData.c: Likewise.
+ tuiDataWin.c, tuiDisassem.c: Likewise.
+ tuiGeneralWin.c, tuiLayout.c: Likewise.
+ tuiRegs.c, tuiSource.c: Likewise.
+ tuiSouceWin.c, tuiStack.c: Likewise.
+
+2001-07-14 Stephane Carrez
+
+ * tuiWin.c, tuiWin.h, tui.c, tui.h, tuiCommand.c: Add FSF copyright.
+ tuiCommand.h, tuiIO.c, tuiIO.h, tuiData.h, tuiData.c: Likewise.
+ tuiDataWin.c, tuiDataWin.h, tuiDisassem.c, tuiDisassem.h: Likewise.
+ tuiGeneralWin.c, tuiGeneralWin.h, tuiLayout.c, tuiLayout.h: Likewise.
+ tuiRegs.c, tuiRegs.h, tuiSource.c, tuiSource.h: Likewise.
+ tuiSouceWin.c, tuiSourceWin.h, tuiStack.c, tuiStack.h: Likewise.
+
+2001-03-08 Andrew Cagney
+
+ * tuiRegs.c: Use NUM_REGS, not ARCH_NUM_REGS.
+
+2001-03-06 Kevin Buettner
+
+ * tui-file.h: Update/correct copyright notice.
+
+Wed Feb 7 19:54:27 2001 Andrew Cagney
+
+ * tui-file.c: Add __FILE__ and __LINE__ parameter to calls to
+ internal_error.
+
+2000-12-14 Kevin Buettner
+
+ * tui-file.c, tui.c, tuiData.c, tuiLayout.c: Replace occurrences
+ of free() with xfree().
+
+2000-06-22 Kevin Buettner
+
+ * tuiSourceWin.h: Eliminate use of PARAMS from this file.
+
+2000-06-20 Kevin Buettner
+
+ * tuiLayout.c: Eliminate use of PARAMS from this file.
+
+2000-06-17 Kevin Buettner
+
+ * tuiIO.c: Eliminate use of PARAMS from this file.
+
+Thu May 25 14:46:20 2000 Andrew Cagney
+
+ * tui-file.c: Include "tui.h", "tuiData.h", "tuiIO.h" and
+ "tuiCommand.h".
+ (tui_file_fputs): Pass ``file'' and not ``stream'' to
+ tui_file_adjust_strbuf.
+
+Thu May 25 16:58:01 2000 Andrew Cagney
+
+ * tui.h: Include when available.
+ * tui.c, tuiGeneralWin.c: Do not include .
+
+Mon May 15 17:16:10 2000 Andrew Cagney
+
+ * Makefile.in: Delete.
+
+Tue Apr 18 15:32:15 2000 Andrew Cagney
+
+ * Makefile.in (distclean, maintainer-clean, realclean,
+ mostlyclean): New targets.
+
+Tue Feb 1 00:17:12 2000 Andrew Cagney
+
+ * tui-file.c, tui-file.h, tuiDisassem.c, tuiIO.c, tuiIO.h,
+ tuiRegs.c: Update to reflect rename of gdb-file / GDB_FILE to
+ ui-file / ``struct ui_file''.
+
+Mon Jan 31 18:12:43 2000 Andrew Cagney
+
+ * tui-file.c (enum streamtype, struct tui_stream, tui_file_new,
+ tui_file_delete, tui_fileopen, tui_sfileopen, tui_file_isatty,
+ tui_file_rewind, tui_file_put, tui_file_fputs,
+ tui_file_get_strbuf, tui_file_adjust_strbuf, tui_file_flush,
+ fputs_unfiltered_hook): Move to here from ../utils.c
+
+ * tui-file.h, tui-file.c: New files.
+
+Mon Nov 8 17:47:37 1999 Andrew Cagney
+
+ * tuiRegs.c (_tuiRegisterFormat), tuiDisassem.c
+ (tuiSetDisassemContent): Replace gdb_file_init_astring with
+ tui_sfileopen. Replace gdb_file_get_strbuf with
+ tui_file_get_strbuf.
+
+Mon Nov 8 16:54:51 1999 Andrew Cagney
+
+ * tuiRegs.c (_tuiRegisterFormat), tuiDisassem.c
+ (tuiSetDisassemContent): Repace gdb_file_deallocate with
+ gdb_file_delete. Replace gdb_file_init_astring with tui_sfileopen.
+
+Fri Sep 17 19:34:38 1999 Andrew Cagney
+
+ * tuiSource.c: Include "source.h".
+ (open_source_file, find_source_lines): Delete declarations.
+
+1999-01-26 Jason Molenda (jsm@bugshack.cygnus.com)
+
+ * tui.h: Include stdarg.h instead of varargs.h if we're on an ISO Cish
+ system.
+
+Thu Dec 31 12:08:32 1998 David Taylor
+
+ The following changes were made by Jim Blandy ,
+ Edith Epstein , Elena Zannoni
+ Stan Shebs , and David
+ Taylor , as part of the project to merge in
+ changes originally made by HP; HP did not create ChangeLog
+ entries.
+
+ * Makefile.in: New file; we're merging HP's changes into GDB, and
+ we've moved the TUI files into a subdirectory, so we need a new
+ Makefile.
+
+ * tui.c:
+ #include , if we have it, to get declarations for
+ the termcap functions on Solaris.
+ (tgoto): Add external K&R declaration for this; Solaris doesn't
+ bother to actually declare it in their header files.
+ (_tuiReset): Ignore the #definition of TIOCGETC if USG is defined;
+ we'd rather use the USG mechanisms than the Berkeley mechanisms
+ (TIOCGETC is one of the Berkeley terminal control ioctls).
+ Apologies if this causes trouble later; this should all be handled
+ by autoconf...
+ (strcat_to_buf, strcat_to_buf_with_fmt): New functions, moved here
+ from ../utils.h.
+ (tuiFree): replace safe_free with free.
+ (strcat_to_buf): new function, copied from utils.c.
+ (tuiInit): Add ignored `argv0' argument, to match the type that
+ init_ui_hook expects; updated declaration. Call the
+ initialize_tui_files function constructed above. Initialize
+ flush_hook to NULL.
+ (tuiInitWindows): Call tuiSetLocatorContent, to get the first
+ element of the locator window's content allocated. This seems
+ wrong, because it must have been initialized somehow in HP's
+ sources, and we should do it the same way now. But we do get
+ further before it segfaults. [Postscript: HP didn't bother to
+ initialize it; they compile
+ (va_catch_errors, vcatch_errors): Functions moved here from
+ ../utils.c in HP's sources. They're not used anywhere else.
+ (xdb_style): Delete this variable, and remove all references to
+ it. It's always true.
+ (tuiInit, _tui_vDo): References removed.
+
+ * tui.h: Add prototypes.
+ Don't #include "gendefs.h"; it's only used in the TUI.
+ Integrate its contents into this file:
+ #include here.
+ (Opaque, OpaqueFuncPtr): Typedefs moved to here.
+
+ * tuiCommand.c: #include "defs.h", so we get the appropriate
+ definition of GDB_FILE.
+
+ * tuiData.c
+ (freeWindow): replace safe_free with free.
+ (tui_version): don't define it here; it's defined in main.c now.
+
+ * tuiDisassem.c
+ (tuiSetDisassemContent): Call strcat_address_numeric instead of
+ strcat_address. Simplify the control structure. Use predefined
+ GDB function to print asm inst address. Use GDB_FILE to collect
+ output into buffers.
+
+ * tuiIO.c
+ (tgoto): Add external K&R declaration for this here too.
+ (tuiGetc, tuiTermSetup, tuiTermUnsetup): Same.
+ (tuiPuts_unfiltered): change FILE to GDB_FILE.
+ (tui_tputs): fix prototype for 3rd argument.
+
+ * tuiIO.h (tuiPuts_unfiltered): change declaration.
+
+ * tuiLayout.c
+ (_tuiSetLayoutTo): for displaying registers, hook up the HP code
+ that decides which registers to display (i.e. single precision
+ float, double precision float, general, special). Previously,
+ only handled TUI_GENERAL_REGS. Now that the code is hooked up,
+ compiling with -z poses a problem. When the first layout command
+ is 'layout regs', dataWin->detail is a NULL pointer, and gdb
+ core dumps.
+
+ * tuiLayout.c (_tuiSetLayoutTo): replace safe_free with free.
+
+ * tuiRegs.c #include "defs.h" earlier, to avoid problems in
+ . No idea exactly what's conflicting with what, but the
+ errors went away...
+ (_tuiRegisterFormat): Change so that function creates a GDB_FILE
+ object, calls pa_do_strcat_registers_info, copies the register
+ info into a buffer, and deallocates the GDB_FILE object. Remove
+ some code that is not executed. Also, call to
+ pa_do_strcat_registers_info has an additional parameter,
+ precision. This code requires some new per-target functions that
+ we don't want to merge. Dyke it out, with #ifdef
+ TUI_EXTENDED_FORMATTERS.
+ (_tuiSetSpecialRegsContent): this function was ifdefed out.
+ Hooked this up.
+ (_tuiSetGeneralAndSpecialRegsContent): this function was ifdefed
+ out. Hooked it up.
+ (IS_64BIT): Just define this to be zero; we're not merging in the
+ 64-bit support.
+ (tuiShowRegisters): Comment out all references to the "special"
+ regs; we don't have a distinction between the "special" and
+ "non-special" regs in most of our machine descriptions. This code
+ is PA-specific in other ways as well, and needs to be redesigned
+ to be portable to other processors.
+
+ * tuiWin.c: #include , to get a declaration for
+ strchr.
+
+ * tui.c, tuiCommand.c, tuiData.c, tuiDataWin.c, tuiDisassem.c,
+ tuiGeneralWin.c, tuiIO.c, tuiLayout.c, tuiRegs.c, tuiSource.c,
+ tuiSourceWin.c, tuiStack.c, tuiWin.c: New files (from HP). Changed
+ bool to int throughout. Re-indented, GNU style.
+
+ * tui.h, tuiCommand.h, tuiData.h, tuiDataWin.h, tuiDisassem.h,
+ tuiGeneralWin.h, tuiIO.h, tuiLayout.h, tuiRegs.h, tuiSource.h,
+ tuiSourceWin.h, tuiStack.h, tuiWin.h: new files (from HP).
+ Changed bool to int throughout.
Index: tui-source.h
===================================================================
--- tui-source.h (nonexistent)
+++ tui-source.h (revision 157)
@@ -0,0 +1,43 @@
+/* TUI display source window.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_SOURCE_H
+#define TUI_SOURCE_H
+
+#include "tui/tui-data.h"
+
+struct symtab;
+struct tui_win_info;
+
+extern void tui_set_source_content_nil (struct tui_win_info *,
+ char *);
+
+extern enum tui_status tui_set_source_content (struct symtab *,
+ int, int);
+extern void tui_show_symtab_source (struct symtab *,
+ struct tui_line_or_address,
+ int);
+extern int tui_source_is_displayed (char *);
+extern void tui_vertical_source_scroll (enum tui_scroll_direction,
+ int);
+
+#endif
tui-source.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-io.c
===================================================================
--- tui-io.c (nonexistent)
+++ tui-io.c (revision 157)
@@ -0,0 +1,719 @@
+/* TUI support I/O functions.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "target.h"
+#include "event-loop.h"
+#include "event-top.h"
+#include "command.h"
+#include "top.h"
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-io.h"
+#include "tui/tui-command.h"
+#include "tui/tui-win.h"
+#include "tui/tui-wingeneral.h"
+#include "tui/tui-file.h"
+#include "ui-out.h"
+#include "cli-out.h"
+#include
+#include
+#include
+
+#include "gdb_curses.h"
+
+/* This redefines CTRL if it is not already defined, so it must come
+ after terminal state releated include files like and
+ "gdb_curses.h". */
+#include "readline/readline.h"
+
+int
+key_is_start_sequence (int ch)
+{
+ return (ch == 27);
+}
+
+int
+key_is_end_sequence (int ch)
+{
+ return (ch == 126);
+}
+
+int
+key_is_backspace (int ch)
+{
+ return (ch == 8);
+}
+
+int
+key_is_command_char (int ch)
+{
+ return ((ch == KEY_NPAGE) || (ch == KEY_PPAGE)
+ || (ch == KEY_LEFT) || (ch == KEY_RIGHT)
+ || (ch == KEY_UP) || (ch == KEY_DOWN)
+ || (ch == KEY_SF) || (ch == KEY_SR)
+ || (ch == (int)'\f')
+ || key_is_start_sequence (ch));
+}
+
+/* Use definition from readline 4.3. */
+#undef CTRL_CHAR
+#define CTRL_CHAR(c) \
+ ((c) < control_character_threshold && (((c) & 0x80) == 0))
+
+/* This file controls the IO interactions between gdb and curses.
+ When the TUI is enabled, gdb has two modes a curses and a standard
+ mode.
+
+ In curses mode, the gdb outputs are made in a curses command
+ window. For this, the gdb_stdout and gdb_stderr are redirected to
+ the specific ui_file implemented by TUI. The output is handled by
+ tui_puts(). The input is also controlled by curses with
+ tui_getc(). The readline library uses this function to get its
+ input. Several readline hooks are installed to redirect readline
+ output to the TUI (see also the note below).
+
+ In normal mode, the gdb outputs are restored to their origin, that
+ is as if TUI is not used. Readline also uses its original getc()
+ function with stdin.
+
+ Note SCz/2001-07-21: the current readline is not clean in its
+ management of the output. Even if we install a redisplay handler,
+ it sometimes writes on a stdout file. It is important to redirect
+ every output produced by readline, otherwise the curses window will
+ be garbled. This is implemented with a pipe that TUI reads and
+ readline writes to. A gdb input handler is created so that reading
+ the pipe is handled automatically. This will probably not work on
+ non-Unix platforms. The best fix is to make readline clean enougth
+ so that is never write on stdout.
+
+ Note SCz/2002-09-01: we now use more readline hooks and it seems
+ that with them we don't need the pipe anymore (verified by creating
+ the pipe and closing its end so that write causes a SIGPIPE). The
+ old pipe code is still there and can be conditionally removed by
+ #undef TUI_USE_PIPE_FOR_READLINE. */
+
+/* For gdb 5.3, prefer to continue the pipe hack as a backup wheel. */
+#define TUI_USE_PIPE_FOR_READLINE
+/* #undef TUI_USE_PIPE_FOR_READLINE */
+
+/* TUI output files. */
+static struct ui_file *tui_stdout;
+static struct ui_file *tui_stderr;
+struct ui_out *tui_out;
+
+/* GDB output files in non-curses mode. */
+static struct ui_file *tui_old_stdout;
+static struct ui_file *tui_old_stderr;
+struct ui_out *tui_old_uiout;
+
+/* Readline previous hooks. */
+static Function *tui_old_rl_getc_function;
+static VFunction *tui_old_rl_redisplay_function;
+static VFunction *tui_old_rl_prep_terminal;
+static VFunction *tui_old_rl_deprep_terminal;
+static int tui_old_readline_echoing_p;
+
+/* Readline output stream.
+ Should be removed when readline is clean. */
+static FILE *tui_rl_outstream;
+static FILE *tui_old_rl_outstream;
+#ifdef TUI_USE_PIPE_FOR_READLINE
+static int tui_readline_pipe[2];
+#endif
+
+/* The last gdb prompt that was registered in readline.
+ This may be the main gdb prompt or a secondary prompt. */
+static char *tui_rl_saved_prompt;
+
+static unsigned int tui_handle_resize_during_io (unsigned int);
+
+static void
+tui_putc (char c)
+{
+ char buf[2];
+
+ buf[0] = c;
+ buf[1] = 0;
+ tui_puts (buf);
+}
+
+/* Print the string in the curses command window. */
+void
+tui_puts (const char *string)
+{
+ static int tui_skip_line = -1;
+ char c;
+ WINDOW *w;
+
+ w = TUI_CMD_WIN->generic.handle;
+ while ((c = *string++) != 0)
+ {
+ /* Catch annotation and discard them. We need two \032 and
+ discard until a \n is seen. */
+ if (c == '\032')
+ {
+ tui_skip_line++;
+ }
+ else if (tui_skip_line != 1)
+ {
+ tui_skip_line = -1;
+ waddch (w, c);
+ }
+ else if (c == '\n')
+ tui_skip_line = -1;
+ }
+ getyx (w, TUI_CMD_WIN->detail.command_info.cur_line,
+ TUI_CMD_WIN->detail.command_info.curch);
+ TUI_CMD_WIN->detail.command_info.start_line = TUI_CMD_WIN->detail.command_info.cur_line;
+
+ /* We could defer the following. */
+ wrefresh (w);
+ fflush (stdout);
+}
+
+/* Readline callback.
+ Redisplay the command line with its prompt after readline has
+ changed the edited text. */
+void
+tui_redisplay_readline (void)
+{
+ int prev_col;
+ int height;
+ int col, line;
+ int c_pos;
+ int c_line;
+ int in;
+ WINDOW *w;
+ char *prompt;
+ int start_line;
+
+ /* Detect when we temporarily left SingleKey and now the readline
+ edit buffer is empty, automatically restore the SingleKey
+ mode. */
+ if (tui_current_key_mode == TUI_ONE_COMMAND_MODE && rl_end == 0)
+ tui_set_key_mode (TUI_SINGLE_KEY_MODE);
+
+ if (tui_current_key_mode == TUI_SINGLE_KEY_MODE)
+ prompt = "";
+ else
+ prompt = tui_rl_saved_prompt;
+
+ c_pos = -1;
+ c_line = -1;
+ w = TUI_CMD_WIN->generic.handle;
+ start_line = TUI_CMD_WIN->detail.command_info.start_line;
+ wmove (w, start_line, 0);
+ prev_col = 0;
+ height = 1;
+ for (in = 0; prompt && prompt[in]; in++)
+ {
+ waddch (w, prompt[in]);
+ getyx (w, line, col);
+ if (col < prev_col)
+ height++;
+ prev_col = col;
+ }
+ for (in = 0; in < rl_end; in++)
+ {
+ unsigned char c;
+
+ c = (unsigned char) rl_line_buffer[in];
+ if (in == rl_point)
+ {
+ getyx (w, c_line, c_pos);
+ }
+
+ if (CTRL_CHAR (c) || c == RUBOUT)
+ {
+ waddch (w, '^');
+ waddch (w, CTRL_CHAR (c) ? UNCTRL (c) : '?');
+ }
+ else
+ {
+ waddch (w, c);
+ }
+ if (c == '\n')
+ {
+ getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
+ TUI_CMD_WIN->detail.command_info.curch);
+ }
+ getyx (w, line, col);
+ if (col < prev_col)
+ height++;
+ prev_col = col;
+ }
+ wclrtobot (w);
+ getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
+ TUI_CMD_WIN->detail.command_info.curch);
+ if (c_line >= 0)
+ {
+ wmove (w, c_line, c_pos);
+ TUI_CMD_WIN->detail.command_info.cur_line = c_line;
+ TUI_CMD_WIN->detail.command_info.curch = c_pos;
+ }
+ TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
+
+ wrefresh (w);
+ fflush(stdout);
+}
+
+/* Readline callback to prepare the terminal. It is called once each
+ time we enter readline. Terminal is already setup in curses
+ mode. */
+static void
+tui_prep_terminal (int notused1)
+{
+ /* Save the prompt registered in readline to correctly display it.
+ (we can't use gdb_prompt() due to secondary prompts and can't use
+ rl_prompt because it points to an alloca buffer). */
+ xfree (tui_rl_saved_prompt);
+ tui_rl_saved_prompt = xstrdup (rl_prompt);
+}
+
+/* Readline callback to restore the terminal. It is called once each
+ time we leave readline. There is nothing to do in curses mode. */
+static void
+tui_deprep_terminal (void)
+{
+}
+
+#ifdef TUI_USE_PIPE_FOR_READLINE
+/* Read readline output pipe and feed the command window with it.
+ Should be removed when readline is clean. */
+static void
+tui_readline_output (int code, gdb_client_data data)
+{
+ int size;
+ char buf[256];
+
+ size = read (tui_readline_pipe[0], buf, sizeof (buf) - 1);
+ if (size > 0 && tui_active)
+ {
+ buf[size] = 0;
+ tui_puts (buf);
+ }
+}
+#endif
+
+/* Return the portion of PATHNAME that should be output when listing
+ possible completions. If we are hacking filename completion, we
+ are only interested in the basename, the portion following the
+ final slash. Otherwise, we return what we were passed.
+
+ Comes from readline/complete.c. */
+static char *
+printable_part (char *pathname)
+{
+ char *temp;
+
+ temp = rl_filename_completion_desired ? strrchr (pathname, '/') : (char *)NULL;
+#if defined (__MSDOS__)
+ if (rl_filename_completion_desired
+ && temp == 0 && isalpha (pathname[0])
+ && pathname[1] == ':')
+ temp = pathname + 1;
+#endif
+ return (temp ? ++temp : pathname);
+}
+
+/* Output TO_PRINT to rl_outstream. If VISIBLE_STATS is defined and
+ we are using it, check for and output a single character for
+ `special' filenames. Return the number of characters we
+ output. */
+
+#define PUTX(c) \
+ do { \
+ if (CTRL_CHAR (c)) \
+ { \
+ tui_puts ("^"); \
+ tui_putc (UNCTRL (c)); \
+ printed_len += 2; \
+ } \
+ else if (c == RUBOUT) \
+ { \
+ tui_puts ("^?"); \
+ printed_len += 2; \
+ } \
+ else \
+ { \
+ tui_putc (c); \
+ printed_len++; \
+ } \
+ } while (0)
+
+static int
+print_filename (char *to_print, char *full_pathname)
+{
+ int printed_len = 0;
+ char *s;
+
+ for (s = to_print; *s; s++)
+ {
+ PUTX (*s);
+ }
+ return printed_len;
+}
+
+/* The user must press "y" or "n". Non-zero return means "y" pressed.
+ Comes from readline/complete.c. */
+static int
+get_y_or_n (void)
+{
+ extern int _rl_abort_internal ();
+ int c;
+
+ for (;;)
+ {
+ c = rl_read_key ();
+ if (c == 'y' || c == 'Y' || c == ' ')
+ return (1);
+ if (c == 'n' || c == 'N' || c == RUBOUT)
+ return (0);
+ if (c == ABORT_CHAR)
+ _rl_abort_internal ();
+ beep ();
+ }
+}
+
+/* A convenience function for displaying a list of strings in
+ columnar format on readline's output stream. MATCHES is the list
+ of strings, in argv format, LEN is the number of strings in MATCHES,
+ and MAX is the length of the longest string in MATCHES.
+
+ Comes from readline/complete.c and modified to write in
+ the TUI command window using tui_putc/tui_puts. */
+static void
+tui_rl_display_match_list (char **matches, int len, int max)
+{
+ typedef int QSFUNC (const void *, const void *);
+ extern int _rl_qsort_string_compare (const void *,
+ const void *);
+ extern int _rl_print_completions_horizontally;
+
+ int count, limit, printed_len;
+ int i, j, k, l;
+ char *temp;
+
+ /* Screen dimension correspond to the TUI command window. */
+ int screenwidth = TUI_CMD_WIN->generic.width;
+
+ /* If there are many items, then ask the user if she really wants to
+ see them all. */
+ if (len >= rl_completion_query_items)
+ {
+ char msg[256];
+
+ sprintf (msg, "\nDisplay all %d possibilities? (y or n)", len);
+ tui_puts (msg);
+ if (get_y_or_n () == 0)
+ {
+ tui_puts ("\n");
+ return;
+ }
+ }
+
+ /* How many items of MAX length can we fit in the screen window? */
+ max += 2;
+ limit = screenwidth / max;
+ if (limit != 1 && (limit * max == screenwidth))
+ limit--;
+
+ /* Avoid a possible floating exception. If max > screenwidth, limit
+ will be 0 and a divide-by-zero fault will result. */
+ if (limit == 0)
+ limit = 1;
+
+ /* How many iterations of the printing loop? */
+ count = (len + (limit - 1)) / limit;
+
+ /* Watch out for special case. If LEN is less than LIMIT, then
+ just do the inner printing loop.
+ 0 < len <= limit implies count = 1. */
+
+ /* Sort the items if they are not already sorted. */
+ if (rl_ignore_completion_duplicates == 0)
+ qsort (matches + 1, len, sizeof (char *),
+ (QSFUNC *)_rl_qsort_string_compare);
+
+ tui_putc ('\n');
+
+ if (_rl_print_completions_horizontally == 0)
+ {
+ /* Print the sorted items, up-and-down alphabetically, like ls. */
+ for (i = 1; i <= count; i++)
+ {
+ for (j = 0, l = i; j < limit; j++)
+ {
+ if (l > len || matches[l] == 0)
+ break;
+ else
+ {
+ temp = printable_part (matches[l]);
+ printed_len = print_filename (temp, matches[l]);
+
+ if (j + 1 < limit)
+ for (k = 0; k < max - printed_len; k++)
+ tui_putc (' ');
+ }
+ l += count;
+ }
+ tui_putc ('\n');
+ }
+ }
+ else
+ {
+ /* Print the sorted items, across alphabetically, like ls -x. */
+ for (i = 1; matches[i]; i++)
+ {
+ temp = printable_part (matches[i]);
+ printed_len = print_filename (temp, matches[i]);
+ /* Have we reached the end of this line? */
+ if (matches[i+1])
+ {
+ if (i && (limit > 1) && (i % limit) == 0)
+ tui_putc ('\n');
+ else
+ for (k = 0; k < max - printed_len; k++)
+ tui_putc (' ');
+ }
+ }
+ tui_putc ('\n');
+ }
+}
+
+/* Setup the IO for curses or non-curses mode.
+ - In non-curses mode, readline and gdb use the standard input and
+ standard output/error directly.
+ - In curses mode, the standard output/error is controlled by TUI
+ with the tui_stdout and tui_stderr. The output is redirected in
+ the curses command window. Several readline callbacks are installed
+ so that readline asks for its input to the curses command window
+ with wgetch(). */
+void
+tui_setup_io (int mode)
+{
+ extern int readline_echoing_p;
+
+ if (mode)
+ {
+ /* Redirect readline to TUI. */
+ tui_old_rl_redisplay_function = rl_redisplay_function;
+ tui_old_rl_deprep_terminal = rl_deprep_term_function;
+ tui_old_rl_prep_terminal = rl_prep_term_function;
+ tui_old_rl_getc_function = rl_getc_function;
+ tui_old_rl_outstream = rl_outstream;
+ tui_old_readline_echoing_p = readline_echoing_p;
+ rl_redisplay_function = tui_redisplay_readline;
+ rl_deprep_term_function = tui_deprep_terminal;
+ rl_prep_term_function = tui_prep_terminal;
+ rl_getc_function = tui_getc;
+ readline_echoing_p = 0;
+ rl_outstream = tui_rl_outstream;
+ rl_prompt = 0;
+ rl_completion_display_matches_hook = tui_rl_display_match_list;
+ rl_already_prompted = 0;
+
+ /* Keep track of previous gdb output. */
+ tui_old_stdout = gdb_stdout;
+ tui_old_stderr = gdb_stderr;
+ tui_old_uiout = uiout;
+
+ /* Reconfigure gdb output. */
+ gdb_stdout = tui_stdout;
+ gdb_stderr = tui_stderr;
+ gdb_stdlog = gdb_stdout; /* for moment */
+ gdb_stdtarg = gdb_stderr; /* for moment */
+ uiout = tui_out;
+
+ /* Save tty for SIGCONT. */
+ savetty ();
+ }
+ else
+ {
+ /* Restore gdb output. */
+ gdb_stdout = tui_old_stdout;
+ gdb_stderr = tui_old_stderr;
+ gdb_stdlog = gdb_stdout; /* for moment */
+ gdb_stdtarg = gdb_stderr; /* for moment */
+ uiout = tui_old_uiout;
+
+ /* Restore readline. */
+ rl_redisplay_function = tui_old_rl_redisplay_function;
+ rl_deprep_term_function = tui_old_rl_deprep_terminal;
+ rl_prep_term_function = tui_old_rl_prep_terminal;
+ rl_getc_function = tui_old_rl_getc_function;
+ rl_outstream = tui_old_rl_outstream;
+ rl_completion_display_matches_hook = 0;
+ readline_echoing_p = tui_old_readline_echoing_p;
+ rl_already_prompted = 0;
+
+ /* Save tty for SIGCONT. */
+ savetty ();
+ }
+}
+
+#ifdef SIGCONT
+/* Catch SIGCONT to restore the terminal and refresh the screen. */
+static void
+tui_cont_sig (int sig)
+{
+ if (tui_active)
+ {
+ /* Restore the terminal setting because another process (shell)
+ might have changed it. */
+ resetty ();
+
+ /* Force a refresh of the screen. */
+ tui_refresh_all_win ();
+
+ /* Update cursor position on the screen. */
+ wmove (TUI_CMD_WIN->generic.handle,
+ TUI_CMD_WIN->detail.command_info.start_line,
+ TUI_CMD_WIN->detail.command_info.curch);
+ wrefresh (TUI_CMD_WIN->generic.handle);
+ }
+ signal (sig, tui_cont_sig);
+}
+#endif
+
+/* Initialize the IO for gdb in curses mode. */
+void
+tui_initialize_io (void)
+{
+#ifdef SIGCONT
+ signal (SIGCONT, tui_cont_sig);
+#endif
+
+ /* Create tui output streams. */
+ tui_stdout = tui_fileopen (stdout);
+ tui_stderr = tui_fileopen (stderr);
+ tui_out = tui_out_new (tui_stdout);
+
+ /* Create the default UI. It is not created because we installed a
+ deprecated_init_ui_hook. */
+ tui_old_uiout = uiout = cli_out_new (gdb_stdout);
+
+#ifdef TUI_USE_PIPE_FOR_READLINE
+ /* Temporary solution for readline writing to stdout: redirect
+ readline output in a pipe, read that pipe and output the content
+ in the curses command window. */
+ if (pipe (tui_readline_pipe) != 0)
+ {
+ fprintf_unfiltered (gdb_stderr, "Cannot create pipe for readline");
+ exit (1);
+ }
+ tui_rl_outstream = fdopen (tui_readline_pipe[1], "w");
+ if (tui_rl_outstream == 0)
+ {
+ fprintf_unfiltered (gdb_stderr, "Cannot redirect readline output");
+ exit (1);
+ }
+ setvbuf (tui_rl_outstream, (char*) NULL, _IOLBF, 0);
+
+#ifdef O_NONBLOCK
+ (void) fcntl (tui_readline_pipe[0], F_SETFL, O_NONBLOCK);
+#else
+#ifdef O_NDELAY
+ (void) fcntl (tui_readline_pipe[0], F_SETFL, O_NDELAY);
+#endif
+#endif
+ add_file_handler (tui_readline_pipe[0], tui_readline_output, 0);
+#else
+ tui_rl_outstream = stdout;
+#endif
+}
+
+/* Get a character from the command window. This is called from the
+ readline package. */
+int
+tui_getc (FILE *fp)
+{
+ int ch;
+ WINDOW *w;
+
+ w = TUI_CMD_WIN->generic.handle;
+
+#ifdef TUI_USE_PIPE_FOR_READLINE
+ /* Flush readline output. */
+ tui_readline_output (GDB_READABLE, 0);
+#endif
+
+ ch = wgetch (w);
+ ch = tui_handle_resize_during_io (ch);
+
+ /* The \n must be echoed because it will not be printed by
+ readline. */
+ if (ch == '\n')
+ {
+ /* When hitting return with an empty input, gdb executes the last
+ command. If we emit a newline, this fills up the command window
+ with empty lines with gdb prompt at beginning. Instead of that,
+ stay on the same line but provide a visual effect to show the
+ user we recognized the command. */
+ if (rl_end == 0)
+ {
+ wmove (w, TUI_CMD_WIN->detail.command_info.cur_line, 0);
+
+ /* Clear the line. This will blink the gdb prompt since
+ it will be redrawn at the same line. */
+ wclrtoeol (w);
+ wrefresh (w);
+ napms (20);
+ }
+ else
+ {
+ wmove (w, TUI_CMD_WIN->detail.command_info.cur_line,
+ TUI_CMD_WIN->detail.command_info.curch);
+ waddch (w, ch);
+ }
+ }
+
+ if (key_is_command_char (ch))
+ { /* Handle prev/next/up/down here. */
+ ch = tui_dispatch_ctrl_char (ch);
+ }
+
+ if (ch == '\n' || ch == '\r' || ch == '\f')
+ TUI_CMD_WIN->detail.command_info.curch = 0;
+ if (ch == KEY_BACKSPACE)
+ return '\b';
+
+ return ch;
+}
+
+
+/* Cleanup when a resize has occured.
+ Returns the character that must be processed. */
+static unsigned int
+tui_handle_resize_during_io (unsigned int original_ch)
+{
+ if (tui_win_resized ())
+ {
+ tui_refresh_all_win ();
+ dont_repeat ();
+ tui_set_win_resized_to (FALSE);
+ return '\n';
+ }
+ else
+ return original_ch;
+}
tui-io.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-io.h
===================================================================
--- tui-io.h (nonexistent)
+++ tui-io.h (revision 157)
@@ -0,0 +1,53 @@
+/* TUI support I/O functions.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_IO_H
+#define TUI_IO_H
+
+struct ui_out;
+
+/* Print the string in the curses command window. */
+extern void tui_puts (const char *);
+
+/* Setup the IO for curses or non-curses mode. */
+extern void tui_setup_io (int mode);
+
+/* Initialize the IO for gdb in curses mode. */
+extern void tui_initialize_io (void);
+
+/* Get a character from the command window. */
+extern int tui_getc (FILE *);
+
+/* Readline callback.
+ Redisplay the command line with its prompt after readline has
+ changed the edited text. */
+extern void tui_redisplay_readline (void);
+
+extern struct ui_out *tui_out;
+extern struct ui_out *tui_old_uiout;
+
+extern int key_is_start_sequence (int ch);
+extern int key_is_end_sequence (int ch);
+extern int key_is_backspace (int ch);
+extern int key_is_command_char (int ch);
+
+#endif
tui-io.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-command.c
===================================================================
--- tui-command.c (nonexistent)
+++ tui-command.c (revision 157)
@@ -0,0 +1,134 @@
+/* Specific command window processing.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-win.h"
+#include "tui/tui-io.h"
+
+#include "gdb_curses.h"
+#include "gdb_string.h"
+
+
+/*****************************************
+** STATIC LOCAL FUNCTIONS FORWARD DECLS **
+******************************************/
+
+
+
+/*****************************************
+** PUBLIC FUNCTIONS **
+******************************************/
+
+/* 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;
+ }
+}
tui-command.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-winsource.c
===================================================================
--- tui-winsource.c (nonexistent)
+++ tui-winsource.c (revision 157)
@@ -0,0 +1,681 @@
+/* TUI display source/assembly window.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include
+#include "symtab.h"
+#include "frame.h"
+#include "breakpoint.h"
+#include "value.h"
+#include "source.h"
+
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-win.h"
+#include "tui/tui-wingeneral.h"
+#include "tui/tui-winsource.h"
+#include "tui/tui-source.h"
+#include "tui/tui-disasm.h"
+
+#include "gdb_string.h"
+#include "gdb_curses.h"
+#include "gdb_assert.h"
+
+/* Function to display the "main" routine. */
+void
+tui_display_main (void)
+{
+ if ((tui_source_windows ())->count > 0)
+ {
+ CORE_ADDR addr;
+
+ addr = tui_get_begin_asm_address ();
+ if (addr != (CORE_ADDR) 0)
+ {
+ struct symtab_and_line sal;
+
+ tui_update_source_windows_with_addr (addr);
+ sal = find_pc_line (addr, 0);
+ if (sal.symtab)
+ tui_update_locator_filename (sal.symtab->filename);
+ else
+ tui_update_locator_filename ("??");
+ }
+ }
+}
+
+
+
+/* Function to display source in the source window. This function
+ initializes the horizontal scroll to 0. */
+void
+tui_update_source_window (struct tui_win_info *win_info,
+ struct symtab *s,
+ struct tui_line_or_address line_or_addr,
+ int noerror)
+{
+ win_info->detail.source_info.horizontal_offset = 0;
+ tui_update_source_window_as_is (win_info, s, line_or_addr, noerror);
+
+ return;
+}
+
+
+/* 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 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 (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;
+
+ sal.line = line_or_addr.u.line_no +
+ (win_info->generic.content_size - 2);
+ sal.symtab = 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;
+}
+
+
+/* Function to ensure that the source and/or disassemly windows
+ reflect the input address. */
+void
+tui_update_source_windows_with_addr (CORE_ADDR addr)
+{
+ if (addr != 0)
+ {
+ struct symtab_and_line sal;
+ struct tui_line_or_address l;
+
+ switch (tui_current_layout ())
+ {
+ case DISASSEM_COMMAND:
+ case DISASSEM_DATA_COMMAND:
+ tui_show_disassem (addr);
+ break;
+ case SRC_DISASSEM_COMMAND:
+ tui_show_disassem_and_update_source (addr);
+ break;
+ default:
+ sal = find_pc_line (addr, 0);
+ l.loa = LOA_LINE;
+ l.u.line_no = sal.line;
+ tui_show_symtab_source (sal.symtab, l, FALSE);
+ break;
+ }
+ }
+ else
+ {
+ int i;
+
+ for (i = 0; i < (tui_source_windows ())->count; i++)
+ {
+ struct tui_win_info *win_info = (tui_source_windows ())->list[i];
+
+ tui_clear_source_content (win_info, EMPTY_SOURCE_PROMPT);
+ tui_clear_exec_info_content (win_info);
+ }
+ }
+}
+
+/* Function to ensure that the source and/or disassemly windows
+ reflect the input address. */
+void
+tui_update_source_windows_with_line (struct symtab *s, int line)
+{
+ CORE_ADDR pc;
+ struct tui_line_or_address l;
+
+ switch (tui_current_layout ())
+ {
+ case DISASSEM_COMMAND:
+ case DISASSEM_DATA_COMMAND:
+ find_line_pc (s, line, &pc);
+ tui_update_source_windows_with_addr (pc);
+ break;
+ default:
+ l.loa = LOA_LINE;
+ l.u.line_no = line;
+ tui_show_symtab_source (s, l, FALSE);
+ if (tui_current_layout () == SRC_DISASSEM_COMMAND)
+ {
+ find_line_pc (s, line, &pc);
+ tui_show_disassem (pc);
+ }
+ break;
+ }
+
+ return;
+}
+
+void
+tui_clear_source_content (struct tui_win_info *win_info,
+ int display_prompt)
+{
+ if (win_info != NULL)
+ {
+ int i;
+
+ win_info->generic.content_in_use = FALSE;
+ tui_erase_source_content (win_info, display_prompt);
+ for (i = 0; i < win_info->generic.content_size; i++)
+ {
+ struct tui_win_element *element =
+ (struct tui_win_element *) win_info->generic.content[i];
+ element->which_element.source.has_break = FALSE;
+ element->which_element.source.is_exec_point = FALSE;
+ }
+ }
+}
+
+
+void
+tui_erase_source_content (struct tui_win_info *win_info,
+ int display_prompt)
+{
+ int x_pos;
+ int half_width = (win_info->generic.width - 2) / 2;
+
+ if (win_info->generic.handle != (WINDOW *) NULL)
+ {
+ werase (win_info->generic.handle);
+ tui_check_and_display_highlight_if_needed (win_info);
+ if (display_prompt == EMPTY_SOURCE_PROMPT)
+ {
+ char *no_src_str;
+
+ if (win_info->generic.type == SRC_WIN)
+ no_src_str = NO_SRC_STRING;
+ else
+ no_src_str = NO_DISASSEM_STRING;
+ if (strlen (no_src_str) >= half_width)
+ x_pos = 1;
+ else
+ x_pos = half_width - strlen (no_src_str);
+ mvwaddstr (win_info->generic.handle,
+ (win_info->generic.height / 2),
+ x_pos,
+ no_src_str);
+
+ /* elz: Added this function call to set the real contents of
+ the window to what is on the screen, so that later calls
+ to refresh, do display the correct stuff, and not the old
+ image. */
+
+ tui_set_source_content_nil (win_info, no_src_str);
+ }
+ tui_refresh_win (&win_info->generic);
+ }
+}
+
+
+/* Redraw the complete line of a source or disassembly window. */
+static void
+tui_show_source_line (struct tui_win_info *win_info, int lineno)
+{
+ struct tui_win_element *line;
+ int x, y;
+
+ line = (struct tui_win_element *) win_info->generic.content[lineno - 1];
+ if (line->which_element.source.is_exec_point)
+ wattron (win_info->generic.handle, A_STANDOUT);
+
+ mvwaddstr (win_info->generic.handle, lineno, 1,
+ line->which_element.source.line);
+ if (line->which_element.source.is_exec_point)
+ wattroff (win_info->generic.handle, A_STANDOUT);
+
+ /* Clear to end of line but stop before the border. */
+ getyx (win_info->generic.handle, y, x);
+ while (x + 1 < win_info->generic.width)
+ {
+ waddch (win_info->generic.handle, ' ');
+ getyx (win_info->generic.handle, y, x);
+ }
+}
+
+void
+tui_show_source_content (struct tui_win_info *win_info)
+{
+ if (win_info->generic.content_size > 0)
+ {
+ int lineno;
+
+ for (lineno = 1; lineno <= win_info->generic.content_size; lineno++)
+ tui_show_source_line (win_info, lineno);
+ }
+ else
+ tui_erase_source_content (win_info, TRUE);
+
+ tui_check_and_display_highlight_if_needed (win_info);
+ tui_refresh_win (&win_info->generic);
+ win_info->generic.content_in_use = TRUE;
+}
+
+
+/* Scroll the source forward or backward horizontally. */
+void
+tui_horizontal_source_scroll (struct tui_win_info *win_info,
+ enum tui_scroll_direction direction,
+ int num_to_scroll)
+{
+ if (win_info->generic.content != NULL)
+ {
+ int offset;
+ struct symtab *s;
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
+ if (cursal.symtab == (struct symtab *) NULL)
+ s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
+ else
+ s = cursal.symtab;
+
+ if (direction == LEFT_SCROLL)
+ offset = win_info->detail.source_info.horizontal_offset + num_to_scroll;
+ else
+ {
+ if ((offset =
+ win_info->detail.source_info.horizontal_offset - num_to_scroll) < 0)
+ offset = 0;
+ }
+ win_info->detail.source_info.horizontal_offset = offset;
+ tui_update_source_window_as_is (win_info, s,
+ ((struct tui_win_element *)
+ win_info->generic.content[0])->which_element.source.line_or_addr,
+ FALSE);
+ }
+
+ return;
+}
+
+
+/* Set or clear the has_break flag in the line whose line is
+ line_no. */
+
+void
+tui_set_is_exec_point_at (struct tui_line_or_address l,
+ struct tui_win_info *win_info)
+{
+ int changed = 0;
+ int i;
+ tui_win_content content = (tui_win_content) win_info->generic.content;
+
+ i = 0;
+ while (i < win_info->generic.content_size)
+ {
+ int new_state;
+ struct tui_line_or_address content_loa =
+ content[i]->which_element.source.line_or_addr;
+
+ gdb_assert (l.loa == LOA_ADDRESS || l.loa == LOA_LINE);
+ gdb_assert (content_loa.loa == LOA_LINE
+ || content_loa.loa == LOA_ADDRESS);
+ if (content_loa.loa == l.loa
+ && ((l.loa == LOA_LINE && content_loa.u.line_no == l.u.line_no)
+ || (content_loa.u.addr == l.u.addr)))
+ new_state = TRUE;
+ else
+ new_state = FALSE;
+ if (new_state != content[i]->which_element.source.is_exec_point)
+ {
+ changed++;
+ content[i]->which_element.source.is_exec_point = new_state;
+ tui_show_source_line (win_info, i + 1);
+ }
+ i++;
+ }
+ if (changed)
+ tui_refresh_win (&win_info->generic);
+}
+
+/* Update the execution windows to show the active breakpoints.
+ This is called whenever a breakpoint is inserted, removed or
+ has its state changed. */
+void
+tui_update_all_breakpoint_info (void)
+{
+ struct tui_list *list = tui_source_windows ();
+ int i;
+
+ for (i = 0; i < list->count; i++)
+ {
+ struct tui_win_info *win = list->list[i];
+
+ if (tui_update_breakpoint_info (win, FALSE))
+ {
+ tui_update_exec_info (win);
+ }
+ }
+}
+
+
+/* Scan the source window and the breakpoints to update the has_break
+ information for each line.
+
+ Returns 1 if something changed and the execution window must be
+ refreshed. */
+
+int
+tui_update_breakpoint_info (struct tui_win_info *win,
+ int current_only)
+{
+ int i;
+ int need_refresh = 0;
+ struct tui_source_info *src = &win->detail.source_info;
+
+ for (i = 0; i < win->generic.content_size; i++)
+ {
+ struct breakpoint *bp;
+ extern struct breakpoint *breakpoint_chain;
+ int mode;
+ struct tui_source_element *line;
+
+ line = &((struct tui_win_element *) win->generic.content[i])->which_element.source;
+ if (current_only && !line->is_exec_point)
+ continue;
+
+ /* Scan each breakpoint to see if the current line has something to
+ do with it. Identify enable/disabled breakpoints as well as
+ those that we already hit. */
+ mode = 0;
+ for (bp = breakpoint_chain;
+ bp != (struct breakpoint *) NULL;
+ bp = bp->next)
+ {
+ gdb_assert (line->line_or_addr.loa == LOA_LINE
+ || line->line_or_addr.loa == LOA_ADDRESS);
+ if ((win == TUI_SRC_WIN
+ && bp->source_file
+ && (strcmp (src->filename, bp->source_file) == 0)
+ && line->line_or_addr.loa == LOA_LINE
+ && bp->line_number == line->line_or_addr.u.line_no)
+ || (win == TUI_DISASM_WIN
+ && line->line_or_addr.loa == LOA_ADDRESS
+ && bp->loc->address == line->line_or_addr.u.addr))
+ {
+ if (bp->enable_state == bp_disabled)
+ mode |= TUI_BP_DISABLED;
+ else
+ mode |= TUI_BP_ENABLED;
+ if (bp->hit_count)
+ mode |= TUI_BP_HIT;
+ if (bp->loc->cond)
+ mode |= TUI_BP_CONDITIONAL;
+ if (bp->type == bp_hardware_breakpoint)
+ mode |= TUI_BP_HARDWARE;
+ }
+ }
+ if (line->has_break != mode)
+ {
+ line->has_break = mode;
+ need_refresh = 1;
+ }
+ }
+ return need_refresh;
+}
+
+
+/* Function to initialize the content of the execution info window,
+ based upon the input window which is either the source or
+ disassembly window. */
+enum tui_status
+tui_set_exec_info_content (struct tui_win_info *win_info)
+{
+ enum tui_status ret = TUI_SUCCESS;
+
+ if (win_info->detail.source_info.execution_info != (struct tui_gen_win_info *) NULL)
+ {
+ struct tui_gen_win_info *exec_info_ptr = win_info->detail.source_info.execution_info;
+
+ if (exec_info_ptr->content == NULL)
+ exec_info_ptr->content =
+ (void **) tui_alloc_content (win_info->generic.height,
+ exec_info_ptr->type);
+ if (exec_info_ptr->content != NULL)
+ {
+ int i;
+
+ tui_update_breakpoint_info (win_info, 1);
+ for (i = 0; i < win_info->generic.content_size; i++)
+ {
+ struct tui_win_element *element;
+ struct tui_win_element *src_element;
+ int mode;
+
+ element = (struct tui_win_element *) exec_info_ptr->content[i];
+ src_element = (struct tui_win_element *) win_info->generic.content[i];
+
+ memset(element->which_element.simple_string, ' ',
+ sizeof(element->which_element.simple_string));
+ element->which_element.simple_string[TUI_EXECINFO_SIZE - 1] = 0;
+
+ /* Now update the exec info content based upon the state
+ of each line as indicated by the source content. */
+ mode = src_element->which_element.source.has_break;
+ if (mode & TUI_BP_HIT)
+ element->which_element.simple_string[TUI_BP_HIT_POS] =
+ (mode & TUI_BP_HARDWARE) ? 'H' : 'B';
+ else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED))
+ element->which_element.simple_string[TUI_BP_HIT_POS] =
+ (mode & TUI_BP_HARDWARE) ? 'h' : 'b';
+
+ if (mode & TUI_BP_ENABLED)
+ element->which_element.simple_string[TUI_BP_BREAK_POS] = '+';
+ else if (mode & TUI_BP_DISABLED)
+ element->which_element.simple_string[TUI_BP_BREAK_POS] = '-';
+
+ if (src_element->which_element.source.is_exec_point)
+ element->which_element.simple_string[TUI_EXEC_POS] = '>';
+ }
+ exec_info_ptr->content_size = win_info->generic.content_size;
+ }
+ else
+ ret = TUI_FAILURE;
+ }
+
+ return ret;
+}
+
+
+void
+tui_show_exec_info_content (struct tui_win_info *win_info)
+{
+ struct tui_gen_win_info *exec_info = win_info->detail.source_info.execution_info;
+ int cur_line;
+
+ werase (exec_info->handle);
+ tui_refresh_win (exec_info);
+ for (cur_line = 1; (cur_line <= exec_info->content_size); cur_line++)
+ mvwaddstr (exec_info->handle,
+ cur_line,
+ 0,
+ ((struct tui_win_element *)
+ exec_info->content[cur_line - 1])->which_element.simple_string);
+ tui_refresh_win (exec_info);
+ exec_info->content_in_use = TRUE;
+}
+
+
+void
+tui_erase_exec_info_content (struct tui_win_info *win_info)
+{
+ struct tui_gen_win_info *exec_info = win_info->detail.source_info.execution_info;
+
+ werase (exec_info->handle);
+ tui_refresh_win (exec_info);
+}
+
+void
+tui_clear_exec_info_content (struct tui_win_info *win_info)
+{
+ win_info->detail.source_info.execution_info->content_in_use = FALSE;
+ tui_erase_exec_info_content (win_info);
+
+ return;
+}
+
+/* Function to update the execution info window. */
+void
+tui_update_exec_info (struct tui_win_info *win_info)
+{
+ tui_set_exec_info_content (win_info);
+ tui_show_exec_info_content (win_info);
+}
+
+enum tui_status
+tui_alloc_source_buffer (struct tui_win_info *win_info)
+{
+ char *src_line_buf;
+ int i, line_width, max_lines;
+
+ max_lines = win_info->generic.height; /* Less the highlight box. */
+ line_width = win_info->generic.width - 1;
+ /*
+ * Allocate the buffer for the source lines. Do this only once
+ * since they will be re-used for all source displays. The only
+ * other time this will be done is when a window's size changes.
+ */
+ if (win_info->generic.content == NULL)
+ {
+ src_line_buf = (char *)
+ xmalloc ((max_lines * line_width) * sizeof (char));
+ if (src_line_buf == (char *) NULL)
+ {
+ fputs_unfiltered ("Unable to Allocate Memory for Source or Disassembly Display.\n",
+ gdb_stderr);
+ return TUI_FAILURE;
+ }
+ /* Allocate the content list. */
+ if ((win_info->generic.content =
+ (void **) tui_alloc_content (max_lines, SRC_WIN)) == NULL)
+ {
+ xfree (src_line_buf);
+ fputs_unfiltered ("Unable to Allocate Memory for Source or Disassembly Display.\n",
+ gdb_stderr);
+ return TUI_FAILURE;
+ }
+ for (i = 0; i < max_lines; i++)
+ ((struct tui_win_element *)
+ win_info->generic.content[i])->which_element.source.line =
+ src_line_buf + (line_width * i);
+ }
+
+ return TUI_SUCCESS;
+}
+
+
+/* Answer whether the a particular line number or address is displayed
+ in the current source window. */
+int
+tui_line_is_displayed (int line,
+ struct tui_win_info *win_info,
+ int check_threshold)
+{
+ int is_displayed = FALSE;
+ int i, threshold;
+
+ if (check_threshold)
+ threshold = SCROLL_THRESHOLD;
+ else
+ threshold = 0;
+ i = 0;
+ while (i < win_info->generic.content_size - threshold
+ && !is_displayed)
+ {
+ is_displayed = (((struct tui_win_element *)
+ win_info->generic.content[i])->which_element.source.line_or_addr.loa
+ == LOA_LINE)
+ && (((struct tui_win_element *)
+ win_info->generic.content[i])->which_element.source.line_or_addr.u.line_no
+ == (int) line);
+ i++;
+ }
+
+ return is_displayed;
+}
+
+
+/* Answer whether the a particular line number or address is displayed
+ in the current source window. */
+int
+tui_addr_is_displayed (CORE_ADDR addr,
+ struct tui_win_info *win_info,
+ int check_threshold)
+{
+ int is_displayed = FALSE;
+ int i, threshold;
+
+ if (check_threshold)
+ threshold = SCROLL_THRESHOLD;
+ else
+ threshold = 0;
+ i = 0;
+ while (i < win_info->generic.content_size - threshold
+ && !is_displayed)
+ {
+ is_displayed = (((struct tui_win_element *)
+ win_info->generic.content[i])->which_element.source.line_or_addr.loa
+ == LOA_ADDRESS)
+ && (((struct tui_win_element *)
+ win_info->generic.content[i])->which_element.source.line_or_addr.u.addr
+ == addr);
+ i++;
+ }
+
+ return is_displayed;
+}
+
+
+/*****************************************
+** STATIC LOCAL FUNCTIONS **
+******************************************/
tui-winsource.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-disasm.c
===================================================================
--- tui-disasm.c (nonexistent)
+++ tui-disasm.c (revision 157)
@@ -0,0 +1,402 @@
+/* Disassembly display.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "symtab.h"
+#include "breakpoint.h"
+#include "frame.h"
+#include "value.h"
+#include "source.h"
+#include "disasm.h"
+#include "gdb_string.h"
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-win.h"
+#include "tui/tui-layout.h"
+#include "tui/tui-winsource.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-file.h"
+
+#include "gdb_curses.h"
+
+struct tui_asm_line
+{
+ CORE_ADDR addr;
+ char *addr_string;
+ char *insn;
+};
+
+/* Function to set the disassembly window's content.
+ Disassemble count lines starting at pc.
+ Return address of the count'th instruction after pc. */
+static CORE_ADDR
+tui_disassemble (struct tui_asm_line *asm_lines,
+ CORE_ADDR pc, int count)
+{
+ struct ui_file *gdb_dis_out;
+
+ /* Now init the ui_file structure. */
+ gdb_dis_out = tui_sfileopen (256);
+
+ /* Now construct each line. */
+ for (; count > 0; count--, asm_lines++)
+ {
+ if (asm_lines->addr_string)
+ xfree (asm_lines->addr_string);
+ if (asm_lines->insn)
+ xfree (asm_lines->insn);
+
+ print_address (pc, gdb_dis_out);
+ asm_lines->addr = pc;
+ asm_lines->addr_string = xstrdup (tui_file_get_strbuf (gdb_dis_out));
+
+ ui_file_rewind (gdb_dis_out);
+
+ pc = pc + gdb_print_insn (pc, gdb_dis_out, NULL);
+
+ asm_lines->insn = xstrdup (tui_file_get_strbuf (gdb_dis_out));
+
+ /* Reset the buffer to empty. */
+ ui_file_rewind (gdb_dis_out);
+ }
+ ui_file_delete (gdb_dis_out);
+ return pc;
+}
+
+/* Find the disassembly address that corresponds to FROM lines above
+ or below the PC. Variable sized instructions are taken into
+ account by the algorithm. */
+static CORE_ADDR
+tui_find_disassembly_address (CORE_ADDR pc, int from)
+{
+ CORE_ADDR new_low;
+ int max_lines;
+ int i;
+ struct tui_asm_line *asm_lines;
+
+ max_lines = (from > 0) ? from : - from;
+ if (max_lines <= 1)
+ return pc;
+
+ asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
+ * max_lines);
+ memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
+
+ new_low = pc;
+ if (from > 0)
+ {
+ tui_disassemble (asm_lines, pc, max_lines);
+ new_low = asm_lines[max_lines - 1].addr;
+ }
+ else
+ {
+ CORE_ADDR last_addr;
+ int pos;
+ struct minimal_symbol *msymbol;
+
+ /* Find backward an address which is a symbol and for which
+ disassembling from that address will fill completely the
+ window. */
+ pos = max_lines - 1;
+ do {
+ new_low -= 1 * max_lines;
+ msymbol = lookup_minimal_symbol_by_pc_section (new_low, 0);
+
+ if (msymbol)
+ new_low = SYMBOL_VALUE_ADDRESS (msymbol);
+ else
+ new_low += 1 * max_lines;
+
+ tui_disassemble (asm_lines, new_low, max_lines);
+ last_addr = asm_lines[pos].addr;
+ } while (last_addr > pc && msymbol);
+
+ /* Scan forward disassembling one instruction at a time until
+ the last visible instruction of the window matches the pc.
+ We keep the disassembled instructions in the 'lines' window
+ and shift it downward (increasing its addresses). */
+ if (last_addr < pc)
+ do
+ {
+ CORE_ADDR next_addr;
+
+ pos++;
+ if (pos >= max_lines)
+ pos = 0;
+
+ next_addr = tui_disassemble (&asm_lines[pos], last_addr, 1);
+
+ /* If there are some problems while disassembling exit. */
+ if (next_addr <= last_addr)
+ break;
+ last_addr = next_addr;
+ } while (last_addr <= pc);
+ pos++;
+ if (pos >= max_lines)
+ pos = 0;
+ new_low = asm_lines[pos].addr;
+ }
+ for (i = 0; i < max_lines; i++)
+ {
+ xfree (asm_lines[i].addr_string);
+ xfree (asm_lines[i].insn);
+ }
+ return new_low;
+}
+
+/* Function to set the disassembly window's content. */
+enum tui_status
+tui_set_disassem_content (CORE_ADDR pc)
+{
+ enum tui_status ret = TUI_FAILURE;
+ int i;
+ int offset = TUI_DISASM_WIN->detail.source_info.horizontal_offset;
+ int line_width, max_lines;
+ CORE_ADDR cur_pc;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+ int tab_len = tui_default_tab_len ();
+ struct tui_asm_line *asm_lines;
+ int insn_pos;
+ int addr_size, max_size;
+ char *line;
+
+ if (pc == 0)
+ return TUI_FAILURE;
+
+ ret = tui_alloc_source_buffer (TUI_DISASM_WIN);
+ if (ret != TUI_SUCCESS)
+ return ret;
+
+ TUI_DISASM_WIN->detail.source_info.start_line_or_addr.loa = LOA_ADDRESS;
+ TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr = pc;
+ cur_pc = (CORE_ADDR)
+ (((struct tui_win_element *) locator->content[0])->which_element.locator.addr);
+
+ max_lines = TUI_DISASM_WIN->generic.height - 2; /* Account for
+ hilite. */
+
+ /* Get temporary table that will hold all strings (addr & insn). */
+ asm_lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
+ * max_lines);
+ memset (asm_lines, 0, sizeof (struct tui_asm_line) * max_lines);
+
+ line_width = TUI_DISASM_WIN->generic.width - 1;
+
+ tui_disassemble (asm_lines, pc, max_lines);
+
+ /* See what is the maximum length of an address and of a line. */
+ addr_size = 0;
+ max_size = 0;
+ for (i = 0; i < max_lines; i++)
+ {
+ size_t len = strlen (asm_lines[i].addr_string);
+ if (len > addr_size)
+ addr_size = len;
+
+ len = strlen (asm_lines[i].insn) + tab_len;
+ if (len > max_size)
+ max_size = len;
+ }
+ max_size += addr_size + tab_len;
+
+ /* Allocate memory to create each line. */
+ line = (char*) alloca (max_size);
+ insn_pos = (1 + (addr_size / tab_len)) * tab_len;
+
+ /* Now construct each line. */
+ for (i = 0; i < max_lines; i++)
+ {
+ struct tui_win_element *element;
+ struct tui_source_element *src;
+ int cur_len;
+
+ element = (struct tui_win_element *) TUI_DISASM_WIN->generic.content[i];
+ src = &element->which_element.source;
+ strcpy (line, asm_lines[i].addr_string);
+ cur_len = strlen (line);
+
+ /* Add spaces to make the instructions start on the same
+ column. */
+ while (cur_len < insn_pos)
+ {
+ strcat (line, " ");
+ cur_len++;
+ }
+
+ strcat (line, asm_lines[i].insn);
+
+ /* Now copy the line taking the offset into account. */
+ if (strlen (line) > offset)
+ strcpy (src->line, &line[offset]);
+ else
+ src->line[0] = '\0';
+
+ src->line_or_addr.loa = LOA_ADDRESS;
+ src->line_or_addr.u.addr = asm_lines[i].addr;
+ src->is_exec_point = asm_lines[i].addr == cur_pc;
+
+ /* See whether there is a breakpoint installed. */
+ src->has_break = (!src->is_exec_point
+ && breakpoint_here_p (pc) != no_breakpoint_here);
+
+ xfree (asm_lines[i].addr_string);
+ xfree (asm_lines[i].insn);
+ }
+ TUI_DISASM_WIN->generic.content_size = i;
+ return TUI_SUCCESS;
+}
+
+
+/* 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 ();
+ struct tui_line_or_address val;
+
+ val.loa = LOA_ADDRESS;
+ val.u.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;
+}
+
+
+/* Function to display the disassembly window. */
+void
+tui_show_disassem_and_update_source (CORE_ADDR start_addr)
+{
+ struct symtab_and_line sal;
+
+ tui_show_disassem (start_addr);
+ if (tui_current_layout () == SRC_DISASSEM_COMMAND)
+ {
+ struct tui_line_or_address val;
+
+ /* Update what is in the source window if it is displayed too,
+ note that it follows what is in the disassembly window and
+ visa-versa. */
+ sal = find_pc_line (start_addr, 0);
+ val.loa = LOA_LINE;
+ val.u.line_no = sal.line;
+ tui_update_source_window (TUI_SRC_WIN, sal.symtab, val, TRUE);
+ if (sal.symtab)
+ {
+ set_current_source_symtab_and_line (&sal);
+ tui_update_locator_filename (sal.symtab->filename);
+ }
+ else
+ tui_update_locator_filename ("?");
+ }
+
+ return;
+}
+
+CORE_ADDR
+tui_get_begin_asm_address (void)
+{
+ struct tui_gen_win_info *locator;
+ struct tui_locator_element *element;
+ CORE_ADDR addr;
+
+ locator = tui_locator_win_info_ptr ();
+ element = &((struct tui_win_element *) locator->content[0])->which_element.locator;
+
+ if (element->addr == 0)
+ {
+ struct minimal_symbol *main_symbol;
+
+ /* Find address of the start of program.
+ Note: this should be language specific. */
+ main_symbol = lookup_minimal_symbol ("main", NULL, NULL);
+ if (main_symbol == 0)
+ main_symbol = lookup_minimal_symbol ("MAIN", NULL, NULL);
+ if (main_symbol == 0)
+ main_symbol = lookup_minimal_symbol ("_start", NULL, NULL);
+ if (main_symbol)
+ addr = SYMBOL_VALUE_ADDRESS (main_symbol);
+ else
+ addr = 0;
+ }
+ else /* The target is executing. */
+ addr = element->addr;
+
+ return addr;
+}
+
+/* Determine what the low address will be to display in the TUI's
+ disassembly window. This may or may not be the same as the low
+ address input. */
+CORE_ADDR
+tui_get_low_disassembly_address (CORE_ADDR low,
+ CORE_ADDR pc)
+{
+ int pos;
+
+ /* Determine where to start the disassembly so that the pc is about
+ in the middle of the viewport. */
+ pos = tui_default_win_viewport_height (DISASSEM_WIN, DISASSEM_COMMAND) / 2;
+ pc = tui_find_disassembly_address (pc, -pos);
+
+ if (pc < low)
+ pc = low;
+ return pc;
+}
+
+/* Scroll the disassembly forward or backward vertically. */
+void
+tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction,
+ int num_to_scroll)
+{
+ if (TUI_DISASM_WIN->generic.content != NULL)
+ {
+ CORE_ADDR pc;
+ tui_win_content content;
+ struct symtab *s;
+ struct tui_line_or_address val;
+ int max_lines, dir;
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+
+ content = (tui_win_content) TUI_DISASM_WIN->generic.content;
+ if (cursal.symtab == (struct symtab *) NULL)
+ s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
+ else
+ s = cursal.symtab;
+
+ /* Account for hilite. */
+ max_lines = TUI_DISASM_WIN->generic.height - 2;
+ pc = content[0]->which_element.source.line_or_addr.u.addr;
+ dir = (scroll_direction == FORWARD_SCROLL) ? max_lines : - max_lines;
+
+ val.loa = LOA_ADDRESS;
+ val.u.addr = tui_find_disassembly_address (pc, dir);
+ tui_update_source_window_as_is (TUI_DISASM_WIN, s, val, FALSE);
+ }
+}
tui-disasm.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-command.h
===================================================================
--- tui-command.h (nonexistent)
+++ tui-command.h (revision 157)
@@ -0,0 +1,28 @@
+/* Specific command window processing.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_COMMAND_H
+#define TUI_COMMAND_H
+
+extern unsigned int tui_dispatch_ctrl_char (unsigned int);
+
+#endif
tui-command.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-winsource.h
===================================================================
--- tui-winsource.h (nonexistent)
+++ tui-winsource.h (revision 157)
@@ -0,0 +1,80 @@
+/* TUI display source/assembly window.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_SOURCEWIN_H
+#define TUI_SOURCEWIN_H
+
+#include "tui/tui-data.h"
+
+struct tui_win_info;
+
+/* Update the execution windows to show the active breakpoints. This
+ is called whenever a breakpoint is inserted, removed or has its
+ state changed. */
+extern void tui_update_all_breakpoint_info (void);
+
+/* Scan the source window and the breakpoints to update the hasBreak
+ information for each line. Returns 1 if something changed and the
+ execution window must be refreshed. */
+extern int tui_update_breakpoint_info (struct tui_win_info *win,
+ int current_only);
+
+/* Function to display the "main" routine. */
+extern void tui_display_main (void);
+extern void tui_update_source_window (struct tui_win_info *,
+ struct symtab *,
+ struct tui_line_or_address,
+ int);
+extern void tui_update_source_window_as_is (struct tui_win_info *,
+ struct symtab *,
+ struct tui_line_or_address,
+ int);
+extern void tui_update_source_windows_with_addr (CORE_ADDR);
+extern void tui_update_source_windows_with_line (struct symtab *,
+ int);
+extern void tui_clear_source_content (struct tui_win_info *, int);
+extern void tui_erase_source_content (struct tui_win_info *, int);
+extern void tui_show_source_content (struct tui_win_info *);
+extern void tui_horizontal_source_scroll (struct tui_win_info *,
+ enum tui_scroll_direction,
+ int);
+extern enum tui_status tui_set_exec_info_content (struct tui_win_info *);
+extern void tui_show_exec_info_content (struct tui_win_info *);
+extern void tui_erase_exec_info_content (struct tui_win_info *);
+extern void tui_clear_exec_info_content (struct tui_win_info *);
+extern void tui_update_exec_info (struct tui_win_info *);
+
+extern void tui_set_is_exec_point_at (struct tui_line_or_address,
+ struct tui_win_info *);
+extern enum tui_status tui_alloc_source_buffer (struct tui_win_info *);
+extern int tui_line_is_displayed (int,
+ struct tui_win_info *,
+ int);
+extern int tui_addr_is_displayed (CORE_ADDR,
+ struct tui_win_info *,
+ int);
+
+
+/* Constant definitions. */
+#define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */
+
+#endif
tui-winsource.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-hooks.c
===================================================================
--- tui-hooks.c (nonexistent)
+++ tui-hooks.c (revision 157)
@@ -0,0 +1,304 @@
+/* GDB hooks for TUI.
+
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include "defs.h"
+#include "symtab.h"
+#include "inferior.h"
+#include "command.h"
+#include "bfd.h"
+#include "symfile.h"
+#include "objfiles.h"
+#include "target.h"
+#include "gdbcore.h"
+#include "event-loop.h"
+#include "event-top.h"
+#include "frame.h"
+#include "breakpoint.h"
+#include "gdb-events.h"
+#include "ui-out.h"
+#include "top.h"
+#include "observer.h"
+#include
+#include
+
+#include "tui/tui.h"
+#include "tui/tui-hooks.h"
+#include "tui/tui-data.h"
+#include "tui/tui-layout.h"
+#include "tui/tui-io.h"
+#include "tui/tui-regs.h"
+#include "tui/tui-win.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-windata.h"
+#include "tui/tui-winsource.h"
+
+#include "gdb_curses.h"
+
+/* This redefines CTRL if it is not already defined, so it must come
+ after terminal state releated include files like and
+ "gdb_curses.h". */
+#include "readline/readline.h"
+
+int tui_target_has_run = 0;
+
+static void
+tui_new_objfile_hook (struct objfile* objfile)
+{
+ if (tui_active)
+ tui_display_main ();
+}
+
+static int ATTR_FORMAT (printf, 1, 0)
+tui_query_hook (const char *msg, va_list argp)
+{
+ int retval;
+ int ans2;
+ int answer;
+
+ echo ();
+ while (1)
+ {
+ wrap_here (""); /* Flush any buffered output. */
+ gdb_flush (gdb_stdout);
+
+ vfprintf_filtered (gdb_stdout, msg, argp);
+ printf_filtered (_("(y or n) "));
+
+ wrap_here ("");
+ gdb_flush (gdb_stdout);
+
+ answer = tui_getc (stdin);
+ clearerr (stdin); /* in case of C-d */
+ if (answer == EOF) /* C-d */
+ {
+ retval = 1;
+ break;
+ }
+ /* Eat rest of input line, to EOF or newline. */
+ if (answer != '\n')
+ do
+ {
+ ans2 = tui_getc (stdin);
+ clearerr (stdin);
+ }
+ while (ans2 != EOF && ans2 != '\n' && ans2 != '\r');
+
+ if (answer >= 'a')
+ answer -= 040;
+ if (answer == 'Y')
+ {
+ retval = 1;
+ break;
+ }
+ if (answer == 'N')
+ {
+ retval = 0;
+ break;
+ }
+ printf_filtered (_("Please answer y or n.\n"));
+ }
+ noecho ();
+ return retval;
+}
+
+/* Prevent recursion of deprecated_register_changed_hook(). */
+static int tui_refreshing_registers = 0;
+
+static void
+tui_register_changed_hook (int regno)
+{
+ struct frame_info *fi;
+
+ fi = get_selected_frame (NULL);
+ if (tui_refreshing_registers == 0)
+ {
+ tui_refreshing_registers = 1;
+ tui_check_data_values (fi);
+ tui_refreshing_registers = 0;
+ }
+}
+
+/* Breakpoint creation hook.
+ Update the screen to show the new breakpoint. */
+static void
+tui_event_create_breakpoint (int number)
+{
+ tui_update_all_breakpoint_info ();
+}
+
+/* Breakpoint deletion hook.
+ Refresh the screen to update the breakpoint marks. */
+static void
+tui_event_delete_breakpoint (int number)
+{
+ tui_update_all_breakpoint_info ();
+}
+
+static void
+tui_event_modify_breakpoint (int number)
+{
+ tui_update_all_breakpoint_info ();
+}
+
+static void
+tui_event_default (int number)
+{
+ ;
+}
+
+static struct gdb_events *tui_old_event_hooks;
+
+static struct gdb_events tui_event_hooks = {
+ tui_event_create_breakpoint,
+ tui_event_delete_breakpoint,
+ tui_event_modify_breakpoint,
+ tui_event_default,
+ tui_event_default,
+ tui_event_default
+};
+
+/* Called when going to wait for the target.
+ Leave curses mode and setup program mode. */
+static ptid_t
+tui_target_wait_hook (ptid_t pid,
+ struct target_waitstatus *status)
+{
+ ptid_t res;
+
+ /* Leave tui mode (optional). */
+#if 0
+ if (tui_active)
+ {
+ target_terminal_ours ();
+ endwin ();
+ target_terminal_inferior ();
+ }
+#endif
+ tui_target_has_run = 1;
+ res = target_wait (pid, status);
+
+ if (tui_active)
+ {
+ /* TODO: need to refresh (optional). */
+ }
+ return res;
+}
+
+/* The selected frame has changed. This is happens after a target
+ stop or when the user explicitly changes the frame
+ (up/down/thread/...). */
+static void
+tui_selected_frame_level_changed_hook (int level)
+{
+ struct frame_info *fi;
+
+ /* Negative level means that the selected frame was cleared. */
+ if (level < 0)
+ return;
+
+ fi = get_selected_frame (NULL);
+ /* Ensure that symbols for this frame are read in. Also, determine
+ the source language of this frame, and switch to it if
+ desired. */
+ if (fi)
+ {
+ struct symtab *s;
+
+ s = find_pc_symtab (get_frame_pc (fi));
+ /* elz: This if here fixes the problem with the pc not being
+ displayed in the tui asm layout, with no debug symbols. The
+ value of s would be 0 here, and select_source_symtab would
+ abort the command by calling the 'error' function. */
+ if (s)
+ select_source_symtab (s);
+
+ /* Display the frame position (even if there is no symbols). */
+ tui_show_frame_info (fi);
+
+ /* Refresh the register window if it's visible. */
+ if (tui_is_window_visible (DATA_WIN))
+ {
+ tui_refreshing_registers = 1;
+ tui_check_data_values (fi);
+ tui_refreshing_registers = 0;
+ }
+ }
+}
+
+/* Called from print_frame_info to list the line we stopped in. */
+static void
+tui_print_frame_info_listing_hook (struct symtab *s,
+ int line,
+ int stopline,
+ int noerror)
+{
+ select_source_symtab (s);
+ tui_show_frame_info (get_selected_frame (NULL));
+}
+
+/* Called when the target process died or is detached.
+ Update the status line. */
+static void
+tui_detach_hook (void)
+{
+ tui_show_frame_info (0);
+ tui_display_main ();
+}
+
+/* Install the TUI specific hooks. */
+void
+tui_install_hooks (void)
+{
+ deprecated_target_wait_hook = tui_target_wait_hook;
+ deprecated_selected_frame_level_changed_hook = tui_selected_frame_level_changed_hook;
+ deprecated_print_frame_info_listing_hook = tui_print_frame_info_listing_hook;
+
+ deprecated_query_hook = tui_query_hook;
+
+ /* Install the event hooks. */
+ tui_old_event_hooks = deprecated_set_gdb_event_hooks (&tui_event_hooks);
+
+ deprecated_register_changed_hook = tui_register_changed_hook;
+ deprecated_detach_hook = tui_detach_hook;
+}
+
+/* Remove the TUI specific hooks. */
+void
+tui_remove_hooks (void)
+{
+ deprecated_target_wait_hook = 0;
+ deprecated_selected_frame_level_changed_hook = 0;
+ deprecated_print_frame_info_listing_hook = 0;
+ deprecated_query_hook = 0;
+ deprecated_register_changed_hook = 0;
+ deprecated_detach_hook = 0;
+
+ /* Restore the previous event hooks. */
+ deprecated_set_gdb_event_hooks (tui_old_event_hooks);
+}
+
+void _initialize_tui_hooks (void);
+
+void
+_initialize_tui_hooks (void)
+{
+ /* Install the permanent hooks. */
+ observer_attach_new_objfile (tui_new_objfile_hook);
+}
tui-hooks.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-disasm.h
===================================================================
--- tui-disasm.h (nonexistent)
+++ tui-disasm.h (revision 157)
@@ -0,0 +1,36 @@
+/* Disassembly display.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2004, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_DISASM_H
+#define TUI_DISASM_H
+
+#include "tui/tui.h" /* For enum tui_status. */
+#include "tui/tui-data.h" /* For enum tui_scroll_direction. */
+
+extern enum tui_status tui_set_disassem_content (CORE_ADDR);
+extern void tui_show_disassem (CORE_ADDR);
+extern void tui_show_disassem_and_update_source (CORE_ADDR);
+extern void tui_vertical_disassem_scroll (enum tui_scroll_direction,
+ int);
+extern CORE_ADDR tui_get_begin_asm_address (void);
+
+#endif
tui-disasm.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-hooks.h
===================================================================
--- tui-hooks.h (nonexistent)
+++ tui-hooks.h (revision 157)
@@ -0,0 +1,26 @@
+/* External/Public TUI hools header file, for GDB the GNU debugger.
+
+ Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#ifndef TUI_HOOKS_H
+#define TUI_HOOKS_H
+
+extern void tui_install_hooks (void);
+extern void tui_remove_hooks (void);
+
+#endif
tui-hooks.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: tui-win.c
===================================================================
--- tui-win.c (nonexistent)
+++ tui-win.c (revision 157)
@@ -0,0 +1,1579 @@
+/* TUI window generic functions.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008
+ Free Software Foundation, Inc.
+
+ Contributed by Hewlett-Packard Company.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+/* This module contains procedures for handling tui window functions
+ like resize, scrolling, scrolling, changing focus, etc.
+
+ Author: Susan B. Macchia */
+
+#include "defs.h"
+#include "command.h"
+#include "symtab.h"
+#include "breakpoint.h"
+#include "frame.h"
+#include "cli/cli-cmds.h"
+#include "top.h"
+#include "source.h"
+
+#include "tui/tui.h"
+#include "tui/tui-data.h"
+#include "tui/tui-wingeneral.h"
+#include "tui/tui-stack.h"
+#include "tui/tui-regs.h"
+#include "tui/tui-disasm.h"
+#include "tui/tui-source.h"
+#include "tui/tui-winsource.h"
+#include "tui/tui-windata.h"
+
+#include "gdb_curses.h"
+
+#include "gdb_string.h"
+#include
+#include "readline/readline.h"
+
+#include
+
+/*******************************
+** Static Local Decls
+********************************/
+static void make_visible_with_new_height (struct tui_win_info *);
+static void make_invisible_and_set_new_height (struct tui_win_info *,
+ int);
+static enum tui_status tui_adjust_win_heights (struct tui_win_info *,
+ int);
+static int new_height_ok (struct tui_win_info *, int);
+static void tui_set_tab_width_command (char *, int);
+static void tui_refresh_all_command (char *, int);
+static void tui_set_win_height_command (char *, int);
+static void tui_xdb_set_win_height_command (char *, int);
+static void tui_all_windows_info (char *, int);
+static void tui_set_focus_command (char *, int);
+static void tui_scroll_forward_command (char *, int);
+static void tui_scroll_backward_command (char *, int);
+static void tui_scroll_left_command (char *, int);
+static void tui_scroll_right_command (char *, int);
+static void parse_scrolling_args (char *,
+ struct tui_win_info **,
+ int *);
+
+
+/***************************************
+** DEFINITIONS
+***************************************/
+#define WIN_HEIGHT_USAGE "Usage: winheight [+ | -] <#lines>\n"
+#define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n"
+#define FOCUS_USAGE "Usage: focus { | next | prev}\n"
+
+/***************************************
+** PUBLIC FUNCTIONS
+***************************************/
+
+#ifndef ACS_LRCORNER
+# define ACS_LRCORNER '+'
+#endif
+#ifndef ACS_LLCORNER
+# define ACS_LLCORNER '+'
+#endif
+#ifndef ACS_ULCORNER
+# define ACS_ULCORNER '+'
+#endif
+#ifndef ACS_URCORNER
+# define ACS_URCORNER '+'
+#endif
+#ifndef ACS_HLINE
+# define ACS_HLINE '-'
+#endif
+#ifndef ACS_VLINE
+# define ACS_VLINE '|'
+#endif
+
+/* Possible values for tui-border-kind variable. */
+static const char *tui_border_kind_enums[] = {
+ "space",
+ "ascii",
+ "acs",
+ NULL
+};
+
+/* Possible values for tui-border-mode and tui-active-border-mode. */
+static const char *tui_border_mode_enums[] = {
+ "normal",
+ "standout",
+ "reverse",
+ "half",
+ "half-standout",
+ "bold",
+ "bold-standout",
+ NULL
+};
+
+struct tui_translate
+{
+ const char *name;
+ int value;
+};
+
+/* Translation table for border-mode variables.
+ The list of values must be terminated by a NULL.
+ After the NULL value, an entry defines the default. */
+struct tui_translate tui_border_mode_translate[] = {
+ { "normal", A_NORMAL },
+ { "standout", A_STANDOUT },
+ { "reverse", A_REVERSE },
+ { "half", A_DIM },
+ { "half-standout", A_DIM | A_STANDOUT },
+ { "bold", A_BOLD },
+ { "bold-standout", A_BOLD | A_STANDOUT },
+ { 0, 0 },
+ { "normal", A_NORMAL }
+};
+
+/* Translation tables for border-kind, one for each border
+ character (see wborder, border curses operations).
+ -1 is used to indicate the ACS because ACS characters
+ are determined at run time by curses (depends on terminal). */
+struct tui_translate tui_border_kind_translate_vline[] = {
+ { "space", ' ' },
+ { "ascii", '|' },
+ { "acs", -1 },
+ { 0, 0 },
+ { "ascii", '|' }
+};
+
+struct tui_translate tui_border_kind_translate_hline[] = {
+ { "space", ' ' },
+ { "ascii", '-' },
+ { "acs", -1 },
+ { 0, 0 },
+ { "ascii", '-' }
+};
+
+struct tui_translate tui_border_kind_translate_ulcorner[] = {
+ { "space", ' ' },
+ { "ascii", '+' },
+ { "acs", -1 },
+ { 0, 0 },
+ { "ascii", '+' }
+};
+
+struct tui_translate tui_border_kind_translate_urcorner[] = {
+ { "space", ' ' },
+ { "ascii", '+' },
+ { "acs", -1 },
+ { 0, 0 },
+ { "ascii", '+' }
+};
+
+struct tui_translate tui_border_kind_translate_llcorner[] = {
+ { "space", ' ' },
+ { "ascii", '+' },
+ { "acs", -1 },
+ { 0, 0 },
+ { "ascii", '+' }
+};
+
+struct tui_translate tui_border_kind_translate_lrcorner[] = {
+ { "space", ' ' },
+ { "ascii", '+' },
+ { "acs", -1 },
+ { 0, 0 },
+ { "ascii", '+' }
+};
+
+
+/* Tui configuration variables controlled with set/show command. */
+const char *tui_active_border_mode = "bold-standout";
+static void
+show_tui_active_border_mode (struct ui_file *file,
+ int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ fprintf_filtered (file, _("\
+The attribute mode to use for the active TUI window border is \"%s\".\n"),
+ value);
+}
+
+const char *tui_border_mode = "normal";
+static void
+show_tui_border_mode (struct ui_file *file,
+ int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ fprintf_filtered (file, _("\
+The attribute mode to use for the TUI window borders is \"%s\".\n"),
+ value);
+}
+
+const char *tui_border_kind = "acs";
+static void
+show_tui_border_kind (struct ui_file *file,
+ int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ fprintf_filtered (file, _("The kind of border for TUI windows is \"%s\".\n"),
+ value);
+}
+
+
+/* Tui internal configuration variables. These variables are updated
+ by tui_update_variables to reflect the tui configuration
+ variables. */
+chtype tui_border_vline;
+chtype tui_border_hline;
+chtype tui_border_ulcorner;
+chtype tui_border_urcorner;
+chtype tui_border_llcorner;
+chtype tui_border_lrcorner;
+
+int tui_border_attrs;
+int tui_active_border_attrs;
+
+/* Identify the item in the translation table.
+ When the item is not recognized, use the default entry. */
+static struct tui_translate *
+translate (const char *name, struct tui_translate *table)
+{
+ while (table->name)
+ {
+ if (name && strcmp (table->name, name) == 0)
+ return table;
+ table++;
+ }
+
+ /* Not found, return default entry. */
+ table++;
+ return table;
+}
+
+/* Update the tui internal configuration according to gdb settings.
+ Returns 1 if the configuration has changed and the screen should
+ be redrawn. */
+int
+tui_update_variables (void)
+{
+ int need_redraw = 0;
+ struct tui_translate *entry;
+
+ entry = translate (tui_border_mode, tui_border_mode_translate);
+ if (tui_border_attrs != entry->value)
+ {
+ tui_border_attrs = entry->value;
+ need_redraw = 1;
+ }
+ entry = translate (tui_active_border_mode, tui_border_mode_translate);
+ if (tui_active_border_attrs != entry->value)
+ {
+ tui_active_border_attrs = entry->value;
+ need_redraw = 1;
+ }
+
+ /* If one corner changes, all characters are changed.
+ Only check the first one. The ACS characters are determined at
+ run time by curses terminal management. */
+ entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
+ if (tui_border_lrcorner != (chtype) entry->value)
+ {
+ tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
+ need_redraw = 1;
+ }
+ entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);
+ tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value;
+
+ entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner);
+ tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value;
+
+ entry = translate (tui_border_kind, tui_border_kind_translate_urcorner);
+ tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value;
+
+ entry = translate (tui_border_kind, tui_border_kind_translate_hline);
+ tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value;
+
+ entry = translate (tui_border_kind, tui_border_kind_translate_vline);
+ tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value;
+
+ return need_redraw;
+}
+
+static void
+set_tui_cmd (char *args, int from_tty)
+{
+}
+
+static void
+show_tui_cmd (char *args, int from_tty)
+{
+}
+
+static struct cmd_list_element *tuilist;
+
+static void
+tui_command (char *args, int from_tty)
+{
+ printf_unfiltered (_("\"tui\" must be followed by the name of a "
+ "tui command.\n"));
+ help_list (tuilist, "tui ", -1, gdb_stdout);
+}
+
+struct cmd_list_element **
+tui_get_cmd_list (void)
+{
+ if (tuilist == 0)
+ add_prefix_cmd ("tui", class_tui, tui_command,
+ _("Text User Interface commands."),
+ &tuilist, "tui ", 0, &cmdlist);
+ return &tuilist;
+}
+
+/* Function to initialize gdb commands, for tui window
+ manipulation. */
+void
+_initialize_tui_win (void)
+{
+ struct cmd_list_element *c;
+ static struct cmd_list_element *tui_setlist;
+ static struct cmd_list_element *tui_showlist;
+
+ /* Define the classes of commands.
+ They will appear in the help list in the reverse of this order. */
+ add_prefix_cmd ("tui", class_tui, set_tui_cmd,
+ _("TUI configuration variables"),
+ &tui_setlist, "set tui ",
+ 0 /* allow-unknown */, &setlist);
+ add_prefix_cmd ("tui", class_tui, show_tui_cmd,
+ _("TUI configuration variables"),
+ &tui_showlist, "show tui ",
+ 0 /* allow-unknown */, &showlist);
+
+ add_com ("refresh", class_tui, tui_refresh_all_command,
+ _("Refresh the terminal display.\n"));
+ if (xdb_commands)
+ add_com_alias ("U", "refresh", class_tui, 0);
+ add_com ("tabset", class_tui, tui_set_tab_width_command, _("\
+Set the width (in characters) of tab stops.\n\
+Usage: tabset \n"));
+ add_com ("winheight", class_tui, tui_set_win_height_command, _("\
+Set the height of a specified window.\n\
+Usage: winheight [+ | -] <#lines>\n\
+Window names are:\n\
+src : the source window\n\
+cmd : the command window\n\
+asm : the disassembly window\n\
+regs : the register display\n"));
+ add_com_alias ("wh", "winheight", class_tui, 0);
+ add_info ("win", tui_all_windows_info,
+ _("List of all displayed windows.\n"));
+ add_com ("focus", class_tui, tui_set_focus_command, _("\
+Set focus to named window or next/prev window.\n\
+Usage: focus { | next | prev}\n\
+Valid Window names are:\n\
+src : the source window\n\
+asm : the disassembly window\n\
+regs : the register display\n\
+cmd : the command window\n"));
+ add_com_alias ("fs", "focus", class_tui, 0);
+ add_com ("+", class_tui, tui_scroll_forward_command, _("\
+Scroll window forward.\n\
+Usage: + [win] [n]\n"));
+ add_com ("-", class_tui, tui_scroll_backward_command, _("\
+Scroll window backward.\n\
+Usage: - [win] [n]\n"));
+ add_com ("<", class_tui, tui_scroll_left_command, _("\
+Scroll window forward.\n\
+Usage: < [win] [n]\n"));
+ add_com (">", class_tui, tui_scroll_right_command, _("\
+Scroll window backward.\n\
+Usage: > [win] [n]\n"));
+ if (xdb_commands)
+ add_com ("w", class_xdb, tui_xdb_set_win_height_command, _("\
+XDB compatibility command for setting the height of a command window.\n\
+Usage: w <#lines>\n"));
+
+ /* Define the tui control variables. */
+ add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums,
+ &tui_border_kind, _("\
+Set the kind of border for TUI windows."), _("\
+Show the kind of border for TUI windows."), _("\
+This variable controls the border of TUI windows:\n\
+space use a white space\n\
+ascii use ascii characters + - | for the border\n\
+acs use the Alternate Character Set"),
+ NULL,
+ show_tui_border_kind,
+ &tui_setlist, &tui_showlist);
+
+ add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums,
+ &tui_border_mode, _("\
+Set the attribute mode to use for the TUI window borders."), _("\
+Show the attribute mode to use for the TUI window borders."), _("\
+This variable controls the attributes to use for the window borders:\n\
+normal normal display\n\
+standout use highlight mode of terminal\n\
+reverse use reverse video mode\n\
+half use half bright\n\
+half-standout use half bright and standout mode\n\
+bold use extra bright or bold\n\
+bold-standout use extra bright or bold with standout mode"),
+ NULL,
+ show_tui_border_mode,
+ &tui_setlist, &tui_showlist);
+
+ add_setshow_enum_cmd ("active-border-mode", no_class, tui_border_mode_enums,
+ &tui_active_border_mode, _("\
+Set the attribute mode to use for the active TUI window border."), _("\
+Show the attribute mode to use for the active TUI window border."), _("\
+This variable controls the attributes to use for the active window border:\n\
+normal normal display\n\
+standout use highlight mode of terminal\n\
+reverse use reverse video mode\n\
+half use half bright\n\
+half-standout use half bright and standout mode\n\
+bold use extra bright or bold\n\
+bold-standout use extra bright or bold with standout mode"),
+ NULL,
+ show_tui_active_border_mode,
+ &tui_setlist, &tui_showlist);
+}
+
+/* Update gdb's knowledge of the terminal size. */
+void
+tui_update_gdb_sizes (void)
+{
+ char cmd[50];
+
+ /* Set to TUI command window dimension or use readline values. */
+ sprintf (cmd, "set width %d",
+ tui_active ? TUI_CMD_WIN->generic.width : tui_term_width());
+ execute_command (cmd, 0);
+ sprintf (cmd, "set height %d",
+ tui_active ? TUI_CMD_WIN->generic.height : tui_term_height());
+ execute_command (cmd, 0);
+}
+
+
+/* Set the logical focus to win_info. */
+void
+tui_set_win_focus_to (struct tui_win_info *win_info)
+{
+ if (win_info != NULL)
+ {
+ struct tui_win_info *win_with_focus = tui_win_with_focus ();
+
+ if (win_with_focus != NULL
+ && win_with_focus->generic.type != CMD_WIN)
+ tui_unhighlight_win (win_with_focus);
+ tui_set_win_with_focus (win_info);
+ if (win_info->generic.type != CMD_WIN)
+ tui_highlight_win (win_info);
+ }
+}
+
+
+void
+tui_scroll_forward (struct tui_win_info *win_to_scroll,
+ int num_to_scroll)
+{
+ if (win_to_scroll != TUI_CMD_WIN)
+ {
+ int _num_to_scroll = num_to_scroll;
+
+ if (num_to_scroll == 0)
+ _num_to_scroll = win_to_scroll->generic.height - 3;
+
+ /* If we are scrolling the source or disassembly window, do a
+ "psuedo" scroll since not all of the source is in memory,
+ only what is in the viewport. If win_to_scroll is the
+ command window do nothing since the term should handle
+ it. */
+ if (win_to_scroll == TUI_SRC_WIN)
+ tui_vertical_source_scroll (FORWARD_SCROLL, _num_to_scroll);
+ else if (win_to_scroll == TUI_DISASM_WIN)
+ tui_vertical_disassem_scroll (FORWARD_SCROLL, _num_to_scroll);
+ else if (win_to_scroll == TUI_DATA_WIN)
+ tui_vertical_data_scroll (FORWARD_SCROLL, _num_to_scroll);
+ }
+}
+
+void
+tui_scroll_backward (struct tui_win_info *win_to_scroll,
+ int num_to_scroll)
+{
+ if (win_to_scroll != TUI_CMD_WIN)
+ {
+ int _num_to_scroll = num_to_scroll;
+
+ if (num_to_scroll == 0)
+ _num_to_scroll = win_to_scroll->generic.height - 3;
+
+ /* If we are scrolling the source or disassembly window, do a
+ "psuedo" scroll since not all of the source is in memory,
+ only what is in the viewport. If win_to_scroll is the
+ command window do nothing since the term should handle
+ it. */
+ if (win_to_scroll == TUI_SRC_WIN)
+ tui_vertical_source_scroll (BACKWARD_SCROLL, _num_to_scroll);
+ else if (win_to_scroll == TUI_DISASM_WIN)
+ tui_vertical_disassem_scroll (BACKWARD_SCROLL, _num_to_scroll);
+ else if (win_to_scroll == TUI_DATA_WIN)
+ tui_vertical_data_scroll (BACKWARD_SCROLL, _num_to_scroll);
+ }
+}
+
+
+void
+tui_scroll_left (struct tui_win_info *win_to_scroll,
+ int num_to_scroll)
+{
+ if (win_to_scroll != TUI_CMD_WIN)
+ {
+ int _num_to_scroll = num_to_scroll;
+
+ if (_num_to_scroll == 0)
+ _num_to_scroll = 1;
+
+ /* If we are scrolling the source or disassembly window, do a
+ "psuedo" scroll since not all of the source is in memory,
+ only what is in the viewport. If win_to_scroll is the command
+ window do nothing since the term should handle it. */
+ if (win_to_scroll == TUI_SRC_WIN
+ || win_to_scroll == TUI_DISASM_WIN)
+ tui_horizontal_source_scroll (win_to_scroll, LEFT_SCROLL, _num_to_scroll);
+ }
+}
+
+
+void
+tui_scroll_right (struct tui_win_info *win_to_scroll,
+ int num_to_scroll)
+{
+ if (win_to_scroll != TUI_CMD_WIN)
+ {
+ int _num_to_scroll = num_to_scroll;
+
+ if (_num_to_scroll == 0)
+ _num_to_scroll = 1;
+
+ /* If we are scrolling the source or disassembly window, do a
+ "psuedo" scroll since not all of the source is in memory,
+ only what is in the viewport. If win_to_scroll is the command
+ window do nothing since the term should handle it. */
+ if (win_to_scroll == TUI_SRC_WIN
+ || win_to_scroll == TUI_DISASM_WIN)
+ tui_horizontal_source_scroll (win_to_scroll, RIGHT_SCROLL, _num_to_scroll);
+ }
+}
+
+
+/* Scroll a window. Arguments are passed through a va_list. */
+void
+tui_scroll (enum tui_scroll_direction direction,
+ struct tui_win_info *win_to_scroll,
+ int num_to_scroll)
+{
+ switch (direction)
+ {
+ case FORWARD_SCROLL:
+ tui_scroll_forward (win_to_scroll, num_to_scroll);
+ break;
+ case BACKWARD_SCROLL:
+ tui_scroll_backward (win_to_scroll, num_to_scroll);
+ break;
+ case LEFT_SCROLL:
+ tui_scroll_left (win_to_scroll, num_to_scroll);
+ break;
+ case RIGHT_SCROLL:
+ tui_scroll_right (win_to_scroll, num_to_scroll);
+ break;
+ default:
+ break;
+ }
+}
+
+
+void
+tui_refresh_all_win (void)
+{
+ enum tui_win_type type;
+
+ clearok (curscr, TRUE);
+ tui_refresh_all (tui_win_list);
+ for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
+ {
+ if (tui_win_list[type]
+ && tui_win_list[type]->generic.is_visible)
+ {
+ switch (type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ tui_show_source_content (tui_win_list[type]);
+ tui_check_and_display_highlight_if_needed (tui_win_list[type]);
+ tui_erase_exec_info_content (tui_win_list[type]);
+ tui_update_exec_info (tui_win_list[type]);
+ break;
+ case DATA_WIN:
+ tui_refresh_data_win ();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ tui_show_locator_content ();
+}
+
+
+/* Resize all the windows based on the the terminal size. This
+ function gets called from within the readline sinwinch handler. */
+void
+tui_resize_all (void)
+{
+ int height_diff, width_diff;
+ int screenheight, screenwidth;
+
+ rl_get_screen_size (&screenheight, &screenwidth);
+ width_diff = screenwidth - tui_term_width ();
+ height_diff = screenheight - tui_term_height ();
+ if (height_diff || width_diff)
+ {
+ enum tui_layout_type cur_layout = tui_current_layout ();
+ struct tui_win_info *win_with_focus = tui_win_with_focus ();
+ struct tui_win_info *first_win;
+ struct tui_win_info *second_win;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+ enum tui_win_type win_type;
+ int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
+
+#ifdef HAVE_RESIZE_TERM
+ resize_term (screenheight, screenwidth);
+#endif
+ /* Turn keypad off while we resize. */
+ if (win_with_focus != TUI_CMD_WIN)
+ keypad (TUI_CMD_WIN->generic.handle, FALSE);
+ tui_update_gdb_sizes ();
+ tui_set_term_height_to (screenheight);
+ tui_set_term_width_to (screenwidth);
+ if (cur_layout == SRC_DISASSEM_COMMAND
+ || cur_layout == SRC_DATA_COMMAND
+ || cur_layout == DISASSEM_DATA_COMMAND)
+ num_wins_displayed++;
+ split_diff = height_diff / num_wins_displayed;
+ cmd_split_diff = split_diff;
+ if (height_diff % num_wins_displayed)
+ {
+ if (height_diff < 0)
+ cmd_split_diff--;
+ else
+ cmd_split_diff++;
+ }
+ /* Now adjust each window. */
+ clear ();
+ refresh ();
+ switch (cur_layout)
+ {
+ case SRC_COMMAND:
+ case DISASSEM_COMMAND:
+ first_win = (struct tui_win_info *) (tui_source_windows ())->list[0];
+ first_win->generic.width += width_diff;
+ locator->width += width_diff;
+ /* Check for invalid heights. */
+ if (height_diff == 0)
+ new_height = first_win->generic.height;
+ else if ((first_win->generic.height + split_diff) >=
+ (screenheight - MIN_CMD_WIN_HEIGHT - 1))
+ new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1;
+ else if ((first_win->generic.height + split_diff) <= 0)
+ new_height = MIN_WIN_HEIGHT;
+ else
+ new_height = first_win->generic.height + split_diff;
+
+ make_invisible_and_set_new_height (first_win, new_height);
+ TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+ TUI_CMD_WIN->generic.width += width_diff;
+ new_height = screenheight - TUI_CMD_WIN->generic.origin.y;
+ make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
+ make_visible_with_new_height (first_win);
+ make_visible_with_new_height (TUI_CMD_WIN);
+ if (first_win->generic.content_size <= 0)
+ tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
+ break;
+ default:
+ if (cur_layout == SRC_DISASSEM_COMMAND)
+ {
+ first_win = TUI_SRC_WIN;
+ first_win->generic.width += width_diff;
+ second_win = TUI_DISASM_WIN;
+ second_win->generic.width += width_diff;
+ }
+ else
+ {
+ first_win = TUI_DATA_WIN;
+ first_win->generic.width += width_diff;
+ second_win = (struct tui_win_info *) (tui_source_windows ())->list[0];
+ second_win->generic.width += width_diff;
+ }
+ /* Change the first window's height/width. */
+ /* Check for invalid heights. */
+ if (height_diff == 0)
+ new_height = first_win->generic.height;
+ else if ((first_win->generic.height +
+ second_win->generic.height + (split_diff * 2)) >=
+ (screenheight - MIN_CMD_WIN_HEIGHT - 1))
+ new_height = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2;
+ else if ((first_win->generic.height + split_diff) <= 0)
+ new_height = MIN_WIN_HEIGHT;
+ else
+ new_height = first_win->generic.height + split_diff;
+ make_invisible_and_set_new_height (first_win, new_height);
+
+ locator->width += width_diff;
+
+ /* Change the second window's height/width. */
+ /* Check for invalid heights. */
+ if (height_diff == 0)
+ new_height = second_win->generic.height;
+ else if ((first_win->generic.height +
+ second_win->generic.height + (split_diff * 2)) >=
+ (screenheight - MIN_CMD_WIN_HEIGHT - 1))
+ {
+ new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1;
+ if (new_height % 2)
+ new_height = (new_height / 2) + 1;
+ else
+ new_height /= 2;
+ }
+ else if ((second_win->generic.height + split_diff) <= 0)
+ new_height = MIN_WIN_HEIGHT;
+ else
+ new_height = second_win->generic.height + split_diff;
+ second_win->generic.origin.y = first_win->generic.height - 1;
+ make_invisible_and_set_new_height (second_win, new_height);
+
+ /* Change the command window's height/width. */
+ TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+ make_invisible_and_set_new_height (
+ TUI_CMD_WIN, TUI_CMD_WIN->generic.height + cmd_split_diff);
+ make_visible_with_new_height (first_win);
+ make_visible_with_new_height (second_win);
+ make_visible_with_new_height (TUI_CMD_WIN);
+ if (first_win->generic.content_size <= 0)
+ tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
+ if (second_win->generic.content_size <= 0)
+ tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
+ break;
+ }
+ /* Now remove all invisible windows, and their content so that
+ they get created again when called for with the new size. */
+ for (win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
+ {
+ if (win_type != CMD_WIN
+ && (tui_win_list[win_type] != NULL)
+ && !tui_win_list[win_type]->generic.is_visible)
+ {
+ tui_free_window (tui_win_list[win_type]);
+ tui_win_list[win_type] = (struct tui_win_info *) NULL;
+ }
+ }
+ tui_set_win_resized_to (TRUE);
+ /* Turn keypad back on, unless focus is in the command
+ window. */
+ if (win_with_focus != TUI_CMD_WIN)
+ keypad (TUI_CMD_WIN->generic.handle, TRUE);
+ }
+}
+
+
+/* SIGWINCH signal handler for the tui. This signal handler is always
+ called, even when the readline package clears signals because it is
+ set as the old_sigwinch() (TUI only). */
+void
+tui_sigwinch_handler (int signal)
+{
+ /* Say that a resize was done so that the readline can do it later
+ when appropriate. */
+ tui_set_win_resized_to (TRUE);
+}
+
+/* Initializes SIGWINCH signal handler for the tui. */
+void
+tui_initialize_win (void)
+{
+#ifdef SIGWINCH
+#ifdef HAVE_SIGACTION
+ struct sigaction old_winch;
+ memset (&old_winch, 0, sizeof (old_winch));
+ old_winch.sa_handler = &tui_sigwinch_handler;
+ sigaction (SIGWINCH, &old_winch, NULL);
+#else
+ signal (SIGWINCH, &tui_sigwinch_handler);
+#endif
+#endif
+}
+
+
+/*************************
+** STATIC LOCAL FUNCTIONS
+**************************/
+
+
+static void
+tui_scroll_forward_command (char *arg, int from_tty)
+{
+ int num_to_scroll = 1;
+ struct tui_win_info *win_to_scroll;
+
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ if (arg == (char *) NULL)
+ parse_scrolling_args (arg, &win_to_scroll, (int *) NULL);
+ else
+ parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
+ tui_scroll (FORWARD_SCROLL, win_to_scroll, num_to_scroll);
+}
+
+
+static void
+tui_scroll_backward_command (char *arg, int from_tty)
+{
+ int num_to_scroll = 1;
+ struct tui_win_info *win_to_scroll;
+
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ if (arg == (char *) NULL)
+ parse_scrolling_args (arg, &win_to_scroll, (int *) NULL);
+ else
+ parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
+ tui_scroll (BACKWARD_SCROLL, win_to_scroll, num_to_scroll);
+}
+
+
+static void
+tui_scroll_left_command (char *arg, int from_tty)
+{
+ int num_to_scroll;
+ struct tui_win_info *win_to_scroll;
+
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
+ tui_scroll (LEFT_SCROLL, win_to_scroll, num_to_scroll);
+}
+
+
+static void
+tui_scroll_right_command (char *arg, int from_tty)
+{
+ int num_to_scroll;
+ struct tui_win_info *win_to_scroll;
+
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
+ tui_scroll (RIGHT_SCROLL, win_to_scroll, num_to_scroll);
+}
+
+
+/* Set focus to the window named by 'arg'. */
+static void
+tui_set_focus (char *arg, int from_tty)
+{
+ if (arg != (char *) NULL)
+ {
+ char *buf_ptr = (char *) xstrdup (arg);
+ int i;
+ struct tui_win_info *win_info = (struct tui_win_info *) NULL;
+
+ for (i = 0; (i < strlen (buf_ptr)); i++)
+ buf_ptr[i] = toupper (arg[i]);
+
+ if (subset_compare (buf_ptr, "NEXT"))
+ win_info = tui_next_win (tui_win_with_focus ());
+ else if (subset_compare (buf_ptr, "PREV"))
+ win_info = tui_prev_win (tui_win_with_focus ());
+ else
+ win_info = tui_partial_win_by_name (buf_ptr);
+
+ if (win_info == (struct tui_win_info *) NULL
+ || !win_info->generic.is_visible)
+ warning (_("Invalid window specified. \n\
+The window name specified must be valid and visible.\n"));
+ else
+ {
+ tui_set_win_focus_to (win_info);
+ keypad (TUI_CMD_WIN->generic.handle, (win_info != TUI_CMD_WIN));
+ }
+
+ if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible)
+ tui_refresh_data_win ();
+ xfree (buf_ptr);
+ printf_filtered (_("Focus set to %s window.\n"),
+ tui_win_name ((struct tui_gen_win_info *) tui_win_with_focus ()));
+ }
+ else
+ warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE);
+}
+
+static void
+tui_set_focus_command (char *arg, int from_tty)
+{
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ tui_set_focus (arg, from_tty);
+}
+
+
+static void
+tui_all_windows_info (char *arg, int from_tty)
+{
+ enum tui_win_type type;
+ struct tui_win_info *win_with_focus = tui_win_with_focus ();
+
+ for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
+ if (tui_win_list[type]
+ && tui_win_list[type]->generic.is_visible)
+ {
+ if (win_with_focus == tui_win_list[type])
+ printf_filtered (" %s\t(%d lines) \n",
+ tui_win_name (&tui_win_list[type]->generic),
+ tui_win_list[type]->generic.height);
+ else
+ printf_filtered (" %s\t(%d lines)\n",
+ tui_win_name (&tui_win_list[type]->generic),
+ tui_win_list[type]->generic.height);
+ }
+}
+
+
+static void
+tui_refresh_all_command (char *arg, int from_tty)
+{
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+
+ tui_refresh_all_win ();
+}
+
+
+/* Set the height of the specified window. */
+static void
+tui_set_tab_width_command (char *arg, int from_tty)
+{
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ if (arg != (char *) NULL)
+ {
+ int ts;
+
+ ts = atoi (arg);
+ if (ts > 0)
+ tui_set_default_tab_len (ts);
+ else
+ warning (_("Tab widths greater than 0 must be specified."));
+ }
+}
+
+
+/* Set the height of the specified window. */
+static void
+tui_set_win_height (char *arg, int from_tty)
+{
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ if (arg != (char *) NULL)
+ {
+ char *buf = xstrdup (arg);
+ char *buf_ptr = buf;
+ char *wname = (char *) NULL;
+ int new_height, i;
+ struct tui_win_info *win_info;
+
+ wname = buf_ptr;
+ buf_ptr = strchr (buf_ptr, ' ');
+ if (buf_ptr != (char *) NULL)
+ {
+ *buf_ptr = (char) 0;
+
+ /* Validate the window name. */
+ for (i = 0; i < strlen (wname); i++)
+ wname[i] = toupper (wname[i]);
+ win_info = tui_partial_win_by_name (wname);
+
+ if (win_info == (struct tui_win_info *) NULL
+ || !win_info->generic.is_visible)
+ warning (_("Invalid window specified. \n\
+The window name specified must be valid and visible.\n"));
+ else
+ {
+ /* Process the size. */
+ while (*(++buf_ptr) == ' ')
+ ;
+
+ if (*buf_ptr != (char) 0)
+ {
+ int negate = FALSE;
+ int fixed_size = TRUE;
+ int input_no;;
+
+ if (*buf_ptr == '+' || *buf_ptr == '-')
+ {
+ if (*buf_ptr == '-')
+ negate = TRUE;
+ fixed_size = FALSE;
+ buf_ptr++;
+ }
+ input_no = atoi (buf_ptr);
+ if (input_no > 0)
+ {
+ if (negate)
+ input_no *= (-1);
+ if (fixed_size)
+ new_height = input_no;
+ else
+ new_height = win_info->generic.height + input_no;
+
+ /* Now change the window's height, and adjust
+ all other windows around it. */
+ if (tui_adjust_win_heights (win_info,
+ new_height) == TUI_FAILURE)
+ warning (_("Invalid window height specified.\n%s"),
+ WIN_HEIGHT_USAGE);
+ else
+ tui_update_gdb_sizes ();
+ }
+ else
+ warning (_("Invalid window height specified.\n%s"),
+ WIN_HEIGHT_USAGE);
+ }
+ }
+ }
+ else
+ printf_filtered (WIN_HEIGHT_USAGE);
+
+ if (buf != (char *) NULL)
+ xfree (buf);
+ }
+ else
+ printf_filtered (WIN_HEIGHT_USAGE);
+}
+
+/* Set the height of the specified window, with va_list. */
+static void
+tui_set_win_height_command (char *arg, int from_tty)
+{
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ tui_set_win_height (arg, from_tty);
+}
+
+
+/* XDB Compatibility command for setting the window height. This will
+ increase or decrease the command window by the specified
+ amount. */
+static void
+tui_xdb_set_win_height (char *arg, int from_tty)
+{
+ /* Make sure the curses mode is enabled. */
+ tui_enable ();
+ if (arg != (char *) NULL)
+ {
+ int input_no = atoi (arg);
+
+ if (input_no > 0)
+ { /* Add 1 for the locator. */
+ int new_height = tui_term_height () - (input_no + 1);
+
+ if (!new_height_ok (tui_win_list[CMD_WIN], new_height)
+ || tui_adjust_win_heights (tui_win_list[CMD_WIN],
+ new_height) == TUI_FAILURE)
+ warning (_("Invalid window height specified.\n%s"),
+ XDBWIN_HEIGHT_USAGE);
+ }
+ else
+ warning (_("Invalid window height specified.\n%s"),
+ XDBWIN_HEIGHT_USAGE);
+ }
+ else
+ warning (_("Invalid window height specified.\n%s"), XDBWIN_HEIGHT_USAGE);
+}
+
+/* Set the height of the specified window, with va_list. */
+static void
+tui_xdb_set_win_height_command (char *arg, int from_tty)
+{
+ tui_xdb_set_win_height (arg, from_tty);
+}
+
+
+/* Function to adjust all window heights around the primary. */
+static enum tui_status
+tui_adjust_win_heights (struct tui_win_info *primary_win_info,
+ int new_height)
+{
+ enum tui_status status = TUI_FAILURE;
+
+ if (new_height_ok (primary_win_info, new_height))
+ {
+ status = TUI_SUCCESS;
+ if (new_height != primary_win_info->generic.height)
+ {
+ int diff;
+ struct tui_win_info *win_info;
+ struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
+ enum tui_layout_type cur_layout = tui_current_layout ();
+
+ diff = (new_height - primary_win_info->generic.height) * (-1);
+ if (cur_layout == SRC_COMMAND
+ || cur_layout == DISASSEM_COMMAND)
+ {
+ struct tui_win_info *src_win_info;
+
+ make_invisible_and_set_new_height (primary_win_info, new_height);
+ if (primary_win_info->generic.type == CMD_WIN)
+ {
+ win_info = (tui_source_windows ())->list[0];
+ src_win_info = win_info;
+ }
+ else
+ {
+ win_info = tui_win_list[CMD_WIN];
+ src_win_info = primary_win_info;
+ }
+ make_invisible_and_set_new_height (win_info,
+ win_info->generic.height + diff);
+ TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+ make_visible_with_new_height (win_info);
+ make_visible_with_new_height (primary_win_info);
+ if (src_win_info->generic.content_size <= 0)
+ tui_erase_source_content (src_win_info, EMPTY_SOURCE_PROMPT);
+ }
+ else
+ {
+ struct tui_win_info *first_win;
+ struct tui_win_info *second_win;
+
+ if (cur_layout == SRC_DISASSEM_COMMAND)
+ {
+ first_win = TUI_SRC_WIN;
+ second_win = TUI_DISASM_WIN;
+ }
+ else
+ {
+ first_win = TUI_DATA_WIN;
+ second_win = (tui_source_windows ())->list[0];
+ }
+ if (primary_win_info == TUI_CMD_WIN)
+ { /* Split the change in height accross the 1st & 2nd
+ windows, adjusting them as well. */
+ /* Subtract the locator. */
+ int first_split_diff = diff / 2;
+ int second_split_diff = first_split_diff;
+
+ if (diff % 2)
+ {
+ if (first_win->generic.height >
+ second_win->generic.height)
+ if (diff < 0)
+ first_split_diff--;
+ else
+ first_split_diff++;
+ else
+ {
+ if (diff < 0)
+ second_split_diff--;
+ else
+ second_split_diff++;
+ }
+ }
+ /* Make sure that the minimum hieghts are
+ honored. */
+ while ((first_win->generic.height + first_split_diff) < 3)
+ {
+ first_split_diff++;
+ second_split_diff--;
+ }
+ while ((second_win->generic.height + second_split_diff) < 3)
+ {
+ second_split_diff++;
+ first_split_diff--;
+ }
+ make_invisible_and_set_new_height (
+ first_win,
+ first_win->generic.height + first_split_diff);
+ second_win->generic.origin.y = first_win->generic.height - 1;
+ make_invisible_and_set_new_height (
+ second_win, second_win->generic.height + second_split_diff);
+ TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+ make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
+ }
+ else
+ {
+ if ((TUI_CMD_WIN->generic.height + diff) < 1)
+ { /* If there is no way to increase the command
+ window take real estate from the 1st or 2nd
+ window. */
+ if ((TUI_CMD_WIN->generic.height + diff) < 1)
+ {
+ int i;
+ for (i = TUI_CMD_WIN->generic.height + diff;
+ (i < 1); i++)
+ if (primary_win_info == first_win)
+ second_win->generic.height--;
+ else
+ first_win->generic.height--;
+ }
+ }
+ if (primary_win_info == first_win)
+ make_invisible_and_set_new_height (first_win, new_height);
+ else
+ make_invisible_and_set_new_height (
+ first_win,
+ first_win->generic.height);
+ second_win->generic.origin.y = first_win->generic.height - 1;
+ if (primary_win_info == second_win)
+ make_invisible_and_set_new_height (second_win, new_height);
+ else
+ make_invisible_and_set_new_height (
+ second_win, second_win->generic.height);
+ TUI_CMD_WIN->generic.origin.y = locator->origin.y + 1;
+ if ((TUI_CMD_WIN->generic.height + diff) < 1)
+ make_invisible_and_set_new_height (TUI_CMD_WIN, 1);
+ else
+ make_invisible_and_set_new_height (
+ TUI_CMD_WIN, TUI_CMD_WIN->generic.height + diff);
+ }
+ make_visible_with_new_height (TUI_CMD_WIN);
+ make_visible_with_new_height (second_win);
+ make_visible_with_new_height (first_win);
+ if (first_win->generic.content_size <= 0)
+ tui_erase_source_content (first_win, EMPTY_SOURCE_PROMPT);
+ if (second_win->generic.content_size <= 0)
+ tui_erase_source_content (second_win, EMPTY_SOURCE_PROMPT);
+ }
+ }
+ }
+
+ return status;
+}
+
+
+/* Function make the target window (and auxillary windows associated
+ with the targer) invisible, and set the new height and
+ location. */
+static void
+make_invisible_and_set_new_height (struct tui_win_info *win_info,
+ int height)
+{
+ int i;
+ struct tui_gen_win_info *gen_win_info;
+
+ tui_make_invisible (&win_info->generic);
+ win_info->generic.height = height;
+ if (height > 1)
+ win_info->generic.viewport_height = height - 1;
+ else
+ win_info->generic.viewport_height = height;
+ if (win_info != TUI_CMD_WIN)
+ win_info->generic.viewport_height--;
+
+ /* Now deal with the auxillary windows associated with win_info. */
+ switch (win_info->generic.type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ gen_win_info = win_info->detail.source_info.execution_info;
+ tui_make_invisible (gen_win_info);
+ gen_win_info->height = height;
+ gen_win_info->origin.y = win_info->generic.origin.y;
+ if (height > 1)
+ gen_win_info->viewport_height = height - 1;
+ else
+ gen_win_info->viewport_height = height;
+ if (win_info != TUI_CMD_WIN)
+ gen_win_info->viewport_height--;
+
+ if (tui_win_has_locator (win_info))
+ {
+ gen_win_info = tui_locator_win_info_ptr ();
+ tui_make_invisible (gen_win_info);
+ gen_win_info->origin.y = win_info->generic.origin.y + height;
+ }
+ break;
+ case DATA_WIN:
+ /* Delete all data item windows. */
+ for (i = 0; i < win_info->generic.content_size; i++)
+ {
+ gen_win_info = (struct tui_gen_win_info *) & ((struct tui_win_element *)
+ win_info->generic.content[i])->which_element.data_window;
+ tui_delete_win (gen_win_info->handle);
+ gen_win_info->handle = (WINDOW *) NULL;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+
+/* Function to make the windows with new heights visible. This means
+ re-creating the windows' content since the window had to be
+ destroyed to be made invisible. */
+static void
+make_visible_with_new_height (struct tui_win_info *win_info)
+{
+ struct symtab *s;
+
+ tui_make_visible (&win_info->generic);
+ tui_check_and_display_highlight_if_needed (win_info);
+ switch (win_info->generic.type)
+ {
+ case SRC_WIN:
+ case DISASSEM_WIN:
+ tui_free_win_content (win_info->detail.source_info.execution_info);
+ tui_make_visible (win_info->detail.source_info.execution_info);
+ if (win_info->generic.content != NULL)
+ {
+ struct tui_line_or_address line_or_addr;
+ struct symtab_and_line cursal
+ = get_current_source_symtab_and_line ();
+
+ line_or_addr = win_info->detail.source_info.start_line_or_addr;
+ tui_free_win_content (&win_info->generic);
+ tui_update_source_window (win_info, cursal.symtab, line_or_addr, TRUE);
+ }
+ else if (deprecated_safe_get_selected_frame () != NULL)
+ {
+ struct tui_line_or_address line;
+ struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ struct frame_info *frame = deprecated_safe_get_selected_frame ();
+
+ s = find_pc_symtab (get_frame_pc (frame));
+ if (win_info->generic.type == SRC_WIN)
+ {
+ line.loa = LOA_LINE;
+ line.u.line_no = cursal.line;
+ }
+ else
+ {
+ line.loa = LOA_ADDRESS;
+ find_line_pc (s, cursal.line, &line.u.addr);
+ }
+ tui_update_source_window (win_info, s, line, TRUE);
+ }
+ if (tui_win_has_locator (win_info))
+ {
+ tui_make_visible (tui_locator_win_info_ptr ());
+ tui_show_locator_content ();
+ }
+ break;
+ case DATA_WIN:
+ tui_display_all_data ();
+ break;
+ case CMD_WIN:
+ win_info->detail.command_info.cur_line = 0;
+ win_info->detail.command_info.curch = 0;
+ wmove (win_info->generic.handle,
+ win_info->detail.command_info.cur_line,
+ win_info->detail.command_info.curch);
+ break;
+ default:
+ break;
+ }
+}
+
+
+static int
+new_height_ok (struct tui_win_info *primary_win_info,
+ int new_height)
+{
+ int ok = (new_height < tui_term_height ());
+
+ if (ok)
+ {
+ int diff;
+ enum tui_layout_type cur_layout = tui_current_layout ();
+
+ diff = (new_height - primary_win_info->generic.height) * (-1);
+ if (cur_layout == SRC_COMMAND || cur_layout == DISASSEM_COMMAND)
+ {
+ ok = ((primary_win_info->generic.type == CMD_WIN
+ && new_height <= (tui_term_height () - 4)
+ && new_height >= MIN_CMD_WIN_HEIGHT)
+ || (primary_win_info->generic.type != CMD_WIN
+ && new_height <= (tui_term_height () - 2)
+ && new_height >= MIN_WIN_HEIGHT));
+ if (ok)
+ { /* Check the total height. */
+ struct tui_win_info *win_info;
+
+ if (primary_win_info == TUI_CMD_WIN)
+ win_info = (tui_source_windows ())->list[0];
+ else
+ win_info = TUI_CMD_WIN;
+ ok = ((new_height +
+ (win_info->generic.height + diff)) <= tui_term_height ());
+ }
+ }
+ else
+ {
+ int cur_total_height, total_height, min_height = 0;
+ struct tui_win_info *first_win;
+ struct tui_win_info *second_win;
+
+ if (cur_layout == SRC_DISASSEM_COMMAND)
+ {
+ first_win = TUI_SRC_WIN;
+ second_win = TUI_DISASM_WIN;
+ }
+ else
+ {
+ first_win = TUI_DATA_WIN;
+ second_win = (tui_source_windows ())->list[0];
+ }
+ /* We could simply add all the heights to obtain the same
+ result but below is more explicit since we subtract 1 for
+ the line that the first and second windows share, and add
+ one for the locator. */
+ total_height = cur_total_height =
+ (first_win->generic.height + second_win->generic.height - 1)
+ + TUI_CMD_WIN->generic.height + 1; /* Locator. */
+ if (primary_win_info == TUI_CMD_WIN)
+ {
+ /* Locator included since first & second win share a line. */
+ ok = ((first_win->generic.height +
+ second_win->generic.height + diff) >=
+ (MIN_WIN_HEIGHT * 2)
+ && new_height >= MIN_CMD_WIN_HEIGHT);
+ if (ok)
+ {
+ total_height = new_height +
+ (first_win->generic.height +
+ second_win->generic.height + diff);
+ min_height = MIN_CMD_WIN_HEIGHT;
+ }
+ }
+ else
+ {
+ min_height = MIN_WIN_HEIGHT;
+
+ /* First see if we can increase/decrease the command
+ window. And make sure that the command window is at
+ least 1 line. */
+ ok = ((TUI_CMD_WIN->generic.height + diff) > 0);
+ if (!ok)
+ { /* Looks like we have to increase/decrease one of
+ the other windows. */
+ if (primary_win_info == first_win)
+ ok = (second_win->generic.height + diff) >= min_height;
+ else
+ ok = (first_win->generic.height + diff) >= min_height;
+ }
+ if (ok)
+ {
+ if (primary_win_info == first_win)
+ total_height = new_height +
+ second_win->generic.height +
+ TUI_CMD_WIN->generic.height + diff;
+ else
+ total_height = new_height +
+ first_win->generic.height +
+ TUI_CMD_WIN->generic.height + diff;
+ }
+ }
+ /* Now make sure that the proposed total height doesn't
+ exceed the old total height. */
+ if (ok)
+ ok = (new_height >= min_height
+ && total_height <= cur_total_height);
+ }
+ }
+
+ return ok;
+}
+
+
+static void
+parse_scrolling_args (char *arg,
+ struct tui_win_info **win_to_scroll,
+ int *num_to_scroll)
+{
+ if (num_to_scroll)
+ *num_to_scroll = 0;
+ *win_to_scroll = tui_win_with_focus ();
+
+ /* First set up the default window to scroll, in case there is no
+ window name arg. */
+ if (arg != (char *) NULL)
+ {
+ char *buf, *buf_ptr;
+
+ /* Process the number of lines to scroll. */
+ buf = buf_ptr = xstrdup (arg);
+ if (isdigit (*buf_ptr))
+ {
+ char *num_str;
+
+ num_str = buf_ptr;
+ buf_ptr = strchr (buf_ptr, ' ');
+ if (buf_ptr != (char *) NULL)
+ {
+ *buf_ptr = (char) 0;
+ if (num_to_scroll)
+ *num_to_scroll = atoi (num_str);
+ buf_ptr++;
+ }
+ else if (num_to_scroll)
+ *num_to_scroll = atoi (num_str);
+ }
+
+ /* Process the window name if one is specified. */
+ if (buf_ptr != (char *) NULL)
+ {
+ char *wname;
+ int i;
+
+ if (*buf_ptr == ' ')
+ while (*(++buf_ptr) == ' ')
+ ;
+
+ if (*buf_ptr != (char) 0)
+ wname = buf_ptr;
+ else
+ wname = "?";
+
+ /* Validate the window name. */
+ for (i = 0; i < strlen (wname); i++)
+ wname[i] = toupper (wname[i]);
+ *win_to_scroll = tui_partial_win_by_name (wname);
+
+ if (*win_to_scroll == (struct tui_win_info *) NULL
+ || !(*win_to_scroll)->generic.is_visible)
+ error (_("Invalid window specified. \n\
+The window name specified must be valid and visible.\n"));
+ else if (*win_to_scroll == TUI_CMD_WIN)
+ *win_to_scroll = (tui_source_windows ())->list[0];
+ }
+ xfree (buf);
+ }
+}
tui-win.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property