From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#66604: [PATCH] Gud LLDB completions Date: Sat, 21 Oct 2023 12:37:12 +0200 Message-ID: <012EA2B6-279A-4A83-8C63-00EDB44A14CF@gmail.com> References: <13AC7AD2-230A-4FAC-81D9-75FBE53456F8@gmail.com> <586BC992-4776-4C8B-9700-821FF04A1046@gmail.com> <27BF071E-2E0D-49F9-B595-E8A560436C50@gmail.com> <2577C531-285B-49CC-BFAA-3D3A3A0B986D@gmail.com> <22B5EBE2-945E-413F-BCC6-8693AB90988C@gmail.com> <45D77CAF-8694-434D-90BC-448886FBB68E@gmail.com> <68E433F5-C7A5-4DCB-BF2B-FE1054F71E69@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_14F9D228-1909-464D-A491-76953426F413" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11173"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66604@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 21 12:38:06 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qu9Ms-0002k5-BN for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Oct 2023 12:38:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qu9MP-0000jG-Bh; Sat, 21 Oct 2023 06:37:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qu9MN-0000iT-EQ for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 06:37:35 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qu9MN-0005sh-4F for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 06:37:35 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qu9Mo-00014f-Qo for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 06:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 10:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66604 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66604-submit@debbugs.gnu.org id=B66604.16978846704101 (code B ref 66604); Sat, 21 Oct 2023 10:38:02 +0000 Original-Received: (at 66604) by debbugs.gnu.org; 21 Oct 2023 10:37:50 +0000 Original-Received: from localhost ([127.0.0.1]:42324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qu9Mc-000145-7q for submit@debbugs.gnu.org; Sat, 21 Oct 2023 06:37:50 -0400 Original-Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:58435) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qu9Ma-00013s-B5 for 66604@debbugs.gnu.org; Sat, 21 Oct 2023 06:37:49 -0400 Original-Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-507bd19eac8so2417107e87.0 for <66604@debbugs.gnu.org>; Sat, 21 Oct 2023 03:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697884635; x=1698489435; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=+RYgdEy4vmhveHfxCT0Gp6r3CyP4JVNR3H7E6xxlyL4=; b=PzhTqNH296EM0pXQ6ZP/XMja/S4ad9s8TZCk4pwY6O1O54+u9MXlWReJoa600D4sY/ YHW1UCCQU1j9agVu65alU6voLdHwaWybxGTCQL5BO0+V6eif6ugZYQ7G5RSx/co/c+pD rW78DMTPCVqChNLsxha8ytQWr2+okcNYrHPvFq6i5oy0NUEEcgNgOQY563Khdy7BwaiE GayGb7NpxDXrxkEQMEm07PZVHSM8il3t6wFRYZOpv731bE6ZWtatFOSpeclSBqFmPlBi XglRoCpPe50Mo45P17B5n7auaSkMgpgJwcs113g0m8O/KKtFwKkXMPTkBQ972YiNE5P5 GAmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697884635; x=1698489435; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+RYgdEy4vmhveHfxCT0Gp6r3CyP4JVNR3H7E6xxlyL4=; b=YEi49ks5mp4UGQlpafyu5+rm/t3Vc5Qna4XJ048652sG33WLp5U2E7RghudU7vDhBG 1safzFkaVQn4gYZT+bzUR7qixARDJoh100YlDK8hj3Dp744Muf97K9EyaQceWS/qL7u3 sN8WDMlORYuS9TwwP+ZqjLi2eoUBemgO5qO4IgP/HOEwARZqwV1NlPxdfZ1rSo5ZHoR8 nzTE5oHMfcpLJevWlAOkpmF/0wSAWzEDhoCjr8PaeBbrTECCwQe9GhMx4IqQfpnVVGam 3d8RyFqUF5Bl1DNfLeqj9ohu3PsdBW4gI8u21VsVIdSAMVAqvnCvcJ6joh+Q0ne2eq2z hHCQ== X-Gm-Message-State: AOJu0Yx909mf4C4ZNHpjvqluNNDkTKFiYyVxKxVEAa1okFRg63ZaLnZh 4mot/0/UMlrZ4rjSLS/Wj0I= X-Google-Smtp-Source: AGHT+IEyx/gC+2wXJoCNt52n/O9YtRwYZrhYOQiGswnkeLLURCUABpYNMcyBMiBz9qcAXVxWuL9UgQ== X-Received: by 2002:a05:6512:23a0:b0:507:a703:886e with SMTP id c32-20020a05651223a000b00507a703886emr3605043lfv.53.1697884634347; Sat, 21 Oct 2023 03:37:14 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id z19-20020a19f713000000b00507a3b16d29sm810490lfe.191.2023.10.21.03.37.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Oct 2023 03:37:13 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:272857 Archived-At: --Apple-Mail=_14F9D228-1909-464D-A491-76953426F413 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 20 okt. 2023 kl. 19.28 skrev Gerd M=C3=B6llmann = : > Look at these escape sequences that suddenly appear when attaching to = a > process! I don't even know what "[1G" and "[8G" do. Fascinating! We should probably look into the source code producing it = (libedit probably) but I wrote the attached monstrosity and it... seems = to work. (Proof of concept only.) It attempts to edit out the part of strings jumped over by CHA (CSI G), = and it also edits out ED (CSI J) which is in this case just used to do = exactly that immediately after CHA. --Apple-Mail=_14F9D228-1909-464D-A491-76953426F413 Content-Disposition: attachment; filename=lldb-filter-cha.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="lldb-filter-cha.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 8518738d09e..245600a2f94 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -3871,6 +3871,42 @@ gud-lldb-stop (defun gud-lldb-marker-filter (string) "Deduce interesting stuff from process output STRING." + (let ((ofs 0)) + (while (string-match (rx (* (not (in "\n\e"))) + (group "\e[") + (? (group (+ digit))) + (group (in "GJ"))) + string ofs) + (let ((bol (match-beginning 0)) + (seq-start (match-beginning 1)) + (arg (and (match-beginning 2) + (string-to-number (match-string 2 string)))) + (op-char (aref string (match-beginning 3))) + (seq-end (match-end 0))) + (cond ((eq op-char ?G) + ;; Move to absolute column. Argument is 1-based. + (let* ((goal-col (1- (or arg 1))) + (current-col (current-column)) + (prefix-len (- seq-start bol)) + (eff-col (+ current-col prefix-len)) + (rel-move-left (- eff-col goal-col)) + (del-prefix (max 0 (min prefix-len rel-move-left))) + (elide-start (- seq-start del-prefix)) + (elide-end seq-end) + (del-chars (- rel-move-left del-prefix))) + ;; FIXME: insert extra spaces if we move beyond eff-col + (when (> del-chars 0) + (delete-char (- del-chars))) + (setq string + (concat (substring string 0 elide-start) + (substring string elide-end))) + (setq ofs (+ bol (- prefix-len del-prefix))))) + ((eq op-char ?J) + ;; Erase in display + ;; FIXME + (setq string (concat (substring string 0 seq-start) + (substring string seq-end))) + (setq ofs seq-start)))))) (cond ;; gud-info: (function-name args...) ((string-match (rx line-start (0+ blank) "gud-info:" (0+ blank) --Apple-Mail=_14F9D228-1909-464D-A491-76953426F413--