+2005-11-01 Andrew Stubbs <andrew.stubbs@st.com>
+
+ * tui/tui-data.h (tui_line_or_address): Encapsulate the union in a
+ struct with a tag.
+ (tui_source_element, tui_source_info): Update.
+ * tui/tui-disasm.c, tui/tui-source.c: Update to use the tagged union.
+ * tui/tui-source.h, tui/tui-stack.c, tui/tui-win.c: Likewise.
+ * tui/tui-winsource.c, tui/tui-data.c, tui/tui-layout.c: Likewise.
+ * tui/tui-winsource.h: Likewise.
+
2005-11-01 Christopher Faylor <cgf@timesys.com>
* win32-nat.c (CYGWIN_SIGNAL_STRING): Delete.
{
case SRC_WIN:
case DISASSEM_WIN:
- win_info->detail.source_info.start_line_or_addr.addr = 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.horizontal_offset = 0;
break;
case CMD_WIN:
case SRC_WIN:
case DISASSEM_WIN:
element->which_element.source.line = (char *) NULL;
- element->which_element.source.line_or_addr.line_no = 0;
+ 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;
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.addr = 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:
};
/* Structure describing source line or line address */
-union tui_line_or_address
+struct tui_line_or_address
{
- int line_no;
- CORE_ADDR addr;
+ enum { LOA_LINE, LOA_ADDRESS } loa;
+ union
+ {
+ int line_no;
+ CORE_ADDR addr;
+ } u;
};
/* Current Layout definition */
struct tui_source_element
{
char *line;
- union tui_line_or_address line_or_addr;
+ struct tui_line_or_address line_or_addr;
int is_exec_point;
int has_break;
};
/* Execution information window. */
struct tui_gen_win_info *execution_info;
int horizontal_offset; /* used for horizontal scroll */
- union tui_line_or_address start_line_or_addr;
+ struct tui_line_or_address start_line_or_addr;
char* filename;
};
if (ret != TUI_SUCCESS)
return ret;
- TUI_DISASM_WIN->detail.source_info.start_line_or_addr.addr = pc;
+ 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);
else
src->line[0] = '\0';
- src->line_or_addr.addr = asm_lines[i].addr;
+ 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. */
{
struct symtab *s = find_pc_symtab (start_addr);
struct tui_win_info * win_with_focus = tui_win_with_focus ();
- union tui_line_or_address val;
+ struct tui_line_or_address val;
- val.addr = start_addr;
+ 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);
/*
tui_show_disassem (start_addr);
if (tui_current_layout () == SRC_DISASSEM_COMMAND)
{
- union tui_line_or_address val;
+ 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.line_no = sal.line;
+ val.loa = LOA_LINE;
+ val.u.line_no = sal.line;
tui_update_source_window (TUI_SRC_WIN, sal.symtab, val, TRUE);
if (sal.symtab)
{
CORE_ADDR pc;
tui_win_content content;
struct symtab *s;
- union tui_line_or_address val;
+ struct tui_line_or_address val;
int max_lines, dir;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
/* account for hilite */
max_lines = TUI_DISASM_WIN->generic.height - 2;
- pc = content[0]->which_element.source.line_or_addr.addr;
+ pc = content[0]->which_element.source.line_or_addr.u.addr;
dir = (scroll_direction == FORWARD_SCROLL) ? max_lines : - max_lines;
- val.addr = tui_find_disassembly_address (pc, dir);
+ 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);
}
}
case SRC_COMMAND:
case SRC_DATA_COMMAND:
find_line_pc (cursal.symtab,
- TUI_SRC_WIN->detail.source_info.start_line_or_addr.line_no,
+ 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.addr;
+ addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
break;
default:
addr = 0;
stream = fdopen (desc, FOPEN_RT);
clearerr (stream);
cur_line = 0;
- cur_line_no = src->start_line_or_addr.line_no = line_no;
+ 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));
/* Set whether element is the execution point and
whether there is a break point on it. */
- element->which_element.source.line_or_addr.line_no =
+ 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 *)
struct tui_win_element * element =
(struct tui_win_element *) win_info->generic.content[curr_line];
- element->which_element.source.line_or_addr.line_no = 0;
+ 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;
/* Function to display source in the source window. This function
initializes the horizontal scroll to 0. */
void
-tui_show_symtab_source (struct symtab *s, union tui_line_or_address line, int noerror)
+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);
{
if (TUI_SRC_WIN->generic.content != NULL)
{
- union tui_line_or_address l;
+ 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 ();
else
s = cursal.symtab;
+ l.loa = LOA_LINE;
if (scroll_direction == FORWARD_SCROLL)
{
- l.line_no = content[0]->which_element.source.line_or_addr.line_no +
- num_to_scroll;
- if (l.line_no > s->nlines)
+ 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.line_no = content[0]->which_element.source.line_or_addr.line_no;
+ l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no;
}
else
{
- l.line_no = content[0]->which_element.source.line_or_addr.line_no -
- num_to_scroll;
- if (l.line_no <= 0)
- l.line_no = 1;
+ 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.line_no, l.line_no + 1, 0);
+ print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
}
}
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 *, union tui_line_or_address, 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);
if (win_info == TUI_SRC_WIN)
{
- union tui_line_or_address l;
- l.line_no = start_line;
+ 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.line_no = item->locator.line_no;
+ l.u.line_no = item->locator.line_no;
tui_set_is_exec_point_at (l, win_info);
}
}
{
if (win_info == TUI_DISASM_WIN)
{
- union tui_line_or_address a;
- a.addr = low;
+ 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.addr = item->locator.addr;
+ a.u.addr = item->locator.addr;
tui_set_is_exec_point_at (a, win_info);
}
}
tui_make_visible (win_info->detail.source_info.execution_info);
if (win_info->generic.content != NULL)
{
- union tui_line_or_address line_or_addr;
+ struct tui_line_or_address line_or_addr;
struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
- if (win_info->generic.type == SRC_WIN)
- line_or_addr.line_no =
- win_info->detail.source_info.start_line_or_addr.line_no;
- else
- line_or_addr.addr =
- win_info->detail.source_info.start_line_or_addr.addr;
+ 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_selected_frame != (struct frame_info *) NULL)
{
- union tui_line_or_address line;
+ struct tui_line_or_address line;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
if (win_info->generic.type == SRC_WIN)
- line.line_no = cursal.line;
+ {
+ line.loa = LOA_LINE;
+ line.u.line_no = cursal.line;
+ }
else
{
- find_line_pc (s, cursal.line, &line.addr);
+ line.loa = LOA_ADDRESS;
+ find_line_pc (s, cursal.line, &line.u.addr);
}
tui_update_source_window (win_info, s, line, TRUE);
}
#include "gdb_string.h"
#include "gdb_curses.h"
+#include "gdb_assert.h"
/* Function to display the "main" routine. */
void
initializes the horizontal scroll to 0. */
void
tui_update_source_window (struct tui_win_info * win_info, struct symtab *s,
- union tui_line_or_address line_or_addr, int noerror)
+ 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);
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,
- union tui_line_or_address line_or_addr, int noerror)
+ 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.line_no, noerror);
+ ret = tui_set_source_content (s, line_or_addr.u.line_no, noerror);
else
- ret = tui_set_disassem_content (line_or_addr.addr);
+ ret = tui_set_disassem_content (line_or_addr.u.addr);
if (ret == TUI_FAILURE)
{
{
struct symtab_and_line sal;
- sal.line = line_or_addr.line_no +
+ 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 (addr != 0)
{
struct symtab_and_line sal;
- union tui_line_or_address l;
+ struct tui_line_or_address l;
switch (tui_current_layout ())
{
break;
default:
sal = find_pc_line (addr, 0);
- l.line_no = sal.line;
+ l.loa = LOA_LINE;
+ l.u.line_no = sal.line;
tui_show_symtab_source (sal.symtab, l, FALSE);
break;
}
tui_update_source_windows_with_line (struct symtab *s, int line)
{
CORE_ADDR pc;
- union tui_line_or_address l;
+ struct tui_line_or_address l;
switch (tui_current_layout ())
{
tui_update_source_windows_with_addr (pc);
break;
default:
- l.line_no = line;
+ l.loa = LOA_LINE;
+ l.u.line_no = line;
tui_show_symtab_source (s, l, FALSE);
if (tui_current_layout () == SRC_DISASSEM_COMMAND)
{
/* Set or clear the has_break flag in the line whose line is line_no. */
void
-tui_set_is_exec_point_at (union tui_line_or_address l, struct tui_win_info * win_info)
+tui_set_is_exec_point_at (struct tui_line_or_address l, struct tui_win_info * win_info)
{
int changed = 0;
int i;
while (i < win_info->generic.content_size)
{
int new_state;
-
- if (content[i]->which_element.source.line_or_addr.addr == l.addr)
+ 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;
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)
- && bp->line_number == line->line_or_addr.line_no)
+ && line->line_or_addr.loa == LOA_LINE
+ && bp->line_number == line->line_or_addr.u.line_no)
|| (win == TUI_DISASM_WIN
- && bp->loc->address == line->line_or_addr.addr))
+ && 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;
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.line_no
- == (int) line);
+ 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++;
}
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.addr
- == addr);
+ 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++;
}
/* Function to display the "main" routine. */
extern void tui_display_main (void);
extern void tui_update_source_window (struct tui_win_info *, struct symtab *,
- union tui_line_or_address, int);
+ struct tui_line_or_address, int);
extern void tui_update_source_window_as_is (struct tui_win_info *,
struct symtab *,
- union tui_line_or_address, int);
+ 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_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 (union tui_line_or_address,
+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);