[llvm-dev] XRay feature – pid reporting
Dean Michael Berris via llvm-dev
llvm-dev at lists.llvm.org
Wed Jun 27 20:29:04 PDT 2018
> On 28 Jun 2018, at 07:28, Henry Zhu <henryzhu at seas.upenn.edu> wrote:
> Thanks, that cleared up my confusion about version numbers.
> I've implemented the handlers and done up to 6) below. I'm unsure of how to test what I have added.
> 1) Update the Header.Version = 3 (from 2)
> 2) Add a new XRayRecord for pid (XRayPidRecord) in xray_basic_logging.h
> 3) Implement InMemoryRawLogWithPid similar to how InMemoryRawLogWithArg is implemented
> 4) Implement __xray_set_handler_pid
> 5) call __xray_set_handler_pid, passing in basicLoggingHandlePid in the initialization function for basic mode
> 6) Add an assembly stub for the [od handler
Huh, I’m sorry for not being clear here — I suspect you don’t need steps 3 to 6.
You may just need to add a metadata record at the beginning of the block, and getting the PID and TID directly (instead of the cached versions). This way FDR mode will have the PID record and the TID records at the beginning of the block.
For Basic Mode we need to get the TID directly instead of using the cached version, and also to get the PID directly instead of attempting to cache it. This would be an update in the handlers.
In Profiling Mode this would be a little tricky, because it may need changes in more places. I need to think about that I little more.
> 7) Add additional parsing for pid for llvm-xray tool to parse the header for pid and xray entries for pid
> Q1. For 7), on order to log the pid, one would need to patch the function to call the pid logger. Should I add an attribute to clang that patches the function, so that the function calls the pid? Or is there an easier way to test the functionality of the pid logger?
Please see above.
> Q2. Should the PID always be set in the file header when xray starts?
> Q3. How do I run test cases?
There’s a ‘check-all’ and ‘check-xray’ target when you build LLVM+Clang+compiler-rt.
> Q4. Would it be possible to always call the pid logger when fork is called?
Unfortunately no. The simpler solution would be to update the handlers to get the PID alongside the TID, and to always get the TID instead of using a cached version.
More information about the llvm-dev