From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by sourceware.org (Postfix) with ESMTPS id 3FA193857B91 for ; Thu, 26 May 2022 14:04:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3FA193857B91 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f42.google.com with SMTP id p10so2266238wrg.12 for ; Thu, 26 May 2022 07:04:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=lSs/bXASceIAPKHz2Rmijk1AGVGgZ1aNHVO8CHH5nPE=; b=0YM7IXJi8lFdEIQTET75tP8Lvh+wHQQX2G4FNX6vkTHPA7omSXj6oT8cFPWoaAFZC5 D4Y4Pcwf6DIBzJbA7m8RXvKn/whndwJX4wqukYGTDKzfFfXnQEXDHblCZElwSKyNaQza OTYwd/k9zJLYm/G9XopVNb83nK5VF8POzYIiP52phlQk+fjfAqKySvT6jgUwp1PkGhBK aK6Un6LQcvQuvBAUxz7lLI5p5uxqqBo8XUnXcb7/szQnIFrQHgkbSqgMkOqi2VeU+REg MgA3sr9EkS1atPHkoq8SaDKyaMxXREjIubwaV9hVefVNNvsEukoTN3U1NNTwyxwR3yEt 3/Gg== X-Gm-Message-State: AOAM532NoPBMHQs9nu08OV9bx6xcDydKFz2y+jktTLNFy6Hwov05UBrX +7be+mscvSsXhanLwkb167n8E44WMDo= X-Google-Smtp-Source: ABdhPJzu0yrn9rwTAB7pWP2EqNKl6LUo4XYX+wUTgvJdsqzaUjMuoJUK2u1IEx9THOyjDP/jHJcO2Q== X-Received: by 2002:a5d:4d06:0:b0:210:b6:7af0 with SMTP id z6-20020a5d4d06000000b0021000b67af0mr6301795wrt.258.1653573863902; Thu, 26 May 2022 07:04:23 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id 10-20020a5d47aa000000b0020d07d90b71sm1837563wrb.66.2022.05.26.07.04.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 May 2022 07:04:22 -0700 (PDT) Message-ID: Date: Thu, 26 May 2022 15:04:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v2 1/2] Always show locations for breakpoints & show canonical location spec Content-Language: en-US To: Eli Zaretskii Cc: gdb-patches@sourceware.org References: <20220519215552.3254012-1-pedro@palves.net> <20220519215552.3254012-2-pedro@palves.net> <834k1kd7ne.fsf@gnu.org> <625057b2-1691-a472-fa93-0dabacbddd39@palves.net> <83ilpv5bd3.fsf@gnu.org> <4c7a9504-83e0-6c02-fda6-0254ab4eede4@palves.net> <8335gwpiih.fsf@gnu.org> From: Pedro Alves In-Reply-To: <8335gwpiih.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT 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: , X-List-Received-Date: Thu, 26 May 2022 14:04:27 -0000 On 2022-05-26 13:48, Eli Zaretskii wrote: >> Date: Wed, 25 May 2022 20:32:24 +0100 >> Cc: gdb-patches@sourceware.org >> From: Pedro Alves >> >> On 2022-05-24 14:06, Eli Zaretskii wrote: >> >>> >>>>>> +Enabled breakpoints and breakpoint locations are marked with @samp{y}. >>>>> >>>>> What does "enabled breakpoint location" mean? One cannot enable a >>>>> location. >>>> >>>> Sure we can. >>> >>> We are mis-communicating. "Location" is a frequently-used word that >>> has certain natural meaning in many contexts. That natural meaning >>> doesn't support the notion of "enabling". >> >> Well, yeah, but above the text is very clearly talking about "breakpoint >> locations", i.e., the locations in the program where the breakpoint is armed. >> Enabling/disabling one of these locations is really about enabling/disabling >> the arming of a breakpoint at such a location. > > Yes, and that's the point I tried to make: you can enable or disable a > breakpoint at some location, not enable/disable the location itself, > which is what the text was saying. "enable or disable a breakpoint at some location" is slightly ambiguous because it doesn't distinguish between the whole breakpoint vs one individual location the breakpoint is set at. There is one logical breakpoint, and then one or more individual locations that the single/singular breakpoint is set at. See the difference? So we can say instead: you can enable/disable each individual location the breakpoint is set at. and that is more accurate. > >>> My suggestion is to use "location" (with or without additional >>> qualifiers) for only one of these two, if only because we tend to >>> shorthand that by using just "location". We could use it for what you >>> now call "location specification", which would allow us to use just >>> "location" as it shorthand. With your proposed text, "location" is >>> ambiguous, because it could allude to any of these two. The other >>> meaning of "location" I propose to call "address in the code" or >>> "address" for short -- because that's what it conceptually is. (If >>> you are bothered by the case of unloaded shared library and similar >>> situations, we could say "unresolved address" in those cases -- which >>> are rather marginal, so once explained, they can be ignored in the >>> rest of the text. By contrast, these two "locations" are pervasive: >>> we need to refer to them all over the manual. So it's much more >>> important IMO to make that part of our terminology clear and >>> unequivocal.) >> >> I really think that this is the wrong direction, and working on >> the patch that I pointed at above really convinced me so even more. >> I believe that that patch will convince you as well. Please take a look >> there. > > I did, and it didn't. It actually convinced me even more that we > cannot use "location" in both contexts without creating confusion. What a mystery. The current text uses location throughout and it isn't a problem. I would like to hear from anyone who is confused, what misunderstanding said confusion actually caused. > >> As another data point, after writing that other patch, i.e., just now, >> I went to look what other debuggers call similar things, and here's what I saw: > > Other debuggers could mean other things, or they could be also wrong > in this aspect. Our manual should make sense to us, even if other > debuggers decide to use different terminology. Likewise when adopting > terminology used by others. > > Moreover, half if not more of the evidence you provide is about things > I'm not objected to: I'm okay with calling "location spec" what was > formerly known as "linespec". My problem is with the other use of > "location". GDB has been calling the actual locations a breakpoint is set at, as "locations", since forever. Other debuggers do the same. And now, OOTB, you decide that the term is confusing. Who exactly are you protecting? Nobody is confused by this. > We agree about the general goal, but disagree about some minor point, > such as what to call "the place where we insert the breakpoint". It is not a minor point. You are suggesting to change the naming of something that is very core to how breakpoints are displayed to users and they are manipulated by gdb users, both CLI and user interfaces (MI). > But now I'm beginning to wonder what is your definition of "location" > in this context? What does it entail if two different "locations" can > be resolved to the same code address? And where is that meaning of > "location" described? The text you proposed uses "location(s) that > match(es) the location spec", which doesn't seem to imply any > attributes except the "place" where the breakpoint will be set, since > "location spec" is just source-level description of one or more such > "places". How does "location" imply anything about local variables, > commands, etc.? A location is some actual place in the program, identifiable by some "coordinates". Some source line in the program can be a location in the program, if you have its coordinates. Line number alone isn't sufficient. A source location is fully defined by the path to its file and the line number, the full prototype of its function, and the address of the first instruction that the line was compiled down to. Addresses are per-inferior, so add inferior to the coordinate system. If you have the same code loaded in multiple inferiors, GDB considers the same code at each address its own location. E.g. here's a breakpoint set at handle_inferior_event, with two inferior gdbs loaded: 3 breakpoint keep y 3.1 y 0x00000000004ea2ac in handle_inferior_event(execution_control_state*) at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:5331 inf 1 3.2 y 0x00000000004ea2ac in handle_inferior_event(execution_control_state*) at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:5331 inf 2 Note "inf 1" and "inf 2" on the right hand side. So you have two locations for the same code, in two inferiors. You may not have debug info for all locations in the program. So a location may be missing some coordinates, like the file/line. It won't be a source location, but it is still some actual program location. Or you may lack the full path to the filename. Etc. But the tuple of the coordinates identify some actual spot in the actual program. Address alone isn't sufficient to identify source location, given inlining. Of course, if you don't have debug info, address is all you got. OTOH, a location specification is a way to find or refer to these actual locations in the program. A location spec may leave out some parts of the "coordinates". For example, it can just give a relative filename, or a filename with no directory components, or even not specify a filename at all, just a line number. Or, it can specify a function name without specifying the full prototype, like the function arguments, or the namespace and class the function/method belongs to, in C++, for example. The point is that the spec may be incomplete, and GDB will do its best to fill in the missing bits from context, and find all the locations in the program that match the incomplete specification. So for example, with this toy C++ program: $ cat foo.cc void func (int) {} void func (long) {} namespace A { void func (long) {} } int main () {} "func" would be a location specification, and the matching locations that GDB finds would be the actual locations that exist in the program. Like: (gdb) b func Breakpoint 1 at 0x40110d: func. (3 locations) (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x000000000040110d in func(int) at foo.cc:1 1.2 y 0x0000000000401118 in func(long) at foo.cc:2 1.3 y 0x0000000000401123 in A::func(long) at foo.cc:3 (gdb) So would a location spec like "-line 10". That one doesn't identify a location by itself, but GDB fills in the missing bits. This is the problem with the current manual. It uses "location" to refer to the potentially incomplete location specification. Switching to using "location spec" gets rid of the ambiguity. Same thing for all the other examples in the manual that I added to the "Address Specifications" section. This idea of "actual locations" is used the same way throughout multiple commands, not just breakpoints. It just happens that with breakpoint, GDB records the list of locations it found, so it is easier to discuss using breakpoints. But e.g. the "list" command does exactly the same "spec to actual locations in the program" matching. I would like to point out the fact that we've been referring to "location spec" vs "actual location" in these emails (not the patches), and no one ends up confused. Please consider that. > I'm not wedded to "address", btw, I just don't want us to use > "location" for that. If there's some alternative term, we could > consider it. Although "address" is already being used for a very > similar, if not the same, thing, and thus is a natural candidate, > because people won't need to learn a new term. Can we please just focus on documenting how GDB works? That's what the manual should be doing. GDB calls these things breakpoint locations, and it is not going to change because of the manual. That'd backwards. We don't even have to do anything, just keep using the same name we've always used. Please!