OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/debug/debug-interface.h" |
| 6 #include "src/wasm/wasm-macro-gen.h" |
| 7 #include "src/wasm/wasm-objects.h" |
| 8 |
| 9 #include "test/cctest/cctest.h" |
| 10 #include "test/cctest/compiler/value-helper.h" |
| 11 #include "test/cctest/wasm/wasm-run-utils.h" |
| 12 #include "test/common/wasm/test-signatures.h" |
| 13 |
| 14 using namespace v8::internal; |
| 15 using namespace v8::internal::wasm; |
| 16 namespace debug = v8::debug; |
| 17 |
| 18 namespace { |
| 19 |
| 20 void CheckLocations( |
| 21 WasmCompiledModule *compiled_module, debug::Location start, |
| 22 debug::Location end, |
| 23 std::initializer_list<debug::Location> expected_locations_init) { |
| 24 std::vector<debug::Location> locations; |
| 25 bool success = |
| 26 compiled_module->GetPossibleBreakpoints(start, end, &locations); |
| 27 CHECK(success); |
| 28 |
| 29 printf("got %d locations: ", static_cast<int>(locations.size())); |
| 30 for (size_t i = 0, e = locations.size(); i != e; ++i) { |
| 31 printf("%s<%d,%d>", i == 0 ? "" : ", ", locations[i].GetLineNumber(), |
| 32 locations[i].GetColumnNumber()); |
| 33 } |
| 34 printf("\n"); |
| 35 |
| 36 std::vector<debug::Location> expected_locations(expected_locations_init); |
| 37 CHECK_EQ(expected_locations.size(), locations.size()); |
| 38 for (size_t i = 0, e = locations.size(); i != e; ++i) { |
| 39 CHECK_EQ(expected_locations[i].GetLineNumber(), |
| 40 locations[i].GetLineNumber()); |
| 41 CHECK_EQ(expected_locations[i].GetColumnNumber(), |
| 42 locations[i].GetColumnNumber()); |
| 43 } |
| 44 } |
| 45 void CheckLocationsFail(WasmCompiledModule *compiled_module, |
| 46 debug::Location start, debug::Location end) { |
| 47 std::vector<debug::Location> locations; |
| 48 bool success = |
| 49 compiled_module->GetPossibleBreakpoints(start, end, &locations); |
| 50 CHECK(!success); |
| 51 } |
| 52 |
| 53 } // namespace |
| 54 |
| 55 TEST(CollectPossibleBreakpoints) { |
| 56 WasmRunner<int> runner(kExecuteCompiled); |
| 57 |
| 58 BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE)); |
| 59 |
| 60 Handle<WasmInstanceObject> instance = runner.module().instance_object(); |
| 61 std::vector<debug::Location> locations; |
| 62 CheckLocations(instance->get_compiled_module(), {0, 0}, {1, 0}, |
| 63 {{0, 1}, {0, 2}, {0, 4}, {0, 6}}); |
| 64 CheckLocations(instance->get_compiled_module(), {0, 2}, {0, 4}, {{0, 2}}); |
| 65 CheckLocations(instance->get_compiled_module(), {0, 2}, {0, 5}, |
| 66 {{0, 2}, {0, 4}}); |
| 67 CheckLocations(instance->get_compiled_module(), {0, 6}, {0, 7}, {{0, 6}}); |
| 68 CheckLocations(instance->get_compiled_module(), {0, 6}, {1, 0}, {{0, 6}}); |
| 69 CheckLocations(instance->get_compiled_module(), {0, 7}, {1, 0}, {}); |
| 70 CheckLocationsFail(instance->get_compiled_module(), {0, 8}, {1, 0}); |
| 71 } |
OLD | NEW |