diff options
author | dknysh <d.knysh@nips.ru> | 2020-10-06 17:14:51 +0700 |
---|---|---|
committer | Darya Knysh <d.knysh@nips.ru> | 2020-10-07 07:51:03 +0000 |
commit | 254b3d3190ee3f264a083f32704748c24c6f3a94 (patch) | |
tree | 1c26d96fb792b8cd07fa8b23087bc056055efe11 | |
parent | 0d969e8e5354514011aa2fccc08d9f820e892c80 (diff) |
Allow zero sized symbols in the address cache
Apparently there are situations where the compiler generates entries
in the symbol table with zero size which are still referenced by some
callstacks. After commit d8d56b7e we ended up losing the symbol names
in such cases. This patch fixes it again and restores the symbol names
for such zero-size symbols.
Change-Id: If98f68626ab4251ccfed89d791ebd333f6a6a60a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/perfaddresscache.cpp | 2 | ||||
-rw-r--r-- | app/perfaddresscache.h | 2 | ||||
-rw-r--r-- | tests/auto/addresscache/tst_addresscache.cpp | 3 | ||||
-rw-r--r-- | tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt | 3 | ||||
-rw-r--r-- | tests/auto/perfdata/vector_static_gcc/perf.data.zstd.expected.txt | 3 |
5 files changed, 8 insertions, 5 deletions
diff --git a/app/perfaddresscache.cpp b/app/perfaddresscache.cpp index 18edef1..46938cf 100644 --- a/app/perfaddresscache.cpp +++ b/app/perfaddresscache.cpp @@ -86,7 +86,7 @@ PerfAddressCache::SymbolCacheEntry PerfAddressCache::findSymbol(const QByteArray --it; - if (it->offset <= relAddr && it->offset + it->size > relAddr) { + if (it->offset <= relAddr && (it->offset + it->size > relAddr || (it->size == 0))) { // demangle symbols on demand instead of demangling all symbols directly // hopefully most of the symbols we won't ever encounter after all if (!it->demangled) { diff --git a/app/perfaddresscache.h b/app/perfaddresscache.h index 6e18a34..6bc780d 100644 --- a/app/perfaddresscache.h +++ b/app/perfaddresscache.h @@ -48,7 +48,7 @@ public: , symname(symname) {} - bool isValid() const { return size != 0; } + bool isValid() const { return !symname.isEmpty(); } quint64 offset; quint64 size; diff --git a/tests/auto/addresscache/tst_addresscache.cpp b/tests/auto/addresscache/tst_addresscache.cpp index 8136682..6387a4e 100644 --- a/tests/auto/addresscache/tst_addresscache.cpp +++ b/tests/auto/addresscache/tst_addresscache.cpp @@ -72,7 +72,7 @@ private slots: QVERIFY(!cache.findSymbol(libfoo_a, 0).isValid()); QVERIFY(!cache.findSymbol(libfoo_b, 0).isValid()); - cache.setSymbolCache(libfoo_a, {{0x100, 10, "Foo"}}); + cache.setSymbolCache(libfoo_a, {{0x100, 10, "Foo"}, {0x11a, 0, "FooZ"}, {0x12a, 10, "FooN"}}); for (auto addr : {0x100, 0x100 + 9}) { const auto cached = cache.findSymbol(libfoo_a, addr); QVERIFY(cached.isValid()); @@ -83,6 +83,7 @@ private slots: QVERIFY(!cache.findSymbol(libfoo_a, 0x100 + 10).isValid()); QVERIFY(!cache.findSymbol(libfoo_b, 0x100).isValid()); QVERIFY(!cache.findSymbol(libfoo_b, 0x100 + 9).isValid()); + QVERIFY(cache.findSymbol(libfoo_a, 0x11a + 1).isValid()); } }; diff --git a/tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt b/tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt index d494b31..9ef4378 100644 --- a/tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt +++ b/tests/auto/perfdata/vector_static_gcc/perf.data.expected.txt @@ -711,7 +711,8 @@ vector_static_g 349054 349054 65149.476874692 vector_static_g 349054 349054 65149.477126147 cycles: 315591 - 400480 <.plt+400480> vector_static_gcc_v9.1.0 /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/auto/perfdata/vector_static_gcc/vector_static_gcc_v9.1.0 + 400480 + 400430 _init vector_static_gcc_v9.1.0 /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/auto/perfdata/vector_static_gcc/vector_static_gcc_v9.1.0 40155c /usr/include/c++/9.1.0/bits/stl_algo.h:4449:13 40152b /usr/include/c++/9.1.0/bits/stl_algo.h:4441:5 std::generate_n<std::back_insert_iterator<std::vector<double> >, int, main()::<lambda()> > vector_static_gcc_v9.1.0 /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/auto/perfdata/vector_static_gcc/vector_static_gcc_v9.1.0 40152b ../../../manual/clients/vector.cpp:16:6 diff --git a/tests/auto/perfdata/vector_static_gcc/perf.data.zstd.expected.txt b/tests/auto/perfdata/vector_static_gcc/perf.data.zstd.expected.txt index e62f41a..f7af600 100644 --- a/tests/auto/perfdata/vector_static_gcc/perf.data.zstd.expected.txt +++ b/tests/auto/perfdata/vector_static_gcc/perf.data.zstd.expected.txt @@ -247,7 +247,8 @@ vector_static_g 267677 267677 9952.368475245 vector_static_g 267677 267677 9952.368668898 cycles: 415081 - 400490 <.plt+400490> vector_static_gcc_v9.1.0 /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/auto/perfdata/vector_static_gcc/vector_static_gcc_v9.1.0 + 400490 + 400430 _init vector_static_gcc_v9.1.0 /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/auto/perfdata/vector_static_gcc/vector_static_gcc_v9.1.0 401572 /usr/include/c++/9.1.0/bits/stl_algo.h:4449:13 40152b /usr/include/c++/9.1.0/bits/stl_algo.h:4441:5 std::generate_n<std::back_insert_iterator<std::vector<double> >, int, main()::<lambda()> > vector_static_gcc_v9.1.0 /home/milian/projects/kdab/rnd/hotspot/3rdparty/perfparser/tests/auto/perfdata/vector_static_gcc/vector_static_gcc_v9.1.0 40152b ../../../manual/clients/vector.cpp:16:6 |