Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: src/debug/debug.cc

Issue 2069823003: [wasm] Enable wasm frame inspection for debugging (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@split-wasm-debug
Patch Set: rebase & address andreas' comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index c69b04b0c8327f5dd95a90a8b8ddb945b2ecbe07..7287ceb1865ab214ad49bfbfd08d2a87f13b8733 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -22,12 +22,34 @@
#include "src/log.h"
#include "src/messages.h"
#include "src/snapshot/natives.h"
+#include "src/wasm/wasm-debug.h"
+#include "src/wasm/wasm-module.h"
#include "include/v8-debug.h"
namespace v8 {
namespace internal {
+namespace {
+
+int GetCodeOffset(StandardFrame* frame) {
+ if (frame->is_java_script()) {
+ return FrameSummary::GetFirst(JavaScriptFrame::cast(frame)).code_offset();
+ }
+ DCHECK(frame->is_wasm());
+ return static_cast<int>(frame->pc() -
+ frame->unchecked_code()->instruction_start());
+}
+
+inline int CallOffsetFromCodeOffset(int code_offset, bool is_interpreted) {
+ // Code offset points to the instruction after the call. Subtract 1 to
+ // exclude that instruction from the search. For bytecode, the code offset
+ // still points to the call.
+ return is_interpreted ? code_offset : code_offset - 1;
+}
+
+} // namespace
+
Debug::Debug(Isolate* isolate)
: debug_context_(Handle<Context>()),
event_listener_(Handle<Object>()),
@@ -260,18 +282,11 @@ BreakLocation BreakLocation::FromCodeOffset(Handle<DebugInfo> debug_info,
return it->GetBreakLocation();
}
-int CallOffsetFromCodeOffset(int code_offset, bool is_interpreted) {
- // Code offset points to the instruction after the call. Subtract 1 to
- // exclude that instruction from the search. For bytecode, the code offset
- // still points to the call.
- return is_interpreted ? code_offset : code_offset - 1;
-}
-
BreakLocation BreakLocation::FromFrame(Handle<DebugInfo> debug_info,
- JavaScriptFrame* frame) {
- FrameSummary summary = FrameSummary::GetFirst(frame);
+ StandardFrame* frame) {
+ int code_offset = GetCodeOffset(frame);
int call_offset =
- CallOffsetFromCodeOffset(summary.code_offset(), frame->is_interpreted());
+ CallOffsetFromCodeOffset(code_offset, frame->is_interpreted());
return FromCodeOffset(debug_info, call_offset);
}
@@ -793,6 +808,9 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
Handle<Object> break_point_object,
int* source_position,
BreakPositionAlignment alignment) {
+ if (script->type() == Script::TYPE_WASM) {
+ // TODO(clemensh): set breakpoint for wasm.
Yang 2016/06/20 13:43:39 Can we return false here? This seems untested and
Clemens Hammacher 2016/06/23 13:26:10 Done.
+ }
HandleScope scope(isolate_);
// Obtain shared function info for the function.
@@ -1601,23 +1619,26 @@ void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) {
}
}
-
-bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
+bool Debug::IsBreakAtReturn(StandardFrame* frame) {
HandleScope scope(isolate_);
+ if (frame->is_wasm()) {
+ // TODO(clemensh): find out what we want to do for wasm
+ return false;
+ }
+
+ JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
// Get the executing function in which the debug break occurred.
- Handle<JSFunction> function(JSFunction::cast(frame->function()));
- Handle<SharedFunctionInfo> shared(function->shared());
+ Handle<SharedFunctionInfo> shared(js_frame->function()->shared());
// With no debug info there are no break points, so we can't be at a return.
if (!shared->HasDebugInfo()) return false;
DCHECK(!frame->is_optimized());
- FrameSummary summary = FrameSummary::GetFirst(frame);
-
+ int code_offset = GetCodeOffset(frame);
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
BreakLocation location =
- BreakLocation::FromCodeOffset(debug_info, summary.code_offset());
+ BreakLocation::FromCodeOffset(debug_info, code_offset);
return location.IsReturn() || location.IsTailCall();
}
@@ -2305,10 +2326,10 @@ DebugScope::DebugScope(Debug* debug)
// Create the new break info. If there is no JavaScript frames there is no
// break frame id.
- JavaScriptFrameIterator it(isolate());
- bool has_js_frames = !it.done();
- debug_->thread_local_.break_frame_id_ = has_js_frames ? it.frame()->id()
- : StackFrame::NO_ID;
+ StackTraceFrameIterator it(isolate());
+ bool has_frames = !it.done();
+ debug_->thread_local_.break_frame_id_ =
+ has_frames ? it.frame()->id() : StackFrame::NO_ID;
debug_->SetNextBreakId();
debug_->UpdateState();
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-evaluate.cc » ('j') | src/runtime/runtime-debug.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698