Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1034365lqt; Tue, 19 Mar 2024 10:45:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUr02DbhOxGIGSSUHqFfLRk2LUPmhIe67ANgwgIM++no1PwAnGaM76Qwwv9Iy46qDM/zom1/0wuPuPaB564h1YRRWJ/WRwF5vUH9biBJA== X-Google-Smtp-Source: AGHT+IGbcgDDequpfCiW3NB+JAPfICC0I1Ws3Ee+irB+z1dCG28ZqE86Mbqf14oTv1elyGiSyCPg X-Received: by 2002:a05:6808:1489:b0:3c3:84c5:173e with SMTP id e9-20020a056808148900b003c384c5173emr6429297oiw.50.1710870321437; Tue, 19 Mar 2024 10:45:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710870321; cv=pass; d=google.com; s=arc-20160816; b=J+BchKUgpwc0DQNA3K3VA/sjb1vCkwMjgUlkUf/PUnvCn7/CG6cldYWNCqdMZSlywB v7nzCSLdvHM+bFlGgMj81gcM5DB5Jmv3VsQlFhDgwMrfqlZWXiOqWvGPq0Oe+i0+ZVIC bw/v4tT4pybI2771sha3yKSO/XKZbFG/JEptz0z79sWil5oSTxOI0cLDZRvVn6aGTscU hNwmSlTfX+JJQy4HM/6bBPENjVaYoxb+CXAs9Q00x1VtBh/skzoC5UXbdQ/Brp1X8yuA yM1VA76lk5feIDJqXY3sGlfGP1Ktknby+TmOP07l0slO3t/T0UD/NMuKQ9J6m9NMoW1i RUNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=LLidFdPPt+9QGX0eU+M4Nd/N7qIdu9ep3/M0iAS5xu8=; fh=2BI/gYlGL7W9l4Y78ZosY4QqWc+psGSIbosOwPJ2nxM=; b=0vg4BlfHuZ+xLtf9srCO5t98wp7bC7z/K+mF3LAZSZZrhV3tPgSjXrAkd3uNUjg4AA xBWyg3sF1TE+Hjn04Mh+BFvVh8Ga7Zv0f4hdYznHfHIWb4mKJ8EecIoh0dp+4G5wdL7g iriX8vD3l/OtJQpgQSTsxd0hjkDEynISiYkip6WSugrq/7SiF1faO31L9xxpZ8MwDtXR pIu0nDYb/u/q+ovDNk/0p2MSY1sNDZpEVy8lcbInMIchknzZN4m/abnNr9AWRH2RBYEH u4UZZQd2bOECvfoHNMRrrd1K1Z4b1/miMMEE39yyMa/W78OntSlL+4FlAQuoK1xkSKkj PFKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-107939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o1-20020a63f141000000b005e858e6fd4bsi875455pgk.784.2024.03.19.10.45.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 10:45:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-107939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1AC1C2817D9 for ; Tue, 19 Mar 2024 17:45:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B3C725777; Tue, 19 Mar 2024 17:44:46 +0000 (UTC) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B7302B9CF; Tue, 19 Mar 2024 17:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710870285; cv=none; b=T19UgmrnTYlHZswjLUj2fJskbzKxBPwaRQ+y7fGRjGKF4eg2Qg4xNPD0+HCXVxU749rNitzasWmbckmP7KgxenaFWxgLWZf8IwlEtzrnEIxg5O/kuh/8lL/V2vPOzGQBdFsOlfhSNb45KWR6XubUNS0gIKFsyKyc+9VtVBDhM+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710870285; c=relaxed/simple; bh=YNQG5gO9WlpU/AlVGMzkLhdH1gT/jgzXyquEnTHOZ+k=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VShQO6oHLksBO9IUDcUqSPcKhLFyTnlMWoheHtW7KOKi0t2UWiYilb5XxI7dm7EQu9S/6VnUdwXJCTDrpwzWHn+78M0wiAvHZMJadLjAZXuwGki5DJvR0jSXwKc8YOxe3mvLMjO7azlRYb0//9azPMZwY3YXqEB32+N+qRaqsks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so4723730a12.1; Tue, 19 Mar 2024 10:44:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710870283; x=1711475083; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LLidFdPPt+9QGX0eU+M4Nd/N7qIdu9ep3/M0iAS5xu8=; b=cEWK4zAIUwliT+5wxQS3Z1UD6P4VM+fZd0H6tj4KfaPxtc/RVHUVZtE5SoSH1uoR5G STHrut/XE+f2GfOuOdU7yMwRvL2Cg2PlAisv22XUpLxlJ1lytfO1I6FDF4n0V8yFI5zn 5XROr3DLVAVF6u6jq5artN4AmWQiCefWiyyItCDbUMErShMi7omQKXRgoJAd0tgZWTz4 pKblbxUbC3zbjPU2uYLMsi5QUXsCUmemaJNcCigvGyOV+1B/0iMEXkRiyKAt/2qnV8j7 ACdQtMrNe97CARH6tSbXhUxjEufXO46r/RMFpzN2oHlqAPxYmJ8tGVOJ5mjKO4wDD30M hzlA== X-Forwarded-Encrypted: i=1; AJvYcCXpvTwIu0sAahrN0JWn9l2ygycNvikVgRmDWHKRH302434V/UMmIsfsJgVqogNqkdKENtss+Ectx72fCfnw8OF57ndRL/xSLX8lK2aLvLJAaiCNmMXMURVag6l5vj8zaoPEA+Q4s72Us/RNM6mymF+zYYB6fRhzmYNtfFBgQCqtTvbt/o48+xZlMghmjOiULhSUb0i6XZoxrBQQXUMUWAYud2L+DBEWokt7Ts5ACK/t7aIpUA== X-Gm-Message-State: AOJu0YyhumyqE3V+i9L4MK3YDrwv90TaRzBQmjyOreh97IhiR3K76q+l GDrnp7kUp0hnN57KK8J4UMdSHl052XJQOm4WI6hc9W4dwbkh/F3/EGaDUqIpcngzzYo4eaZw9mc HGrsjTXFCCmGK5U1Ng90dnrv1ClE= X-Received: by 2002:a17:90a:ce12:b0:29b:b485:f4f8 with SMTP id f18-20020a17090ace1200b0029bb485f4f8mr12573838pju.20.1710870283313; Tue, 19 Mar 2024 10:44:43 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240319055115.4063940-1-namhyung@kernel.org> <20240319055115.4063940-10-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Tue, 19 Mar 2024 10:44:31 -0700 Message-ID: Subject: Re: [PATCH 09/23] perf annotate-data: Maintain variable type info To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Linus Torvalds , Stephane Eranian , Masami Hiramatsu , linux-toolchains@vger.kernel.org, linux-trace-devel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 19, 2024 at 7:07=E2=80=AFAM Arnaldo Carvalho de Melo wrote: > > On Mon, Mar 18, 2024 at 10:51:01PM -0700, Namhyung Kim wrote: > > As it collected basic block and variable information in each scope, it > > now can build a state table to find matching variable at the location. > > > > The struct type_state is to keep the type info saved in each register > > and stack slot. The update_var_state() updates the table when it finds > > variables in the current address. It expects die_collect_vars() filled > > a list of variables with type info and starting address. > > > > Signed-off-by: Namhyung Kim > > --- > > tools/perf/util/annotate-data.c | 173 ++++++++++++++++++++++++++++++++ > > tools/perf/util/dwarf-aux.c | 4 + > > 2 files changed, 177 insertions(+) > > > > diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate= -data.c > > index f482ccfdaa91..8eaa06f1cee5 100644 > > --- a/tools/perf/util/annotate-data.c > > +++ b/tools/perf/util/annotate-data.c > > @@ -46,6 +46,62 @@ static void pr_debug_type_name(Dwarf_Die *die) > > free(str); > > } > > > > +/* Type information in a register, valid when ok is true */ > > +struct type_state_reg { > > + Dwarf_Die type; > > + bool ok; > > +}; > > + > > +/* Type information in a stack location, dynamically allocated */ > > +struct type_state_stack { > > + struct list_head list; > > + Dwarf_Die type; > > + int offset; > > + int size; > > + bool compound; > > +}; > > + > > +/* FIXME: This should be arch-dependent */ > > +#define TYPE_STATE_MAX_REGS 16 > > + > > +/* > > + * State table to maintain type info in each register and stack locati= on. > > + * It'll be updated when new variable is allocated or type info is mov= ed > > + * to a new location (register or stack). As it'd be used with the > > + * shortest path of basic blocks, it only maintains a single table. > > + */ > > +struct type_state { > > + struct type_state_reg regs[TYPE_STATE_MAX_REGS]; > > + struct list_head stack_vars; > > +}; > > + > > +static bool has_reg_type(struct type_state *state, int reg) > > +{ > > + return (unsigned)reg < ARRAY_SIZE(state->regs); > > +} > > + > > +/* These declarations will be remove once they are changed to static *= / > > +void init_type_state(struct type_state *state, struct arch *arch __may= be_unused); > > +void exit_type_state(struct type_state *state); > > +void update_var_state(struct type_state *state, struct data_loc_info *= dloc, > > + u64 addr, u64 insn_offset, struct die_var_type *var= _types); > > + > > +void init_type_state(struct type_state *state, struct arch *arch __may= be_unused) > > +{ > > + memset(state, 0, sizeof(*state)); > > + INIT_LIST_HEAD(&state->stack_vars); > > +} > > + > > +void exit_type_state(struct type_state *state) > > +{ > > + struct type_state_stack *stack, *tmp; > > + > > + list_for_each_entry_safe(stack, tmp, &state->stack_vars, list) { > > + list_del(&stack->list); > > list_del_init()? Maybe.. but I'm not sure how much value it'd have as we free it right after= . Thanks, Namhyung > > > + free(stack); > > + } > > +} > > +