From nobody Tue Feb 10 05:44:39 2026 Received: from mail-yx1-f46.google.com (mail-yx1-f46.google.com [74.125.224.46]) (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 BBE782F83B7 for ; Tue, 27 Jan 2026 02:06:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769479608; cv=none; b=sj332LOT4kxSuyB5bx1AxZH9cqqf/npbqWNZLgK1W56PjfFcLuzjVX7jTsAKaYReHBsw+lLoQQbc+FKRPuTzX2+OUfgRHrN2j3GwJOXH5Emqn+ihfE8lpipeSDiYiX9vBehX0H3SOdAQXaIkmswqaxLDZYg5GY28rl0EfwgQeqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769479608; c=relaxed/simple; bh=b57Ock6we7x/mhDuBxpj3syCmE1BZKO8JFrTsuTWzrY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NFBjmksc2/v1XLYerne4sBUrQ3Tg/S2R1LZm6ZVwE6LnbTFtZ2wqUPDScYfMVN0YIHomaygA4Q/nEkfSpsRm/FD7dTqdsFXsaI0+XMoCQenqe8yLwrLT9CKKDAk4oZvO/2N/6g+u5fhVIObgM4A8gFDJXNYczzHseC942dj3XEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ncsu.edu; spf=pass smtp.mailfrom=ncsu.edu; dkim=pass (2048-bit key) header.d=ncsu.edu header.i=@ncsu.edu header.b=QdUEy+51; arc=none smtp.client-ip=74.125.224.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ncsu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ncsu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ncsu.edu header.i=@ncsu.edu header.b="QdUEy+51" Received: by mail-yx1-f46.google.com with SMTP id 956f58d0204a3-6481bd173c0so4377793d50.2 for ; Mon, 26 Jan 2026 18:06:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncsu.edu; s=google; t=1769479606; x=1770084406; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TZ3wA5lS89Oy1XytQhdRYz1uEnxzfP2eJ7+UqS1aa2s=; b=QdUEy+51XjwAAw8kPv+ySk3/HVuTMqkTc7YE6oKek/EI4wD1yKmNv403Xq8RBvRTv2 besMs1PL3sCJW/LzfRy+yWj4cYLJFYhjW0c/Di82hYRazUOID3PqRofwu3Niga9OxRlq TJq0ohw/8+EELNww+c1rGgIeNF0/h3s++1BJWieyRq/Wn1hwoyX3ZGTywTNWBDMM6NF7 H1ygXrfcMbSMTJ6XQbMegICw9CJo7rqLiViKSYTwfQxGBLPzaTZaASAr8KSMeSPuxsyW SVbMPwcDPK5KGRAwcLhfEwcxrXPgMd8xiHoeNJZJSSEu1BLwhqfuBfYiEz1qWP+uRU3C LwUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769479606; x=1770084406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TZ3wA5lS89Oy1XytQhdRYz1uEnxzfP2eJ7+UqS1aa2s=; b=gnSIxg2zCYIpAb5qa86vBK22AqQL72As+kR6vMddwfxZt+A63reZPAOXbRSn4FXHDl c9m2xGyoY+n69HzvQZri6x7o9xAW/xOm7+ZePRI29Y9+8v71J8q6AKd7MssjYqT7DGVL qvliPFobr2pzoZG76DNI/QZ8cjMRIMpnnUKLHBv/fCTW1yr1C/ukLRKwAahg916+fQvc phX6Pn0e4JNCb18SPXlXBCQ2MwVQA+DNleu4jK7MA0X1b6fRiwDcletwIordDJow745W eHFLDRCxBBzU2eAKSMI2N7CQ425yuIt0dFJkii88Uy1JCrcxn6ai0NN04coL9N9qCSCY h4fQ== X-Forwarded-Encrypted: i=1; AJvYcCUFHU5Ksp9jR4NnvOD4QFYcpfqhzfgPvS9gUGncrgSWzWKb4sBIg7mtO4YW6t1+PgP/YcurQXJUw7z0ST4=@vger.kernel.org X-Gm-Message-State: AOJu0YwY3sAPH3CNGcLDnWsa5q1+z3bReD80Wct67JCJt6JDQDcl4ND3 WPjc0mQSubDVy64y5ZxnHvsjTyKZTL40BDwwzc+N3sGv5PAWTvi7OQkA8hhO39cxmw== X-Gm-Gg: AZuq6aKq7L2XUqMnHNvd9w2HHm/xS5wT7eKKVi0KSwhzSJEfmy1SklzuQHXeD93P5nr kYyAy6bl/Cq4+L4Ai4Y5A+WbJsruBU4uQtFFpK4lptzg/ATOFm6OzUOIkngDn8c1F43orKw9iHk CWatHK3QRztCusagj63h4oqTzjORHrT0jf1lkfpOu5Bfo9bGb8fIQPhSpdO+A8YqXntQ83efNBR 8myFmYLVqNwOPeF9svl7HrkG3nSTPKPurhIsM45odiCUGVCfrjfAgeNV53PWTEg/JaZ3nC/OQ2n VOB+CGUpbbv2GIB1kuYv4w0pQ1iJYb6Z5NnRQXg7+7LH+pOWT8Sl3zecbW3nk2vPKIAWm3/c8Xw cPjefo28hdTLzdd49Yzw0EId6/joJYRcy2BpOo0ZVCUb3XY3URnF//1bbbrRn9jDeqlU1mtpssF sTCrgQn7UHdQ== X-Received: by 2002:a05:690e:13c2:b0:649:3bd8:22b0 with SMTP id 956f58d0204a3-64970d3ee4cmr5023325d50.83.1769479605648; Mon, 26 Jan 2026 18:06:45 -0800 (PST) Received: from um773-cachyos ([2600:1700:cc0:94af:eca6:9ff9:6f3c:5de9]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-6496855d65esm4217415d50.12.2026.01.26.18.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 18:06:45 -0800 (PST) From: Zecheng Li To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Zecheng Li , xliuprof@google.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 11/11] perf dwarf-aux: Collect all variable locations for insn tracking Date: Mon, 26 Jan 2026 21:05:04 -0500 Message-ID: <20260127020617.2804780-12-zli94@ncsu.edu> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260127020617.2804780-1-zli94@ncsu.edu> References: <20260127020617.2804780-1-zli94@ncsu.edu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously, only the first DWARF location entry was collected for each variable. This was based on the assumption that instruction tracking could reconstruct the remaining state. However, variables may have different locations across different address ranges, and relying solely on instruction tracking can miss valid type information. Change __die_collect_vars_cb() to iterate over all location entries using dwarf_getlocations() in a loop. This ensures that variables with multiple location ranges are properly tracked, improving type coverage. Signed-off-by: Zecheng Li --- tools/perf/util/dwarf-aux.c | 60 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index a05d73d6e9e7..3a028d4acb78 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -1643,6 +1643,7 @@ static int __die_collect_vars_cb(Dwarf_Die *die_mem, = void *arg) Dwarf_Op *ops; size_t nops; struct die_var_type *vt; + ptrdiff_t off; =20 if (tag !=3D DW_TAG_variable && tag !=3D DW_TAG_formal_parameter) return DIE_FIND_CB_SIBLING; @@ -1650,41 +1651,40 @@ static int __die_collect_vars_cb(Dwarf_Die *die_mem= , void *arg) if (dwarf_attr(die_mem, DW_AT_location, &attr) =3D=3D NULL) return DIE_FIND_CB_SIBLING; =20 - /* - * Only collect the first location as it can reconstruct the - * remaining state by following the instructions. - * start =3D 0 means it covers the whole range. - */ - if (dwarf_getlocations(&attr, 0, &base, &start, &end, &ops, &nops) <=3D 0) - return DIE_FIND_CB_SIBLING; - - if (!check_allowed_ops(ops, nops)) - return DIE_FIND_CB_SIBLING; - if (__die_get_real_type(die_mem, &type_die) =3D=3D NULL) return DIE_FIND_CB_SIBLING; =20 - vt =3D malloc(sizeof(*vt)); - if (vt =3D=3D NULL) - return DIE_FIND_CB_END; - - /* Usually a register holds the value of a variable */ - vt->is_reg_var_addr =3D false; + /* + * Collect all location entries as variables may have different + * locations across different address ranges. + */ + off =3D 0; + while ((off =3D dwarf_getlocations(&attr, off, &base, &start, &end, &ops,= &nops)) > 0) { + if (!check_allowed_ops(ops, nops)) + continue; =20 - if (((ops->atom >=3D DW_OP_breg0 && ops->atom <=3D DW_OP_breg31) || - ops->atom =3D=3D DW_OP_bregx || ops->atom =3D=3D DW_OP_fbreg) && - !is_breg_access_indirect(ops, nops)) - /* The register contains an address of the variable. */ - vt->is_reg_var_addr =3D true; + vt =3D malloc(sizeof(*vt)); + if (vt =3D=3D NULL) + return DIE_FIND_CB_END; =20 - vt->die_off =3D dwarf_dieoffset(&type_die); - vt->addr =3D start; - vt->end =3D end; - vt->has_range =3D (end !=3D 0 || start !=3D 0); - vt->reg =3D reg_from_dwarf_op(ops); - vt->offset =3D offset_from_dwarf_op(ops); - vt->next =3D *var_types; - *var_types =3D vt; + /* Usually a register holds the value of a variable */ + vt->is_reg_var_addr =3D false; + + if (((ops->atom >=3D DW_OP_breg0 && ops->atom <=3D DW_OP_breg31) || + ops->atom =3D=3D DW_OP_bregx || ops->atom =3D=3D DW_OP_fbreg) && + !is_breg_access_indirect(ops, nops)) + /* The register contains an address of the variable. */ + vt->is_reg_var_addr =3D true; + + vt->die_off =3D dwarf_dieoffset(&type_die); + vt->addr =3D start; + vt->end =3D end; + vt->has_range =3D (end !=3D 0 || start !=3D 0); + vt->reg =3D reg_from_dwarf_op(ops); + vt->offset =3D offset_from_dwarf_op(ops); + vt->next =3D *var_types; + *var_types =3D vt; + } =20 return DIE_FIND_CB_SIBLING; } --=20 2.52.0