public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Consolidate "if"s in tui_show_frame_info Date: Wed, 17 Jul 2019 18:36:00 -0000 [thread overview] Message-ID: <20190717183646.59840.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9ad7fdef7c72b2aca0398ce8e63b89e560873807 commit 9ad7fdef7c72b2aca0398ce8e63b89e560873807 Author: Tom Tromey <tom@tromey.com> Date: Sun Jun 23 21:00:01 2019 -0600 Consolidate "if"s in tui_show_frame_info tui_show_frame_info has two parallel "if"s with the same condition and no intervening code. The second "if" perhaps wasn't obviously identical, but earlier refactorings made it clearer, by pointing out that only source and disassembly windows can be handled here. This merges the two statements. gdb/ChangeLog 2019-07-17 Tom Tromey <tom@tromey.com> * tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s. Diff: --- gdb/ChangeLog | 4 ++++ gdb/tui/tui-stack.c | 62 +++++++++++++++++++++++------------------------------ 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f3cd6e9..54c19e0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2019-07-17 Tom Tromey <tom@tromey.com> + * tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s. + +2019-07-17 Tom Tromey <tom@tromey.com> + * tui/tui-winsource.c (tui_update_source_window_as_is) (tui_update_source_windows_with_addr): Update. * tui/tui-source.h (tui_set_source_content) diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index f761ac1..e1b996d 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -341,8 +341,6 @@ tui_show_frame_info (struct frame_info *fi) if (fi) { - int start_line; - CORE_ADDR low; struct tui_locator_window *locator = tui_locator_win_info_ptr (); int source_already_displayed; CORE_ADDR pc; @@ -372,32 +370,15 @@ tui_show_frame_info (struct frame_info *fi) return 0; tui_show_locator_content (); - start_line = 0; for (struct tui_source_window_base *win_info : tui_source_windows ()) { if (win_info == TUI_SRC_WIN) { - start_line = (locator->line_no - - (win_info->viewport_height / 2)) + 1; + int start_line = (locator->line_no - + (win_info->viewport_height / 2)) + 1; if (start_line <= 0) start_line = 1; - } - else - { - if (find_pc_partial_function (get_frame_pc (fi), - NULL, &low, NULL) == 0) - { - /* There is no symbol available for current PC. There is no - safe way how to "disassemble backwards". */ - low = get_frame_pc (fi); - } - else - low = tui_get_low_disassembly_address (get_frame_arch (fi), - low, get_frame_pc (fi)); - } - if (win_info == TUI_SRC_WIN) - { struct tui_line_or_address l; l.loa = LOA_LINE; @@ -415,23 +396,34 @@ tui_show_frame_info (struct frame_info *fi) } else { - if (win_info == TUI_DISASM_WIN) + CORE_ADDR low; + + if (find_pc_partial_function (get_frame_pc (fi), + NULL, &low, NULL) == 0) + { + /* There is no symbol available for current PC. There is no + safe way how to "disassemble backwards". */ + low = get_frame_pc (fi); + } + else + low = tui_get_low_disassembly_address (get_frame_arch (fi), + low, get_frame_pc (fi)); + + struct tui_line_or_address a; + + a.loa = LOA_ADDRESS; + a.u.addr = low; + if (!tui_addr_is_displayed (locator->addr, + win_info, TRUE)) + tui_update_source_window (win_info, get_frame_arch (fi), + sal.symtab, a, TRUE); + else { - struct tui_line_or_address a; - - a.loa = LOA_ADDRESS; - a.u.addr = low; - if (!tui_addr_is_displayed (locator->addr, - win_info, TRUE)) - tui_update_source_window (win_info, get_frame_arch (fi), - sal.symtab, a, TRUE); - else - { - a.u.addr = locator->addr; - win_info->set_is_exec_point_at (a); - } + a.u.addr = locator->addr; + win_info->set_is_exec_point_at (a); } } + tui_update_exec_info (win_info); }
reply other threads:[~2019-07-17 18:36 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190717183646.59840.qmail@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).