From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonic302-21.consmr.mail.ir2.yahoo.com (sonic302-21.consmr.mail.ir2.yahoo.com [87.248.110.84]) by sourceware.org (Postfix) with ESMTPS id 5303D3982EEB for ; Sat, 16 May 2020 17:28:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5303D3982EEB X-YMail-OSG: wB.LTK8VM1m4r8TY7RpFtldjNkystUZ3r1mj9B.6diEgyz4b1LcIIROH6jPDUL9 MXo2zNwjWAx0ZYs2vYkS3y4RsOyUxhhkOiL79SgK3Oh2Ihaq2Q1sOL3DriGD1ul_UVD7z2JvQqSO 1TsVohcj6BwnFfZSnEmPn_BKEyss8S9HsfRfoDuoxUwVIWXr1NPAcI1zs6CHZDVIN46hykA2TvIE x30j4gHdTJVCcvcoDOb.l4KI4jbVzu50X5t6w4jgAxy5XC76NYWI7k4eUdIuc80pxNH6t8lHRNhp P1pezATBczFkPQd3mDfiWESF.TzsCbR7eKI5j3iLBJmLFXyBN0tUJNOqcS9p8XIHqjD6dmwuNgFm gquPnuEy6NSveDxnDIPIUwFDZGoQQXD3Gwy0fDs58dzj_DRxbMSZIMfis21swsCWHZ9PPrfDC889 FatRixcdslXisWkOLpEEOb5cmm3pljTOIQI1OiT6HBYIee4S5pxBlu7X.16F0aFrM2GRlf0.2lG3 YI_Uib3v05XB5yTGgv8Y7x391LVH7X9.GJx2p1zOg4Mn9aNxyTQ90gGsEeNhEi0SC.u0idp0gMMR LhotN7rAG2HN5bJDM_dtr7X_M_Po6N_BxGh1HMVBpOSQG3GOe.AfoOxXD5creQuN2U46ShlmYPVl Cc6HkMJ82Vs0MN_XffElMkcWECWUsmx9yOWmDJiFiszH2oM0g.M56x9e_M2FUClOrsY2AR9oTWYd 8blWm1CHBIngznpwBmP_PskDMkcD3wGJ4qkKGiUNoSwxBT7WYHKz7Jd9.Ura5R00HaewF6zLiXI0 u2ZXe9hJrBOgabUmGTJi24W9ZpmuiYShS9paaeoYhYoIpkAW2fdnL8FYk3wFfuDkUVYPR_J9JcMm J.otTh3eP1BFsBLP9EhKGNvhsrdBmba61bBwtq_Rv81GtMQIokXz5_BfXGPzDABYAY0YKWkfQuH3 gNGfEESwyMOPy6DJIqE7FP0ZMxKBgiFX8i62peWllsXtghZF5hqz7krTEED7hnHnEs0hAPrCW0Tq oMhL5c1ivVl830f8gbCetbnObT9MVjx4UOn9zuGoqsGv2wX7DNzh2fhLfUOp0AYp9eRiV2EgX57V H223P450PcjXDWdDZX49ROQ.DVGan.MvzPZnz0axkX.wDHxhcQ8Awot8mzLygGgTR22jIaKtdj3Y Va8vHT86SPh1O9svSUpCF_IaycA8bUHX.fZ30tU2LDKAR3em2y677HtwbPmeP2u.F5Wo3ziqBiXa MzlE2nK3bFwJ.M4wIAedF6jqrahNakbThmgiuUXKDrwIGI85N2arvf_PtcYdlDDqqRPwnaEoWezm LsRYN_iUrd2gAN4SuFnvogvAGj0Lxtt4sESFDt.O8GbIlu7JLywow60N7QgdBm19JjaCARzzEE2l cUx60LX7WUU2Z_EthXlXty7QPGLiBstA- Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ir2.yahoo.com with HTTP; Sat, 16 May 2020 17:28:20 +0000 Received: by smtp418.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 8142922a7a13f425a55b77cec3219a55; Sat, 16 May 2020 17:28:19 +0000 (UTC) From: Hannes Domani To: gdb-patches@sourceware.org Subject: [PATCH 6/6] Show column of current execution point in TUI Date: Sat, 16 May 2020 19:26:33 +0200 Message-Id: <20200516172632.4803-7-ssbssa@yahoo.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200516172632.4803-1-ssbssa@yahoo.de> References: <20200516172632.4803-1-ssbssa@yahoo.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Antivirus: Avast (VPS 200515-0, 05/15/2020), Outbound message X-Antivirus-Status: Clean X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2020 17:28:23 -0000 --- gdb/tui/tui-data.h | 6 +++++- gdb/tui/tui-source.c | 18 ++++++++++++------ gdb/tui/tui-stack.c | 2 ++ gdb/tui/tui-stack.h | 1 + gdb/tui/tui-winsource.c | 35 +++++++++++++++++++++++++++++++++-- gdb/tui/tui-winsource.h | 9 +++++++-- 6 files changed, 60 insertions(+), 11 deletions(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 2dc73b963d..1b36b5930d 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -148,7 +148,11 @@ struct tui_line_or_address enum tui_line_or_address_kind loa; union { - int line_no; + struct + { + int line_no; + int column_no; + }; CORE_ADDR addr; } u; }; diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index fd5bd7dd96..c82647c0a4 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -93,20 +93,25 @@ tui_source_window::set_contents (struct gdbarch *arch, { struct tui_source_element *element = &m_content[cur_line]; - std::string text; - if (*iter != '\0') - text = tui_copy_source_line (&iter, cur_line_no, - m_horizontal_offset, - line_width, digits); - /* Set whether element is the execution point and whether there is a break point on it. */ element->line_or_addr.loa = LOA_LINE; element->line_or_addr.u.line_no = cur_line_no; + element->line_or_addr.u.column_no = 0; element->is_exec_point = (filename_cmp (locator->full_name.c_str (), symtab_to_fullname (s)) == 0 && cur_line_no == locator->line_no); + element->exec_column = element->is_exec_point ? locator->column_no : 0; + + std::string text; + int column = element->exec_column; + if (*iter != '\0') + text = tui_copy_source_line (&iter, cur_line_no, + m_horizontal_offset, + line_width, digits, &column); + if (element->is_exec_point) + element->line_or_addr.u.column_no = column; m_content[cur_line].line = std::move (text); @@ -212,6 +217,7 @@ tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal) l.loa = LOA_LINE; l.u.line_no = sal.line; + l.u.column_no = sal.column; set_is_exec_point_at (l); } } diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index f1e075a3d2..052a11ec30 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -271,12 +271,14 @@ tui_locator_window::set_locator_info (struct gdbarch *gdbarch_in, locator_changed_p |= proc_name != procname; locator_changed_p |= sal.line != line_no; + locator_changed_p |= sal.column != column_no; locator_changed_p |= sal.pc != addr; locator_changed_p |= gdbarch_in != gdbarch; locator_changed_p |= full_name != fullname; proc_name = procname; line_no = sal.line; + column_no = sal.column; addr = sal.pc; gdbarch = gdbarch_in; set_locator_fullname (fullname); diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h index fde7c6dd2c..13e4f9537b 100644 --- a/gdb/tui/tui-stack.h +++ b/gdb/tui/tui-stack.h @@ -62,6 +62,7 @@ struct tui_locator_window : public tui_gen_win_info std::string full_name; std::string proc_name; int line_no = 0; + int column_no = 0; CORE_ADDR addr = 0; /* Architecture associated with code at this location. */ struct gdbarch *gdbarch = nullptr; diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index db0add9968..24bacbbb18 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -66,7 +66,7 @@ tui_display_main () std::string tui_copy_source_line (const char **ptr, int line_no, int first_col, - int line_width, int ndigits) + int line_width, int ndigits, int *exec_column) { const char *lineptr = *ptr; @@ -87,6 +87,7 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col, } int column = 0; + int raw_column = 0; char c; do { @@ -105,6 +106,7 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col, ++lineptr; ++column; + ++raw_column; auto process_tab = [&] () { @@ -127,6 +129,12 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col, continue; } + if (exec_column != nullptr && *exec_column == raw_column) + { + *exec_column = result.size (); + exec_column = nullptr; + } + if (c == '\n' || c == '\r' || c == '\0') { /* Nothing. */ @@ -152,6 +160,9 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col, ++lineptr; *ptr = lineptr; + if (exec_column != nullptr) + *exec_column = 0; + return result; } @@ -261,7 +272,20 @@ tui_source_window_base::show_source_line (int lineno) tui_set_reverse_mode (handle.get (), true); wmove (handle.get (), lineno, TUI_EXECINFO_SIZE); - tui_puts (line->line.c_str (), handle.get ()); + if (line->is_exec_point && line->line_or_addr.u.column_no > 0 + && line->line_or_addr.u.column_no < line->line.size ()) + { + /* Mark the column by disabling the reverse mode for the + corresponding character. */ + int column = line->line_or_addr.u.column_no; + tui_puts (line->line.substr (0, column).c_str (), handle.get ()); + tui_set_reverse_mode (handle.get (), false); + tui_puts (line->line.substr (column, 1).c_str (), handle.get ()); + tui_set_reverse_mode (handle.get (), true); + tui_puts (line->line.substr (column + 1).c_str (), handle.get ()); + } + else + tui_puts (line->line.c_str (), handle.get ()); if (line->is_exec_point) tui_set_reverse_mode (handle.get (), false); @@ -411,8 +435,15 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l) { changed = true; m_content[i].is_exec_point = new_state; + m_content[i].exec_column = l.loa == LOA_LINE ? l.u.column_no : 0; show_source_line (i + 1); } + else if (new_state && m_content[i].is_exec_point && l.loa == LOA_LINE + && m_content[i].exec_column != l.u.column_no) + { + changed = true; + m_content[i].exec_column = l.u.column_no; + } i++; } if (changed) diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 501dd31ccf..8810ba1dd6 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -58,6 +58,7 @@ struct tui_source_element : line (std::move (other.line)), line_or_addr (other.line_or_addr), is_exec_point (other.is_exec_point), + exec_column (other.exec_column), break_mode (other.break_mode) { } @@ -65,6 +66,7 @@ struct tui_source_element std::string line; struct tui_line_or_address line_or_addr; bool is_exec_point = false; + int exec_column = 0; tui_bp_flags break_mode = 0; }; @@ -250,11 +252,14 @@ extern void tui_update_source_windows_with_line (struct symtab_and_line sal); digits are used; otherwise the line number is formatted with 6 digits and the text is aligned to the next tab stop. Returns a string holding the desired text. PTR is updated to point to the - start of the next line. */ + start of the next line. + If EXEC_COLUMN is supplied, it is updated to the position of the + specified colum in the returned string. */ extern std::string tui_copy_source_line (const char **ptr, int line_no, int first_col, - int line_width, int ndigits); + int line_width, int ndigits, + int *exec_column = nullptr); /* Constant definitions. */ #define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */ -- 2.26.2