diff options
author | Tom Tromey <tom@tromey.com> | 2019-11-12 17:56:42 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-12-20 09:15:53 -0700 |
commit | 9f7540a5deb07875fb8e75de86857a9cae8bd30a (patch) | |
tree | 0e096b931c7d2ee08da1ac95d2cf24245320aa8a | |
parent | 57e4b379e96383c4c7ee0aa0bb9b81018688f47d (diff) | |
download | gdb-9f7540a5deb07875fb8e75de86857a9cae8bd30a.zip gdb-9f7540a5deb07875fb8e75de86857a9cae8bd30a.tar.gz gdb-9f7540a5deb07875fb8e75de86857a9cae8bd30a.tar.bz2 |
Use symtab_and_line when updating TUI windows
This changes a few TUI source window methods to take a symtab_and_line
rather than separate symtab and tui_line_or_address parameters. A
symtab_and_line already incorporates the same information, so this
seemed simpler. Also, it helps avoid the problem that the source and
disassembly windows need different information -- both forms are
present in the SAL.
gdb/ChangeLog
2019-12-20 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (struct tui_source_window_base)
<set_contents, update_source_window_as_is, update_source_window>:
Take a sal, not a separate symtab and tui_line_or_address.
* tui/tui-winsource.c (tui_source_window_base::update_source_window)
(tui_source_window_base::update_source_window_as_is): Take a sal,
not a separate symtab and tui_line_or_address.
(tui_update_source_windows_with_addr)
(tui_update_source_windows_with_line)
(tui_source_window_base::rerender)
(tui_source_window_base::refill): Update.
* tui/tui-source.h (struct tui_source_window) <set_contents>: Take
a sal, not a separate symtab and tui_line_or_address.
* tui/tui-source.c (tui_source_window::set_contents): Take a sal,
not a separate symtab and tui_line_or_address.
(tui_source_window::maybe_update): Update.
* tui/tui-disasm.h (struct tui_disasm_window) <set_contents>: Take
a sal, not a separate symtab and tui_line_or_address.
* tui/tui-disasm.c (tui_disasm_window::set_contents): Take a sal,
not a separate symtab and tui_line_or_address.
(tui_disasm_window::do_scroll_vertical)
(tui_disasm_window::maybe_update): Update.
Change-Id: I6974a03589930a0f910c657ef50b7f6f7397c87d
-rw-r--r-- | gdb/ChangeLog | 24 | ||||
-rw-r--r-- | gdb/tui/tui-disasm.c | 19 | ||||
-rw-r--r-- | gdb/tui/tui-disasm.h | 3 | ||||
-rw-r--r-- | gdb/tui/tui-source.c | 19 | ||||
-rw-r--r-- | gdb/tui/tui-source.h | 3 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.c | 92 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.h | 9 |
7 files changed, 88 insertions, 81 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fef0cfc..feb406b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,29 @@ 2019-12-20 Tom Tromey <tom@tromey.com> + * tui/tui-winsource.h (struct tui_source_window_base) + <set_contents, update_source_window_as_is, update_source_window>: + Take a sal, not a separate symtab and tui_line_or_address. + * tui/tui-winsource.c (tui_source_window_base::update_source_window) + (tui_source_window_base::update_source_window_as_is): Take a sal, + not a separate symtab and tui_line_or_address. + (tui_update_source_windows_with_addr) + (tui_update_source_windows_with_line) + (tui_source_window_base::rerender) + (tui_source_window_base::refill): Update. + * tui/tui-source.h (struct tui_source_window) <set_contents>: Take + a sal, not a separate symtab and tui_line_or_address. + * tui/tui-source.c (tui_source_window::set_contents): Take a sal, + not a separate symtab and tui_line_or_address. + (tui_source_window::maybe_update): Update. + * tui/tui-disasm.h (struct tui_disasm_window) <set_contents>: Take + a sal, not a separate symtab and tui_line_or_address. + * tui/tui-disasm.c (tui_disasm_window::set_contents): Take a sal, + not a separate symtab and tui_line_or_address. + (tui_disasm_window::do_scroll_vertical) + (tui_disasm_window::maybe_update): Update. + +2019-12-20 Tom Tromey <tom@tromey.com> + * tui/tui-winsource.c (tui_source_window_base::refill): Use start_line_or_addr. * tui/tui-source.c (tui_source_window::do_scroll_vertical): Use diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index 8a46bba..376343b 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -200,8 +200,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) /* Function to set the disassembly window's content. */ bool tui_disasm_window::set_contents (struct gdbarch *arch, - struct symtab *s, - struct tui_line_or_address line_or_addr) + const struct symtab_and_line &sal) { int i; int offset = horizontal_offset; @@ -211,8 +210,7 @@ tui_disasm_window::set_contents (struct gdbarch *arch, int tab_len = tui_tab_width; int insn_pos; - gdb_assert (line_or_addr.loa == LOA_ADDRESS); - CORE_ADDR pc = line_or_addr.u.addr; + CORE_ADDR pc = sal.pc; if (pc == 0) return false; @@ -323,7 +321,6 @@ tui_disasm_window::do_scroll_vertical (int num_to_scroll) if (!content.empty ()) { CORE_ADDR pc; - struct tui_line_or_address val; pc = start_line_or_addr.u.addr; if (num_to_scroll >= 0) @@ -331,9 +328,10 @@ tui_disasm_window::do_scroll_vertical (int num_to_scroll) else --num_to_scroll; - val.loa = LOA_ADDRESS; - val.u.addr = tui_find_disassembly_address (gdbarch, pc, num_to_scroll); - update_source_window_as_is (gdbarch, NULL, val); + symtab_and_line sal {}; + sal.pspace = current_program_space; + sal.pc = tui_find_disassembly_address (gdbarch, pc, num_to_scroll); + update_source_window_as_is (gdbarch, sal); } } @@ -383,7 +381,10 @@ tui_disasm_window::maybe_update (struct frame_info *fi, symtab_and_line sal) a.loa = LOA_ADDRESS; a.u.addr = low; if (!addr_is_displayed (sal.pc)) - update_source_window (frame_arch, sal.symtab, a); + { + sal.pc = low; + update_source_window (frame_arch, sal); + } else { a.u.addr = sal.pc; diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h index ec8d7f1..e46cf1a 100644 --- a/gdb/tui/tui-disasm.h +++ b/gdb/tui/tui-disasm.h @@ -56,8 +56,7 @@ protected: void do_scroll_vertical (int num_to_scroll) override; bool set_contents (struct gdbarch *gdbarch, - struct symtab *s, - struct tui_line_or_address line_or_addr) override; + const struct symtab_and_line &sal) override; private: /* Answer whether a particular line number or address is displayed diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 113195d..0728263 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -42,11 +42,10 @@ /* Function to display source in the source window. */ bool tui_source_window::set_contents (struct gdbarch *arch, - struct symtab *s, - struct tui_line_or_address line_or_addr) + const struct symtab_and_line &sal) { - gdb_assert (line_or_addr.loa == LOA_LINE); - int line_no = line_or_addr.u.line_no; + struct symtab *s = sal.symtab; + int line_no = sal.line; if (s == NULL) return false; @@ -201,14 +200,16 @@ tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal) bool source_already_displayed = (sal.symtab != 0 && showing_source_p (m_fullname.get ())); - struct tui_line_or_address l; - - l.loa = LOA_LINE; - l.u.line_no = start_line; if (!(source_already_displayed && line_is_displayed (sal.line))) - update_source_window (get_frame_arch (fi), sal.symtab, l); + { + sal.line = start_line; + update_source_window (get_frame_arch (fi), sal); + } else { + struct tui_line_or_address l; + + l.loa = LOA_LINE; l.u.line_no = sal.line; set_is_exec_point_at (l); } diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 36515e7..beff9bc 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -61,8 +61,7 @@ protected: void do_scroll_vertical (int num_to_scroll) override; bool set_contents (struct gdbarch *gdbarch, - struct symtab *s, - struct tui_line_or_address line_or_addr) override; + const struct symtab_and_line &sal) override; private: diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 708c2fe..cad7dea 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -167,11 +167,10 @@ tui_source_window_base::style_changed () void tui_source_window_base::update_source_window (struct gdbarch *gdbarch, - struct symtab *s, - struct tui_line_or_address line_or_addr) + const struct symtab_and_line &sal) { horizontal_offset = 0; - update_source_window_as_is (gdbarch, s, line_or_addr); + update_source_window_as_is (gdbarch, sal); } @@ -180,10 +179,9 @@ tui_source_window_base::update_source_window void tui_source_window_base::update_source_window_as_is (struct gdbarch *gdbarch, - struct symtab *s, - struct tui_line_or_address line_or_addr) + const struct symtab_and_line &sal) { - bool ret = set_contents (gdbarch, s, line_or_addr); + bool ret = set_contents (gdbarch, sal); if (!ret) erase_source_content (); @@ -194,12 +192,10 @@ tui_source_window_base::update_source_window_as_is update_exec_info (); if (type == SRC_WIN) { - symtab_and_line sal; + symtab_and_line new_sal = sal; - sal.line = line_or_addr.u.line_no + (content.size () - 2); - sal.symtab = s; - sal.pspace = SYMTAB_PSPACE (s); - set_current_source_symtab_and_line (sal); + new_sal.line = sal.line + (content.size () - 2); + set_current_source_symtab_and_line (new_sal); } } } @@ -213,21 +209,12 @@ tui_update_source_windows_with_addr (struct gdbarch *gdbarch, CORE_ADDR addr) if (addr != 0) { struct symtab_and_line sal = find_pc_line (addr, 0); - struct tui_line_or_address l; if (TUI_DISASM_WIN != nullptr) - { - l.loa = LOA_ADDRESS; - l.u.addr = addr; - TUI_DISASM_WIN->update_source_window (gdbarch, sal.symtab, l); - } + TUI_DISASM_WIN->update_source_window (gdbarch, sal); if (TUI_SRC_WIN != nullptr) - { - l.loa = LOA_LINE; - l.u.line_no = sal.line; - TUI_SRC_WIN->update_source_window (gdbarch, sal.symtab, l); - } + TUI_SRC_WIN->update_source_window (gdbarch, sal); } else { @@ -243,11 +230,15 @@ tui_update_source_windows_with_line (struct symtab *s, int line) { struct gdbarch *gdbarch; CORE_ADDR pc; - struct tui_line_or_address l; + struct symtab_and_line sal; if (!s) return; + sal.pspace = current_program_space; + sal.symtab = s; + sal.line = line; + gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); switch (tui_current_layout ()) @@ -258,16 +249,11 @@ tui_update_source_windows_with_line (struct symtab *s, int line) tui_update_source_windows_with_addr (gdbarch, pc); break; default: - l.loa = LOA_LINE; - l.u.line_no = line; - TUI_SRC_WIN->update_source_window (gdbarch, s, l); + find_line_pc (s, line, &pc); + sal.pc = pc; + TUI_SRC_WIN->update_source_window (gdbarch, sal); if (tui_current_layout () == SRC_DISASSEM_COMMAND) - { - find_line_pc (s, line, &pc); - l.loa = LOA_ADDRESS; - l.u.addr = pc; - TUI_DISASM_WIN->update_source_window (gdbarch, s, l); - } + TUI_DISASM_WIN->update_source_window (gdbarch, sal); break; } } @@ -366,33 +352,26 @@ tui_source_window_base::rerender () { if (!content.empty ()) { - struct tui_line_or_address line_or_addr; struct symtab_and_line cursal = get_current_source_symtab_and_line (); - line_or_addr = start_line_or_addr; - update_source_window (gdbarch, cursal.symtab, line_or_addr); + if (start_line_or_addr.loa == LOA_LINE) + cursal.line = start_line_or_addr.u.line_no; + else + cursal.pc = start_line_or_addr.u.addr; + update_source_window (gdbarch, cursal); } 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 (); struct gdbarch *gdbarch = get_frame_arch (frame); struct symtab *s = find_pc_line_symtab (get_frame_pc (frame)); - if (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); - } - update_source_window (gdbarch, s, line); + if (type != SRC_WIN) + find_line_pc (s, cursal.line, &cursal.pc); + update_source_window (gdbarch, cursal); } else erase_source_content (); @@ -403,17 +382,24 @@ tui_source_window_base::rerender () void tui_source_window_base::refill () { - symtab *s = nullptr; + symtab_and_line sal {}; if (type == SRC_WIN) { - symtab_and_line cursal = get_current_source_symtab_and_line (); - s = (cursal.symtab == NULL - ? find_pc_line_symtab (get_frame_pc (get_selected_frame (NULL))) - : cursal.symtab); + sal = get_current_source_symtab_and_line (); + if (sal.symtab == NULL) + sal = find_pc_line (get_frame_pc (get_selected_frame (NULL)), 0); } - update_source_window_as_is (gdbarch, s, start_line_or_addr); + if (sal.pspace == nullptr) + sal.pspace = current_program_space; + + if (start_line_or_addr.loa == LOA_LINE) + sal.line = start_line_or_addr.u.line_no; + else + sal.pc = start_line_or_addr.u.addr; + + update_source_window_as_is (gdbarch, sal); } /* Scroll the source forward or backward horizontally. */ diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 1991d04..dde56a7 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -88,8 +88,7 @@ protected: void rerender () override; virtual bool set_contents (struct gdbarch *gdbarch, - struct symtab *s, - struct tui_line_or_address line_or_addr) = 0; + const struct symtab_and_line &sal) = 0; public: @@ -111,11 +110,9 @@ public: virtual void maybe_update (struct frame_info *fi, symtab_and_line sal) = 0; void update_source_window_as_is (struct gdbarch *gdbarch, - struct symtab *s, - struct tui_line_or_address line_or_addr); + const struct symtab_and_line &sal); void update_source_window (struct gdbarch *gdbarch, - struct symtab *s, - struct tui_line_or_address line_or_addr); + const struct symtab_and_line &sal); /* Scan the source window and the breakpoints to update the break_mode information for each line. Returns true if something |