| Index: test/cctest/wasm/test-wasm-breakpoints.cc
|
| diff --git a/test/cctest/wasm/test-wasm-breakpoints.cc b/test/cctest/wasm/test-wasm-breakpoints.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..23226348c6f0f5735003469ee77f6a21dfe40cb4
|
| --- /dev/null
|
| +++ b/test/cctest/wasm/test-wasm-breakpoints.cc
|
| @@ -0,0 +1,71 @@
|
| +// Copyright 2016 the V8 project authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "src/debug/debug-interface.h"
|
| +#include "src/wasm/wasm-macro-gen.h"
|
| +#include "src/wasm/wasm-objects.h"
|
| +
|
| +#include "test/cctest/cctest.h"
|
| +#include "test/cctest/compiler/value-helper.h"
|
| +#include "test/cctest/wasm/wasm-run-utils.h"
|
| +#include "test/common/wasm/test-signatures.h"
|
| +
|
| +using namespace v8::internal;
|
| +using namespace v8::internal::wasm;
|
| +namespace debug = v8::debug;
|
| +
|
| +namespace {
|
| +
|
| +void CheckLocations(
|
| + WasmCompiledModule *compiled_module, debug::Location start,
|
| + debug::Location end,
|
| + std::initializer_list<debug::Location> expected_locations_init) {
|
| + std::vector<debug::Location> locations;
|
| + bool success =
|
| + compiled_module->GetPossibleBreakpoints(start, end, &locations);
|
| + CHECK(success);
|
| +
|
| + printf("got %d locations: ", static_cast<int>(locations.size()));
|
| + for (size_t i = 0, e = locations.size(); i != e; ++i) {
|
| + printf("%s<%d,%d>", i == 0 ? "" : ", ", locations[i].GetLineNumber(),
|
| + locations[i].GetColumnNumber());
|
| + }
|
| + printf("\n");
|
| +
|
| + std::vector<debug::Location> expected_locations(expected_locations_init);
|
| + CHECK_EQ(expected_locations.size(), locations.size());
|
| + for (size_t i = 0, e = locations.size(); i != e; ++i) {
|
| + CHECK_EQ(expected_locations[i].GetLineNumber(),
|
| + locations[i].GetLineNumber());
|
| + CHECK_EQ(expected_locations[i].GetColumnNumber(),
|
| + locations[i].GetColumnNumber());
|
| + }
|
| +}
|
| +void CheckLocationsFail(WasmCompiledModule *compiled_module,
|
| + debug::Location start, debug::Location end) {
|
| + std::vector<debug::Location> locations;
|
| + bool success =
|
| + compiled_module->GetPossibleBreakpoints(start, end, &locations);
|
| + CHECK(!success);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +TEST(CollectPossibleBreakpoints) {
|
| + WasmRunner<int> runner(kExecuteCompiled);
|
| +
|
| + BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE));
|
| +
|
| + Handle<WasmInstanceObject> instance = runner.module().instance_object();
|
| + std::vector<debug::Location> locations;
|
| + CheckLocations(instance->get_compiled_module(), {0, 0}, {1, 0},
|
| + {{0, 1}, {0, 2}, {0, 4}, {0, 6}});
|
| + CheckLocations(instance->get_compiled_module(), {0, 2}, {0, 4}, {{0, 2}});
|
| + CheckLocations(instance->get_compiled_module(), {0, 2}, {0, 5},
|
| + {{0, 2}, {0, 4}});
|
| + CheckLocations(instance->get_compiled_module(), {0, 6}, {0, 7}, {{0, 6}});
|
| + CheckLocations(instance->get_compiled_module(), {0, 6}, {1, 0}, {{0, 6}});
|
| + CheckLocations(instance->get_compiled_module(), {0, 7}, {1, 0}, {});
|
| + CheckLocationsFail(instance->get_compiled_module(), {0, 8}, {1, 0});
|
| +}
|
|
|