From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH 4/4] Skip .cold functions in search_minsyms_for_name
Date: Sun, 31 Jan 2021 10:13:54 +0100 [thread overview]
Message-ID: <AM8PR10MB4708A65F874E98524AA80E7FE4B79@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM> (raw)
When a function with the same name is also available,
that is preferred.
The .cold function is not the external interface.
Fixes 77f2120b200 ("Don't drop static function bp locations w/o debug info")
gdb:
2020-11-30 Bernd Edlinger <bernd.edlinger@hotmail.de>
* linespec.c (search_minsyms_for_name): Filter .cold functions when
a real function with the same name is found.
gdb/testsuite:
2020-11-30 Bernd Edlinger <bernd.edlinger@hotmail.de>
* gdb.cp/step-and-next-inline-1.exp: New test.
---
gdb/linespec.c | 24 ++++++++++++++++++++
gdb/testsuite/gdb.cp/step-and-next-inline-1.exp | 30 +++++++++++++++++++++++++
2 files changed, 54 insertions(+)
create mode 100644 gdb/testsuite/gdb.cp/step-and-next-inline-1.exp
diff --git a/gdb/linespec.c b/gdb/linespec.c
index a9809a5..37feaed 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4394,6 +4394,30 @@ class symtab_collector
break;
}
}
+ else if (MSYMBOL_TYPE (item.minsym) == mst_file_text
+ && strlen (item.minsym->linkage_name ()) > 5)
+ {
+ size_t namelen = strlen (item.minsym->linkage_name ()) - 5;
+ if (memcmp (item.minsym->linkage_name () + namelen, ".cold", 5) == 0)
+ for (const bound_minimal_symbol &item2 : minsyms)
+ {
+ if (&item2 == &item)
+ continue;
+
+ if (MSYMBOL_TYPE (item2.minsym) != mst_file_text
+ && MSYMBOL_TYPE (item2.minsym) != mst_text)
+ continue;
+
+ if (strlen (item2.minsym->linkage_name ()) == namelen
+ && memcmp (item.minsym->linkage_name (),
+ item2.minsym->linkage_name (), namelen) != 0)
+ continue;
+
+ /* found a real function with the same name as cold part. */
+ skip = true;
+ break;
+ }
+ }
if (!skip)
info->result.minimal_symbols->push_back (item);
diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline-1.exp b/gdb/testsuite/gdb.cp/step-and-next-inline-1.exp
new file mode 100644
index 0000000..02200a4
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/step-and-next-inline-1.exp
@@ -0,0 +1,30 @@
+# Copyright 2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile step-and-next-inline.cc
+
+if [get_compiler_info "c++"] {
+ unsupported "couldn't find a valid c++ compiler"
+ return -1
+}
+
+set options {c++ debug nowarnings optimize=-O2}
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile $options] } {
+ return -1
+}
+
+# Test that b get_alias_set sets only one breakpoint,
+# thus get_alias_set.cold is filtered away.
+gdb_test "b get_alias_set" ".*Breakpoint .*$srcfile, line .*" "test1"
--
1.9.1
next reply other threads:[~2021-01-31 9:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-31 9:13 Bernd Edlinger [this message]
2021-01-31 17:03 ` Andrew Burgess
2021-01-31 18:06 ` Bernd Edlinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM8PR10MB4708A65F874E98524AA80E7FE4B79@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM \
--to=bernd.edlinger@hotmail.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox