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

Unified Diff: src/debug.h

Issue 6234: Refactored the logic for entering the debugger into one abstraction EnterDebu... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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
« no previous file with comments | « no previous file | src/debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug.h
===================================================================
--- src/debug.h (revision 384)
+++ src/debug.h (working copy)
@@ -31,6 +31,7 @@
#include "../include/v8-debug.h"
#include "assembler.h"
#include "code-stubs.h"
+#include "execution.h"
#include "factory.h"
#include "platform.h"
#include "string-stream.h"
@@ -469,10 +470,15 @@
};
-// Helper class to support saving/restoring the top break frame id.
-class SaveBreakFrame {
+// This class is used for entering the debugger. Create an instance in the stack
+// to enter the debugger. This will set the current break state, make sure the
+// debugger is loaded and switch to the debugger context. If the debugger for
+// some reason could not be entered FailedToEnter will return true.
+class EnterDebugger BASE_EMBEDDED {
public:
- SaveBreakFrame() : set_(!it_.done()) {
+ EnterDebugger() : set_(!it_.done()) {
+ // If there is no JavaScript frames on the stack don't switch to new break
+ // and break frame.
if (set_) {
// Store the previous break is and frame id.
break_id_ = Top::break_id();
@@ -481,39 +487,37 @@
// Create the new break info.
Top::new_break(it_.frame()->id());
}
+
+ // Make sure that debugger is loaded and enter the debugger context.
+ load_failed_ = !Debug::Load();
+ if (!load_failed_) {
+ // NOTE the member variable save which saves the previous context before
+ // this change.
+ Top::set_context(*Debug::debug_context());
+ Top::set_security_context(*Debug::debug_context());
+ }
}
- ~SaveBreakFrame() {
+ ~EnterDebugger() {
if (set_) {
- // restore to the previous break state.
+ // Restore to the previous break state.
Top::set_break(break_frame_id_, break_id_);
}
}
+ // Check whether the debugger could be entered.
+ inline bool FailedToEnter() { return load_failed_; }
+
private:
JavaScriptFrameIterator it_;
const bool set_; // Was the break actually set?
StackFrame::Id break_frame_id_; // Previous break frame id.
int break_id_; // Previous break id.
+ bool load_failed_; // Did the debugger fail to load?
+ SaveContext save_; // Saves previous context.
};
-class EnterDebuggerContext BASE_EMBEDDED {
- public:
- // Enter the debugger by storing the previous top context and setting the
- // current top context to the debugger context.
- EnterDebuggerContext() {
- // NOTE the member variable save which saves the previous context before
- // this change.
- Top::set_context(*Debug::debug_context());
- Top::set_security_context(*Debug::debug_context());
- }
-
- private:
- SaveContext save;
-};
-
-
// Stack allocated class for disabling break.
class DisableBreak BASE_EMBEDDED {
public:
« no previous file with comments | « no previous file | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698