From patchwork Sun Feb 12 09:15:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Johnson X-Patchwork-Id: 64774 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A66AB385B526 for ; Sun, 12 Feb 2023 09:15:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail.spocom.com (mail.spocom.com [206.63.224.240]) by sourceware.org (Postfix) with ESMTP id A588F3858D32 for ; Sun, 12 Feb 2023 09:15:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A588F3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=spocom.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=spocom.com Received: from localhost (137.sub-75-213-6.myvzw.com [75.213.6.137]) by mail.spocom.com with SMTP; Sun, 12 Feb 2023 01:14:52 -0800 Date: Sun, 12 Feb 2023 01:15:34 -0800 From: Gary Johnson To: gdb-patches@sourceware.org Subject: [PATCH] Fix 5-line offset of edit command Message-ID: <20230212091534.GA27308@phoenix> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline X-Operating-System: Linux 2.6.32-74-generic GNU/Linux User-Agent: Mutt/1.5.20 (2009-06-14) X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" [I originally sent this to the gdb list by mistake.] When gdb is paused at a line and I open the current file with the edit command, gdb uses vim to open the file at the current line, but the line number given to vim is always too high by 5. For example, using gdb-12.1 and the gdb-12.1 source, cd to gdb-12.1/gdb and run gdb on itself. $ gdb gdb (gdb) b main (gdb) run Gdb will stop at line 25. (gdb) edit will open vim at line 30. Executing :ps -fH confirms that vim was started with the argument "+30". The problem appears to be in the edit_command() function in cli-cmds.c, at line 966 in version 12.1. The solution is to delete that line. The patch is below. Regards, Gary -------------------------------------------------------------------- --- cli-cmds.c.orig 2022-05-01 11:46:31.000000000 -0700 +++ cli-cmds.c 2023-02-11 00:54:01.695108617 -0800 @@ -963,7 +963,6 @@ { if (sal.symtab == 0) error (_("No default source file yet.")); - sal.line += get_lines_to_list () / 2; } else {