Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
disassembler_test.cc
Go to the documentation of this file.
1// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
7#include "vm/unit_test.h"
8#include "vm/virtual_memory.h"
9
10namespace dart {
11
12#if !defined(PRODUCT)
13
15 compiler::ObjectPoolBuilder object_pool_builder;
16 compiler::Assembler assembler(&object_pool_builder);
17
18 // The used instructions work on all platforms.
19 Register reg = static_cast<Register>(0);
20 assembler.PopRegister(reg);
21 assembler.Stop("testing disassembler");
22
23 // Only verify that the disassembler does not crash.
24 AssemblerTest test("Disassembler", &assembler, Thread::Current()->zone());
25 test.Assemble();
26 Disassembler::Disassemble(test.entry(), test.entry() + assembler.CodeSize());
27}
28
29ISOLATE_UNIT_TEST_CASE(Disassembler_InvalidInput) {
30 // Test that Disassembler doesn't crash even if the input is nonsense.
31 uint32_t bad_input[] = {
32 0x00000000, 0xFFFFFFFF, 0x12345678, 0x9ABCDEF0, 0x01110001,
33 0xDEADC0DE, 0xBAADF00D, 0xDABADEEE, 0xDABAD111, 0xB000DEAD,
34 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
35 };
37 reinterpret_cast<uword>(&bad_input[0]),
38 reinterpret_cast<uword>(ARRAY_SIZE(bad_input) + &bad_input[0]));
39}
40
41#endif // !PRODUCT
42
43} // namespace dart
static void Disassemble(uword start, uword end, DisassemblyFormatter *formatter, const Code &code, const CodeComments *comments=nullptr)
static Thread * Current()
Definition thread.h:361
void Stop(const char *message)
void PopRegister(Register r)
uintptr_t uword
Definition globals.h:501
#define ISOLATE_UNIT_TEST_CASE(name)
Definition unit_test.h:64
#define ARRAY_SIZE(array)
Definition globals.h:72