Emit LLVM Code Coverage Mapping


I am interested in emitting Mapping Region information for my src code while compiling with clang++.

we are using the following command to compile our program and generate the binary:
clang++ foo.cc -o foo

I am looking for a flag to clang++ cmd, which can emit the Mapping Region to a file.

I see that there is a flag “-fcoverage-mapping”, but the issue with this flag is it creates an instrumented binary. We are wondering if there is a way to emit the mapping data (in any format), without instrumenting the binary?

I did look at the debug info (llvm-dwarfdump tool) to see if i can figure out the code regions from the debug info. But it looks like the output of llvm-dwarfdump only contains the map between addresses and the source code line. So I could not find a way to extract regions from debug info.

Thank you.

Can someone please take a look at my question?