diff options
-rw-r--r-- | gdb/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/tui/tui-data.c | 9 | ||||
-rw-r--r-- | gdb/tui/tui-data.h | 14 | ||||
-rw-r--r-- | gdb/tui/tui-disasm.c | 23 | ||||
-rw-r--r-- | gdb/tui/tui-layout.c | 4 | ||||
-rw-r--r-- | gdb/tui/tui-source.c | 33 | ||||
-rw-r--r-- | gdb/tui/tui-source.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-stack.c | 14 | ||||
-rw-r--r-- | gdb/tui/tui-win.c | 19 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.c | 56 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.h | 6 |
11 files changed, 119 insertions, 71 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4b12983..769139d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +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. diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 800d72a..746e85b 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -207,7 +207,8 @@ tui_clear_win_detail (struct tui_win_info * win_info) { 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: @@ -486,7 +487,8 @@ init_content_element (struct tui_win_element * element, enum tui_win_type type) 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; @@ -537,7 +539,8 @@ init_win_info (struct tui_win_info * win_info) 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: diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 02bebb4..4a6c413 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -147,10 +147,14 @@ enum tui_register_display_type }; /* 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 */ @@ -166,7 +170,7 @@ struct tui_layout_def 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; }; @@ -259,7 +263,7 @@ struct tui_source_info /* 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; }; diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 9c3072b..aa5a62c 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -188,7 +188,8 @@ tui_set_disassem_content (CORE_ADDR pc) 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); @@ -249,7 +250,8 @@ tui_set_disassem_content (CORE_ADDR pc) 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. */ @@ -270,9 +272,10 @@ tui_show_disassem (CORE_ADDR start_addr) { struct symtab *s = find_pc_symtab (start_addr); struct tui_win_info * win_with_focus = tui_win_with_focus (); - union tui_line_or_address val; + 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); /* @@ -295,14 +298,15 @@ tui_show_disassem_and_update_source (CORE_ADDR start_addr) 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) { @@ -376,7 +380,7 @@ tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction, 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 (); @@ -388,10 +392,11 @@ tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction, /* 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); } } diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index d2d8efe..5b65533 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -519,14 +519,14 @@ extract_display_start_addr (void) 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; diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index d5154b1..2710f98 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -106,7 +106,8 @@ tui_set_source_content (struct symtab *s, int line_no, int noerror) 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)); @@ -137,7 +138,9 @@ tui_set_source_content (struct symtab *s, int line_no, int noerror) /* 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 *) @@ -247,7 +250,8 @@ tui_set_source_content_nil (struct tui_win_info * win_info, char *warning_string 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; @@ -295,7 +299,7 @@ tui_set_source_content_nil (struct tui_win_info * win_info, char *warning_string /* 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); @@ -320,7 +324,7 @@ tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction, { 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 (); @@ -330,23 +334,24 @@ tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction, 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); } } diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 3b61ca4..4e49488 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -33,7 +33,7 @@ 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 *, 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); diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index c0a1b82..bba77fd 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -364,14 +364,15 @@ tui_show_frame_info (struct frame_info *fi) 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); } } @@ -379,13 +380,14 @@ tui_show_frame_info (struct frame_info *fi) { 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); } } diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index cdd2550..739c53c 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -1322,31 +1322,30 @@ make_visible_with_new_height (struct tui_win_info * 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); } diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index de19d25..d5c786d 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -41,6 +41,7 @@ #include "gdb_string.h" #include "gdb_curses.h" +#include "gdb_assert.h" /* Function to display the "main" routine. */ void @@ -71,7 +72,7 @@ tui_display_main (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); @@ -84,14 +85,14 @@ tui_update_source_window (struct tui_win_info * win_info, struct symtab *s, 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) { @@ -107,7 +108,7 @@ tui_update_source_window_as_is (struct tui_win_info * win_info, struct symtab *s { 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); @@ -134,7 +135,7 @@ tui_update_source_windows_with_addr (CORE_ADDR addr) if (addr != 0) { struct symtab_and_line sal; - union tui_line_or_address l; + struct tui_line_or_address l; switch (tui_current_layout ()) { @@ -147,7 +148,8 @@ tui_update_source_windows_with_addr (CORE_ADDR addr) 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; } @@ -172,7 +174,7 @@ void 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 ()) { @@ -182,7 +184,8 @@ tui_update_source_windows_with_line (struct symtab *s, int line) 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) { @@ -336,7 +339,7 @@ tui_horizontal_source_scroll (struct tui_win_info * win_info, /* 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; @@ -346,8 +349,15 @@ tui_set_is_exec_point_at (union tui_line_or_address l, struct tui_win_info * win 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; @@ -414,12 +424,16 @@ tui_update_breakpoint_info (struct tui_win_info * win, int current_only) 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; @@ -614,8 +628,11 @@ tui_line_is_displayed (int line, struct tui_win_info * win_info, 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++; } @@ -640,8 +657,11 @@ tui_addr_is_displayed (CORE_ADDR addr, struct tui_win_info * win_info, 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++; } diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index e64589b..d45c589 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -43,10 +43,10 @@ extern int tui_update_breakpoint_info (struct tui_win_info * win, /* 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); @@ -60,7 +60,7 @@ 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 (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); |