diff options
author | Tom Tromey <tom@tromey.com> | 2020-02-22 11:48:26 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-02-22 12:57:25 -0700 |
commit | 432b5c40220d80d539284f0ee8f6d081d39f0578 (patch) | |
tree | 31e9ee9a0c8d1536ee566ce46291adbfd37b32d4 /gdb/tui/tui-source.c | |
parent | 01b1af321f804ef6dfd40d3054c8757f31096ea8 (diff) | |
download | fsf-binutils-gdb-432b5c40220d80d539284f0ee8f6d081d39f0578.zip fsf-binutils-gdb-432b5c40220d80d539284f0ee8f6d081d39f0578.tar.gz fsf-binutils-gdb-432b5c40220d80d539284f0ee8f6d081d39f0578.tar.bz2 |
Make some tui_source_window_base members "protected"
This renames a few members of tui_source_window_base, and makes them
"protected".
2020-02-22 Tom Tromey <tom@tromey.com>
* tui/tui-layout.c (extract_display_start_addr): Rewrite.
* tui/tui-disasm.h (struct tui_disasm_window)
<display_start_addr>: Declare.
* tui/tui-source.h (struct tui_source_window)
<display_start_addr>: Declare.
* tui/tui-winsource.h (struct tui_source_window_base)
<show_source_line, display_start_addr>: New methods.
<m_horizontal_offset, m_start_line_or_addr, m_gdbarch, m_content>:
Rename and move to protected section.
* tui/tui-winsource.c (tui_source_window_base::update_source_window)
(tui_source_window_base::do_erase_source_content): Update.
(tui_source_window_base::show_source_line): Now a method.
(tui_source_window_base::show_source_content)
(tui_source_window_base::tui_source_window_base)
(tui_source_window_base::rerender)
(tui_source_window_base::refill)
(tui_source_window_base::do_scroll_horizontal)
(tui_source_window_base::set_is_exec_point_at)
(tui_source_window_base::update_breakpoint_info)
(tui_source_window_base::update_exec_info): Update.
* tui/tui-source.c (tui_source_window::set_contents)
(tui_source_window::showing_source_p)
(tui_source_window::do_scroll_vertical)
(tui_source_window::location_matches_p)
(tui_source_window::line_is_displayed): Update.
(tui_source_window::display_start_addr): New method.
* tui/tui-disasm.c (tui_disasm_window::set_contents)
(tui_disasm_window::do_scroll_vertical)
(tui_disasm_window::location_matches_p): Update.
(tui_disasm_window::display_start_addr): New method.
Change-Id: I74d72b9da5f458664427db643a108634690c6e19
Diffstat (limited to 'gdb/tui/tui-source.c')
-rw-r--r-- | gdb/tui/tui-source.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 3c7a8e1..7bc1220 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -74,9 +74,9 @@ tui_source_window::set_contents (struct gdbarch *arch, m_fullname = make_unique_xstrdup (symtab_to_fullname (s)); cur_line = 0; - gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); - start_line_or_addr.loa = LOA_LINE; - cur_line_no = start_line_or_addr.u.line_no = line_no; + m_gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); + m_start_line_or_addr.loa = LOA_LINE; + cur_line_no = m_start_line_or_addr.u.line_no = line_no; int digits = 0; if (compact_source) @@ -88,16 +88,15 @@ tui_source_window::set_contents (struct gdbarch *arch, } const char *iter = srclines.c_str (); - content.resize (nlines); + m_content.resize (nlines); while (cur_line < nlines) { - struct tui_source_element *element - = &content[cur_line]; + struct tui_source_element *element = &m_content[cur_line]; std::string text; if (*iter != '\0') text = tui_copy_source_line (&iter, cur_line_no, - horizontal_offset, + m_horizontal_offset, line_width, digits); /* Set whether element is the execution point @@ -109,7 +108,7 @@ tui_source_window::set_contents (struct gdbarch *arch, symtab_to_fullname (s)) == 0 && cur_line_no == locator->line_no); - content[cur_line].line = std::move (text); + m_content[cur_line].line = std::move (text); cur_line++; cur_line_no++; @@ -124,7 +123,7 @@ tui_source_window::set_contents (struct gdbarch *arch, bool tui_source_window::showing_source_p (const char *fullname) const { - return (!content.empty () + return (!m_content.empty () && (filename_cmp (tui_locator_win_info_ptr ()->full_name.c_str (), fullname) == 0)); } @@ -134,11 +133,11 @@ tui_source_window::showing_source_p (const char *fullname) const void tui_source_window::do_scroll_vertical (int num_to_scroll) { - if (!content.empty ()) + if (!m_content.empty ()) { struct symtab *s; struct symtab_and_line cursal = get_current_source_symtab_and_line (); - struct gdbarch *arch = gdbarch; + struct gdbarch *arch = m_gdbarch; if (cursal.symtab == NULL) { @@ -149,11 +148,11 @@ tui_source_window::do_scroll_vertical (int num_to_scroll) else s = cursal.symtab; - int line_no = start_line_or_addr.u.line_no + num_to_scroll; + int line_no = m_start_line_or_addr.u.line_no + num_to_scroll; const std::vector<off_t> *offsets; if (g_source_cache.get_line_charpos (s, &offsets) && line_no > offsets->size ()) - line_no = start_line_or_addr.u.line_no; + line_no = m_start_line_or_addr.u.line_no; if (line_no <= 0) line_no = 1; @@ -167,8 +166,8 @@ tui_source_window::do_scroll_vertical (int num_to_scroll) bool tui_source_window::location_matches_p (struct bp_location *loc, int line_no) { - return (content[line_no].line_or_addr.loa == LOA_LINE - && content[line_no].line_or_addr.u.line_no == loc->line_number + return (m_content[line_no].line_or_addr.loa == LOA_LINE + && m_content[line_no].line_or_addr.u.line_no == loc->line_number && loc->symtab != NULL && filename_cmp (m_fullname.get (), symtab_to_fullname (loc->symtab)) == 0); @@ -179,13 +178,13 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no) bool tui_source_window::line_is_displayed (int line) const { - if (content.size () < SCROLL_THRESHOLD) + if (m_content.size () < SCROLL_THRESHOLD) return false; - for (size_t i = 0; i < content.size () - SCROLL_THRESHOLD; ++i) + for (size_t i = 0; i < m_content.size () - SCROLL_THRESHOLD; ++i) { - if (content[i].line_or_addr.loa == LOA_LINE - && content[i].line_or_addr.u.line_no == line) + if (m_content[i].line_or_addr.loa == LOA_LINE + && m_content[i].line_or_addr.u.line_no == line) return true; } @@ -216,3 +215,13 @@ tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal) set_is_exec_point_at (l); } } + +void +tui_source_window::display_start_addr (struct gdbarch **gdbarch_p, + CORE_ADDR *addr_p) +{ + struct symtab_and_line cursal = get_current_source_symtab_and_line (); + + *gdbarch_p = m_gdbarch; + find_line_pc (cursal.symtab, m_start_line_or_addr.u.line_no, addr_p); +} |