From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id EB7893858416 for ; Fri, 6 Jan 2023 15:53:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB7893858416 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673020433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hOp6rnBPwKbfWvXLjDihwLxFSiPDHXyyMsD+PSl8pWQ=; b=YWd/yizlcxz/n4m8pW53nHg+Pn4ENkNjlXT843CBFDVyCY+ksrl0m0Z/lvzt4UaCA0aGPx QJQx+umdXFG64iVPdosZRQSTiGLIhlaSF/6Z2YW6O4UU2CtCv1OSeGikKaMPVBTiy8aE3/ SrIwmi/jXtgpbvaMYn7rqM2p1vmnoMI= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-136-ofytT8DkPUqzHESKZCtKHw-1; Fri, 06 Jan 2023 10:53:52 -0500 X-MC-Unique: ofytT8DkPUqzHESKZCtKHw-1 Received: by mail-qk1-f200.google.com with SMTP id u11-20020a05620a430b00b007052a66d201so1172157qko.23 for ; Fri, 06 Jan 2023 07:53:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hOp6rnBPwKbfWvXLjDihwLxFSiPDHXyyMsD+PSl8pWQ=; b=wmPxBAehaZyCDC3M1Lk3/WiM8R6Hb9KZptj0S8AVN4AlhjPAOktmQdEhyuR4ZiJ4Xq Axnit8uIFJ4+OWagwq9Ws9X9NjmJ1kOHvvrov4iVw1+j/aGrWgDRIYjPcrVELWy9Ua6r qG06Vk+wOi2FsYr9Af2x45RYRBUfbcmAkrX/0MXfDKDUFJDBgDLqsKdMeK1YRf1PrfQt 6TJ5Brq8h4UDHXcwm3sbrGzKCA8FZLhVyznyUVZEutikZMcLxGFdmQ6UaQE6Hnc0d/5H 1ZGgWLkZXDvdBuZTd0q36hybY8d06TRYWr1njog38bpX4hnqx7Rnm5u54c9A82e86zZu bpmg== X-Gm-Message-State: AFqh2krC2qEZciIwUlMJ5W5hB9pnEhNBIyD2Qe4scIuBXvis8RijiGnz dbNbZjKZ7iXjEgai1vetmaDAsbp23egwPISXF8bzis4R5UqM+y2Ixwx12aAmZBQ1sMxJUzOABML kgHF492P3r8ZaHuLePwJ9OA== X-Received: by 2002:ac8:41d4:0:b0:3a5:402:4bcf with SMTP id o20-20020ac841d4000000b003a504024bcfmr77736171qtm.24.1673020431884; Fri, 06 Jan 2023 07:53:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuK38b3ryTxzO7FmKIy0AC09aTiPglscO1KWmaH+ZzaD4kzzBLhz59y2hcVkPNykJ243PiRrw== X-Received: by 2002:ac8:41d4:0:b0:3a5:402:4bcf with SMTP id o20-20020ac841d4000000b003a504024bcfmr77736146qtm.24.1673020431624; Fri, 06 Jan 2023 07:53:51 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id k8-20020ac80748000000b0038b684a1642sm651999qth.32.2023.01.06.07.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 07:53:51 -0800 (PST) From: Andrew Burgess To: linuxmaker , Tom Tromey Cc: Zheng Zhan Liang via Gdb-patches , Zheng Zhan Subject: Re:Re: [PATCH] I'm debugging https://github.com/helix-editor/helix.git@63dcaae1b9083396fb3faaef9eaa2421f7e48fb9, which is a editor implemented with rust lang. When I type gdb command below: (gdb) b pars gdb dumped. I got: m_match = 0x7fffd8173cc7 "parse::h3bbecc5bbd82b347" m_ignored_ranges = { first = 0x7fffd8173cbb "::parse::h3bbecc5bbd82b347", second = 0x7fffd8173cc5 "::parse::h3bbecc5bbd82b347" } In-Reply-To: <548304b6.2be2.185850681f6.Coremail.linuxmaker@163.com> References: <20230102124334.120786-1-linuxmaker@163.com> <875ydkd911.fsf@tromey.com> <548304b6.2be2.185850681f6.Coremail.linuxmaker@163.com> Date: Fri, 06 Jan 2023 15:53:48 +0000 Message-ID: <87lemfy7zn.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 List-Id: linuxmaker via Gdb-patches writes: > At 2023-01-06 04:24:42, "Tom Tromey" wrote: >>>>>>> "Zheng" == Zheng Zhan Liang via Gdb-patches writes: >> >>Zheng> From: Zheng Zhan >> >>Hi. Thank you for the patch. >> >>The text all seemed to end up in the Subject line. Probably you need >>another newline after the first line of the commit message. >> >>Zheng> --- a/gdb/completer.h >>Zheng> +++ b/gdb/completer.h >>Zheng> @@ -163,8 +163,11 @@ class completion_match_for_lcd >>Zheng> const char *prev = m_match; >>Zheng> for (const auto &range : m_ignored_ranges) >>Zheng> { >>Zheng> - m_finished_storage.append (prev, range.first); >>Zheng> - prev = range.second; >>Zheng> + if (prev < range.first) >>Zheng> + { >>Zheng> + m_finished_storage.append (prev, range.first); >>Zheng> + prev = range.second; >>Zheng> + } >> >>Is there any way to construct a test case for this? > seems pretty common in rust. you can test it like below: > fn main() { > let four: u8 = "4".parse().unwrap(); > println!("{}", four); > } > (gdb) b pars[TAB] I haven't reviewed the fix. But in case this makes it easier for anyone, below is the original patch along with the test written as a script for GDB's testsuite. I can confirm that the new test passes with the fix, and fails without. I haven't done a full testsuite run yet, so I don't know if there are any other regressions. Thanks, Andrew --- diff --git a/gdb/completer.h b/gdb/completer.h index 8b4ad8ec4d4..e2f340c0ce8 100644 --- a/gdb/completer.h +++ b/gdb/completer.h @@ -163,8 +163,11 @@ class completion_match_for_lcd const char *prev = m_match; for (const auto &range : m_ignored_ranges) { - m_finished_storage.append (prev, range.first); - prev = range.second; + if (prev < range.first) + { + m_finished_storage.append (prev, range.first); + prev = range.second; + } } m_finished_storage.append (prev); diff --git a/gdb/testsuite/gdb.rust/completion.exp b/gdb/testsuite/gdb.rust/completion.exp new file mode 100644 index 00000000000..00923db14a6 --- /dev/null +++ b/gdb/testsuite/gdb.rust/completion.exp @@ -0,0 +1,34 @@ +# Copyright (C) 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test a completion case that was causing GDB to crash. + +load_lib rust-support.exp +if {[skip_rust_tests]} { + return +} + +standard_testfile .rs +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} { + return -1 +} + +set line [gdb_get_line_number "set breakpoint here"] +if {![runto ${srcfile}:$line]} { + untested "could not run to breakpoint" + return -1 +} + +gdb_test "complete break pars" ".*" diff --git a/gdb/testsuite/gdb.rust/completion.rs b/gdb/testsuite/gdb.rust/completion.rs new file mode 100644 index 00000000000..8396e3f4086 --- /dev/null +++ b/gdb/testsuite/gdb.rust/completion.rs @@ -0,0 +1,19 @@ +// Copyright (C) 2023 Free Software Foundation, Inc. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +fn main() { + let four: u8 = "4".parse().unwrap(); + println!("{}", four); // set breakpoint here +}