Re: [PATCH -tip 4/5] [BUGFIX] perf probe: Fix the order of searchingscopes for variables

From: Pekka Enberg
Date: Sun Jul 10 2011 - 12:26:20 EST


On Sun, Jul 10, 2011 at 3:08 PM, Masami Hiramatsu
<masami.hiramatsu.pt@xxxxxxxxxxx> wrote:
> Hi Pekka,
>
> (2011/07/10 20:05), Pekka Enberg wrote:
>> On Sun, Jul 10, 2011 at 1:00 PM, Masami Hiramatsu
>> <masami.hiramatsu.pt@xxxxxxxxxxx> wrote:
>>> Fix variable searching routine to search from inner scope
>>> to outer scope.
>>
>> Admittedly, I don't really know this code at all. However, the
>> changelog is somewhat vague. Why do we need this change? What problem
>> does it fix? Why does the order in which we iterate 'scopes' matter?
>
> Hmm, I see.
>
> Debuginfo expresses functions and nested inlined functions as
> DIE(Dwarf Information Entry) tree, and "scope" means each
> level of the DIE.
>
> Outer
> ^
> |
> ÂCU DIE [A](compile unit: it's an object file)
> Â +-global variable DIEs
> Â +-inline function declaration DIEs
> Â +-function [B] DIE
> Â Â Â+-local variable DIEs
> Â Â Â+-inline function instance [C] DIE
> Â Â Â Â +-inline local variable DIEs
> Â Â Â Â +-(nested)inline function instance [D] DIE
> Â Â Â Â Â Â+...
> |
> v
> Inner
>
> Imagine that if we are at [C],
>
> nscopes = dwarf_getscopes_die([C], &scopes)
>
> this returns scopes[] DIEs containing [C] DIE, and nscopes = 3
> On that array, scopes[0] is [C], scopes[1] is [B], and scopes[2]
> is [A].
>
> And, the below loop
>
> Âwhile (nscopes-- > 1)
> Â Â Â Âdie_find_variable_at(&scopes[nscopes], ...
>
> starts to find variables from the outermost scope [A] and
> find a global variable first.ãThis changes searching order
> from inner scope ([B]) to outer ([A]) to search global vars
> last.

Thanks for the explanation! What kind of problems does this cause for
'perf probe' users?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/