From patchwork Thu Nov 9 23:59:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 163641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp786226vqs; Thu, 9 Nov 2023 16:02:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGq1kJUqSU5l3/Jfd6tDlCEvbqSa5l8G+aEDABtwc9LBEDrQtWzrClKugFZw2ARg+kxPEE5 X-Received: by 2002:a05:6830:2003:b0:6d6:3fe4:d4a5 with SMTP id e3-20020a056830200300b006d63fe4d4a5mr958227otp.24.1699574545997; Thu, 09 Nov 2023 16:02:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699574545; cv=none; d=google.com; s=arc-20160816; b=eSHIoLv4l5A/6zHSvNjBLRHjwbWXrlq/Aj0fj/SpeQY5plC4aqhIgbqXpptzzUMtmC FJXN5zqNtdsefSdl9TODmSVpli5WEdPkPw3mIIO4ab2y7o8hKR8TyezTIM4Gnqhj0p9R D8bpKlrhz2OVFO6i1sVIi6opaFpcDQ9hGV5fKc2MDYvSnuttwP6/LxEzqcRTOBD4v7N3 LvtKbzOfCa2RNXPuFc3t4zlb7kx5lD8o0qkNRxAjgFW22xr1M/EsIELjBhBHtXDHvKk2 3cMFtcdRE50zFZGZEQKjpYRpQzibHk0dToH5KNp12YqK+aeFAGABjxgBvlRTpZ88Qg6Q bK5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=YFMOX8SX01fXKILUSbNGFFOegaedr50GlhEgN7HfJ3c=; fh=K//si1Hi/RYC7s39rVvmvh0YbZGmBrdWWHQg3cPF7Xc=; b=D5mdpuq04RcOMT64kQkt/jUrgOks1dZQx4IJO6OK0BwPkMQVdoFzVyoIJKpvSkiwj6 ZJTHsO54c3+Roqz9ZWAg629BEQwuJo3PsOpkI2fvG/TZ6OWDUMLC+xlbrwq9JSmVcyr0 KuI2SCgxWQ29naG1/UsEXrKBUoWEw88ZqAE0D79u55dPjCq1xYS1BvbzXvad0E7rSGzL aUcUq0atj8BZlU2Hdzkors0n2hx1a26n9yEI7fSxNIxMJ/nVyQCLSeRZWPvJEVKgv6k2 gUcH9bV3rcZC1Xni42OQMYLM2olsloapwojOBDvq06HUVBHQ5eQe5knurTRPsPnrjDCr 674Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CbLFzvPC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k8-20020a056830150800b006ce3241a7fbsi6920381otp.338.2023.11.09.16.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:02:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CbLFzvPC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B5E5980E4A25; Thu, 9 Nov 2023 16:01:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345480AbjKJAAh (ORCPT + 30 others); Thu, 9 Nov 2023 19:00:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345446AbjKJAAY (ORCPT ); Thu, 9 Nov 2023 19:00:24 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E4544BE; Thu, 9 Nov 2023 16:00:22 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-27ff7fe7fbcso1299554a91.1; Thu, 09 Nov 2023 16:00:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699574422; x=1700179222; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=YFMOX8SX01fXKILUSbNGFFOegaedr50GlhEgN7HfJ3c=; b=CbLFzvPC358cS0wOpDSrPGATDH0xnqTgZD0dqsUDQcOfBytmiDL3raJOWTRUicod6X wHXzk4NuiM6GcCK0clPzu1SlkG9oBJC2uU2VyA2Av0SCs20VUpwRn0PsdxgfOmJcwhMX Hy4sGGo1FRdoS2hcbnfLAYNh7kOiVuV0dE1+2rWb/AirRrud7TtxZFJl/W9czdrSo+qU zfW/B1WQ2cNe7ykTb3SKrAx8GYadAMvQX4rbU9Ua+LBlTGsVj+RkVwdmAXhnW/2I4tbP H6GxQ+oFJOGr/i8FTkIhnhCgSGnbbBKNCnzPRtgQ8vSLwO3tEYHh0j+61Q620hlGxmut G11w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699574422; x=1700179222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YFMOX8SX01fXKILUSbNGFFOegaedr50GlhEgN7HfJ3c=; b=f7iO/DpGZppY8pXBqHJ84jmT2CH1Eco5OznaId5G8jIogTIyN5kAFmmEXqtceDp8+z UmLV8/pYOZ4/QGwjdGM7tGI4MQMIMGYmBKorWDf5iomyGypxEkhG1NslQgs4lskPpnwq YiTb8LCUAkohWx8CHaKGyIS6WFDXQbZ+B93GeFA/XjufAiTIpzNQobFzWn9v1FW1Crkr eOye93utTxw5GIGbjZpoR/+3ZewG9h+tW9VIF2Vp37dJi5Dqao28phStJE18g42R+pWE 9xOMyJ34saxxlW6LQHLCe4B17RF566MjrPO599NAvFQNKQnh9adFn1Y0Iu96qWVgeH22 xc6A== X-Gm-Message-State: AOJu0YxVEsgW+mMGEhdmYkSoU86vnSsMK5KAEaGa26k6BlRhafUOUGPA K2u4vAdmlI5RbKUO5CIYRqA= X-Received: by 2002:a17:90a:e7c7:b0:281:3fb:6df1 with SMTP id kb7-20020a17090ae7c700b0028103fb6df1mr3301226pjb.46.1699574422245; Thu, 09 Nov 2023 16:00:22 -0800 (PST) Received: from bangji.corp.google.com ([2620:15c:2c0:5:d45c:ae16:d959:a5f1]) by smtp.gmail.com with ESMTPSA id k32-20020a17090a4ca300b002635db431a0sm371312pjh.45.2023.11.09.16.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 16:00:21 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa , Peter Zijlstra Cc: Ian Rogers , Adrian Hunter , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Linus Torvalds , Stephane Eranian , Masami Hiramatsu , Andi Kleen , linux-trace-devel@vger.kernel.org, linux-toolchains@vger.kernel.org Subject: [PATCH 04/52] perf dwarf-aux: Fix die_get_typename() for void * Date: Thu, 9 Nov 2023 15:59:23 -0800 Message-ID: <20231110000012.3538610-5-namhyung@kernel.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231110000012.3538610-1-namhyung@kernel.org> References: <20231110000012.3538610-1-namhyung@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 09 Nov 2023 16:01:23 -0800 (PST) X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782133079069775228 X-GMAIL-MSGID: 1782133079069775228 The die_get_typename() is to return a C-like type name from DWARF debug entry and it follows data type if the target entry is a pointer type. But I found void pointers don't have the type attribte to follow and then the function returns an error for that case. This results in a broken type string for void pointer types. For example, the following type entries are pointer types. <1><48c>: Abbrev Number: 4 (DW_TAG_pointer_type) <48d> DW_AT_byte_size : 8 <48d> DW_AT_type : <0x481> <1><491>: Abbrev Number: 211 (DW_TAG_pointer_type) <493> DW_AT_byte_size : 8 <1><494>: Abbrev Number: 4 (DW_TAG_pointer_type) <495> DW_AT_byte_size : 8 <495> DW_AT_type : <0x49e> The first one at offset 48c and the third one at offset 494 have type information. Then they are pointer types for the referenced types. But the second one at offset 491 doesn't have the type attribute. Acked-by: Masami Hiramatsu (Google) Signed-off-by: Namhyung Kim --- tools/perf/util/dwarf-aux.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 2941d88f2199..4849c3bbfd95 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -1090,7 +1090,14 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf) return strbuf_addf(buf, "%s%s", tmp, name ?: ""); } ret = die_get_typename(&type, buf); - return ret ? ret : strbuf_addstr(buf, tmp); + if (ret < 0) { + /* void pointer has no type attribute */ + if (tag == DW_TAG_pointer_type && ret == -ENOENT) + return strbuf_addf(buf, "void*"); + + return ret; + } + return strbuf_addstr(buf, tmp); } /**