Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2780074rwd; Fri, 9 Jun 2023 17:22:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6AZWy+caq6iwO++TIbvrlojwofRkk24OeIePhiCNagHGQQxSbXFyTMhMGeAKKotrT8y3c4 X-Received: by 2002:a05:6a00:24d6:b0:646:59e4:94eb with SMTP id d22-20020a056a0024d600b0064659e494ebmr3328514pfv.15.1686356547003; Fri, 09 Jun 2023 17:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686356546; cv=none; d=google.com; s=arc-20160816; b=EOQeeAkW/h+gyeOsQQnASwol+SRqW59Q6Pq5prX5K/P9XYvoFm/XoUyt5MpC2T4kzQ 6TvRuxgHCs43ZsUSmNEkx6pEhHW5ScJC452P/5+VhUPmKO3ifr/lQG3IWIZEfzveXOLm cHtjZY1kRcvT9xN855fCa7qGbazyiqvDzg/421XVl23oAAjx/mM76NSqKSLbVVePh4Rn bKApykb8Jj9V5OlVROLS7ZpL4QXLs02sBC78kokU9rv3M3pEGNWgrfFz3lR+nMmbHY+L gplswGlL2/q52DbjCuz3m9r4PNFg42x1myJ6n442O0seuZZSeDkog8cgwb6Lq8JbSw8+ 6w1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=cZRa8J45tSEoIBwwMfP3oeiIjnBxryB3tiHQ4mYVspA=; b=Hq8RVpvw2ppzyTSeGywpZ/gy8RVG+leJACEnn7vYLZww/JiVpSO+fvodWra8j5aNSA bohVsgPQ9eRNW+2TQ7ZY70yAxgVJxBERCFmY7bQXXNFNVowg1ZTrBpKilAJQlWaWgoYj ufwjctglMVkTcd7z6J6oz7QwafRjbYky2x2fHYH/4d48q/K8+043arORK2ociC2CkFoz Lg4lNLeB3ViB7ZtVrtnRhLWPEQvNGAg9EQrMzWZSqOj+N94o8QH7zavi2fNk+pkiYxTL FXUfDduSAkprVZkFFMbTcjEynQKZT8zkErj0MO/bJ4z13rYQiioM+o8VEj487h7XLGuJ /U0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=A0YP3D1M; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a056a00080b00b0064f3c650248si3352136pfk.91.2023.06.09.17.22.13; Fri, 09 Jun 2023 17:22:26 -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=@google.com header.s=20221208 header.b=A0YP3D1M; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231630AbjFIXyb (ORCPT + 99 others); Fri, 9 Jun 2023 19:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjFIXya (ORCPT ); Fri, 9 Jun 2023 19:54:30 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C87D135B0 for ; Fri, 9 Jun 2023 16:54:28 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-bb397723627so2798914276.1 for ; Fri, 09 Jun 2023 16:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686354868; x=1688946868; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=cZRa8J45tSEoIBwwMfP3oeiIjnBxryB3tiHQ4mYVspA=; b=A0YP3D1MDS6ipDOhIWcopNNcD1QYcBlz/2xVJXWlJnEcbGaUxeiAs8tAUYkIngCOa8 MQo2PIbwQsXAFY1yuFQGkjf3bvgbdqa3mrQBK2i0yIO5RLeYwe/tpXG6AkOgOrci1IM6 ee3XPIDjmnxTfAdqa01/cUYTAwXqQaBt3LihZqFiSQfj+Jb56vCWeBQ0D7e3X0KHZvuN yynmKcETGjwSFfENJ2wUnkXz3Ho9B6qnkXADkQCciNzXPJ2rCD22RrDxLcS5y4lyZldw C5JPSBAZ0ooPspDHdyJ11GeQVbOA4ixy1f+h1W52hL6Td8d6Y+NofNCoJTEmAYSVrDGh 4PwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686354868; x=1688946868; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cZRa8J45tSEoIBwwMfP3oeiIjnBxryB3tiHQ4mYVspA=; b=FXZwumC8j2AbujeCu7vNAEcVvo+3j4hD/M4azzb3F4MLMT7pIqIWleC0IsGw+jjkad YO6Rb1oIEo1mEk6hZ5uLDVRJpEQk8h8mEeHDE2iLObiyDbbRyENxVNGtPzOQXQoKA8Cl LUpvmvrOneq/Pa/5NKYr1Na5LkYOLh86lJCcU2sN0g7G3N7jDbnZPFCjziY0BoTfejNf l9NEjbsedxkIfRtg/nNRNw1+l9pyB1WP6dhsxSgSERWYBdeffu2zQcnyyrI8oeeUmEeA iIhneLwBk83bhzD2XD3SP4Y0buLStknDPuVYp/DzeO6RkbADUTCz3lZHwSmu4HnkHVxo SVGA== X-Gm-Message-State: AC+VfDzaM7Bw4KdMMTILhcRtmq2pS0+RkiCWUX3d02uX7Zl0VRvremQq V6OffsFf6NtDoEFV8HPf9EXMXRRBqXue X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:55f2:1922:c44b:472d]) (user=irogers job=sendgmr) by 2002:a05:6902:1085:b0:ba8:cbd2:61b3 with SMTP id v5-20020a056902108500b00ba8cbd261b3mr731327ybu.5.1686354868009; Fri, 09 Jun 2023 16:54:28 -0700 (PDT) Date: Fri, 9 Jun 2023 16:54:18 -0700 Message-Id: <20230609235419.204624-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v1 1/2] perf srcline: Make addr2line configuration failure more verbose From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Changbin Du Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham 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 To aid debugging why it fails. Also, combine the loops for reading a line for the llvm/binutils cases. Signed-off-by: Ian Rogers --- tools/perf/util/srcline.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index b8e596528d7e..fc85cdd6c8f9 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -441,7 +441,7 @@ enum a2l_style { LLVM, }; -static enum a2l_style addr2line_configure(struct child_process *a2l) +static enum a2l_style addr2line_configure(struct child_process *a2l, const char *dso_name) { static bool cached; static enum a2l_style style; @@ -450,6 +450,7 @@ static enum a2l_style addr2line_configure(struct child_process *a2l) char buf[128]; struct io io; int ch; + int lines; if (write(a2l->in, ",\n", 2) != 2) return BROKEN; @@ -459,19 +460,29 @@ static enum a2l_style addr2line_configure(struct child_process *a2l) if (ch == ',') { style = LLVM; cached = true; + lines = 1; } else if (ch == '?') { style = GNU_BINUTILS; cached = true; + lines = 2; } else { - style = BROKEN; + if (!symbol_conf.disable_add2line_warn) { + char *output; + size_t output_len; + + io__getline(&io, &output, &output_len); + pr_warning("%s %s: addr2line configuration failed\n", + __func__, dso_name); + pr_warning("\t%c%s\n", ch, output); + } + return BROKEN; } - do { + while (lines) { ch = io__get_char(&io); - } while (ch > 0 && ch != '\n'); - if (style == GNU_BINUTILS) { - do { - ch = io__get_char(&io); - } while (ch > 0 && ch != '\n'); + if (ch <= 0) + break; + if (ch == '\n') + lines--; } /* Ignore SIGPIPE in the event addr2line exits. */ signal(SIGPIPE, SIG_IGN); @@ -591,12 +602,9 @@ static int addr2line(const char *dso_name, u64 addr, pr_warning("%s %s: addr2line_subprocess_init failed\n", __func__, dso_name); goto out; } - a2l_style = addr2line_configure(a2l); - if (a2l_style == BROKEN) { - if (!symbol_conf.disable_add2line_warn) - pr_warning("%s: addr2line configuration failed\n", __func__); + a2l_style = addr2line_configure(a2l, dso_name); + if (a2l_style == BROKEN) goto out; - } /* * Send our request and then *deliberately* send something that can't be interpreted as -- 2.41.0.162.gfafddb0af9-goog