This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Fuzzer] Have fuzzers write artifacts to specific directory
ClosedPublic

Authored by cassanova on Jun 23 2022, 8:44 AM.

Details

Summary

This makes the LLDB fuzzers write their fuzzer artifacts to their own directory in the build directory. It also adds an artifact prefix to the target fuzzer to make it easier to tell which fuzzer wrote the artifact.

Diff Detail

Event Timeline

cassanova created this revision.Jun 23 2022, 8:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 8:44 AM
Herald added a subscriber: mgorny. · View Herald Transcript
cassanova requested review of this revision.Jun 23 2022, 8:44 AM
JDevlieghere requested changes to this revision.Jun 23 2022, 9:11 AM

Instead of bundling together multiple shell commands into a single one, you should break them down so CMake can have the build system (e.g. ninja) schedule the different parts of it.

To create the directory, you can either create a separate target and make the fuzz-lldb-target depend on it:

add_custom_target(foo ALL
    COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})

But even better would. be to make it a pre-build command for the fuzz-lldb-target:

add_custom_command(TARGET fuzz-lldb-target PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})

Then you can avoid the cd by using the WORKING_DIRECTORY in add_custom_target.

This revision now requires changes to proceed.Jun 23 2022, 9:11 AM

This is a lot cleaner than chaining shell commands, I just implemented the second solution on my end. To clarify, it would create the directory before running the fuzz-lldb-target and within the fuzz-lldb-target we would just change the working directory to the one that the pre-build command created?

mib added a comment.Jun 23 2022, 9:41 AM

@cassanova You probably also want to implement this for the command-interpreter-fuzzer target

Yes, I can include the command interpreter's cmake file in the diff.

cassanova retitled this revision from [lldb/Fuzzer] Have target fuzzer write artifacts to specific directory to [lldb/Fuzzer] Have fuzzers write artifacts to specific directory.
cassanova edited the summary of this revision. (Show Details)

Removed the chain of shell commands in the target fuzzer's CMakeLists file and added a pre build command that creates the necessary directory and changes the working directory in the target to this directory.

Also implemented these changes to the command interpreter fuzzer's CMakeLists file and added it to this diff.

mib accepted this revision.Jun 23 2022, 1:41 PM

This looks way better :) !

This revision was not accepted when it landed; it landed in state Needs Review.Jun 23 2022, 1:55 PM
This revision was automatically updated to reflect the committed changes.