From 02a9f9fbcecbc5b62d7b047bead1c0831f5d6257 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Tue, 11 Dec 2018 02:17:38 +0100 Subject: [PATCH] linux_callstack: don't compute offset to .text section manually addr2line can do it by itself and seems to be better at it. --- renderdoc/os/posix/linux/linux_callstack.cpp | 35 ++------------------ 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/renderdoc/os/posix/linux/linux_callstack.cpp b/renderdoc/os/posix/linux/linux_callstack.cpp index 48ca43f54..09e9b7b1a 100644 --- a/renderdoc/os/posix/linux/linux_callstack.cpp +++ b/renderdoc/os/posix/linux/linux_callstack.cpp @@ -178,8 +178,7 @@ private: if(addr >= m_Modules[i].base && addr < m_Modules[i].end) { uint64_t relative = addr - m_Modules[i].base + m_Modules[i].offset; - string cmd = - StringFormat::Fmt("addr2line -j.text -fCe \"%s\" 0x%llx", m_Modules[i].path, relative); + string cmd = StringFormat::Fmt("addr2line -fCe \"%s\" 0x%llx", m_Modules[i].path, relative); FILE *f = ::popen(cmd.c_str(), "r"); @@ -297,37 +296,7 @@ StackResolver *MakeResolver(byte *moduleDB, size_t DBSize, RENDERDOC_ProgressCal mod.path[i] = search[i]; } - // addr2line wants offsets relative to text section, have to find offset of .text section - // in this - // mmapped section - - int textoffs = 0; - string cmd = StringFormat::Fmt("readelf -WS \"%s\"", mod.path); - - FILE *f = ::popen(cmd.c_str(), "r"); - - char result[4096] = {0}; - fread(result, 1, 4095, f); - - fclose(f); - - // find .text line - char *find = strstr(result, ".text"); - - if(find) - { - find += 5; - - while(isalpha(*find) || isspace(*find)) - find++; - - // virtual address is listed first, we want the offset - sscanf(find, "%*x %x", &textoffs); - - mod.base += textoffs; - - modules.push_back(mod); - } + modules.push_back(mod); } } }