Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp478986rwd; Mon, 12 Jun 2023 17:13:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sIldPIKsTvScdDeZLFlFMh3/LOSNO+bfT4bkOC7RTUr48JHveil7rO9vHIsi496+nDxB5 X-Received: by 2002:a17:907:3f91:b0:978:8a30:a8b with SMTP id hr17-20020a1709073f9100b009788a300a8bmr11241991ejc.27.1686615209240; Mon, 12 Jun 2023 17:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686615209; cv=none; d=google.com; s=arc-20160816; b=fyFbgL0saGugLzqRaN2T1kkPXaY9wcday0HZJ4hZEzd31YvW09jw9AED/icN0rtBWu sb/pigr5GPyjQMTZ5qCNh+KZHL7yFGeZpLNyNBYCGhx0ZwlpO7P3+DLWYXJ//uy/ZZHC /2ob9GWje4vpEr43Ee7opDttnuv7XpAgDSW4ZRSIEA3Yoc5icPP5gU1NSl53bmMtR6g4 XM75+uC6L8SkofUd5IPOX466eQ7ACvZyVMMBjHk5P4r5NK3J3v+D49ShC8/7KK8IFuC2 e+bnPQqeqGrmm3lkqNfeKkBBySaBISp5Xha3UAa44zrhtJxJTtV8WWcAMhNIX2gtx/Dk Mw7Q== 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=2idTz1dI6R8Bw9mKAT+NEGNVBgEcKr2rXGyUpAj9+VU=; b=vYRGISD8hSYxVx8F9OkPpPEqNiV5l3dloAavTqfZtklLhXUibK7djo649Ock2MPHQU rc29cPbZmODgs2kXSdcgH2yyMrAE3+9LiDqbi4K2LeR8r/Vhtv7ZjLMEAGAZ6cGAHVHi zMe09Ij8wiVkoDIvEJGEiMZwWgl92SyZKQuP/Ot9pbVPbfEIiaCCh108LQDJ3uWHhjaa EAd9Vuia2OMu46Lr6S1HOPD3eXakH7LdrCqBW0b4z2ctS+oz3OKsjalIlKc1Mxajr677 2iB6caYP7KnNnRtVNMpTq8fJIJ7sNvn6QMbyqnNV/rL/l4r36J7+V3DH7LF7kfxrxDTw hB7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mB7cvxai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jo16-20020a170906f6d000b0096664e81917si6064209ejb.997.2023.06.12.17.12.53; Mon, 12 Jun 2023 17:13:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mB7cvxai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238194AbjFLXlS (ORCPT + 99 others); Mon, 12 Jun 2023 19:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238039AbjFLXlK (ORCPT ); Mon, 12 Jun 2023 19:41:10 -0400 Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0BB7124; Mon, 12 Jun 2023 16:41:07 -0700 (PDT) Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1a6b7060862so191157fac.2; Mon, 12 Jun 2023 16:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686613267; x=1689205267; 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=2idTz1dI6R8Bw9mKAT+NEGNVBgEcKr2rXGyUpAj9+VU=; b=mB7cvxaim/8ZW9lHIU6lPRBtBVdQGyUyF7w/Ves7I7UzY9aln8lv2zFB8x6FiAsoQx evbQJQlxpWjEMLrfL05DdfpvfCKwiCayTx8Cihk32yBvYSvP6vUkjx5kX6Ulaq5L4i2o iflgiWkANNwHQrkF59utzROQChv2vSRy47uBfgVsNt/aUHDprnSjyx6qOzEATxjsXSSf ZQSE7au3F3SwDnx9Z7EDfc4TQl0jMqmBh4HGj8cVygjsOs5zb9ShcNDij2Lt2gQHAInF LZZZq/4JvuOkTln9n5GXrLwd6CDpMURymHyBXCYeKBaHOPaignGE83NFu8k1M5B0G9Qc 6VrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686613267; x=1689205267; 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=2idTz1dI6R8Bw9mKAT+NEGNVBgEcKr2rXGyUpAj9+VU=; b=K0p0lA5Bk0JLLaiIegJV9rqz+q/tBPBXjgzyCJFqby03MAo9QQR2Pi3C5LbEskUgIz HHJEWd/wO8HabovFCqexTd+p58NqqgkAovYMB9XxgUkBvSMcLFMh/lvXQxypHJIPdrvi x4DIlM2T3bG+jYcnL0csXDqYNv/Wn7sUnZkdOzEUvqk/a2e+bW2Q/+XeuCinDQaojlEN qsNeVBkYcpjYomIagsSsg/1EoGHseHEX87/9mz0hxHbfDJbtbYj53uS6WdybUbcWNldm rOsSwERSQQvOuoq942TfsiEUz1Dt75J+v/6Ii9pauuqUDUk143x/d+8soUKLZyzXr05n 4Ufw== X-Gm-Message-State: AC+VfDzAWThQyAb7elIbvZ8G16EUXyC5/FenfzjvxqT+eTGSrvH+eVQj g/aZLsaxgwhzMkt+8XCc/KjQtOF/Iac= X-Received: by 2002:a05:6871:555:b0:177:809e:ead3 with SMTP id t21-20020a056871055500b00177809eead3mr7199845oal.41.1686613266879; Mon, 12 Jun 2023 16:41:06 -0700 (PDT) Received: from moohyul.svl.corp.google.com ([2620:15c:2a3:200:1e19:385a:b5d0:f4a2]) by smtp.gmail.com with ESMTPSA id t12-20020a62ea0c000000b00643355ff6a6sm7565619pfh.99.2023.06.12.16.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 16:41:06 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Masami Hiramatsu Subject: [PATCH 2/2] perf dwarf-aux: Allow unnamed struct/union/enum Date: Mon, 12 Jun 2023 16:41:02 -0700 Message-ID: <20230612234102.3909116-2-namhyung@kernel.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230612234102.3909116-1-namhyung@kernel.org> References: <20230612234102.3909116-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's possible some struct/union/enum type don't have type name. Allow the empty name after "struct"/"union"/"enum" string rather than fail. Signed-off-by: Namhyung Kim --- tools/perf/util/dwarf-aux.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 1ac88b79687d..759434552653 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -1074,16 +1074,18 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf) /* Function pointer */ return strbuf_add(buf, "(function_type)", 15); } else { - if (!dwarf_diename(&type)) - return -ENOENT; + const char *name = dwarf_diename(&type); + if (tag == DW_TAG_union_type) tmp = "union "; else if (tag == DW_TAG_structure_type) tmp = "struct "; else if (tag == DW_TAG_enumeration_type) tmp = "enum "; + else if (name == NULL) + return -ENOENT; /* Write a base name */ - return strbuf_addf(buf, "%s%s", tmp, dwarf_diename(&type)); + return strbuf_addf(buf, "%s%s", tmp, name ?: ""); } ret = die_get_typename(&type, buf); return ret ? ret : strbuf_addstr(buf, tmp); -- 2.41.0.162.gfafddb0af9-goog