summaryrefslogtreecommitdiffstats
path: root/llvm/tools/sancov
Commit message (Collapse)AuthorAgeFilesLines
* [Disassembler] Delete the VStream parameter of MCDisassembler::getInstruction()Fangrui Song2020-01-111-1/+1
| | | | | | | | | | The argument is llvm::null() everywhere except llvm::errs() in llvm-objdump in -DLLVM_ENABLE_ASSERTIONS=On builds. It is used by no target but X86 in -DLLVM_ENABLE_ASSERTIONS=On builds. If we ever have the needs to add verbose log to disassemblers, we can record log with a member function, instead of passing it around as an argument.
* Reland 9f3fdb0d7fab: [Driver] Use VFS to check if sanitizer blacklists existIlya Biryukov2019-11-211-1/+3
| | | | | | | With updates to various LLVM tools that use SpecialCastList. It was tempting to use RealFileSystem as the default, but that makes it too easy to accidentally forget passing VFS in clang code.
* [Mips] Use appropriate private label prefix based on Mips ABIMirko Brkusanin2019-10-231-1/+3
| | | | | | | | | | MipsMCAsmInfo was using '$' prefix for Mips32 and '.L' for Mips64 regardless of -target-abi option. By passing MCTargetOptions to MCAsmInfo we can find out Mips ABI and pick appropriate prefix. Tags: #llvm, #clang, #lldb Differential Revision: https://reviews.llvm.org/D66795
* Revert 374629 "[sancov] Accommodate sancov and coverage report server for ↵Vitaly Buka2019-10-122-5/+3
| | | | | | | | | | | | use under Windows" http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/27650/steps/ninja%20check%201/logs/stdio http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/31759 http://lab.llvm.org:8011/builders/clang-s390x-linux-lnt/builds/15095 http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/21075 http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/31759 llvm-svn: 374636
* [sancov] Accommodate sancov and coverage report server for use under WindowsVitaly Buka2019-10-122-3/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: This patch makes the following changes to SanCov and its complementary Python script in order to resolve issues pertaining to non-UNIX file paths in JSON symbolization information: * Convert all paths to use forward slash. * Update `coverage-report-server.py` to correctly handle paths to sources which contain spaces. * Remove Linux platform restriction for all SanCov unit tests. All SanCov tests passed when ran on my local Windows machine. Patch by Douglas Gliner. Reviewers: kcc, filcab, phosek, morehouse, vitalybuka, metzman Reviewed By: vitalybuka Subscribers: vsk, Dor1s, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D51018 llvm-svn: 374629
* [sancov] Use LLVM Support library JSON writer in favor of individual ↵Vitaly Buka2019-10-121-132/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | implementation Summary: In this diff, I've replaced the individual implementation of `JSONWriter` with `json::OStream` provided by `llvm/Support/JSON.h`. Important Note: The output format of the JSON is considerably different compared to the original implementation. Important differences include: * New line for each entry in an array (should make diffs cleaner) * No space between keys and colon in attributed object entries. * Attributes with empty strings will now print the attribute name and a quote pair rather than excluding the attribute altogether Examples of these differences can be seen in the changes to the sancov tests which compare the JSON output. Patch by Douglas Gliner. Reviewers: kcc, filcab, phosek, morehouse, vitalybuka, metzman Subscribers: mehdi_amini, dexonsmith, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68752 llvm-svn: 374628
* [sancov][NFC] Make filename Regexes "const"Thomas Preud'homme2019-09-271-2/+2
| | | | | | | | | | | | | | | | | | Summary: The const-correctness of match() was fixed in rL372764, which allows such static Regex objects to be marked const. Reviewers: thopre Reviewed By: thopre Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68091 llvm-svn: 373058
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-4/+4
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* [sancov] Ignore PC samples with value 0Petr Hosek2019-07-111-1/+5
| | | | | | | | | | | | | The sancov runtime for the (Fuchsia) Zircon kernel delivers results in the standard format, but as the full array of possible samples with 0 in uncovered slots. That runtime delivers "live" data and has no final "export" pass to compactify out the uncovered slots, and it seems silly to require another offline tool just for that. Patch By: mcgrathr Differential Revision: https://reviews.llvm.org/D63695 llvm-svn: 365839
* [sancov] Avoid unnecessary unique_ptrFangrui Song2019-06-241-12/+10
| | | | llvm-svn: 364175
* Recommit [Object] Change object::SectionRef::getContents() to return ↵Fangrui Song2019-05-161-3/+3
| | | | | | | | | | | | Expected<StringRef> r360876 didn't fix 2 call sites in clang. Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360892
* Revert r360876 "[Object] Change object::SectionRef::getContents() to return ↵Hans Wennborg2019-05-161-3/+3
| | | | | | | | | | | | Expected<StringRef>" It broke the Clang build, see llvm-commits thread. > Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. > > Follow-up of D61781. llvm-svn: 360878
* [Object] Change object::SectionRef::getContents() to return Expected<StringRef>Fangrui Song2019-05-161-3/+3
| | | | | | | | Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360876
* Change some StringRef::data() reinterpret_cast to bytes_begin() or ↵Fangrui Song2019-04-071-2/+1
| | | | | | arrayRefFromStringRef() llvm-svn: 357852
* [DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin2019-02-271-5/+21
| | | | | | | | | | | | | | | | | That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703 "wrong line number info for obj file compiled with -ffunction-sections" bug. The problem happened with only .o files. If object file contains several .text sections then line number information showed incorrectly. The reason for this is that DwarfLineTable could not detect section which corresponds to specified address(because address is the local to the section). And as the result it could not select proper sequence in the line table. The fix is to pass SectionIndex with the address. So that it would be possible to differentiate addresses from various sections. With this fix llvm-objdump shows correct line numbers for disassembled code. Differential review: https://reviews.llvm.org/D58194 llvm-svn: 354972
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-192-8/+6
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Python compat - print statementSerge Guelton2019-01-031-0/+2
| | | | | | | | | Make sure all print statements are compatible with Python 2 and Python3 using the `from __future__ import print_function` statement. Differential Revision: https://reviews.llvm.org/D56249 llvm-svn: 350307
* [sancov] Generalize the code to get the previous instruction to multiple ↵George Karpenkov2018-10-101-1/+14
| | | | | | | | | | | | | architectures sancov subtracts one from the address to get the previous instruction, which makes sense on x86_64, but not on other platforms. This change ensures that the offset is correct for different platforms. The logic for computing the offset is copied from sanitizer_common. Differential Revision: https://reviews.llvm.org/D53039 llvm-svn: 344103
* Rename sancov.cc to sancov.cppNico Weber2018-04-252-3/+2
| | | | | | | LLVM uses cpp as its C++ file ending. https://reviews.llvm.org/D46068 llvm-svn: 330853
* Remove redundant includes from tools.Michael Zolotukhin2017-12-131-8/+0
| | | | llvm-svn: 320631
* Add section headers to SpecialCaseListsVlad Tsyrklevich2017-09-251-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Sanitizer blacklist entries currently apply to all sanitizers--there is no way to specify that an entry should only apply to a specific sanitizer. This is important for Control Flow Integrity since there are several different CFI modes that can be enabled at once. For maximum security, CFI blacklist entries should be scoped to only the specific CFI mode(s) that entry applies to. Adding section headers to SpecialCaseLists allows users to specify more information about list entries, like sanitizer names or other metadata, like so: [section1] fun:*fun1* [section2|section3] fun:*fun23* The section headers are regular expressions. For backwards compatbility, blacklist entries entered before a section header are put into the '[*]' section so that blacklists without sections retain the same behavior. SpecialCaseList has been modified to also accept a section name when matching against the blacklist. It has also been modified so the follow-up change to clang can define a derived class that allows matching sections by SectionMask instead of by string. Reviewers: pcc, kcc, eugenis, vsk Reviewed By: eugenis, vsk Subscribers: vitalybuka, llvm-commits Differential Revision: https://reviews.llvm.org/D37924 llvm-svn: 314170
* [sancov] coverage-report-server.py: ServerHandler(): open file as UTF8Roman Lebedev2017-09-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is nessesary in Python3. Everywhere else we assume that encoding is UTF8. If we don't specify it here, the defaults from the environment will be used, which may result in ASCII decoder being used. And if the file is non-ASCII, then it will crash: ``` File "/usr/local/bin/coverage-report-server.py", line 168, in do_GET for line_no, line in enumerate(f, start=1)]) File "/usr/local/bin/coverage-report-server.py", line 165, in <listcomp> ["<span class='{cls}'>{line}&nbsp;</span>".format( File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 106: ordinal not in range(128) ``` Fixes https://bugs.llvm.org/show_bug.cgi?id=33548 Now, how would i add a testcase here? Reviewers: m.ostapenko, kcc Reviewed By: kcc Subscribers: kcc, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D37661 llvm-svn: 313063
* [sancov] Fix broken links and displaced coloring in coverage-report-server.pyMaxim Ostapenko2017-03-201-2/+2
| | | | | | | | | | | | | | This patch fixes two issues: * Fixed relative links to source files * Enumeration of lines in source files starts from 1 instead of 0 to align with .symcov files generated by sancov -symbolize Patch by Dmitiriy Nikiforov. Differential Revision: https://reviews.llvm.org/D31038 llvm-svn: 298250
* [sancov] better input parameters validationMike Aizatsky2017-03-031-4/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D30370 llvm-svn: 296900
* [sancov] extending sancov --help documentationMike Aizatsky2017-02-241-2/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D30361 llvm-svn: 296205
* [sancov] applying blacklist to covered points tooMike Aizatsky2017-01-191-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D28872 llvm-svn: 292468
* [sancov] skip duplicated pointsMike Aizatsky2016-12-211-0/+5
| | | | llvm-svn: 290278
* [sancov] hash prefix results in huge merge files, use shorter prefixMike Aizatsky2016-12-211-2/+1
| | | | llvm-svn: 290277
* [sancov] skip dead files from computationsMike Aizatsky2016-12-171-18/+38
| | | | | | Differential Revision: https://reviews.llvm.org/D27863 llvm-svn: 290017
* Make the Error class constructor protectedMehdi Amini2016-11-111-1/+1
| | | | | | | | | This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 llvm-svn: 286561
* [sancov] add __sanitizer_cov_trace_pc_guard to the supported coverage pointsKostya Serebryany2016-10-181-1/+3
| | | | llvm-svn: 284509
* Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini2016-10-081-1/+1
| | | | | | | | | | | | | | | template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671
* [sancov] renamed symcov-report-server to coverage-report-serverMike Aizatsky2016-10-042-2/+2
| | | | llvm-svn: 283241
* [sancov] using env for better portabilityMike Aizatsky2016-10-031-1/+1
| | | | llvm-svn: 283136
* [sancov] introducing symbolized coverage files (.symcov)Mike Aizatsky2016-09-281-740/+626
| | | | | | | | | | | | | | | | | | | | | Summary: Answering any meaningful questions about .sancov files requires accessing symbol information from the corresponding binary. This change introduces a separate intermediate data structure and format: symbolized coverage. It contains all symbol information that is required to answer common queries: - merging - coverd/uncovered files and functions - line status. Also removing the html report functionality from sancov: generated HTML files are too huge, and a different approach is required. Maintaining this half-working approach in the C++ is painful. Differential Revision: https://reviews.llvm.org/D24947 llvm-svn: 282639
* [sancov] a simple .symcov coverage report serverMike Aizatsky2016-09-281-0/+203
| | | | | | | | | | Coverage reports for gigabyte-sized binaries are huge. There's no practical reason to generate them statically. Implementing an experiment http coverage report server. The server loads .symcov file and serves interactive coverage pages. llvm-svn: 282637
* [sancov] MachO indirect symbols support.Mike Aizatsky2016-08-121-8/+56
| | | | | | Differential Revision: https://reviews.llvm.org/D23338 llvm-svn: 278551
* [sancov] Port sancov -print-coverage-pcs to COFFReid Kleckner2016-08-101-5/+26
| | | | | | | | | | | The export table is not considered part of the object file symbol table, so we have to look through it separately. Reviewers: kcc Differential Revision: https://reviews.llvm.org/D23321 llvm-svn: 278284
* [Object] Re-apply r275316 now that I have the corresponding LLD patch ready.Lang Hames2016-07-141-6/+11
| | | | llvm-svn: 275361
* [Object] Revert r275316, Archive::child_iterator changes, while I update lld.Lang Hames2016-07-141-11/+6
| | | | | | Should fix the bots broken by r275316. llvm-svn: 275353
* [Object] Change Archive::child_iterator for better interop with Error/Expected.Lang Hames2016-07-131-6/+11
| | | | | | | | | | | | | | | | | | | | | | | See http://reviews.llvm.org/D22079 Changes the Archive::child_begin and Archive::children to require a reference to an Error. If iterator increment fails (because the archive header is damaged) the iterator will be set to 'end()', and the error stored in the given Error&. The Error value should be checked by the user immediately after the loop. E.g.: Error Err; for (auto &C : A->children(Err)) { // Do something with archive child C. } // Check the error immediately after the loop. if (Err) return Err; Failure to check the Error will result in an abort() when the Error goes out of scope (as guaranteed by the Error class). llvm-svn: 275316
* Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to ↵Kevin Enderby2016-06-241-2/+2
| | | | | | | | | | | | | | | | | | | | | allow a good error message to be produced. This is nearly the last libObject interface that used ErrorOr and the last one that appears in llvm/include/llvm/Object/MachO.h . For Mach-O objects this is just a clean up because it’s version of getSymbolAddress() can’t return an error. I will leave it to the experts on COFF and ELF to actually add meaning full error messages in their tests if they wish. And also leave it to these experts to change the last two ErrorOr interfaces in llvm/include/llvm/Object/ObjectFile.h for createCOFFObjectFile() and createELFObjectFile() if they wish. Since there are no test cases for COFF and ELF error cases with respect to getSymbolAddress() in the test suite this is no functional change (NFC). llvm-svn: 273701
* Apply another batch of fixes from clang-tidy's ↵Benjamin Kramer2016-06-171-12/+13
| | | | | | | | performance-unnecessary-value-param. Contains some manual fixes. No functionality change intended. llvm-svn: 273047
* Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith2016-06-091-1/+1
| | | | | | | looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
* [Symbolize] Check if the PE file has a PDB and emit an error if we can't load itReid Kleckner2016-06-031-0/+6
| | | | | | | | | | | | | | | | | | | | | Summary: Previously we would try to load PDBs for every PE executable we tried to symbolize. If that failed, we would fall back to DWARF. If there wasn't any DWARF, we'd print mostly useless symbol information using the export table. With this change, we only try to load PDBs for executables that claim to have them. If that fails, we can now print an error rather than falling back silently. This should make it a lot easier to diagnose and fix common symbolization issues, such as not having DIA or not having a PDB. Reviewers: zturner, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20982 llvm-svn: 271725
* Avoid some copies by using const references.Benjamin Kramer2016-05-271-7/+7
| | | | | | | clang-tidy's performance-unnecessary-copy-initialization with some manual fixes. No functional changes intended. llvm-svn: 270988
* Change llvm-objdump, llvm-nm and llvm-size when reporting an object file errorKevin Enderby2016-05-171-2/+2
| | | | | | | | | | | | | | | | | | | | | when the object is in an archive to use something like libx.a(foo.o) as part of the error message. Also changed llvm-objdump and llvm-size to be like llvm-nm and ignore non-object files in archives and not produce any error message. To do this Archive::Child::getAsBinary() was changed from ErrorOr<...> to Expected<...> then that was threaded up to its users. Converting this interface to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now the use of errorToErrorCode() is still used in one place yet to be fully converted. Again there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comments for those. llvm-svn: 269784
* [sancov] using normalized filenames for blacklist checks.Mike Aizatsky2016-04-211-9/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D19395 llvm-svn: 267078
* Thread Expected<...> up from libObject’s getName() for symbols to allow ↵Kevin Enderby2016-04-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | llvm-objdump to produce a good error message. Produce another specific error message for a malformed Mach-O file when a symbol’s string index is past the end of the string table. The existing test case in test/Object/macho-invalid.test for macho-invalid-symbol-name-past-eof now reports the error with the message indicating that a symbol at a specific index has a bad sting index and that bad string index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. There is some code for this that could be factored into a routine but I would like to leave that for the code owners post-commit to do as they want for handling an llvm::Error. An example of how this could be done is shown in the diff in lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine already for std::error_code so I added one like it for llvm::Error . Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there fixes needed to lld that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 266919
* Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby2016-04-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to produce a real error message Produce the first specific error message for a malformed Mach-O file describing the problem instead of the generic message for object_error::parse_failed of "Invalid data was encountered while parsing the file”.  Many more good error messages will follow after this first one. This is built on Lang Hames’ great work of adding the ’Error' class for structured error handling and threading Error through MachOObjectFile construction. And making createMachOObjectFile return Expected<...> . So to to get the error to the llvm-obdump tool, I changed the stack of these methods to also return Expected<...> : object::ObjectFile::createObjectFile() object::SymbolicFile::createSymbolicFile() object::createBinary() Then finally in ParseInputMachO() in MachODump.cpp the error can be reported and the specific error message can be printed in llvm-objdump and can be seen in the existing test case for the existing malformed binary but with the updated error message. Converting these interfaces to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now use of errorToErrorCode() and errorOrToExpected() are used where the callers are yet to be converted. Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values. So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(ObjOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 265606
OpenPOWER on IntegriCloud