From ed79e85ae0cccc5aa912856bbebfd86986d8df86 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 17 Jul 2024 12:47:07 -0400 Subject: [PATCH] profile: Don't try to be clever in SharedImage::ContainsAddress(). The data section could theoretically be before the text section, but it also may not exist and have a size of 0. The commpage image is one such image with those qualities, and so we would thus always find it as having a hit when encountering it in the list. And since data_size might be 0, just do < instead of <= and -1. This massively fixes the profiler's output. --- src/bin/debug/profile/SharedImage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/debug/profile/SharedImage.h b/src/bin/debug/profile/SharedImage.h index 1afa03b72d..dd9eb55a1c 100644 --- a/src/bin/debug/profile/SharedImage.h +++ b/src/bin/debug/profile/SharedImage.h @@ -106,8 +106,8 @@ SharedImage::SymbolCount() const bool SharedImage::ContainsAddress(addr_t address) const { - return address >= (addr_t)fInfo.text - && address <= (addr_t)fInfo.data + fInfo.data_size - 1; + return (address >= (addr_t)fInfo.text && address < ((addr_t)fInfo.text + fInfo.text_size)) + || (address >= (addr_t)fInfo.data && address < ((addr_t)fInfo.data + fInfo.data_size)); }