diff options
author | Jacob Bramley <jacob.bramley@arm.com> | 2019-06-12 15:51:34 +0100 |
---|---|---|
committer | Jacob Bramley <jacob.bramley@arm.com> | 2019-06-12 15:51:34 +0100 |
commit | 4ba4913f064fc5a1182f74b5e8bbd455403fbbaf (patch) | |
tree | 640f0192a05db20768910f7e0b5af31fb5abcca9 /test/aarch64 | |
parent | a5b3cefd7869a10765f3750658658dac75629c44 (diff) | |
download | vixl-4ba4913f064fc5a1182f74b5e8bbd455403fbbaf.tar.gz |
Support --disassemble in TRACE tests.
Normally, the temporary file is removed when the test exits, so there's
no way to know what was actually traced.
Now, --disassemble and --trace-sim work as they do for other tests.
Change-Id: Ie241647824fe28168108ae1d0a009c00db8963e6
Diffstat (limited to 'test/aarch64')
-rw-r--r-- | test/aarch64/test-trace-aarch64.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/aarch64/test-trace-aarch64.cc b/test/aarch64/test-trace-aarch64.cc index 963666d9..3fd393ca 100644 --- a/test/aarch64/test-trace-aarch64.cc +++ b/test/aarch64/test-trace-aarch64.cc @@ -2780,6 +2780,12 @@ static void MaskAddresses(const char* trace) { } } +static void PrintFile(const char* name) { + FILE* file = fopen(name, "r"); + char buffer[1024]; // The buffer size is arbitrary. + while (fgets(buffer, sizeof(buffer), file) != NULL) fputs(buffer, stdout); + fclose(file); +} static bool CheckOrGenerateTrace(const char* filename, const char* ref_file) { bool trace_matched_reference; @@ -2871,9 +2877,22 @@ static void TraceTestHelper(bool coloured_trace, masm.Ret(); masm.FinalizeCode(); + if (Test::disassemble()) { + PrintDisassembler disasm(stdout); + Instruction* start = masm.GetBuffer()->GetStartAddress<Instruction*>(); + Instruction* end = masm.GetBuffer()->GetEndAddress<Instruction*>(); + disasm.DisassembleBuffer(start, end); + } + simulator.RunFrom(masm.GetBuffer()->GetStartAddress<Instruction*>()); fclose(trace_stream); + + // We already traced into the temporary file, so just print the file. + // Note that these tests need to control the trace flags, so we ignore all + // --trace-* options here except for --trace-sim. + if (Test::trace_sim()) PrintFile(trace_stream_filename); + MaskAddresses(trace_stream_filename); bool trace_matched_reference = @@ -2963,6 +2982,10 @@ static void PrintDisassemblerTestHelper(const char* prefix, } fclose(trace_stream); + + // We already disassembled into the temporary file, so just print the file. + if (Test::disassemble()) PrintFile(trace_stream_filename); + MaskAddresses(trace_stream_filename); bool trace_matched_reference = |