How do you get debugging symbols working in linux perf tool inside Docker containers?

后端 未结 2 1329
别那么骄傲
别那么骄傲 2021-02-08 22:58

I am using Docker containers based on the \"ubuntu\" tag and cannot get linux perf tool to display debugging symbols.

Here is what I\'m doing to demonstrate the problem.

2条回答
  •  星月不相逢
    2021-02-08 23:51

    Another way that doesn't require changing how you run the container (so you can profile an already running process) is to mount container's root on host using bindfs:

    bindfs /proc/$(docker inspect --format {{.State.Pid}} $CONTAINER_ID)/root /foo
    

    Then run perf report as perf report --symfs /foo

    You'll have to run perf record system wide, but you can restrict it to only collect events for the specific container:

    perf record -g -a -F 100 -e cpu-clock -G docker/$(docker inspect --format {{.Id}} $CONTAINER_ID) sleep 90
    

提交回复
热议问题