diff options
author | Tom Tromey <tom@tromey.com> | 2019-06-25 14:42:49 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-07-04 10:36:31 -0600 |
commit | 0598af4880f58af5ce7c15419551362646892c7f (patch) | |
tree | 86064bd52fa57b21c7b5a145b08c6cb2cd850a4b /gdb/tui | |
parent | 213fd9faf563ce5726ce66c8104cbaba44ba9c09 (diff) | |
download | binutils-0598af4880f58af5ce7c15419551362646892c7f.zip binutils-0598af4880f58af5ce7c15419551362646892c7f.tar.gz binutils-0598af4880f58af5ce7c15419551362646892c7f.tar.bz2 |
Fix TUI use of "has_break" field
The TUI uses the "has_break" in two different ways: sometimes as a
boolean, and sometimes as flags.
This patch changes the TUI to be more type-safe here, and fixes the
code. I could not find a bug that this caused, so apparently this is
just cosmetic.
This deletes some code from tui_set_disassem_content. Whenver this is
called, I believe the TUI updates the breakpoint information
afterward, so this assignment is redundant; which is good because it
is also incorrect.
gdb/ChangeLog
2019-07-04 Tom Tromey <tom@tromey.com>
PR tui/24724:
* tui/tui-winsource.c (tui_clear_source_content): Update.
(tui_source_window_base::set_is_exec_point_at): Fix comment.
(tui_update_breakpoint_info): Update.
(tui_set_exec_info_content): Update.
* tui/tui-source.c (tui_set_source_content_nil): Update.
* tui/tui-disasm.c (tui_set_disassem_content): Don't set
has_break.
* tui/tui-data.h (enum tui_bp_flag): New.
(tui_bp_flags): New enum flags type.
(struct tui_source_element) <break_mode>: Change type. Rename
from has_break.
(TUI_BP_ENABLED, TUI_BP_DISABLED, TUI_BP_HIT)
(TUI_BP_CONDITIONAL, TUI_BP_HARDWARE): Don't define. Now enum
constants.
* tui/tui-winsource.h: Fix comment.
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-data.h | 21 | ||||
-rw-r--r-- | gdb/tui/tui-disasm.c | 6 | ||||
-rw-r--r-- | gdb/tui/tui-source.c | 2 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.c | 17 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.h | 2 |
5 files changed, 23 insertions, 25 deletions
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 8991a4a..412be1c 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -164,6 +164,18 @@ struct tui_layout_def enum tui_win_type display_mode; }; +/* Flags to tell what kind of breakpoint is at current line. */ +enum tui_bp_flag +{ + TUI_BP_ENABLED = 0x01, + TUI_BP_DISABLED = 0x02, + TUI_BP_HIT = 0x04, + TUI_BP_CONDITIONAL = 0x08, + TUI_BP_HARDWARE = 0x10 +}; + +DEF_ENUM_FLAGS_TYPE (enum tui_bp_flag, tui_bp_flags); + /* Elements in the Source/Disassembly Window. */ struct tui_source_element { @@ -181,7 +193,7 @@ struct tui_source_element char *line = nullptr; struct tui_line_or_address line_or_addr; bool is_exec_point = false; - int has_break = 0; + tui_bp_flags break_mode = 0; }; @@ -191,13 +203,6 @@ struct tui_source_element # define MAX_LOCATOR_ELEMENT_LEN 1024 #endif -/* 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 diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 4899b1d..b22368e 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -239,12 +239,6 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc) 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 (current_program_space->aspace, - pc) - != no_breakpoint_here); - xfree (asm_lines[i].addr_string); xfree (asm_lines[i].insn); } diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 889b950..81ede06 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -240,7 +240,7 @@ tui_set_source_content_nil (struct tui_source_window_base *win_info, element->line_or_addr.loa = LOA_LINE; element->line_or_addr.u.line_no = 0; element->is_exec_point = false; - element->has_break = FALSE; + element->break_mode = 0; /* Set the contents of the line to blank. */ element->line[0] = (char) 0; diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 6ec1f1b..dbede41 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -217,7 +217,7 @@ tui_clear_source_content (struct tui_source_window_base *win_info, { struct tui_source_element *element = &win_info->content[i]; - element->has_break = FALSE; + element->break_mode = 0; element->is_exec_point = false; } } @@ -344,7 +344,7 @@ tui_source_window_base::do_scroll_horizontal (int num_to_scroll) } -/* Set or clear the has_break flag in the line whose line is +/* Set or clear the is_exec_point flag in the line whose line is line_no. */ void @@ -415,7 +415,6 @@ tui_update_breakpoint_info (struct tui_source_window_base *win, { struct breakpoint *bp; extern struct breakpoint *breakpoint_chain; - int mode; struct tui_source_element *line; line = &win->content[i]; @@ -425,7 +424,7 @@ tui_update_breakpoint_info (struct tui_source_window_base *win, /* 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; + tui_bp_flags mode = 0; for (bp = breakpoint_chain; bp != NULL; bp = bp->next) @@ -460,10 +459,10 @@ tui_update_breakpoint_info (struct tui_source_window_base *win, } } } - if (line->has_break != mode) + if (line->break_mode != mode) { - line->has_break = mode; - need_refresh = 1; + line->break_mode = mode; + need_refresh = true; } } return need_refresh; @@ -496,7 +495,7 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info) { tui_exec_info_content &element = content[i]; struct tui_source_element *src_element; - int mode; + tui_bp_flags mode; src_element = &win_info->content[i]; @@ -505,7 +504,7 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info) /* Now update the exec info content based upon the state of each line as indicated by the source content. */ - mode = src_element->has_break; + mode = src_element->break_mode; if (mode & TUI_BP_HIT) element[TUI_BP_HIT_POS] = (mode & TUI_BP_HARDWARE) ? 'H' : 'B'; else if (mode & (TUI_BP_ENABLED | TUI_BP_DISABLED)) diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index adf4af4..2a85a00 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -31,7 +31,7 @@ struct tui_win_info; state changed. */ extern void tui_update_all_breakpoint_info (void); -/* Scan the source window and the breakpoints to update the hasBreak +/* Scan the source window and the breakpoints to update the break_mode information for each line. Returns 1 if something changed and the execution window must be refreshed. */ extern int tui_update_breakpoint_info (struct tui_source_window_base *win, |