v8/test/cctest/wasm/test-wasm-breakpoints.cc
clemensh 081ac37048 [wasm] Introduce WasmSharedModuleData and refactor other objects
The new object will hold information which is shared by all clones of a
WasmCompiledModule, e.g. the decoded asm.js offset table, and in the
future also breakpoints. From there, we can set them on each new
instantiation of any clone.

While already changing lots of the code base, I also renamed all
getters from "get_foo" to "foo", to conform to the style guide.

R=titzer@chromium.org, yangguo@chromium.org
BUG=v8:5732

Review-Url: https://codereview.chromium.org/2591653002
Cr-Commit-Position: refs/heads/master@{#41862}
2016-12-20 14:34:07 +00:00

71 lines
2.6 KiB
C++

// 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->compiled_module(), {0, 0}, {1, 0},
{{0, 1}, {0, 2}, {0, 4}, {0, 6}});
CheckLocations(instance->compiled_module(), {0, 2}, {0, 4}, {{0, 2}});
CheckLocations(instance->compiled_module(), {0, 2}, {0, 5}, {{0, 2}, {0, 4}});
CheckLocations(instance->compiled_module(), {0, 6}, {0, 7}, {{0, 6}});
CheckLocations(instance->compiled_module(), {0, 6}, {1, 0}, {{0, 6}});
CheckLocations(instance->compiled_module(), {0, 7}, {1, 0}, {});
CheckLocationsFail(instance->compiled_module(), {0, 8}, {1, 0});
}