I am putting together a performance profiler in Linux and I am having trouble mapping the collected stack trace information to function names.
I am currently calling addr2line as follows from my post processing code
FILE* pipe = popen("addr2line -f -i -s -C -e <libname> <address>", "r");
if (!pipe) return;
const size_t BUFFER_SIZE = 8192;
char buffer[BUFFER_SIZE];
string result;
while (!feof(pipe))
{
if (fgets(buffer, BUFFER_SIZE, pipe) != NULL)
result += buffer;
}
pclose(pipe);
However, this is terribly slow as my profile has a lot of samples. Is there any other utility like addr2line that is faster or can I call addr2line in a more efficient way than I am doing?
I got past this problem by modifying the source code of the addr2line utility and converted it into a library. So I am now loading this library into my profile analyzer and calling 'addr2line' as if it were a function!