From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonic312-26.consmr.mail.ir2.yahoo.com (sonic312-26.consmr.mail.ir2.yahoo.com [77.238.178.97]) by sourceware.org (Postfix) with ESMTPS id 740643985C07 for ; Sat, 16 May 2020 17:28:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 740643985C07 X-YMail-OSG: Iyw0JKwVM1npp074bRrZu1rDdcbRSkzIDsuqINtGy.4BM1g3OHtgpBgvMo1CmPB 3UZ0_QMDwAu.9Ff.ZjtuFqdiG4c_MPpn9_DLBZ.jczs1NkNiOUiWBki0srL9hvUcgWSrKHzmDgkJ eZNwLE9yhJm8zrp5_ivMk_lm4pOB3.v4VK1da349zAf4FL9jjTlgzQrMJL5ERBNY4WY_X.iIwe6G JJsT4jd10TKArewFYmdwqKGOksMJPzcTCiF3Mq9z13zzlkwXunSpDnh2yO1pg7GQLPfIuKrXQWT4 BpuW1MqscNbR.Fp5mDy7o2U56OyiWjqwY8r6KM67wCWIXyxyS1xb2m8ACSGfmMCfbWu1IUQkLzoo lIVo7tmmnkdVN1zOjYxITdTq6KFW9EXRAF9EIPOj6vG1qDii.oEjzFpGccp7ngqDhaoqCNLXcfXA gGD.jdyQopXLWATv6vupg6wBq348wcwp3nWBmZm2SQcRmZprNwJs_KuYI2BQGATCn8z2AEKyNr27 eaVs6lNlEWYAkLnkURNUfUKX7ERP6q9OLyMbnUNEuRcftLpVce_cKFYGYM2HC..ErwWMmoAh265m y0opqhNy9KohoprBPPt.OaeICO8y3rtEwVCqvL0g2XdmBNeXkYOxbdZSXUVwBN.ftfqdsFF7TsE8 LB_lh1sDALFDj2Mv54IVNThpL.lBahaxxDcRJ.boRpGLn8U514rD37c62qaIXyXxwkssM.Po.6dr w1ZlmjUg6smtCB_Jwst3l3GutROiMQBMSjurh_OaTSQlorgUiqy5sDR7RhSB3VuI.yxZcjM9DHJD nP3NJbgBgppwmiOnFzdj8x15n3f3PSDIvca2vh5B2b7Zda_WFcG.JDP2KVsxryOZFo03m3wj5Gg6 HbBe2DpqkXaX5iJ8xAuMAu99UeotlrKki64s3sSXff5xyIVb.7nbar5bIT.XGzKsRLFHjAOxiVES ZpRcxIZtuI8zRimN7W5CI4qyE29ojLtGwaquAqKYiVEU6hCBisdhuuAfUmGh674FbIj9901Lvndo Yg0GrOdzqldlPFjZ.Dcq1aNMQN_qOAyEb2TYX37B28WAt8kxMlvpev278497dFiyQaDEitk98pBT 43K_.Xy_SJA7hRA8FcUmJGBKoaAJ1rEWKvM0H7NYnR.XjeMzbmAV7XMElyb4pRqIDs8CHlPFv4.0 _EV_tZMn38.RxnjfCfjSEvEKJSK1tIaelTk99EAlmojUquRZzPP2NqW4OHw9B5z0WcG0iIejpaph qiHo38q0C8csMr.KsdrR3bxGjMKu5NcOqeqBJXlx4bDIF3ekAreFjKgzxCBaW3.xCBqUw32dSeOJ VC.dV1tsV9VpdURHDQuc.S9En2T6xznuISaGGjFRjbOpQaKq8NDPcKiYIibS65B0hC.6zoJKODjl o2UH6mxWLkPOO5NdzejUymIRXStf2S1bH Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ir2.yahoo.com with HTTP; Sat, 16 May 2020 17:28:21 +0000 Received: by smtp418.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 8142922a7a13f425a55b77cec3219a55; Sat, 16 May 2020 17:28:17 +0000 (UTC) From: Hannes Domani To: gdb-patches@sourceware.org Subject: [PATCH 5/6][PR gdb/25911] Show column of current execution point in frame info Date: Sat, 16 May 2020 19:26:32 +0200 Message-Id: <20200516172632.4803-6-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=0.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FROM, GIT_PATCH_0, KAM_DMARC_STATUS, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, UNWANTED_LANGUAGE_BODY 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:24 -0000 --- gdb/source.c | 37 ++++++++++++++++++++++++++++++++++++- gdb/source.h | 6 ++++++ gdb/stack.c | 21 +++++++++++++++++---- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/gdb/source.c b/gdb/source.c index b94c6af487..bf9ec71464 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1243,7 +1243,8 @@ symtab_to_filename_for_display (struct symtab *symtab) static void print_source_lines_base (struct symtab *s, int line, int stopline, - print_source_lines_flags flags) + print_source_lines_flags flags, + int *column_pos = nullptr) { bool noprint = false; int nlines = stopline - line; @@ -1356,8 +1357,11 @@ print_source_lines_base (struct symtab *s, int line, int stopline, uiout->text (":"); } xsnprintf (buf, sizeof (buf), "%d\t", new_lineno++); + int printed = strlen (buf); + printed = ((printed >> 3) + 1) << 3; uiout->text (buf); + int column = 0; while (*iter != '\0') { /* Find a run of characters that can be emitted at once. @@ -1369,6 +1373,24 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int skip_bytes; char c = *iter; + if (c != '\033') + { + column++; + if (column_pos != nullptr && *column_pos == column) + { + *column_pos = printed; + column_pos = nullptr; + } + + if (c == '\t') + printed = ((printed >> 3) + 1) << 3; + else if (c >= 0 && c < 040) + printed += 2; + else if (c == 0177) + printed += 2; + else + printed++; + } if (c == '\033' && skip_ansi_escape (iter, &skip_bytes)) iter += skip_bytes; else if (c >= 0 && c < 040 && c != '\t') @@ -1408,6 +1430,11 @@ print_source_lines_base (struct symtab *s, int line, int stopline, ++iter; } } + if (column_pos != nullptr && *column_pos == column) + { + *column_pos = printed; + column_pos = nullptr; + } uiout->text ("\n"); } @@ -1434,6 +1461,14 @@ print_source_lines (struct symtab *s, source_lines_range line_range, line_range.stopline (), flags); } +/* See source.h. */ + +void +print_source_line_column (struct symtab *s, int line, int &column) +{ + print_source_lines_base (s, line, line + 1, 0, &column); +} + /* Print info on range of pc's in a specified line. */ diff --git a/gdb/source.h b/gdb/source.h index 6273a2cc18..5535964e3c 100644 --- a/gdb/source.h +++ b/gdb/source.h @@ -140,6 +140,12 @@ DEF_ENUM_FLAGS_TYPE (enum print_source_lines_flag, print_source_lines_flags); extern void print_source_lines (struct symtab *s, int line, int stopline, print_source_lines_flags flags); +/* Show source line with number LINE from the file of symtab S. + The column number COLUMN is updated to the real number of characters + printed until the specified column was reached. */ +extern void print_source_line_column (struct symtab *s, int line, + int &column); + /* Wrap up the logic to build a line number range for passing to print_source_lines when using get_lines_to_list. An instance of this class can be built from a single line number and a direction (forward or diff --git a/gdb/stack.c b/gdb/stack.c index f67a151aee..055c4bbe29 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -989,13 +989,15 @@ print_frame_info_to_print_what (const char *print_frame_info) print_frame_info); } -/* Print the PC from FRAME, plus any flags, to UIOUT. */ +/* Print the PC from FRAME, plus any flags, to UIOUT. + Returns number of characters printed. */ -static void +static int print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info *frame, CORE_ADDR pc) { uiout->field_core_addr ("addr", gdbarch, pc); + int printed = 2 + (gdbarch_addr_bit (gdbarch) <= 32 ? 8 : 16); std::string flags = gdbarch_get_pc_address_flags (gdbarch, frame, pc); if (!flags.empty ()) @@ -1003,7 +1005,10 @@ print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info *frame, uiout->text (" ["); uiout->field_string ("addr_flags", flags); uiout->text ("]"); + printed += 3 + flags.size (); } + + return printed; } /* See stack.h. */ @@ -1135,6 +1140,7 @@ print_frame_info (const frame_print_options &fp_opts, else { struct value_print_options opts; + int printed = 0; get_user_print_options (&opts); /* We used to do this earlier, but that is clearly @@ -1147,11 +1153,18 @@ print_frame_info (const frame_print_options &fp_opts, ability to decide for themselves if it is desired. */ if (opts.addressprint && mid_statement) { - print_pc (uiout, gdbarch, frame, get_frame_pc (frame)); + printed = print_pc (uiout, gdbarch, frame, get_frame_pc (frame)); uiout->text ("\t"); + printed = ((printed >> 3) + 1) << 3; } - print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); + int column = sal.column; + print_source_line_column (sal.symtab, sal.line, column); + if (column > 0) + { + uiout->spaces (printed + column); + uiout->text ("^\n"); + } } /* If disassemble-next-line is set to on and there is line debug -- 2.26.2