| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 return heap->undefined_value(); | 1029 return heap->undefined_value(); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 | 1032 |
| 1033 // Check the break point objects for whether one or more are actually | 1033 // Check the break point objects for whether one or more are actually |
| 1034 // triggered. This function returns a JSArray with the break point objects | 1034 // triggered. This function returns a JSArray with the break point objects |
| 1035 // which is triggered. | 1035 // which is triggered. |
| 1036 Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) { | 1036 Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) { |
| 1037 // Count the number of break points hit. If there are multiple break points |
| 1038 // they are in a FixedArray. |
| 1039 Handle<FixedArray> break_points_hit; |
| 1037 int break_points_hit_count = 0; | 1040 int break_points_hit_count = 0; |
| 1038 Handle<JSArray> break_points_hit = FACTORY->NewJSArray(1); | |
| 1039 | |
| 1040 // If there are multiple break points they are in a FixedArray. | |
| 1041 ASSERT(!break_point_objects->IsUndefined()); | 1041 ASSERT(!break_point_objects->IsUndefined()); |
| 1042 if (break_point_objects->IsFixedArray()) { | 1042 if (break_point_objects->IsFixedArray()) { |
| 1043 Handle<FixedArray> array(FixedArray::cast(*break_point_objects)); | 1043 Handle<FixedArray> array(FixedArray::cast(*break_point_objects)); |
| 1044 break_points_hit = FACTORY->NewFixedArray(array->length()); |
| 1044 for (int i = 0; i < array->length(); i++) { | 1045 for (int i = 0; i < array->length(); i++) { |
| 1045 Handle<Object> o(array->get(i)); | 1046 Handle<Object> o(array->get(i)); |
| 1046 if (CheckBreakPoint(o)) { | 1047 if (CheckBreakPoint(o)) { |
| 1047 SetElement(break_points_hit, | 1048 break_points_hit->set(break_points_hit_count++, *o); |
| 1048 break_points_hit_count++, | |
| 1049 o, | |
| 1050 kNonStrictMode); | |
| 1051 } | 1049 } |
| 1052 } | 1050 } |
| 1053 } else { | 1051 } else { |
| 1052 break_points_hit = FACTORY->NewFixedArray(1); |
| 1054 if (CheckBreakPoint(break_point_objects)) { | 1053 if (CheckBreakPoint(break_point_objects)) { |
| 1055 SetElement(break_points_hit, | 1054 break_points_hit->set(break_points_hit_count++, *break_point_objects); |
| 1056 break_points_hit_count++, | |
| 1057 break_point_objects, | |
| 1058 kNonStrictMode); | |
| 1059 } | 1055 } |
| 1060 } | 1056 } |
| 1061 | 1057 |
| 1062 // Return undefined if no break points were triggered. | 1058 // Return undefined if no break points were triggered. |
| 1063 if (break_points_hit_count == 0) { | 1059 if (break_points_hit_count == 0) { |
| 1064 return FACTORY->undefined_value(); | 1060 return FACTORY->undefined_value(); |
| 1065 } | 1061 } |
| 1066 return break_points_hit; | 1062 // Return break points hit as a JSArray. |
| 1063 Handle<JSArray> result = FACTORY->NewJSArrayWithElements(break_points_hit); |
| 1064 result->set_length(Smi::FromInt(break_points_hit_count)); |
| 1065 return result; |
| 1067 } | 1066 } |
| 1068 | 1067 |
| 1069 | 1068 |
| 1070 // Check whether a single break point object is triggered. | 1069 // Check whether a single break point object is triggered. |
| 1071 bool Debug::CheckBreakPoint(Handle<Object> break_point_object) { | 1070 bool Debug::CheckBreakPoint(Handle<Object> break_point_object) { |
| 1072 HandleScope scope; | 1071 HandleScope scope; |
| 1073 | 1072 |
| 1074 // Ignore check if break point object is not a JSObject. | 1073 // Ignore check if break point object is not a JSObject. |
| 1075 if (!break_point_object->IsJSObject()) return true; | 1074 if (!break_point_object->IsJSObject()) return true; |
| 1076 | 1075 |
| 1077 // Get the function CheckBreakPoint (defined in debug.js). | 1076 // Get the function IsBreakPointTriggered (defined in debug-debugger.js). |
| 1078 Handle<String> is_break_point_triggered_symbol = | 1077 Handle<String> is_break_point_triggered_symbol = |
| 1079 FACTORY->LookupAsciiSymbol("IsBreakPointTriggered"); | 1078 FACTORY->LookupAsciiSymbol("IsBreakPointTriggered"); |
| 1080 Handle<JSFunction> check_break_point = | 1079 Handle<JSFunction> check_break_point = |
| 1081 Handle<JSFunction>(JSFunction::cast( | 1080 Handle<JSFunction>(JSFunction::cast( |
| 1082 debug_context()->global()->GetPropertyNoExceptionThrown( | 1081 debug_context()->global()->GetPropertyNoExceptionThrown( |
| 1083 *is_break_point_triggered_symbol))); | 1082 *is_break_point_triggered_symbol))); |
| 1084 | 1083 |
| 1085 // Get the break id as an object. | 1084 // Get the break id as an object. |
| 1086 Handle<Object> break_id = FACTORY->NewNumberFromInt(Debug::break_id()); | 1085 Handle<Object> break_id = FACTORY->NewNumberFromInt(Debug::break_id()); |
| 1087 | 1086 |
| (...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3166 { | 3165 { |
| 3167 Locker locker; | 3166 Locker locker; |
| 3168 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3167 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
| 3169 } | 3168 } |
| 3170 } | 3169 } |
| 3171 } | 3170 } |
| 3172 | 3171 |
| 3173 #endif // ENABLE_DEBUGGER_SUPPORT | 3172 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3174 | 3173 |
| 3175 } } // namespace v8::internal | 3174 } } // namespace v8::internal |
| OLD | NEW |