Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb/Util] Add a utility to run transparently capture and replay tests.
This patch introduces a small new utility (lldb-repro) to transparently capture and replay debugger sessions through the command line driver. Its used to test the reproducers by running the test suite twice. During the first run, it captures a reproducer for every lldb invocation and saves it to a well-know location derived from the arguments and current working directory. During the second run, the test suite is run again but this time every invocation of lldb replays the previously recorded session. Differential revision: https://reviews.llvm.org/D72823
- Loading branch information
1 parent
b37f6d3
commit 67420f1
Showing
6 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
add_subdirectory(lit-cpuid) | ||
add_subdirectory(lldb-dotest) | ||
add_subdirectory(lldb-repro) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
add_custom_target(lldb-repro) | ||
add_dependencies(lldb-repro lldb-test-deps) | ||
set_target_properties(lldb-repro PROPERTIES FOLDER "lldb utils") | ||
configure_file(lldb-repro.py ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-repro COPYONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python | ||
"""lldb-repro | ||
lldb-repro is a utility to transparently capture and replay debugger sessions | ||
through the command line driver. Its used to test the reproducers by running | ||
the test suite twice. | ||
During the first run, with 'capture' as its first argument, it captures a | ||
reproducer for every lldb invocation and saves it to a well-know location | ||
derived from the arguments and current working directory. | ||
During the second run, with 'replay' as its first argument, the test suite is | ||
run again but this time every invocation of lldb replays the previously | ||
recorded session. | ||
""" | ||
|
||
import sys | ||
import os | ||
import tempfile | ||
import subprocess | ||
|
||
|
||
def help(): | ||
print("usage: {} capture|replay [args]".fmt(sys.argv[0])) | ||
|
||
|
||
def main(): | ||
if len(sys.argv) < 3: | ||
help() | ||
return 1 | ||
|
||
# Compute a hash based on the input arguments and the current working | ||
# directory. | ||
args = ' '.join(sys.argv[3:]) | ||
cwd = os.getcwd() | ||
input_hash = str(hash((cwd, args))) | ||
|
||
# Use the hash to "uniquely" identify a reproducer path. | ||
reproducer_path = os.path.join(tempfile.gettempdir(), input_hash) | ||
|
||
# Create a new lldb invocation with capture or replay enabled. | ||
lldb = os.path.join(os.path.dirname(sys.argv[0]), 'lldb') | ||
new_args = [sys.argv[1]] | ||
if sys.argv[2] == "replay": | ||
new_args.extend(['--replay', reproducer_path]) | ||
elif sys.argv[2] == "capture": | ||
new_args.extend([ | ||
'--capture', '--capture-path', reproducer_path, | ||
'--reproducer-auto-generate' | ||
]) | ||
new_args.extend(sys.argv[1:]) | ||
else: | ||
help() | ||
return 1 | ||
|
||
return subprocess.call(new_args) | ||
|
||
|
||
if __name__ == '__main__': | ||
exit(main()) |