Re: [PATCH v4] gdb/manual: Introduce location specs

Pedro Alves
2022-05-27T19:17:38Z

On 2022-05-27 20:14, Eli Zaretskii wrote:
>> Date: Fri, 27 May 2022 20:05:25 +0100
>> Cc: gdb-patches@sourceware.org
>> From: Pedro Alves <pedro@palves.net>
>>
>>> I understand (I think). But all this does is fill in the attributes
>>> that were missing from the input location spec. This is done either
>>> by using the (implied) defaults, like the name of the current file, or
>>> bhy using the debug info. And if it turns out that some attribute can
>>> be filled in more than one way, we have a breakpoint with multiple
>>> code locations. Right?
>>>
>>
>> You start with e.g., just one attribute, like "-function func". This
>> makes GDB iterate over all the functions is knows about, finding the
>> ones that are called "func". This matches "func(int)", "A::func()",
>> "func(long)", etc. GDB collects the PC and source file and line number of
>> those functions too along the wa. If you did "break -function func", then
>> you end up with a breakpoint with multiple code locations, one
>> for each function matched.
>>
>> Or you start with "a/file.c:100". This makes GDB iterate over all source
>> files it knows about, and then for each that has a file name that ends
>> with "a/file.c", like e.g., "src/program/a/file.c" and "somelib/a/file.c"
>> it searches for line 100, collecting the PC and function name of the
>> location. If you did "break a/file.c:100", you end up with a breakpoint with
>> multiple locations, one per resolved location. If you did
>> "list a/file.c:100", GDB lists the source for around each of the locations.
>> Etc.
>>
>> Or you start with "*0x1000". Conceptually it's the same. GDB finds the code
>> locations that match that, resolves that to a location with
>> PC/function/source/line, and then the command does what it wants with it.
>
> Is this supposed to confirm my understanding, or to refute it? I
> think it confirms it.

I didn't understand what you meant by "attribute can be filled in
more than one way", so I explained how it works. If you start with my example
for "-function func" example from above, what does "attribute is filled in more
than one way" mean in that example?