diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2021-02-25 22:35:52 +0100 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2022-06-10 08:46:35 +0000 |
commit | 53cd4872a092f4619d2a383d6dc39086d3ce9a34 (patch) | |
tree | 1928e65f5b7f05e31624433aaf7a9f228afd080e | |
parent | bf8d70fd31f2d8ad7e208847303f6317788d1e32 (diff) |
Add missing '::' when hitting cached scope names
Fixes C++ symbol names in some situations as shown by the changes
to the expected test data. Because the code to build the scope
names is complex, I added a longer comment in the hope that this
better explains the behavior and logic of this code.
The test e.g. now has this changed behavior:
```
- 201650 201700 /usr/include/c++/12.1.0/bits/shared_ptr_base.h:611:7 201650 dc std_Sp_counted_ptr_inplace<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main(int, char**)::<lambda()> > >, double>, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>_M_dispose parallel_static_gcc /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/manual/clients/parallel_static_gcc
+ 201650 201700 /usr/include/c++/12.1.0/bits/shared_ptr_base.h:611:7 201650 dc std::_Sp_counted_ptr_inplace<std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<main(int, char**)::<lambda()> > >, double>, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose parallel_static_gcc /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/manual/clients/parallel_static_gcc
```
Change-Id: Iaa82add2c878796890decb4365b3ca783b46f355
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/perfdwarfdiecache.cpp | 12 | ||||
-rw-r--r-- | tests/auto/perfdata/parallel_static_gcc/perf.data.zstd.expected.txt.zlib | bin | 14836 -> 14745 bytes | |||
-rw-r--r-- | tests/auto/perfdata/tst_perfdata.cpp | 2 |
3 files changed, 14 insertions, 0 deletions
diff --git a/app/perfdwarfdiecache.cpp b/app/perfdwarfdiecache.cpp index 123ebac..fb87b25 100644 --- a/app/perfdwarfdiecache.cpp +++ b/app/perfdwarfdiecache.cpp @@ -139,6 +139,14 @@ void prependScopeNames(QByteArray &name, Dwarf_Die *die, QHash<Dwarf_Off, QByteA Dwarf_Die *scopes = nullptr; auto nscopes = dwarf_getscopes_die(die, &scopes); + // We essentially visit and build the scope name in reverse order. + // The cache ops encode offsets we can lookup directly that then map to fully + // qualified identifiers, which must obviously _not_ end on a double-colon separator. + // Note that while filling cacheOps below, we thus always have to prepend the double-colon + // first to the name, then store the cacheOps with the size of `name`. While that may sound + // confusing, that gives us the desired results: `ScopesToCache::trailing` will then be set + // to the size _following_ the current entry, which may get more identifiers appended to + // it when we continue to visit the other DIEs next. struct ScopesToCache { Dwarf_Off offset; @@ -154,6 +162,10 @@ void prependScopeNames(QByteArray &name, Dwarf_Die *die, QHash<Dwarf_Off, QByteA auto it = cache.find(scopeOffset); if (it != cache.end()) { + // prepend the fully qualified cached identifier + // that won't end on `::`, so we have to add that manually here + if (!name.isEmpty()) + name.prepend("::"); name.prepend(*it); // we can stop, cached names are always fully qualified break; diff --git a/tests/auto/perfdata/parallel_static_gcc/perf.data.zstd.expected.txt.zlib b/tests/auto/perfdata/parallel_static_gcc/perf.data.zstd.expected.txt.zlib Binary files differindex eaaa310..39f0703 100644 --- a/tests/auto/perfdata/parallel_static_gcc/perf.data.zstd.expected.txt.zlib +++ b/tests/auto/perfdata/parallel_static_gcc/perf.data.zstd.expected.txt.zlib diff --git a/tests/auto/perfdata/tst_perfdata.cpp b/tests/auto/perfdata/tst_perfdata.cpp index b4a72dd..d0706c9 100644 --- a/tests/auto/perfdata/tst_perfdata.cpp +++ b/tests/auto/perfdata/tst_perfdata.cpp @@ -348,6 +348,8 @@ void TestPerfData::testFiles() } if (actualText != expectedText) { + compressFile(actualOutputFile); + const auto diff = QStandardPaths::findExecutable("diff"); if (!diff.isEmpty()) { { |