blob: c5c6b5ee56a55227ac6598b028ee4d901c51487e [file] [log] [blame]
ager@chromium.org9258b6b2008-09-11 09:11:10 +00001// Copyright 2006-2008 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
ager@chromium.org5ec48922009-05-05 07:25:34 +000028#ifndef V8_DEBUG_H_
29#define V8_DEBUG_H_
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000030
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000031#include "assembler.h"
32#include "code-stubs.h"
kasperl@chromium.org7be3c992009-03-12 07:19:55 +000033#include "debug-agent.h"
kasperl@chromium.org41044eb2008-10-06 08:24:46 +000034#include "execution.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000035#include "factory.h"
kasperl@chromium.org71affb52009-05-26 05:44:31 +000036#include "hashmap.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000037#include "platform.h"
38#include "string-stream.h"
kasperl@chromium.org7be3c992009-03-12 07:19:55 +000039#include "v8threads.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000040
ager@chromium.org65dad4b2009-04-23 08:48:43 +000041#ifdef ENABLE_DEBUGGER_SUPPORT
42#include "../include/v8-debug.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000043
kasperl@chromium.org71affb52009-05-26 05:44:31 +000044namespace v8 {
45namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000046
kasperl@chromium.org7be3c992009-03-12 07:19:55 +000047
48// Forward declarations.
49class EnterDebugger;
50
51
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000052// Step actions. NOTE: These values are in macros.py as well.
53enum StepAction {
54 StepNone = -1, // Stepping not prepared.
55 StepOut = 0, // Step out of the current function.
56 StepNext = 1, // Step to the next statement in the current function.
57 StepIn = 2, // Step into new functions invoked or the next statement
58 // in the current function.
59 StepMin = 3, // Perform a minimum step in the current function.
60 StepInMin = 4 // Step into new functions invoked or perform a minimum step
61 // in the current function.
62};
63
64
65// Type of exception break. NOTE: These values are in macros.py as well.
66enum ExceptionBreakType {
67 BreakException = 0,
68 BreakUncaughtException = 1
69};
70
71
72// Type of exception break. NOTE: These values are in macros.py as well.
73enum BreakLocatorType {
74 ALL_BREAK_LOCATIONS = 0,
75 SOURCE_BREAK_LOCATIONS = 1
76};
77
78
79// Class for iterating through the break points in a function and changing
80// them.
81class BreakLocationIterator {
82 public:
83 explicit BreakLocationIterator(Handle<DebugInfo> debug_info,
84 BreakLocatorType type);
85 virtual ~BreakLocationIterator();
86
87 void Next();
88 void Next(int count);
89 void FindBreakLocationFromAddress(Address pc);
90 void FindBreakLocationFromPosition(int position);
91 void Reset();
92 bool Done() const;
93 void SetBreakPoint(Handle<Object> break_point_object);
94 void ClearBreakPoint(Handle<Object> break_point_object);
95 void SetOneShot();
96 void ClearOneShot();
97 void PrepareStepIn();
98 bool IsExit() const;
99 bool HasBreakPoint();
100 bool IsDebugBreak();
101 Object* BreakPointObjects();
ager@chromium.org381abbb2009-02-25 13:23:22 +0000102 void ClearAllDebugBreak();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000103
104
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000105 inline int code_position() {
106 return static_cast<int>(pc() - debug_info_->code()->entry());
107 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000108 inline int break_point() { return break_point_; }
109 inline int position() { return position_; }
110 inline int statement_position() { return statement_position_; }
111 inline Address pc() { return reloc_iterator_->rinfo()->pc(); }
112 inline Code* code() { return debug_info_->code(); }
113 inline RelocInfo* rinfo() { return reloc_iterator_->rinfo(); }
ager@chromium.org236ad962008-09-25 09:45:57 +0000114 inline RelocInfo::Mode rmode() const {
115 return reloc_iterator_->rinfo()->rmode();
116 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000117 inline RelocInfo* original_rinfo() {
118 return reloc_iterator_original_->rinfo();
119 }
ager@chromium.org236ad962008-09-25 09:45:57 +0000120 inline RelocInfo::Mode original_rmode() const {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000121 return reloc_iterator_original_->rinfo()->rmode();
122 }
123
ager@chromium.orga1645e22009-09-09 19:27:10 +0000124 bool IsDebuggerStatement();
125
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000126 protected:
127 bool RinfoDone() const;
128 void RinfoNext();
129
130 BreakLocatorType type_;
131 int break_point_;
132 int position_;
133 int statement_position_;
134 Handle<DebugInfo> debug_info_;
ager@chromium.orga1645e22009-09-09 19:27:10 +0000135 Handle<Code> debug_break_stub_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000136 RelocIterator* reloc_iterator_;
137 RelocIterator* reloc_iterator_original_;
138
139 private:
140 void SetDebugBreak();
141 void ClearDebugBreak();
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000142
143 void SetDebugBreakAtIC();
144 void ClearDebugBreakAtIC();
145
iposva@chromium.org245aa852009-02-10 00:49:54 +0000146 bool IsDebugBreakAtReturn();
147 void SetDebugBreakAtReturn();
148 void ClearDebugBreakAtReturn();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000149
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000150 DISALLOW_COPY_AND_ASSIGN(BreakLocationIterator);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000151};
152
153
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000154// Cache of all script objects in the heap. When a script is added a weak handle
155// to it is created and that weak handle is stored in the cache. The weak handle
156// callback takes care of removing the script from the cache. The key used in
157// the cache is the script id.
158class ScriptCache : private HashMap {
159 public:
160 ScriptCache() : HashMap(ScriptMatch), collected_scripts_(10) {}
161 virtual ~ScriptCache() { Clear(); }
162
163 // Add script to the cache.
164 void Add(Handle<Script> script);
165
166 // Return the scripts in the cache.
167 Handle<FixedArray> GetScripts();
168
169 // Generate debugger events for collected scripts.
170 void ProcessCollectedScripts();
171
172 private:
173 // Calculate the hash value from the key (script id).
174 static uint32_t Hash(int key) { return ComputeIntegerHash(key); }
175
176 // Scripts match if their keys (script id) match.
177 static bool ScriptMatch(void* key1, void* key2) { return key1 == key2; }
178
179 // Clear the cache releasing all the weak handles.
180 void Clear();
181
182 // Weak handle callback for scripts in the cache.
183 static void HandleWeakScript(v8::Persistent<v8::Value> obj, void* data);
184
185 // List used during GC to temporarily store id's of collected scripts.
186 List<int> collected_scripts_;
187};
188
189
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000190// Linked list holding debug info objects. The debug info objects are kept as
191// weak handles to avoid a debug info object to keep a function alive.
192class DebugInfoListNode {
193 public:
194 explicit DebugInfoListNode(DebugInfo* debug_info);
195 virtual ~DebugInfoListNode();
196
197 DebugInfoListNode* next() { return next_; }
198 void set_next(DebugInfoListNode* next) { next_ = next; }
199 Handle<DebugInfo> debug_info() { return debug_info_; }
200
201 private:
202 // Global (weak) handle to the debug info object.
203 Handle<DebugInfo> debug_info_;
204
205 // Next pointer for linked list.
206 DebugInfoListNode* next_;
207};
208
209
210// This class contains the debugger support. The main purpose is to handle
211// setting break points in the code.
212//
213// This class controls the debug info for all functions which currently have
214// active breakpoints in them. This debug info is held in the heap root object
215// debug_info which is a FixedArray. Each entry in this list is of class
216// DebugInfo.
217class Debug {
218 public:
219 static void Setup(bool create_heap_objects);
220 static bool Load();
221 static void Unload();
222 static bool IsLoaded() { return !debug_context_.is_null(); }
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000223 static bool InDebugger() { return thread_local_.debugger_entry_ != NULL; }
224 static void PreemptionWhileInDebugger();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000225 static void Iterate(ObjectVisitor* v);
226
227 static Object* Break(Arguments args);
228 static void SetBreakPoint(Handle<SharedFunctionInfo> shared,
229 int source_position,
230 Handle<Object> break_point_object);
231 static void ClearBreakPoint(Handle<Object> break_point_object);
ager@chromium.org381abbb2009-02-25 13:23:22 +0000232 static void ClearAllBreakPoints();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000233 static void FloodWithOneShot(Handle<SharedFunctionInfo> shared);
234 static void FloodHandlerWithOneShot();
235 static void ChangeBreakOnException(ExceptionBreakType type, bool enable);
236 static void PrepareStep(StepAction step_action, int step_count);
237 static void ClearStepping();
238 static bool StepNextContinue(BreakLocationIterator* break_location_iterator,
239 JavaScriptFrame* frame);
240 static Handle<DebugInfo> GetDebugInfo(Handle<SharedFunctionInfo> shared);
241 static bool HasDebugInfo(Handle<SharedFunctionInfo> shared);
kasper.lundbd3ec4e2008-07-09 11:06:54 +0000242
ager@chromium.org32912102009-01-16 10:38:43 +0000243 // Returns whether the operation succeeded.
kasper.lundbd3ec4e2008-07-09 11:06:54 +0000244 static bool EnsureDebugInfo(Handle<SharedFunctionInfo> shared);
245
sgjesse@chromium.org911335c2009-08-19 12:59:44 +0000246 // Returns true if the current stub call is patched to call the debugger.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000247 static bool IsDebugBreak(Address addr);
sgjesse@chromium.org911335c2009-08-19 12:59:44 +0000248 // Returns true if the current return statement has been patched to be
249 // a debugger breakpoint.
ager@chromium.org381abbb2009-02-25 13:23:22 +0000250 static bool IsDebugBreakAtReturn(RelocInfo* rinfo);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000251
252 // Check whether a code stub with the specified major key is a possible break
253 // point location.
254 static bool IsSourceBreakStub(Code* code);
255 static bool IsBreakStub(Code* code);
256
257 // Find the builtin to use for invoking the debug break
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000258 static Handle<Code> FindDebugBreak(Handle<Code> code, RelocInfo::Mode mode);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000259
260 static Handle<Object> GetSourceBreakLocations(
261 Handle<SharedFunctionInfo> shared);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000262
263 // Getter for the debug_context.
264 inline static Handle<Context> debug_context() { return debug_context_; }
265
266 // Check whether a global object is the debug global object.
267 static bool IsDebugGlobal(GlobalObject* global);
268
269 // Fast check to see if any break points are active.
270 inline static bool has_break_points() { return has_break_points_; }
271
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000272 static void NewBreak(StackFrame::Id break_frame_id);
273 static void SetBreak(StackFrame::Id break_frame_id, int break_id);
274 static StackFrame::Id break_frame_id() {
275 return thread_local_.break_frame_id_;
276 }
277 static int break_id() { return thread_local_.break_id_; }
278
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000279 static bool StepInActive() { return thread_local_.step_into_fp_ != 0; }
christian.plesner.hansen@gmail.com37abdec2009-01-06 14:43:28 +0000280 static void HandleStepIn(Handle<JSFunction> function,
kasperl@chromium.orgdefbd102009-07-13 14:04:26 +0000281 Handle<Object> holder,
christian.plesner.hansen@gmail.com37abdec2009-01-06 14:43:28 +0000282 Address fp,
283 bool is_constructor);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000284 static Address step_in_fp() { return thread_local_.step_into_fp_; }
285 static Address* step_in_fp_addr() { return &thread_local_.step_into_fp_; }
286
ager@chromium.orga1645e22009-09-09 19:27:10 +0000287 static bool StepOutActive() { return thread_local_.step_out_fp_ != 0; }
288 static Address step_out_fp() { return thread_local_.step_out_fp_; }
289
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000290 static EnterDebugger* debugger_entry() {
291 return thread_local_.debugger_entry_;
292 }
293 static void set_debugger_entry(EnterDebugger* entry) {
294 thread_local_.debugger_entry_ = entry;
295 }
296
sgjesse@chromium.org755c5b12009-05-29 11:04:38 +0000297 // Check whether any of the specified interrupts are pending.
298 static bool is_interrupt_pending(InterruptFlag what) {
299 return (thread_local_.pending_interrupts_ & what) != 0;
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000300 }
sgjesse@chromium.org755c5b12009-05-29 11:04:38 +0000301
302 // Set specified interrupts as pending.
303 static void set_interrupts_pending(InterruptFlag what) {
304 thread_local_.pending_interrupts_ |= what;
305 }
306
307 // Clear specified interrupts from pending.
308 static void clear_interrupt_pending(InterruptFlag what) {
309 thread_local_.pending_interrupts_ &= ~static_cast<int>(what);
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000310 }
311
kasper.lundbd3ec4e2008-07-09 11:06:54 +0000312 // Getter and setter for the disable break state.
313 static bool disable_break() { return disable_break_; }
314 static void set_disable_break(bool disable_break) {
315 disable_break_ = disable_break;
316 }
317
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000318 // Getters for the current exception break state.
319 static bool break_on_exception() { return break_on_exception_; }
320 static bool break_on_uncaught_exception() {
321 return break_on_uncaught_exception_;
322 }
323
324 enum AddressId {
325 k_after_break_target_address,
326 k_debug_break_return_address,
327 k_register_address
328 };
329
330 // Support for setting the address to jump to when returning from break point.
331 static Address* after_break_target_address() {
332 return reinterpret_cast<Address*>(&thread_local_.after_break_target_);
333 }
334
335 // Support for saving/restoring registers when handling debug break calls.
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000336 static Object** register_address(int r) {
337 return &registers_[r];
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000338 }
339
ager@chromium.orga1645e22009-09-09 19:27:10 +0000340 // Access to the debug break on return code.
341 static Code* debug_break_return() { return debug_break_return_; }
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000342 static Code** debug_break_return_address() {
343 return &debug_break_return_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000344 }
345
346 static const int kEstimatedNofDebugInfoEntries = 16;
347 static const int kEstimatedNofBreakPointsInFunction = 16;
348
kasperl@chromium.org5a8ca6c2008-10-23 13:57:19 +0000349 static void HandleWeakDebugInfo(v8::Persistent<v8::Value> obj, void* data);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000350
351 friend class Debugger;
ager@chromium.org381abbb2009-02-25 13:23:22 +0000352 friend Handle<FixedArray> GetDebuggedFunctions(); // In test-debug.cc
353 friend void CheckDebuggerUnloaded(bool check_functions); // In test-debug.cc
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000354
355 // Threading support.
356 static char* ArchiveDebug(char* to);
357 static char* RestoreDebug(char* from);
358 static int ArchiveSpacePerThread();
sgjesse@chromium.orgc5145742009-10-07 09:00:33 +0000359 static void FreeThreadResources() { }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000360
ager@chromium.org32912102009-01-16 10:38:43 +0000361 // Mirror cache handling.
362 static void ClearMirrorCache();
363
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000364 // Script cache handling.
365 static void CreateScriptCache();
366 static void DestroyScriptCache();
367 static void AddScriptToScriptCache(Handle<Script> script);
368 static Handle<FixedArray> GetLoadedScripts();
369
370 // Garbage collection notifications.
371 static void AfterGarbageCollection();
372
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000373 // Code generation assumptions.
374 static const int kIa32CallInstructionLength = 5;
375 static const int kIa32JSReturnSequenceLength = 6;
376
kasperl@chromium.orgdefbd102009-07-13 14:04:26 +0000377 // The x64 JS return sequence is padded with int3 to make it large
378 // enough to hold a call instruction when the debugger patches it.
sgjesse@chromium.org911335c2009-08-19 12:59:44 +0000379 static const int kX64CallInstructionLength = 13;
kasperl@chromium.orgdefbd102009-07-13 14:04:26 +0000380 static const int kX64JSReturnSequenceLength = 13;
381
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000382 static const int kARMJSReturnSequenceLength = 4;
383
ager@chromium.org8bb60582008-12-11 12:02:20 +0000384 // Code generator routines.
385 static void GenerateLoadICDebugBreak(MacroAssembler* masm);
386 static void GenerateStoreICDebugBreak(MacroAssembler* masm);
387 static void GenerateKeyedLoadICDebugBreak(MacroAssembler* masm);
388 static void GenerateKeyedStoreICDebugBreak(MacroAssembler* masm);
389 static void GenerateConstructCallDebugBreak(MacroAssembler* masm);
390 static void GenerateReturnDebugBreak(MacroAssembler* masm);
ager@chromium.org8bb60582008-12-11 12:02:20 +0000391 static void GenerateStubNoRegistersDebugBreak(MacroAssembler* masm);
392
393 // Called from stub-cache.cc.
394 static void GenerateCallICDebugBreak(MacroAssembler* masm);
395
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000396 private:
397 static bool CompileDebuggerScript(int index);
398 static void ClearOneShot();
399 static void ActivateStepIn(StackFrame* frame);
400 static void ClearStepIn();
ager@chromium.orga1645e22009-09-09 19:27:10 +0000401 static void ActivateStepOut(StackFrame* frame);
402 static void ClearStepOut();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000403 static void ClearStepNext();
ager@chromium.org32912102009-01-16 10:38:43 +0000404 // Returns whether the compile succeeded.
kasper.lundbd3ec4e2008-07-09 11:06:54 +0000405 static bool EnsureCompiled(Handle<SharedFunctionInfo> shared);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000406 static void RemoveDebugInfo(Handle<DebugInfo> debug_info);
407 static void SetAfterBreakTarget(JavaScriptFrame* frame);
408 static Handle<Object> CheckBreakPoints(Handle<Object> break_point);
409 static bool CheckBreakPoint(Handle<Object> break_point_object);
410
411 // Global handle to debug context where all the debugger JavaScript code is
412 // loaded.
413 static Handle<Context> debug_context_;
414
415 // Boolean state indicating whether any break points are set.
416 static bool has_break_points_;
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000417
418 // Cache of all scripts in the heap.
419 static ScriptCache* script_cache_;
420
421 // List of active debug info objects.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000422 static DebugInfoListNode* debug_info_list_;
423
kasper.lundbd3ec4e2008-07-09 11:06:54 +0000424 static bool disable_break_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000425 static bool break_on_exception_;
426 static bool break_on_uncaught_exception_;
427
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000428 // Per-thread data.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000429 class ThreadLocal {
430 public:
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000431 // Counter for generating next break id.
432 int break_count_;
433
434 // Current break id.
435 int break_id_;
436
437 // Frame id for the frame of the current break.
438 StackFrame::Id break_frame_id_;
439
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000440 // Step action for last step performed.
441 StepAction last_step_action_;
442
443 // Source statement position from last step next action.
444 int last_statement_position_;
445
446 // Number of steps left to perform before debug event.
447 int step_count_;
448
449 // Frame pointer from last step next action.
450 Address last_fp_;
451
452 // Frame pointer for frame from which step in was performed.
453 Address step_into_fp_;
454
ager@chromium.orga1645e22009-09-09 19:27:10 +0000455 // Frame pointer for the frame where debugger should be called when current
456 // step out action is completed.
457 Address step_out_fp_;
458
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000459 // Storage location for jump when exiting debug break calls.
460 Address after_break_target_;
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000461
462 // Top debugger entry.
463 EnterDebugger* debugger_entry_;
464
sgjesse@chromium.org755c5b12009-05-29 11:04:38 +0000465 // Pending interrupts scheduled while debugging.
466 int pending_interrupts_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000467 };
468
469 // Storage location for registers when handling debug break calls
470 static JSCallerSavedBuffer registers_;
471 static ThreadLocal thread_local_;
472 static void ThreadInit();
473
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000474 // Code to call for handling debug break on return.
475 static Code* debug_break_return_;
476
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000477 DISALLOW_COPY_AND_ASSIGN(Debug);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000478};
479
480
ager@chromium.org5ec48922009-05-05 07:25:34 +0000481// Message delivered to the message handler callback. This is either a debugger
482// event or the response to a command.
483class MessageImpl: public v8::Debug::Message {
484 public:
485 // Create a message object for a debug event.
486 static MessageImpl NewEvent(DebugEvent event,
487 bool running,
488 Handle<JSObject> exec_state,
489 Handle<JSObject> event_data);
490
491 // Create a message object for the response to a debug command.
492 static MessageImpl NewResponse(DebugEvent event,
493 bool running,
494 Handle<JSObject> exec_state,
495 Handle<JSObject> event_data,
496 Handle<String> response_json,
497 v8::Debug::ClientData* client_data);
498
499 // Implementation of interface v8::Debug::Message.
500 virtual bool IsEvent() const;
501 virtual bool IsResponse() const;
502 virtual DebugEvent GetEvent() const;
503 virtual bool WillStartRunning() const;
504 virtual v8::Handle<v8::Object> GetExecutionState() const;
505 virtual v8::Handle<v8::Object> GetEventData() const;
506 virtual v8::Handle<v8::String> GetJSON() const;
507 virtual v8::Handle<v8::Context> GetEventContext() const;
508 virtual v8::Debug::ClientData* GetClientData() const;
509
510 private:
511 MessageImpl(bool is_event,
512 DebugEvent event,
513 bool running,
514 Handle<JSObject> exec_state,
515 Handle<JSObject> event_data,
516 Handle<String> response_json,
517 v8::Debug::ClientData* client_data);
518
519 bool is_event_; // Does this message represent a debug event?
520 DebugEvent event_; // Debug event causing the break.
521 bool running_; // Will the VM start running after this event?
522 Handle<JSObject> exec_state_; // Current execution state.
523 Handle<JSObject> event_data_; // Data associated with the event.
524 Handle<String> response_json_; // Response JSON if message holds a response.
525 v8::Debug::ClientData* client_data_; // Client data passed with the request.
526};
527
528
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000529// Message send by user to v8 debugger or debugger output message.
530// In addition to command text it may contain a pointer to some user data
531// which are expected to be passed along with the command reponse to message
532// handler.
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000533class CommandMessage {
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000534 public:
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000535 static CommandMessage New(const Vector<uint16_t>& command,
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000536 v8::Debug::ClientData* data);
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000537 CommandMessage();
538 ~CommandMessage();
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000539
540 // Deletes user data and disposes of the text.
541 void Dispose();
542 Vector<uint16_t> text() const { return text_; }
543 v8::Debug::ClientData* client_data() const { return client_data_; }
544 private:
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000545 CommandMessage(const Vector<uint16_t>& text,
546 v8::Debug::ClientData* data);
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000547
548 Vector<uint16_t> text_;
549 v8::Debug::ClientData* client_data_;
550};
551
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000552// A Queue of CommandMessage objects. A thread-safe version is
553// LockingCommandMessageQueue, based on this class.
554class CommandMessageQueue BASE_EMBEDDED {
ager@chromium.org41826e72009-03-30 13:30:57 +0000555 public:
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000556 explicit CommandMessageQueue(int size);
557 ~CommandMessageQueue();
ager@chromium.org41826e72009-03-30 13:30:57 +0000558 bool IsEmpty() const { return start_ == end_; }
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000559 CommandMessage Get();
560 void Put(const CommandMessage& message);
ager@chromium.org41826e72009-03-30 13:30:57 +0000561 void Clear() { start_ = end_ = 0; } // Queue is empty after Clear().
562 private:
563 // Doubles the size of the message queue, and copies the messages.
564 void Expand();
565
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000566 CommandMessage* messages_;
ager@chromium.org41826e72009-03-30 13:30:57 +0000567 int start_;
568 int end_;
569 int size_; // The size of the queue buffer. Queue can hold size-1 messages.
570};
571
572
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000573// LockingCommandMessageQueue is a thread-safe circular buffer of CommandMessage
574// messages. The message data is not managed by LockingCommandMessageQueue.
ager@chromium.org41826e72009-03-30 13:30:57 +0000575// Pointers to the data are passed in and out. Implemented by adding a
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000576// Mutex to CommandMessageQueue. Includes logging of all puts and gets.
577class LockingCommandMessageQueue BASE_EMBEDDED {
ager@chromium.org41826e72009-03-30 13:30:57 +0000578 public:
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000579 explicit LockingCommandMessageQueue(int size);
580 ~LockingCommandMessageQueue();
ager@chromium.org41826e72009-03-30 13:30:57 +0000581 bool IsEmpty() const;
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000582 CommandMessage Get();
583 void Put(const CommandMessage& message);
ager@chromium.org41826e72009-03-30 13:30:57 +0000584 void Clear();
585 private:
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000586 CommandMessageQueue queue_;
ager@chromium.org41826e72009-03-30 13:30:57 +0000587 Mutex* lock_;
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000588 DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue);
ager@chromium.org41826e72009-03-30 13:30:57 +0000589};
590
591
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000592class Debugger {
593 public:
594 static void DebugRequest(const uint16_t* json_request, int length);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000595
596 static Handle<Object> MakeJSObject(Vector<const char> constructor_name,
597 int argc, Object*** argv,
598 bool* caught_exception);
599 static Handle<Object> MakeExecutionState(bool* caught_exception);
600 static Handle<Object> MakeBreakEvent(Handle<Object> exec_state,
601 Handle<Object> break_points_hit,
602 bool* caught_exception);
603 static Handle<Object> MakeExceptionEvent(Handle<Object> exec_state,
604 Handle<Object> exception,
605 bool uncaught,
606 bool* caught_exception);
607 static Handle<Object> MakeNewFunctionEvent(Handle<Object> func,
608 bool* caught_exception);
609 static Handle<Object> MakeCompileEvent(Handle<Script> script,
iposva@chromium.org245aa852009-02-10 00:49:54 +0000610 bool before,
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000611 bool* caught_exception);
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000612 static Handle<Object> MakeScriptCollectedEvent(int id,
613 bool* caught_exception);
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000614 static void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000615 static void OnException(Handle<Object> exception, bool uncaught);
616 static void OnBeforeCompile(Handle<Script> script);
617 static void OnAfterCompile(Handle<Script> script,
618 Handle<JSFunction> fun);
619 static void OnNewFunction(Handle<JSFunction> fun);
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000620 static void OnScriptCollected(int id);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000621 static void ProcessDebugEvent(v8::DebugEvent event,
ager@chromium.org5ec48922009-05-05 07:25:34 +0000622 Handle<JSObject> event_data,
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000623 bool auto_continue);
ager@chromium.org41826e72009-03-30 13:30:57 +0000624 static void NotifyMessageHandler(v8::DebugEvent event,
ager@chromium.org5ec48922009-05-05 07:25:34 +0000625 Handle<JSObject> exec_state,
626 Handle<JSObject> event_data,
ager@chromium.org41826e72009-03-30 13:30:57 +0000627 bool auto_continue);
iposva@chromium.org245aa852009-02-10 00:49:54 +0000628 static void SetEventListener(Handle<Object> callback, Handle<Object> data);
ager@chromium.org5ec48922009-05-05 07:25:34 +0000629 static void SetMessageHandler(v8::Debug::MessageHandler2 handler);
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000630 static void SetHostDispatchHandler(v8::Debug::HostDispatchHandler handler,
631 int period);
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000632 static void SetDebugMessageDispatchHandler(
633 v8::Debug::DebugMessageDispatchHandler handler);
ager@chromium.org41826e72009-03-30 13:30:57 +0000634
635 // Invoke the message handler function.
ager@chromium.org5ec48922009-05-05 07:25:34 +0000636 static void InvokeMessageHandler(MessageImpl message);
ager@chromium.org41826e72009-03-30 13:30:57 +0000637
638 // Add a debugger command to the command queue.
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000639 static void ProcessCommand(Vector<const uint16_t> command,
640 v8::Debug::ClientData* client_data = NULL);
ager@chromium.org41826e72009-03-30 13:30:57 +0000641
642 // Check whether there are commands in the command queue.
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000643 static bool HasCommands();
ager@chromium.org41826e72009-03-30 13:30:57 +0000644
ager@chromium.orga74f0da2008-12-03 16:05:52 +0000645 static Handle<Object> Call(Handle<JSFunction> fun,
646 Handle<Object> data,
647 bool* pending_exception);
648
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000649 // Start the debugger agent listening on the provided port.
ager@chromium.orgbb29dc92009-03-24 13:25:23 +0000650 static bool StartAgent(const char* name, int port);
651
652 // Stop the debugger agent.
653 static void StopAgent();
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000654
sgjesse@chromium.orgc5145742009-10-07 09:00:33 +0000655 // Blocks until the agent has started listening for connections
656 static void WaitForAgent();
657
ager@chromium.org71daaf62009-04-01 07:22:49 +0000658 // Unload the debugger if possible. Only called when no debugger is currently
659 // active.
660 static void UnloadDebugger();
661
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000662 inline static bool EventActive(v8::DebugEvent event) {
ager@chromium.org71daaf62009-04-01 07:22:49 +0000663 ScopedLock with(debugger_access_);
664
665 // Check whether the message handler was been cleared.
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000666 if (debugger_unload_pending_) {
ager@chromium.org71daaf62009-04-01 07:22:49 +0000667 UnloadDebugger();
668 }
669
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000670 // Currently argument event is not used.
ager@chromium.org71daaf62009-04-01 07:22:49 +0000671 return !compiling_natives_ && Debugger::IsDebuggerActive();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000672 }
673
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000674 static void set_compiling_natives(bool compiling_natives) {
675 Debugger::compiling_natives_ = compiling_natives;
676 }
677 static bool compiling_natives() { return Debugger::compiling_natives_; }
mads.s.agercbaa0602008-08-14 13:41:48 +0000678 static void set_loading_debugger(bool v) { is_loading_debugger_ = v; }
679 static bool is_loading_debugger() { return Debugger::is_loading_debugger_; }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000680
681 private:
ager@chromium.org71daaf62009-04-01 07:22:49 +0000682 static bool IsDebuggerActive();
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000683 static void ListenersChanged();
ager@chromium.org71daaf62009-04-01 07:22:49 +0000684
685 static Mutex* debugger_access_; // Mutex guarding debugger variables.
686 static Handle<Object> event_listener_; // Global handle to listener.
iposva@chromium.org245aa852009-02-10 00:49:54 +0000687 static Handle<Object> event_listener_data_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000688 static bool compiling_natives_; // Are we compiling natives?
mads.s.agercbaa0602008-08-14 13:41:48 +0000689 static bool is_loading_debugger_; // Are we loading the debugger?
ager@chromium.org71daaf62009-04-01 07:22:49 +0000690 static bool never_unload_debugger_; // Can we unload the debugger?
ager@chromium.org5ec48922009-05-05 07:25:34 +0000691 static v8::Debug::MessageHandler2 message_handler_;
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000692 static bool debugger_unload_pending_; // Was message handler cleared?
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000693 static v8::Debug::HostDispatchHandler host_dispatch_handler_;
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000694 static v8::Debug::DebugMessageDispatchHandler debug_message_dispatch_handler_;
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000695 static int host_dispatch_micros_;
ager@chromium.org381abbb2009-02-25 13:23:22 +0000696
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000697 static DebuggerAgent* agent_;
698
ager@chromium.org41826e72009-03-30 13:30:57 +0000699 static const int kQueueInitialSize = 4;
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000700 static LockingCommandMessageQueue command_queue_;
ager@chromium.org41826e72009-03-30 13:30:57 +0000701 static Semaphore* command_received_; // Signaled for each command received.
ager@chromium.org41826e72009-03-30 13:30:57 +0000702
ager@chromium.org71daaf62009-04-01 07:22:49 +0000703 friend class EnterDebugger;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000704};
705
706
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000707// This class is used for entering the debugger. Create an instance in the stack
708// to enter the debugger. This will set the current break state, make sure the
709// debugger is loaded and switch to the debugger context. If the debugger for
710// some reason could not be entered FailedToEnter will return true.
711class EnterDebugger BASE_EMBEDDED {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000712 public:
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000713 EnterDebugger()
714 : prev_(Debug::debugger_entry()),
715 has_js_frames_(!it_.done()) {
sgjesse@chromium.org755c5b12009-05-29 11:04:38 +0000716 ASSERT(prev_ != NULL || !Debug::is_interrupt_pending(PREEMPT));
717 ASSERT(prev_ != NULL || !Debug::is_interrupt_pending(DEBUGBREAK));
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000718
719 // Link recursive debugger entry.
720 Debug::set_debugger_entry(this);
721
ager@chromium.org8bb60582008-12-11 12:02:20 +0000722 // Store the previous break id and frame id.
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000723 break_id_ = Debug::break_id();
724 break_frame_id_ = Debug::break_frame_id();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000725
ager@chromium.org8bb60582008-12-11 12:02:20 +0000726 // Create the new break info. If there is no JavaScript frames there is no
727 // break frame id.
728 if (has_js_frames_) {
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000729 Debug::NewBreak(it_.frame()->id());
ager@chromium.org8bb60582008-12-11 12:02:20 +0000730 } else {
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000731 Debug::NewBreak(StackFrame::NO_ID);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000732 }
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000733
734 // Make sure that debugger is loaded and enter the debugger context.
735 load_failed_ = !Debug::Load();
736 if (!load_failed_) {
737 // NOTE the member variable save which saves the previous context before
738 // this change.
739 Top::set_context(*Debug::debug_context());
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000740 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000741 }
742
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000743 ~EnterDebugger() {
ager@chromium.org8bb60582008-12-11 12:02:20 +0000744 // Restore to the previous break state.
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000745 Debug::SetBreak(break_frame_id_, break_id_);
746
sgjesse@chromium.org755c5b12009-05-29 11:04:38 +0000747 // Check for leaving the debugger.
ager@chromium.org71daaf62009-04-01 07:22:49 +0000748 if (prev_ == NULL) {
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000749 // Clear mirror cache when leaving the debugger. Skip this if there is a
750 // pending exception as clearing the mirror cache calls back into
751 // JavaScript. This can happen if the v8::Debug::Call is used in which
752 // case the exception should end up in the calling code.
753 if (!Top::has_pending_exception()) {
sgjesse@chromium.org755c5b12009-05-29 11:04:38 +0000754 // Try to avoid any pending debug break breaking in the clear mirror
755 // cache JavaScript code.
756 if (StackGuard::IsDebugBreak()) {
757 Debug::set_interrupts_pending(DEBUGBREAK);
758 StackGuard::Continue(DEBUGBREAK);
759 }
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000760 Debug::ClearMirrorCache();
761 }
sgjesse@chromium.org755c5b12009-05-29 11:04:38 +0000762
763 // Request preemption and debug break when leaving the last debugger entry
764 // if any of these where recorded while debugging.
765 if (Debug::is_interrupt_pending(PREEMPT)) {
766 // This re-scheduling of preemption is to avoid starvation in some
767 // debugging scenarios.
768 Debug::clear_interrupt_pending(PREEMPT);
769 StackGuard::Preempt();
770 }
771 if (Debug::is_interrupt_pending(DEBUGBREAK)) {
772 Debug::clear_interrupt_pending(DEBUGBREAK);
773 StackGuard::DebugBreak();
774 }
775
776 // If there are commands in the queue when leaving the debugger request
777 // that these commands are processed.
778 if (Debugger::HasCommands()) {
779 StackGuard::DebugCommand();
780 }
781
kasperl@chromium.org71affb52009-05-26 05:44:31 +0000782 // If leaving the debugger with the debugger no longer active unload it.
ager@chromium.org71daaf62009-04-01 07:22:49 +0000783 if (!Debugger::IsDebuggerActive()) {
784 Debugger::UnloadDebugger();
785 }
786 }
787
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000788 // Leaving this debugger entry.
789 Debug::set_debugger_entry(prev_);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000790 }
791
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000792 // Check whether the debugger could be entered.
793 inline bool FailedToEnter() { return load_failed_; }
794
ager@chromium.orga74f0da2008-12-03 16:05:52 +0000795 // Check whether there are any JavaScript frames on the stack.
ager@chromium.org8bb60582008-12-11 12:02:20 +0000796 inline bool HasJavaScriptFrames() { return has_js_frames_; }
ager@chromium.orga74f0da2008-12-03 16:05:52 +0000797
ager@chromium.org9085a012009-05-11 19:22:57 +0000798 // Get the active context from before entering the debugger.
799 inline Handle<Context> GetContext() { return save_.context(); }
800
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000801 private:
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000802 EnterDebugger* prev_; // Previous debugger entry if entered recursively.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000803 JavaScriptFrameIterator it_;
ager@chromium.org8bb60582008-12-11 12:02:20 +0000804 const bool has_js_frames_; // Were there any JavaScript frames?
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000805 StackFrame::Id break_frame_id_; // Previous break frame id.
806 int break_id_; // Previous break id.
kasperl@chromium.org41044eb2008-10-06 08:24:46 +0000807 bool load_failed_; // Did the debugger fail to load?
808 SaveContext save_; // Saves previous context.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000809};
810
811
kasper.lundbd3ec4e2008-07-09 11:06:54 +0000812// Stack allocated class for disabling break.
813class DisableBreak BASE_EMBEDDED {
814 public:
815 // Enter the debugger by storing the previous top context and setting the
816 // current top context to the debugger context.
817 explicit DisableBreak(bool disable_break) {
818 prev_disable_break_ = Debug::disable_break();
819 Debug::set_disable_break(disable_break);
820 }
821 ~DisableBreak() {
822 Debug::set_disable_break(prev_disable_break_);
823 }
824
825 private:
826 // The previous state of the disable break used to restore the value when this
827 // object is destructed.
828 bool prev_disable_break_;
829};
830
831
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000832// Debug_Address encapsulates the Address pointers used in generating debug
833// code.
834class Debug_Address {
835 public:
836 Debug_Address(Debug::AddressId id, int reg = 0)
837 : id_(id), reg_(reg) {
838 ASSERT(reg == 0 || id == Debug::k_register_address);
839 }
840
841 static Debug_Address AfterBreakTarget() {
842 return Debug_Address(Debug::k_after_break_target_address);
843 }
844
845 static Debug_Address DebugBreakReturn() {
846 return Debug_Address(Debug::k_debug_break_return_address);
847 }
848
849 static Debug_Address Register(int reg) {
850 return Debug_Address(Debug::k_register_address, reg);
851 }
852
853 Address address() const {
854 switch (id_) {
855 case Debug::k_after_break_target_address:
856 return reinterpret_cast<Address>(Debug::after_break_target_address());
857 case Debug::k_debug_break_return_address:
858 return reinterpret_cast<Address>(Debug::debug_break_return_address());
859 case Debug::k_register_address:
860 return reinterpret_cast<Address>(Debug::register_address(reg_));
861 default:
862 UNREACHABLE();
863 return NULL;
864 }
865 }
866 private:
867 Debug::AddressId id_;
868 int reg_;
869};
870
871
872} } // namespace v8::internal
873
ager@chromium.org65dad4b2009-04-23 08:48:43 +0000874#endif // ENABLE_DEBUGGER_SUPPORT
875
ager@chromium.org5ec48922009-05-05 07:25:34 +0000876#endif // V8_DEBUG_H_