Commit 32ee3c27 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Handle possible difference between function code and activated code on preparation for break points

The full code activated for a function might not be the same code as
is currently the active full code for a function. There where some
asumptions in the debugger preparation for break points.

Unfortunately there is currently no regression test.

R=jkummerow@chromium.org

BUG=
TEST=

Review URL: http://codereview.chromium.org//8818010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10176 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 81302d3b
...@@ -1796,8 +1796,9 @@ void Debug::PrepareForBreakPoints() { ...@@ -1796,8 +1796,9 @@ void Debug::PrepareForBreakPoints() {
} }
} else if (frame->function()->IsJSFunction()) { } else if (frame->function()->IsJSFunction()) {
JSFunction* function = JSFunction::cast(frame->function()); JSFunction* function = JSFunction::cast(frame->function());
if (function->code()->kind() == Code::FUNCTION && ASSERT(frame->LookupCode()->kind() == Code::FUNCTION);
!function->code()->has_debug_break_slots()) { if (!frame->LookupCode()->has_debug_break_slots() ||
!function->shared()->code()->has_debug_break_slots()) {
active_functions.Add(Handle<JSFunction>(function)); active_functions.Add(Handle<JSFunction>(function));
} }
} }
...@@ -1853,20 +1854,16 @@ void Debug::PrepareForBreakPoints() { ...@@ -1853,20 +1854,16 @@ void Debug::PrepareForBreakPoints() {
if (function->code() == *lazy_compile) { if (function->code() == *lazy_compile) {
function->set_code(shared->code()); function->set_code(shared->code());
} }
Handle<Code> current_code(function->code()); if (!shared->code()->has_debug_break_slots()) {
if (shared->code()->has_debug_break_slots()) {
// if the code is already recompiled to have break slots skip
// recompilation.
ASSERT(!function->code()->has_debug_break_slots());
} else {
// Try to compile the full code with debug break slots. If it // Try to compile the full code with debug break slots. If it
// fails just keep the current code. // fails just keep the current code.
ASSERT(shared->code() == *current_code); Handle<Code> current_code(function->shared()->code());
ZoneScope zone_scope(isolate_, DELETE_ON_EXIT); ZoneScope zone_scope(isolate_, DELETE_ON_EXIT);
shared->set_code(*lazy_compile); shared->set_code(*lazy_compile);
bool prev_force_debugger_active = bool prev_force_debugger_active =
isolate_->debugger()->force_debugger_active(); isolate_->debugger()->force_debugger_active();
isolate_->debugger()->set_force_debugger_active(true); isolate_->debugger()->set_force_debugger_active(true);
ASSERT(current_code->kind() == Code::FUNCTION);
CompileFullCodeForDebugging(shared, current_code); CompileFullCodeForDebugging(shared, current_code);
isolate_->debugger()->set_force_debugger_active( isolate_->debugger()->set_force_debugger_active(
prev_force_debugger_active); prev_force_debugger_active);
...@@ -1883,10 +1880,13 @@ void Debug::PrepareForBreakPoints() { ...@@ -1883,10 +1880,13 @@ void Debug::PrepareForBreakPoints() {
// If the current frame is for this function in its // If the current frame is for this function in its
// non-optimized form rewrite the return address to continue // non-optimized form rewrite the return address to continue
// in the newly compiled full code with debug break slots. // in the newly compiled full code with debug break slots.
if (frame->function()->IsJSFunction() && if (!frame->is_optimized() &&
frame->function() == *function && frame->function()->IsJSFunction() &&
frame->LookupCode()->kind() == Code::FUNCTION) { frame->function() == *function) {
intptr_t delta = frame->pc() - current_code->instruction_start(); ASSERT(frame->LookupCode()->kind() == Code::FUNCTION);
Handle<Code> frame_code(frame->LookupCode());
if (frame_code->has_debug_break_slots()) continue;
intptr_t delta = frame->pc() - frame_code->instruction_start();
int debug_break_slot_count = 0; int debug_break_slot_count = 0;
int mask = RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT); int mask = RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT);
for (RelocIterator it(*new_code, mask); !it.done(); it.next()) { for (RelocIterator it(*new_code, mask); !it.done(); it.next()) {
...@@ -1915,11 +1915,11 @@ void Debug::PrepareForBreakPoints() { ...@@ -1915,11 +1915,11 @@ void Debug::PrepareForBreakPoints() {
"for debugging, " "for debugging, "
"changing pc from %08" V8PRIxPTR " to %08" V8PRIxPTR "\n", "changing pc from %08" V8PRIxPTR " to %08" V8PRIxPTR "\n",
reinterpret_cast<intptr_t>( reinterpret_cast<intptr_t>(
current_code->instruction_start()), frame_code->instruction_start()),
reinterpret_cast<intptr_t>( reinterpret_cast<intptr_t>(
current_code->instruction_start()) + frame_code->instruction_start()) +
current_code->instruction_size(), frame_code->instruction_size(),
current_code->instruction_size(), frame_code->instruction_size(),
reinterpret_cast<intptr_t>(new_code->instruction_start()), reinterpret_cast<intptr_t>(new_code->instruction_start()),
reinterpret_cast<intptr_t>(new_code->instruction_start()) + reinterpret_cast<intptr_t>(new_code->instruction_start()) +
new_code->instruction_size(), new_code->instruction_size(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment