From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A4BCA3858D33 for ; Thu, 18 Jan 2024 00:15:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4BCA3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A4BCA3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705536918; cv=none; b=TYqTG85KumNlMGJ9bqOg8KmKulO0rr1NUcpEKRogWHYEM+GXWKk3TVSBx6D3XbsM5o5GkCl0mOtqQJrb6kTwyvtx2MbXLmbuwzDFQHBDe4j6oy1S0eUG7kC3rmj5vgdDL9n1EIEKkv0l82sS4RYq3B04/aFhohCBmtkbAQeb03o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705536918; c=relaxed/simple; bh=wLEO/Q4rXMoL7cz8bypzKnFKERBfPrZukOQWxpsM+fY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=BUjH2Nirs5Vhw/VVcssLyU65EUYxIXA1KK5wF93gKFQw0q4ekM6bqpCXM1K2oYypIjotqcOpWVKrVU/8OIWIi1weTxwKyxX6q+CHmmX+e3uyaEfvtUSs7NSII3N2cHChXeq+Y0FU5uHxpNbrYzp7m/V0uhj0+lR4KI1vouKkNGg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705536916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H3Gp3oxzMget3TkvrQzMprykBCD7lmkkPsAvIXXUsoM=; b=WVFK73OgMCb9Z3xYra2JNLfVUmkhcoPmytYpDN3uwtjIZZQlwwiahzwRdR6e2C7awqXNxa Q8a4C0CtOo9UsrEfYfBA70pgJRpPbN6otSkllaMGZ7457CfInPxZCgx4VrsAWAJfOZjOkr eKNBMPfw3vk5pdNSRliGcjxMmTB0hb8= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-45-c1WbhfRdO46KUqgO_XRO9w-1; Wed, 17 Jan 2024 19:15:14 -0500 X-MC-Unique: c1WbhfRdO46KUqgO_XRO9w-1 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-28be574c1c4so12186384a91.1 for ; Wed, 17 Jan 2024 16:15:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705536913; x=1706141713; 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=H3Gp3oxzMget3TkvrQzMprykBCD7lmkkPsAvIXXUsoM=; b=m+PcFN8lwWCFDAV/VO7wYTrv0GrXKdqwlKAahFHKbGYFunlUdhIRwDrfAyNMNZ6HH8 U2NxYTDj3WnDv8DEyCW+laxK92kCORE5zJolUEdgkNMQa0Vu8mwK+uWtoA0Ai4AwbQRw QBGglNy2vULzrrQus/W1S2ieFZdPPPMrsLdxk6g21VD8b34pLo/rnmxGTSEu2ZlUpZeV /A1x7e19ooMvVfWuobHKvsvZERMQFPl4eMHoVr3UHNEb2BI3pCoYt1ADzu1gFzxa25Gk p02G+99V7ZrLYceNQReGl+sgTS5rIUuQY80YhCOpI1nPn7pNHC4Qm3DR/BqjjXsj6Mm9 UIBg== X-Gm-Message-State: AOJu0YxLh7dwJcL1Ei9rTiU15dd0TN4Rc3xfLL5b3XiaOwhsxLVmFDvL 9Kyx1PJ3lXzJvFazuVwX8A/FXfQEYsYu3xxd5TIAiDPyWgUEtADYsFgtqMwMsoQTLVehhnrhlQi pUIdOrWF11NfjM1BvVS7YCOdoPWzRCSRMyIkAdRdetUT63TOU/hBwQkCJ8uVh3oDBTc2D5MH+lR YgLkpnXm+DwbI4DWB/VRDlTqznDI6LHk1s+2pF/j2p X-Received: by 2002:a17:90b:fd6:b0:290:14a2:55be with SMTP id gd22-20020a17090b0fd600b0029014a255bemr71449pjb.25.1705536913320; Wed, 17 Jan 2024 16:15:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHAQc8uYVzBUtCiV9lY3SOAGV/XpSl3fHRf45EZzJNxGvSH9kJdXSnR2BB4sMnak9AAbnIA5WFdOeQ+casLPs= X-Received: by 2002:a17:90b:fd6:b0:290:14a2:55be with SMTP id gd22-20020a17090b0fd600b0029014a255bemr71442pjb.25.1705536913001; Wed, 17 Jan 2024 16:15:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Aaron Merey Date: Wed, 17 Jan 2024 19:15:01 -0500 Message-ID: Subject: Re: [PATCH] PR29997: Fix the symbol aliases search failure when symbol version is missing To: Di Chen Cc: systemtap@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Di, Thanks for the patch. On Tue, Dec 19, 2023 at 9:56=E2=80=AFPM Di Chen wrote: > > Hey Aaron, > > I have added the wildcard handling for the PR29997. > > From 0c95ce19272d6e13abf6f41c4ae29b6aa925ca20 Mon Sep 17 00:00:00 2001 > From: Di Chen > Date: Sun, 5 Nov 2023 11:23:50 +0800 > Subject: [PATCH] PR29997: Fix the symbol aliases search failure when symb= ol > version is missing > > After calling module_info::update_symtab, function aliases will be > populated. Then the updated symtab will be used for symbol searching. > > For the _IO_new_fopen familty with the aliases: > > $ eu-readelf -s /lib64/libc.so.6 | grep 0000000000077440 > 247: 0000000000077440 14 FUNC WEAK DEFAULT 16 fopen64@= @GLIBC_2.2.5 > 1014: 0000000000077440 14 FUNC GLOBAL DEFAULT 16 fopen@@G= LIBC_2.2.5 > 1028: 0000000000077440 14 FUNC GLOBAL DEFAULT 16 _IO_fope= n@@GLIBC_2.2.5 > 1556: 0000000000077440 14 FUNC LOCAL DEFAULT 16 _IO_fope= n64 > 3471: 0000000000077440 14 FUNC LOCAL DEFAULT 16 __new_fo= pen > 4765: 0000000000077440 14 FUNC LOCAL DEFAULT 16 _IO_new_= fopen > 5110: 0000000000077440 14 FUNC WEAK DEFAULT 16 fopen64 > 7198: 0000000000077440 14 FUNC GLOBAL DEFAULT 16 fopen@@G= LIBC_2.2.5 > 7433: 0000000000077440 14 FUNC GLOBAL DEFAULT 16 _IO_fope= n@@GLIBC_2.2.5 > > a) fopen@@GLIBC_2.2.5 exists in the updated symtab > b) fopen does not exist in the updated symtab > > This PR is to add a version info padding when symbol cannot be found in > the updated symtab. > > Signed-off-by: Di Chen > --- > dwflpp.cxx | 44 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 43 insertions(+), 1 deletion(-) > > diff --git a/dwflpp.cxx b/dwflpp.cxx > index 9fccca0a9..044b0ca97 100644 > --- a/dwflpp.cxx > +++ b/dwflpp.cxx > @@ -1055,6 +1055,15 @@ dwflpp::iterate_over_functions(int (*callbac= k)(Dwarf_Die*, void*), > } > > auto range =3D v->equal_range(function); > + // version padding if the symbol is not found > + if (range.first =3D=3D range.second) > + { > + std::string function_with_ver =3D function + "@"; > + for (auto it =3D v->begin(); it !=3D v->end(); ++it) > + if (it->first.find(function_with_ver) =3D=3D 0) > + function_with_ver =3D it->first; > + range =3D v->equal_range(function_with_ver); > + } Just a nit but there should be another 2 spaces of indentation for the lines between these braces. > if (range.first !=3D range.second) > { > for (auto it =3D range.first; it !=3D range.second; ++it) > @@ -1098,7 +1107,10 @@ dwflpp::iterate_over_functions(int (*callbac= k)(Dwarf_Die*, void*), > if (pending_interrupts) return DWARF_CB_ABORT; > const string& func_name =3D it->first; > Dwarf_Die& die =3D it->second; > - if (function_name_matches_pattern (func_name, function)) > + > + // version padding if the pattern is not matched > + if ((function_name_matches_pattern (func_name, function)) || > + (function_name_matches_pattern (func_name, function + "@*"= ))) Nice, this fixes the issue where names containing wildcards and version info aren't found. > { > if (sess.verbose > 4) > clog << _F("function cache %s:%s match %s vs %s", module= _name.c_str(), > @@ -1141,6 +1153,15 @@ dwflpp::iterate_single_function(int (*callba= ck)(Dwarf_Die*, void*), > } > > auto range =3D v->equal_range(function); > + // version padding if the symbol is not found > + if (range.first =3D=3D range.second) > + { > + std::string function_with_ver =3D function + "@"; > + for (auto it =3D v->begin(); it !=3D v->end(); ++it) > + if (it->first.find(function_with_ver) =3D=3D 0) > + function_with_ver =3D it->first; > + range =3D v->equal_range(function_with_ver); > + } > if (range.first !=3D range.second) > { > for (auto it =3D range.first; it !=3D range.second; ++it) > @@ -1158,6 +1179,27 @@ dwflpp::iterate_single_function(int (*callba= ck)(Dwarf_Die*, void*), > if (rc !=3D DWARF_CB_OK) break; > } > } > + else if (name_has_wildcard (function)) > + { > + for (auto it =3D v->begin(); it !=3D v->end(); ++it) > + { > + if (pending_interrupts) return DWARF_CB_ABORT; > + const string& func_name =3D it->first; > + Dwarf_Die& die =3D it->second; > + > + // version padding if the pattern is not matched > + if ((function_name_matches_pattern (func_name, function)) || > + (function_name_matches_pattern (func_name, function + "@*"= ))) > + { > + if (sess.verbose > 4) > + clog << _F("function cache %s:%s match %s vs %s", module= _name.c_str(), > + cu_name().c_str(), func_name.c_str(), functio= n.c_str()) << endl; > + > + rc =3D (*callback)(& die, data); > + if (rc !=3D DWARF_CB_OK) break; > + } > + } > + } Do we need to include wildcard handling here? Since this function didn't originally include any wildcard handling, I'd assume that searches for names with wildcards would always go through dwflpp::iterate_over_functions instead. > > // undo the focus_on_cu > this->cu =3D NULL; > -- > 2.41.0 I was also thinking about whether we should include "@" handling for mangled C++ names as well in dwflpp::iterate_over_functions. I experimented with trying to list probe points with mangled function names that include version info. eu-readelf shows some mangled names with "@" in the stap binary. However it looks like these names never appear among the linkage_names from dwarf_linkage_name that are searched for a match. For example, "_ZSt24__throw_out_of_range_fmtPKcz@GLIBCXX_3.4.20" is list by eu-readelf in my locally built stap binary but it doesn't appear in a dump of linkage_names search during `stap -L 'process("/usr/local/bin/stap").function("_ZSt24__throw_out_of_range_fmtPKc= z")'`. This might be a bug or possibly a limitation of dwarf_linkage_name. However this goes beyond the scope of your patch so it's ok to not address this in your patch. Aaron ~