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

Side by Side Diff: src/runtime.cc

Issue 16093040: Debug: support breakpoints set in the middle of statement (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: follow code review 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 12079 matching lines...) Expand 10 before | Expand all | Expand 10 after
12090 // args[0]: disable break state 12090 // args[0]: disable break state
12091 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { 12091 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) {
12092 HandleScope scope(isolate); 12092 HandleScope scope(isolate);
12093 ASSERT(args.length() == 1); 12093 ASSERT(args.length() == 1);
12094 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); 12094 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0);
12095 isolate->debug()->set_disable_break(disable_break); 12095 isolate->debug()->set_disable_break(disable_break);
12096 return isolate->heap()->undefined_value(); 12096 return isolate->heap()->undefined_value();
12097 } 12097 }
12098 12098
12099 12099
12100 static bool IsPositionAlignmentValueCorrect(BreakPositionAlignment alignment) {
12101 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED;
12102 }
12103
12104
12100 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { 12105 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) {
12101 HandleScope scope(isolate); 12106 HandleScope scope(isolate);
12102 ASSERT(args.length() == 1); 12107 ASSERT(args.length() == 2);
12103 12108
12104 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 12109 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
12110 CONVERT_NUMBER_CHECKED(int32_t, statement_alighned_code, Int32, args[1]);
12111
12112 BreakPositionAlignment alignment =
12113 static_cast<BreakPositionAlignment>(statement_alighned_code);
12114 if (!IsPositionAlignmentValueCorrect(alignment)) {
12115 return isolate->ThrowIllegalOperation();
12116 }
12117
12105 Handle<SharedFunctionInfo> shared(fun->shared()); 12118 Handle<SharedFunctionInfo> shared(fun->shared());
12106 // Find the number of break points 12119 // Find the number of break points
12107 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); 12120 Handle<Object> break_locations =
12121 Debug::GetSourceBreakLocations(shared, alignment);
12108 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); 12122 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value();
12109 // Return array as JS array 12123 // Return array as JS array
12110 return *isolate->factory()->NewJSArrayWithElements( 12124 return *isolate->factory()->NewJSArrayWithElements(
12111 Handle<FixedArray>::cast(break_locations)); 12125 Handle<FixedArray>::cast(break_locations));
12112 } 12126 }
12113 12127
12114 12128
12115 // Set a break point in a function. 12129 // Set a break point in a function.
12116 // args[0]: function 12130 // args[0]: function
12117 // args[1]: number: break source position (within the function source) 12131 // args[1]: number: break source position (within the function source)
(...skipping 12 matching lines...) Expand all
12130 12144
12131 return Smi::FromInt(source_position); 12145 return Smi::FromInt(source_position);
12132 } 12146 }
12133 12147
12134 12148
12135 // Changes the state of a break point in a script and returns source position 12149 // Changes the state of a break point in a script and returns source position
12136 // where break point was set. NOTE: Regarding performance see the NOTE for 12150 // where break point was set. NOTE: Regarding performance see the NOTE for
12137 // GetScriptFromScriptData. 12151 // GetScriptFromScriptData.
12138 // args[0]: script to set break point in 12152 // args[0]: script to set break point in
12139 // args[1]: number: break source position (within the script source) 12153 // args[1]: number: break source position (within the script source)
12140 // args[2]: number: break point object 12154 // args[2]: number, breakpoint position alignment
12155 // args[3]: number: break point object
12141 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { 12156 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) {
12142 HandleScope scope(isolate); 12157 HandleScope scope(isolate);
12143 ASSERT(args.length() == 3); 12158 ASSERT(args.length() == 4);
12144 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); 12159 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
12145 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 12160 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
12146 RUNTIME_ASSERT(source_position >= 0); 12161 RUNTIME_ASSERT(source_position >= 0);
12147 Handle<Object> break_point_object_arg = args.at<Object>(2); 12162 CONVERT_NUMBER_CHECKED(int32_t, statement_alighned_code, Int32, args[2]);
12163 Handle<Object> break_point_object_arg = args.at<Object>(3);
12164
12165 BreakPositionAlignment alignment =
12166 static_cast<BreakPositionAlignment>(statement_alighned_code);
12167 if (!IsPositionAlignmentValueCorrect(alignment)) {
12168 return isolate->ThrowIllegalOperation();
12169 }
12148 12170
12149 // Get the script from the script wrapper. 12171 // Get the script from the script wrapper.
12150 RUNTIME_ASSERT(wrapper->value()->IsScript()); 12172 RUNTIME_ASSERT(wrapper->value()->IsScript());
12151 Handle<Script> script(Script::cast(wrapper->value())); 12173 Handle<Script> script(Script::cast(wrapper->value()));
12152 12174
12153 // Set break point. 12175 // Set break point.
12154 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, 12176 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
12155 &source_position)) { 12177 &source_position,
12178 alignment)) {
12156 return isolate->heap()->undefined_value(); 12179 return isolate->heap()->undefined_value();
12157 } 12180 }
12158 12181
12159 return Smi::FromInt(source_position); 12182 return Smi::FromInt(source_position);
12160 } 12183 }
12161 12184
12162 12185
12163 // Clear a break point 12186 // Clear a break point
12164 // args[0]: number: break point object 12187 // args[0]: number: break point object
12165 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { 12188 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) {
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after
13919 // Handle last resort GC and make sure to allow future allocations 13942 // Handle last resort GC and make sure to allow future allocations
13920 // to grow the heap without causing GCs (if possible). 13943 // to grow the heap without causing GCs (if possible).
13921 isolate->counters()->gc_last_resort_from_js()->Increment(); 13944 isolate->counters()->gc_last_resort_from_js()->Increment();
13922 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13945 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13923 "Runtime::PerformGC"); 13946 "Runtime::PerformGC");
13924 } 13947 }
13925 } 13948 }
13926 13949
13927 13950
13928 } } // namespace v8::internal 13951 } } // 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