From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +Qj5D3YSemo8SBsAWB0awg (envelope-from ) for ; Mon, 10 Aug 2026 14:03:34 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ZhnbwWCo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3DA211E09B; Mon, 10 Aug 2026 14:03:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B42D71E09B for ; Mon, 10 Aug 2026 14:03:33 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5CF244BA2E37 for ; Mon, 10 Aug 2026 18:03:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CF244BA2E37 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ZhnbwWCo Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id 09E964BAE7FC for ; Mon, 10 Aug 2026 18:03:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09E964BAE7FC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 09E964BAE7FC Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a00:1450:4864:20::232 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1786384990; cv=pass; b=x62GH1ZKB0GXTew0eo0VBM2Hxab1ooxbx54luQyDHsUictRtTlwwJfKXSi3qyMW2chFDWq1Iv/mNY0+gPOZekNzReTV91ElkgedZ8FVkrawQbNWsl4Bj56/Wqjqat1LxOzm72NujbemUUQCOywH1ulcid5u0OpGx6SorxXQJazA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1786384990; c=relaxed/simple; bh=e39/YRdntsCcp6c3rTJ9ptMXlNqj4JHoC/AkXl+jnGQ=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=aJPsj1bCckQsvCVQR/1RyzyQj38tlOBYk1bG0zJqceGncNFiBmaSNSfC47RjQZQtvwwxvvvqBlEkiBEH9GpVqKr77gfVJxlf81z5HabAIEoD3g9I5VgE4RY/lRbXXflag9vId+wN18WVF+tpa3VDzRL8gU6k54BJ8orOlvnoDok= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ZhnbwWCo DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09E964BAE7FC Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-39c8ee87f7eso16483271fa.3 for ; Mon, 10 Aug 2026 11:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1786384989; cv=none; d=google.com; s=arc-20260327; b=GDSrs5wILWaarCjvdQNP/3n/A4n3ErZGKtLH1SsFXSrnxZLPKrblyX1fuGUtR5xn9e loNUEbXNvDzb8lu7ByMMC5fUbyHMLZwGhq2+QjUBJGRj3IQRDwtE/aSvTjKQ6jf4enrq ngbvUYYUuNZWs4UhQUh/eme1vEiiM7cjTnbNv2o6ZS92khZp05O7nSMxcA1JwsCEW9BS 7Za0utj4dJzZSI3nHJi6Kh31NZ7GSqpsttXuKa6NeeGjV6HRZlZvRFW6JwangtuFWUAH N3UhI1QXVeYXAWDnw08Rn5ECQqKr/vaREVBM7Lni1L7JCznISazI2TrnImjIbC6Y493C IQ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=X7jEV1iTQXRLzLe+5A2yIsrVCdM5cARCHV8PDLA9hz4=; fh=w8lL/y/EqnDezsmM22zXjVo3ejHea2HLugBTF2zng1I=; b=ncRsNswlvABkIRsYGyowEnVMiNJPpxV45csy+0i3lFEd4k1jTDUq+3LvNaQ3JlABqP QYRoVO73iHJjk2K9vlGCRe0ronGHu2esmlhXUV4gFqXlMrwG0OiBWq5750QCqaY8yb2U PkHERGgV8CzQFJZVIs6ROSuGFg2qK1kOFj78mCEOSVCuL/mvu30MOPUg2mr7Kr7aaC5a KGNSJJasW0Y+Oa1TMwVRmXkB47orcg5LIp+I9pTxZ1iGKoisMjG+fhnR+lX8gU9/TqDN chis3c9rhCRbu8NIb4+/JSNuUFF1QInjlrx4JXB8tA7o9oz3yhL+kCuGkZp314Y85YMU GArQ==; darn=sourceware.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786384989; x=1786989789; darn=sourceware.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=X7jEV1iTQXRLzLe+5A2yIsrVCdM5cARCHV8PDLA9hz4=; b=ZhnbwWCoNj+0Cd9gbaT0OrjPxRymCGhGKJ1ttpNQTZDAssU9oFx+XlrJxlmfpdISbI qHPeOIIskuT/SSoc7Nzkalqci9icb8WmqnhLTQUOL/Mpff1RgjLTk31AvB39ntorPM6d IJt9nrGJ+f0aBD/GySYyf4Iw8jlnN2IfFe6s8rTQKgdiTFL/fq931nAyq/wqSMM6fT+F GYdRpTR15UZ3g//R0KjDUNWoSyljNgOyihw1fFYCqxeL+WNv/X951Q7yvSaXyhMThusG Qy3G0G1lycgPqZPsVCH8UxJbHSpjbRBT/oEGJe79HEUAIuNLypFg6LMNzpXazJa/J7t2 qOlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786384989; x=1786989789; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=X7jEV1iTQXRLzLe+5A2yIsrVCdM5cARCHV8PDLA9hz4=; b=f0jiwO/3ML8qUbXWIOZ5LGjvOoaFIqsrSgOuudsQ/L3zV/mzE5S/0QacOnoM+q3bqh bDUgUpj31leHamuD0pSXJUoSO4RXwKD0qYoOFXWh+dOI4UQKvLpIYbs1PZ/2vjV3VTUP nmIm81/yjquBGuN+a+OKARArptdI48JDOoendLg+WcOkYODAD49MM2yYVDr2At0KNPdU y9SZpU6+PAoN5zqotkACElcMSNY45648+Ca9bYCXmHYMH4C6mCzhbRNLW7ArnZwPRvtX AmVkcItib76Gw/RFiQFVNfmzfU7xFUuaBRAasA6vSI8Y1/OBow5RcrBgCMaky+oN3EgE a0pQ== X-Gm-Message-State: AOJu0Yxaglt3nTaO7y757LCixNG0Q1v4rFtzLTEReBs3T/unYqep+2R6 2aHJg7nSt60BNuG+NHucFm/3vExJdI/bUIsRb59NfLBqMjcpC7SaJXJ5iNVRmIC4SYSXvenofjK nav+16Re8NKTAtJKYCKJAud1Fz8E74yyZ6A== X-Gm-Gg: AR+sD11G7R3NrG1YN1VyMAzXZwf+gmb0sq1sAXI+QNJzmzU7clgw/UsrxAJLXGNFDDR 48J2q1L3dUHitcIL2fDEj+hOrLfILAgnPKl4/MXgCUuU7msRrYygBTCXbVW3eMdJTI/3BKZkduB qrTe/WPEmSey6e9HU1fCOLvUKxOUxfF74ZTKxSTUd4N5XOLF54gCnB2S3FnG9cIGFCR5msn0JLt yOtpGUTwiq1MpVgH4HluAFzmuJNmekPKulNADrADyTRGjznb0jU1183YWmCNnWka+lkvUPXm2Xf KxBAS4qYqF/ij3iRBVaOpCa1EWX9k09dmlx/2qeDYnJ2ffQ2/Ibj4/J4851qw8EYSA6ENeoaWNy x X-Received: by 2002:a05:651c:220c:b0:39c:99e9:da37 with SMTP id 38308e7fff4ca-39fe564bcdbmr22537951fa.1.1786384988444; Mon, 10 Aug 2026 11:03:08 -0700 (PDT) MIME-Version: 1.0 References: <20260801160146.1318-2-oleg.tolmatcev@gmail.com> <87cxvzmpoa.fsf@redhat.com> In-Reply-To: <87cxvzmpoa.fsf@redhat.com> From: Oleg Tolmatcev Date: Mon, 10 Aug 2026 20:02:55 +0200 X-Gm-Features: AUfX_mzi3Zev-KGB4ZErZfKUuCOKwZx2voDJ1CFeI249wbCXV9Z8AV_a_UiE2NQ Message-ID: Subject: Re: [PATCH] gdb: search local symbols before global symbols in completion To: Andrew Burgess Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org =D0=BF=D0=BD, 3 =D0=B0=D0=B2=D0=B3. 2026=E2=80=AF=D0=B3. =D0=B2 13:03, Andr= ew Burgess : > > Oleg Tolmatcev writes: > > > When symbol completion is performed from a selected frame, search the > > local blocks before scanning minimal symbols and global/static symbols. > > This makes completion prefer names that are visible in the current > > context, including local variables. > > --- > > gdb/symtab.c | 72 ++++++++++++++++++++++++++-------------------------- > > It feels like this really needs a test in the gdb.dap/ directory. > > Thanks, > Andrew > > > > 1 file changed, 36 insertions(+), 36 deletions(-) > > > > diff --git a/gdb/symtab.c b/gdb/symtab.c > > index 5d5076f2e77..85665bebdf4 100644 > > --- a/gdb/symtab.c > > +++ b/gdb/symtab.c > > @@ -5931,6 +5931,42 @@ default_collect_symbol_completion_matches_break_= on > > > > lookup_name_info lookup_name (sym_text, name_match_type, true); > > > > + /* Search upwards from currently selected frame (so that we can > > + complete on local vars). Also catch fields of types defined in > > + this places which match our text string. Only complete on types > > + visible from current context. */ > > + > > + b =3D get_selected_block (); > > + surrounding_static_block =3D b =3D=3D nullptr ? nullptr : b->static_= block (); > > + surrounding_global_block =3D b =3D=3D nullptr ? nullptr : b->global_= block (); > > + if (surrounding_static_block !=3D NULL) > > + while (b !=3D surrounding_static_block) > > + { > > + QUIT; > > + > > + for (struct symbol *sym : block_iterator_range (b)) > > + { > > + if (code =3D=3D TYPE_CODE_UNDEF) > > + { > > + completion_list_add_symbol (tracker, sym, lookup_name, > > + sym_text, word); > > + completion_list_add_fields (tracker, sym, lookup_name, > > + sym_text, word); > > + } > > + else if (sym->domain () =3D=3D STRUCT_DOMAIN > > + && sym->type ()->code () =3D=3D code) > > + completion_list_add_symbol (tracker, sym, lookup_name, > > + sym_text, word); > > + } > > + > > + /* Stop when we encounter an enclosing function. Do not stop for > > + non-inlined functions - the locals of the enclosing function > > + are in scope for a nested function. */ > > + if (b->function () !=3D NULL && b->inlined_p ()) > > + break; > > + b =3D b->superblock (); > > + } > > + > > /* At this point scan through the misc symbol vectors and add each > > symbol you find to the list. Eventually we want to ignore > > anything that isn't a text symbol (everything else will be > > @@ -5974,42 +6010,6 @@ default_collect_symbol_completion_matches_break_= on > > SEARCH_ALL_DOMAINS); > > } > > > > - /* Search upwards from currently selected frame (so that we can > > - complete on local vars). Also catch fields of types defined in > > - this places which match our text string. Only complete on types > > - visible from current context. */ > > - > > - b =3D get_selected_block (); > > - surrounding_static_block =3D b =3D=3D nullptr ? nullptr : b->static_= block (); > > - surrounding_global_block =3D b =3D=3D nullptr ? nullptr : b->global_= block (); > > - if (surrounding_static_block !=3D NULL) > > - while (b !=3D surrounding_static_block) > > - { > > - QUIT; > > - > > - for (struct symbol *sym : block_iterator_range (b)) > > - { > > - if (code =3D=3D TYPE_CODE_UNDEF) > > - { > > - completion_list_add_symbol (tracker, sym, lookup_name, > > - sym_text, word); > > - completion_list_add_fields (tracker, sym, lookup_name, > > - sym_text, word); > > - } > > - else if (sym->domain () =3D=3D STRUCT_DOMAIN > > - && sym->type ()->code () =3D=3D code) > > - completion_list_add_symbol (tracker, sym, lookup_name, > > - sym_text, word); > > - } > > - > > - /* Stop when we encounter an enclosing function. Do not stop for > > - non-inlined functions - the locals of the enclosing function > > - are in scope for a nested function. */ > > - if (b->function () !=3D NULL && b->inlined_p ()) > > - break; > > - b =3D b->superblock (); > > - } > > - > > /* Add fields from the file's types; symbols will be added below. *= / > > > > if (code =3D=3D TYPE_CODE_UNDEF) > > -- > > 2.55.0.windows.1 > I tried 3 times, but every time my test causes regressions on ARM. I don't know how to write a passing test. Is a test really necessary for this trivial patch that only changes the order of completion results? Oleg