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

Side by Side Diff: src/runtime.cc

Issue 18349004: Debug: support breakpoints set in the middle of statement (try #2 after rollback) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 12085 matching lines...) Expand 10 before | Expand all | Expand 10 after
12096 // args[0]: disable break state 12096 // args[0]: disable break state
12097 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { 12097 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) {
12098 HandleScope scope(isolate); 12098 HandleScope scope(isolate);
12099 ASSERT(args.length() == 1); 12099 ASSERT(args.length() == 1);
12100 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); 12100 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0);
12101 isolate->debug()->set_disable_break(disable_break); 12101 isolate->debug()->set_disable_break(disable_break);
12102 return isolate->heap()->undefined_value(); 12102 return isolate->heap()->undefined_value();
12103 } 12103 }
12104 12104
12105 12105
12106 static bool IsPositionAlignmentCodeCorrect(int alignment) {
12107 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED;
12108 }
12109
12110
12106 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { 12111 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) {
12107 HandleScope scope(isolate); 12112 HandleScope scope(isolate);
12108 ASSERT(args.length() == 1); 12113 ASSERT(args.length() == 2);
12109 12114
12110 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 12115 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
12116 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]);
12117
12118 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
12119 return isolate->ThrowIllegalOperation();
12120 }
12121 BreakPositionAlignment alignment =
12122 static_cast<BreakPositionAlignment>(statement_aligned_code);
12123
12111 Handle<SharedFunctionInfo> shared(fun->shared()); 12124 Handle<SharedFunctionInfo> shared(fun->shared());
12112 // Find the number of break points 12125 // Find the number of break points
12113 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); 12126 Handle<Object> break_locations =
12127 Debug::GetSourceBreakLocations(shared, alignment);
12114 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); 12128 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value();
12115 // Return array as JS array 12129 // Return array as JS array
12116 return *isolate->factory()->NewJSArrayWithElements( 12130 return *isolate->factory()->NewJSArrayWithElements(
12117 Handle<FixedArray>::cast(break_locations)); 12131 Handle<FixedArray>::cast(break_locations));
12118 } 12132 }
12119 12133
12120 12134
12121 // Set a break point in a function. 12135 // Set a break point in a function.
12122 // args[0]: function 12136 // args[0]: function
12123 // args[1]: number: break source position (within the function source) 12137 // args[1]: number: break source position (within the function source)
(...skipping 12 matching lines...) Expand all
12136 12150
12137 return Smi::FromInt(source_position); 12151 return Smi::FromInt(source_position);
12138 } 12152 }
12139 12153
12140 12154
12141 // Changes the state of a break point in a script and returns source position 12155 // Changes the state of a break point in a script and returns source position
12142 // where break point was set. NOTE: Regarding performance see the NOTE for 12156 // where break point was set. NOTE: Regarding performance see the NOTE for
12143 // GetScriptFromScriptData. 12157 // GetScriptFromScriptData.
12144 // args[0]: script to set break point in 12158 // args[0]: script to set break point in
12145 // args[1]: number: break source position (within the script source) 12159 // args[1]: number: break source position (within the script source)
12146 // args[2]: number: break point object 12160 // args[2]: number, breakpoint position alignment
12161 // args[3]: number: break point object
12147 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { 12162 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) {
12148 HandleScope scope(isolate); 12163 HandleScope scope(isolate);
12149 ASSERT(args.length() == 3); 12164 ASSERT(args.length() == 4);
12150 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); 12165 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
12151 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 12166 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
12152 RUNTIME_ASSERT(source_position >= 0); 12167 RUNTIME_ASSERT(source_position >= 0);
12153 Handle<Object> break_point_object_arg = args.at<Object>(2); 12168 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]);
12169 Handle<Object> break_point_object_arg = args.at<Object>(3);
12170
12171 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
12172 return isolate->ThrowIllegalOperation();
12173 }
12174 BreakPositionAlignment alignment =
12175 static_cast<BreakPositionAlignment>(statement_aligned_code);
12154 12176
12155 // Get the script from the script wrapper. 12177 // Get the script from the script wrapper.
12156 RUNTIME_ASSERT(wrapper->value()->IsScript()); 12178 RUNTIME_ASSERT(wrapper->value()->IsScript());
12157 Handle<Script> script(Script::cast(wrapper->value())); 12179 Handle<Script> script(Script::cast(wrapper->value()));
12158 12180
12159 // Set break point. 12181 // Set break point.
12160 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, 12182 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
12161 &source_position)) { 12183 &source_position,
12184 alignment)) {
12162 return isolate->heap()->undefined_value(); 12185 return isolate->heap()->undefined_value();
12163 } 12186 }
12164 12187
12165 return Smi::FromInt(source_position); 12188 return Smi::FromInt(source_position);
12166 } 12189 }
12167 12190
12168 12191
12169 // Clear a break point 12192 // Clear a break point
12170 // args[0]: number: break point object 12193 // args[0]: number: break point object
12171 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { 12194 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) {
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after
13925 // Handle last resort GC and make sure to allow future allocations 13948 // Handle last resort GC and make sure to allow future allocations
13926 // to grow the heap without causing GCs (if possible). 13949 // to grow the heap without causing GCs (if possible).
13927 isolate->counters()->gc_last_resort_from_js()->Increment(); 13950 isolate->counters()->gc_last_resort_from_js()->Increment();
13928 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13951 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13929 "Runtime::PerformGC"); 13952 "Runtime::PerformGC");
13930 } 13953 }
13931 } 13954 }
13932 13955
13933 13956
13934 } } // namespace v8::internal 13957 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698