I write a pintool to dump every instruction with pid, thread id, and address. It is stored at Github gist
However, after I ran one example, the pid of first instruction is the same as the pid in the main function, not the same as the second or following instructions. The output is in the following:
cerr
Pid 7292=========
cout
7292-0-b777c0d0-mov eax, esp
1c7c-0-b777c0d2-call 0xb777f790
1c7c-0-b777f790-push ebp
1c7c-0-b777f791-mov ebp, esp
......
I don't know why it occurs. Maybe I use the PIN_GetPid API in the wrong way. Could someone give me some advice?
7292 in decimal is 0x1c7c in hexadecimal. std::hex is maintained across separate invocations of the same stream.
Just prefix printing of pid with std::dec.