I noticed that one thread's backtrace looks like:
Thread 8 (Thread 0x7f385f185700 (LWP 12861)):
#0 0x00007f38655a3cf4 in __mcount_internal (frompc=4287758, selfpc=4287663) at mcount.c:72
#1 0x00007f38655a4ac4 in mcount () at ../sysdeps/x86_64/_mcount.S:47
#2 0x0000000000000005 in ?? ()
#3 0x00007f382c02ece0 in ?? ()
#4 0x000000000000002d in ?? ()
#5 0x000000000000ffff in ?? ()
#6 0x0000000000000005 in ?? ()
#7 0x0000000000000005 in ?? ()
#8 0x0000000000000000 in ?? ()
It seems to be exited thread but I am not sure.
I would like know how to understand it. Especially, I don't understand what does it mean LWP
and Thread 0x7f385f185700
( what is that address)?
Moreover, I noticed that profiler indicates that __mcount_internal
takes relatively a lot of time. What is it and why it is time-consuming? Especially, what are frompc
and selfpc
counters?
The my kernel is Linux 4.4.0 and thread are compatible with POSIX ( C++11 implementaion).
LWP
= Light Weight Process, and means thread. Linux threads each have their own thread-ID, from the same sequence as PID numbers, even though they're not a separate process. If you look in /proc/PID/task
for a multi-threaded process, you will see the entries for each thread ID.
0x7f385f185700
is the pthread ID, as from pthread_self(3)
. This is a pointer to a pthread_t
.
This thread is stopped at RIP = 0x00007f38655a3cf4
, the address in frame #0
.
frompc
and selfpc
are function arguments to the __mcount_internal()
glibc function.
Your backtrace can show names and args them because you have debug symbols installed for glibc. You just get ?? for the parent functions because you don't have debug info installed for the program or library containing them. (Compile your own program with -g
, and install packages like qtbase5-dbg
or libglib2.0-0-dbg
to get debug symbols for libraries packed by your distro).
mcount
seems to be related to profiling (i.e. code generated by -fprofile-generate
or -pg
). That would explain why it takes Program Counter values as args.
Why do applications compiled by GCC always contain the _mcount symbol?
That thread has not exited. You wouldn't see as many details if it had. (And probably wouldn't see it at all.)