Commit Graph

179 Commits

Author SHA1 Message Date
Ying Yi
17a2f3f28e [llvm-cov] Swapped the line and count columns.
In the coverage report, the line and count columns have been swapped to make it more readable.
A follow-up commit in compiler-rt is needed

Differential Revision: https://reviews.llvm.org/D23281

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278152 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-09 19:53:35 +00:00
Vedant Kumar
df48bd9ec3 [llvm-cov] Add some documentation for the -tab-size option
Also, un-hide the cl::opt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04 18:00:42 +00:00
Ying Yi
65787e2459 [LLVM-COV]Replace tabs to the space indentations in the HTML coverage report.
When using orbis-llvm-cov.exe to generate the HTML report, the HTML report 
can look quite different to the source file if it includes tabs.The default
tab size is 2 spaces instead of 8 spaces. A command line switch is
be added to set the tab size.

Differential Revision: https://reviews.llvm.org/D23087

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277715 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04 10:39:43 +00:00
Vedant Kumar
e201775db6 [llvm-cov] Add a debug mode for source range highlighting (in html)
llvm-cov's `-dump' option now emits information which helps debug source
range highlighting in html mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276924 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 21:57:15 +00:00
Vedant Kumar
627477de2c Revert "[llvm-cov] Minor aesthetic improvements for html reports"
This reverts commit r276906. It breaks tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276908 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 19:59:44 +00:00
Vedant Kumar
afafefeaee [llvm-cov] Minor aesthetic improvements for html reports
This fixes the highlighting for lines without any coverage segments. I
don't have a neat way of testing this yet, but am working on it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276906 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 19:51:17 +00:00
Vedant Kumar
c380ddf1dc [llvm-cov] Escape '\' in strings when emitting JSON
Test that Windows path separators are escaped properly. Add a round-trip
test to verify the JSON produced by the exporter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276832 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27 04:08:32 +00:00
Vedant Kumar
53397d1544 Retry: [llvm-cov] Add support for exporting coverage data to JSON
This enables users to export coverage information as portable JSON for use by
analysis tools and storage in document based databases.

The export sub-command is invoked just like the others:

  llvm-cov export -instr-profile path/to/foo.profdata path/to/foo.binary

The resulting JSON contains a list of files and functions. Every file object
contains a list of segments, expansions, and a summary of the file's region,
function, and line coverage. Every function object contains the function's name
and regions. There is also a total summary for the entire object file.

Changes since the initial commit (r276813):

  - Fixed the regexes in the tests to handle Windows filepaths.

Patch by Eddie Hurtig!

Differential Revision: https://reviews.llvm.org/D22651

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276818 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 22:50:58 +00:00
Vedant Kumar
63d80be936 Revert "[llvm-cov] Add support for exporting coverage data to JSON"
This reverts commit r276813. The Windows bots are complaining about some
of the filename regexes in the tests:

  http://bb.pgr.jp/builders/ninja-clang-i686-msc19-R/builds/5299

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276816 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 21:55:39 +00:00
Vedant Kumar
f57cf2f2c7 [llvm-cov] Add support for exporting coverage data to JSON
This enables users to export coverage information as portable JSON for use by
analysis tools and storage in document based databases.

The export sub-command is invoked just like the others:

  llvm-cov export -instr-profile path/to/foo.profdata path/to/foo.binary

The resulting JSON contains a list of files and functions. Every file object
contains a list of segments, expansions, and a summary of the file's region,
function, and line coverage. Every function object contains the function's name
and regions. There is also a total summary for the entire object file.

Patch by Eddie Hurtig!

Differential Revision: https://reviews.llvm.org/D22651

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276813 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-26 21:35:43 +00:00
Vedant Kumar
d12f3729fd [llvm-cov] Don't copy stylesheets into index files
Just link in the stylesheet from the toplevel dir of the report.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276468 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 20:49:23 +00:00
Ying Yi
d6931b112a [llvm-cov] - Add the coverage of lines in the summary report.
The llvm-cov ‘report' command displays a summary of the coverage of a binary file.
The summary report currently only includes covered regions and covered functions.
This patch adds the coverage of lines in the summary report.

Differential Revision: https://reviews.llvm.org/D22569

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276409 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 12:46:13 +00:00
Ying Yi
bb5cae8ec9 test commit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276401 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 09:20:21 +00:00
Vedant Kumar
6aa68be50e [llvm-cov] Use relative paths to the stylesheet (for html reports)
This makes it easy to swap out the default stylesheet for a custom one.
It also shaves ~6.62 MB out of the report directory for a full coverage
build of llvm+clang.

While we're at it, prune the CSS and add tests for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276359 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21 23:26:15 +00:00
Vedant Kumar
ee8657416e [llvm-cov] Re-write a very opaque comment (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275843 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 18:02:54 +00:00
Vedant Kumar
98c7b9a114 [llvm-cov] Place anchors around line numbers in html reports
Based on a suggestion by Harlan Haskins!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275840 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 17:53:16 +00:00
Vedant Kumar
a3ff212693 [llvm-cov] Clean up error reporting (NFC)
Use CodeCoverageTool::{error,warning} everywhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275837 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 17:53:12 +00:00
Vedant Kumar
eb1556ce41 [llvm-cov] Attempt to appease an older builder
It's using a version of clang which can't (or won't) deduce an implicit
conversion from a SmallString to a StringRef. Write the conversion out
explicitly:

  http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-buildserver/builds/8574

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275647 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 23:15:35 +00:00
Vedant Kumar
84b511291b [llvm-cov] Attempt to appease Windows bots
They appear to reject r275640 because stdin is held open during an
ExecuteAndWait in which it's redirected:

  http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/8390

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275642 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 23:08:22 +00:00
Vedant Kumar
13ca1ccb76 [llvm-cov] Optionally use a symbol demangler when preparing reports
Add an option to specify a symbol demangler (as well as options to the
demangler). This can be used to make reports more human-readable.

This option is especially useful in -output-dir mode, since it isn't as
easy to manually pipe reports into a demangler in this mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275640 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 22:44:57 +00:00
Vedant Kumar
a5ec41d9a9 [llvm-cov] Document a few private fields of CodeCoverageTool (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275639 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 22:44:54 +00:00
Vedant Kumar
b972a0f1a0 [llvm-cov] Improve error messages
While we're at it, extend an existing test to make sure that error
messages look reasonable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275520 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 01:53:39 +00:00
Vedant Kumar
343b2711ec [llvm-cov] Fix a use-after-free
Taking a lock before appending to a vector does no good unless threads
reading from the vector also take the lock, because the vector could be
re-sized.

I don't have a good isolated test for this. I found the issue with ASan
while testing a large project.  I'm working on a bot that does this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275516 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 01:19:36 +00:00
Vedant Kumar
b9d9ab2c32 [llvm-cov] Clean up an awkward capture-by-reference (NFC)
Writing `for (StringRef &SourceFile : ...)` is strange to begin with.
Subsequently capturing "SourceFile" by reference is even stranger. Just
copy the StringRef, since that's cheap to do.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275515 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 01:19:35 +00:00
Vedant Kumar
7b18a76385 [Coverage] Mark a few more methods const (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275514 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 01:19:33 +00:00
Vedant Kumar
9240c457f7 [llvm-cov] Use a thread pool to speed up report generation (NFC)
It's safe to print out source coverage views using multiple threads when
using the -output-dir mode of the `llvm-cov show` sub-command.

While testing this on my development machine, I observed that the speed
up is roughly linear with the number of available cores. Avg. time for
`llvm-cov show ./llvm-as -show-line-counts-or-regions`:

    1 thread: 7.79s user 0.33s system 98% cpu 8.228 total
    4 threads: 7.82s user 0.34s system 283% cpu 2.880 total

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275321 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 21:38:36 +00:00
Vedant Kumar
0e9a272ddb Minor formatting change, NFC
The rest of llvm-cov does not use LLVM_ATTRIBUTE_UNUSED. Leave unused
params unnamed to be consistent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274694 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 22:02:55 +00:00
Vedant Kumar
55c8c00ac7 [llvm-cov] Add support for creating html reports
Based on a patch by Harlan Haskins!

Differential Revision: http://reviews.llvm.org/D18278

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274688 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 21:44:05 +00:00
Vedant Kumar
d378d9725e [llvm-cov] Use relative paths to file reports in -output-dir mode
This makes it possible to e.g copy a report to another filesystem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274173 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 21:55:46 +00:00
Vedant Kumar
0cd4101ef2 Use LLVM_ATTRIBUTE_UNUSED instead of void casts; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274139 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 16:56:46 +00:00
Vedant Kumar
651e3ffa96 [llvm-cov] Do not allow ".." to escape the coverage sub-directory
In -output-dir mode, file reports are placed into a "coverage"
directory. If filenames in the coverage mapping contain "..", they might
escape out of this directory.

Fix the problem by removing ".." from source filenames (expand the path
component).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274135 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 16:22:12 +00:00
Vedant Kumar
cd29c6b37b [llvm-cov] Minor cleanups to prepare for the html format patch
- Add renderView{Header,Footer}, renderLineSuffix, and hasSubViews to
  support creating tables with nested views.

- Move the 'Format' cl::opt to make it easier to extend.

- Just create one function view file, instead of overwriting the same
  file for every new function. Add a regression test for this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274086 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 00:38:21 +00:00
Simon Pilgrim
24aa476923 Fix "not all control paths return a value" warning on MSVC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274065 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 21:02:41 +00:00
Vedant Kumar
028d73c4cd [llvm-cov] Create an index of reports in -output-dir mode
This index lists the reports available in the 'coverage' sub-directory.
This will help navigate coverage output from large projects.

This commit factors the file creation code out of SourceCoverageView and
into CoveragePrinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274029 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 16:12:24 +00:00
Vedant Kumar
184c22415b [llvm-cov] Minor cleanups (NFC)
- Test the '-o' alias for -output-dir.
- Use a helper method in a conditional.
- Add a period.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274028 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 16:12:20 +00:00
Vedant Kumar
75f03af542 [llvm-cov] Avoid copying file paths multiple times (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274027 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 16:12:18 +00:00
Vedant Kumar
c5fab6a8fd [llvm-cov] Rename ShowFormat to Format (NFC)
This makes it a bit more generic, in case we want to emit summary
reports in different formats in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274026 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 16:12:15 +00:00
Vedant Kumar
e017372fb5 [llvm-cov] Move a check into a helper method (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274025 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 16:12:12 +00:00
Simon Pilgrim
7b928ec61c Fix "not all control paths return a value" warning on MSVC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274011 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 12:55:35 +00:00
Vedant Kumar
edd67d643a [llvm-cov] Simplify; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273988 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 03:37:56 +00:00
Vedant Kumar
40a78f87a4 Reapply "[llvm-cov] Add an -output-dir option for the show sub-command""
Passing -output-dir path/to/dir to llvm-cov show creates path/to/dir if
it doesn't already exist, and prints reports into that directory.

In function view mode, all views are written into
path/to/dir/functions.$EXTENSION. In file view mode, all views are
written into path/to/dir/coverage/$PATH.$EXTENSION.

Changes since the initial commit:

- Avoid accidentally closing stdout twice.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273985 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 02:09:39 +00:00
Vedant Kumar
69821cb9ef Revert "[llvm-cov] Add an -output-dir option for the show sub-command"
This reverts commit r273971. test/profile/instrprof-visibility.cpp is
failing because of an uncaught error in SafelyCloseFileDescriptor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273978 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 01:14:04 +00:00
Vedant Kumar
b979c03ac6 [llvm-cov] Add an -output-dir option for the show sub-command
Passing -output-dir path/to/dir to llvm-cov show creates path/to/dir if
it doesn't already exist, and prints reports into that directory.

In function view mode, all views are written into
path/to/dir/functions.$EXTENSION. In file view mode, all views are
written into path/to/dir/coverage/$PATH.$EXTENSION.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273971 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 00:18:57 +00:00
Vedant Kumar
aba058fe5f [llvm-cov] clang-format a line, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273969 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 00:18:51 +00:00
Vedant Kumar
0347ce77ea [llvm-cov] Add a format option for the 'show' sub-command (mostly NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273968 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 00:15:54 +00:00
Vedant Kumar
e4356613e3 [llvm-cov] Simplify the way expansion views are rendered (NFC)
If a sub-view has already been rendered, it's helpful to re-render the
expansion site before rendering the next expansion view. Make this fact
explicit in the rendering interface, instead of hiding it behind an
awkward Optional<LineRef> parameter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273789 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-26 02:45:13 +00:00
Vedant Kumar
5e86ac74a4 [llvm-cov] Make an API more consistent, NFC
Make renderExpansionView() look a bit more like renderLine(), and
clarify its doxygen comment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273773 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 05:48:59 +00:00
Vedant Kumar
a6154f98d5 [llvm-cov] Flesh out some doxygen comments, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273772 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 05:48:54 +00:00
Vedant Kumar
49b4592c1a Try to fix the MSVC build
There's some kind of issue with using "constexpr unsigned" in an
anonymous namespace.

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/13395

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273770 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 03:27:29 +00:00
Vedant Kumar
a9bf312be4 [llvm-cov] Separate presentation logic from formatting logic, NFC
This makes it easier to add renderers for new kinds of output formats.

- Define and document a pure-virtual coverage rendering interface.
- Move the text-based rendering logic into its a new file.
- Re-work the API to better reflect the presentation/formatting split.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273767 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-25 02:58:30 +00:00