Reza Salkhordeh
Reza Salkhordeh

Reputation: 31

Intel PIN: print backtrace when segfault happens in tool

I'm developing a tool for Intel PIN. Somewhere in the runtime, it gives me the below error. I want to know if there is a way to tell PIN to print the backtrace or let me handle the segfault in the tool itself.

I'm running my tool with MPI and it crashes when I insert values into an unordered map.

C: Tool (or Pin) caused signal 11 at PC 0x2b09594533cb

mpirun -np 44 pin-3.7-97619-g0d0c92f4f-gcc-linux/pin -follow_execv -t pin-3.7-97619-g0d0c92f4f-gcc-linux/source/tools/Simp ... -- program

Upvotes: 1

Views: 860

Answers (1)

Heyji
Heyji

Reputation: 1211

You can use the following API:

PIN_AddInternalExceptionHandler()

from where you get access to an EXCEPTION_INFO structure which is supposed to be manipulated with the exception API.

Otherwise, you can also debug your tool from within a debugger, by launching your tool with the -pause_tool 20 option. Then you have 20 seconds to attach your debugger to the process. Once attached, the debugger stops (at least with Visual Studio) and lets you set the breakpoints you need in your tool's code.

This is not that easy to debug though, as the whole system switch from pintool code, to pin, to target application constantly. Hence there is not a continuous process of steps inside your pintool code that you can follow, as you can expect when debugging "classic single threaded applications".

Upvotes: 1

Related Questions