Skip to content

Commit 5cf758b

Browse files
author
yangguo@chromium.org
committedSep 13, 2011
Debugger: fix stepping next with trycatch recursion
Added depth check to StepNextContinue. Do step out and queue actual StepNext if check failed. R=yangguo@chromium.org,danno@chromium.org,vegorov@chromium.org BUG=v8:1639 TEST= Review URL: http://codereview.chromium.org/7780033 Patch from Fedor Indutny <fedor@indutny.com>. git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@9264 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
1 parent 5faeddb commit 5cf758b

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed
 

‎AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Daniel Andersson <kodandersson@gmail.com>
2121
Daniel James <dnljms@gmail.com>
2222
Dineel D Sule <dsule@codeaurora.org>
2323
Erich Ocean <erich.ocean@me.com>
24+
Fedor Indutny <fedor@indutny.com>
2425
Jan de Mooij <jandemooij@gmail.com>
2526
Jay Freeman <saurik@saurik.com>
2627
Joel Stanley <joel.stan@gmail.com>

‎src/debug.cc

+45-2
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ void Debug::ThreadInit() {
543543
thread_local_.last_statement_position_ = RelocInfo::kNoPosition;
544544
thread_local_.step_count_ = 0;
545545
thread_local_.last_fp_ = 0;
546+
thread_local_.queued_step_count_ = 0;
546547
thread_local_.step_into_fp_ = 0;
547548
thread_local_.step_out_fp_ = 0;
548549
thread_local_.after_break_target_ = 0;
@@ -958,14 +959,49 @@ Object* Debug::Break(Arguments args) {
958959
// Clear all current stepping setup.
959960
ClearStepping();
960961

961-
// Notify the debug event listeners.
962-
isolate_->debugger()->OnDebugBreak(break_points_hit, false);
962+
if (thread_local_.queued_step_count_ > 0) {
963+
// Perform queued steps
964+
int step_count = thread_local_.queued_step_count_;
965+
966+
// Clear queue
967+
thread_local_.queued_step_count_ = 0;
968+
969+
PrepareStep(StepNext, step_count);
970+
} else {
971+
// Notify the debug event listeners.
972+
isolate_->debugger()->OnDebugBreak(break_points_hit, false);
973+
}
963974
} else if (thread_local_.last_step_action_ != StepNone) {
964975
// Hold on to last step action as it is cleared by the call to
965976
// ClearStepping.
966977
StepAction step_action = thread_local_.last_step_action_;
967978
int step_count = thread_local_.step_count_;
968979

980+
// If StepNext goes deeper in code, StepOut until original frame
981+
// and keep step count queued up in the meantime.
982+
if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) {
983+
// Count frames until target frame
984+
int count = 0;
985+
JavaScriptFrameIterator it(isolate_);
986+
while (!it.done() && it.frame()->fp() != thread_local_.last_fp_) {
987+
count++;
988+
it.Advance();
989+
}
990+
991+
// If we found original frame
992+
if (it.frame()->fp() == thread_local_.last_fp_) {
993+
if (step_count > 1) {
994+
// Save old count and action to continue stepping after
995+
// StepOut
996+
thread_local_.queued_step_count_ = step_count - 1;
997+
}
998+
999+
// Set up for StepOut to reach target frame
1000+
step_action = StepOut;
1001+
step_count = count;
1002+
}
1003+
}
1004+
9691005
// Clear all current stepping setup.
9701006
ClearStepping();
9711007

@@ -1455,6 +1491,13 @@ void Debug::PrepareStep(StepAction step_action, int step_count) {
14551491
// steps before reporting break back to the debugger.
14561492
bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator,
14571493
JavaScriptFrame* frame) {
1494+
// StepNext and StepOut shouldn't bring us deeper in code, so last frame
1495+
// shouldn't be a parent of current frame.
1496+
if (thread_local_.last_step_action_ == StepNext ||
1497+
thread_local_.last_step_action_ == StepOut) {
1498+
if (frame->fp() < thread_local_.last_fp_) return true;
1499+
}
1500+
14581501
// If the step last action was step next or step in make sure that a new
14591502
// statement is hit.
14601503
if (thread_local_.last_step_action_ == StepNext ||

‎src/debug.h

+3
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ class Debug {
508508
// Frame pointer from last step next action.
509509
Address last_fp_;
510510

511+
// Number of queued steps left to perform before debug event.
512+
int queued_step_count_;
513+
511514
// Frame pointer for frame from which step in was performed.
512515
Address step_into_fp_;
513516

0 commit comments

Comments
 (0)
Please sign in to comment.