| OLD | NEW |
| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 const char* condition) { | 295 const char* condition) { |
| 296 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | 296 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; |
| 297 SNPrintF(buffer, | 297 SNPrintF(buffer, |
| 298 "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")", | 298 "debug.Debug.changeScriptBreakPointCondition(%d, \"%s\")", |
| 299 break_point_number, condition); | 299 break_point_number, condition); |
| 300 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 300 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
| 301 CompileRunChecked(isolate, buffer.start()); | 301 CompileRunChecked(isolate, buffer.start()); |
| 302 } | 302 } |
| 303 | 303 |
| 304 | 304 |
| 305 static void ChangeScriptBreakPointIgnoreCountFromJS(v8::Isolate* isolate, | |
| 306 int break_point_number, | |
| 307 int ignoreCount) { | |
| 308 EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> buffer; | |
| 309 SNPrintF(buffer, | |
| 310 "debug.Debug.changeScriptBreakPointIgnoreCount(%d, %d)", | |
| 311 break_point_number, ignoreCount); | |
| 312 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | |
| 313 CompileRunChecked(isolate, buffer.start()); | |
| 314 } | |
| 315 | |
| 316 | |
| 317 // Change break on exception. | 305 // Change break on exception. |
| 318 static void ChangeBreakOnException(bool caught, bool uncaught) { | 306 static void ChangeBreakOnException(bool caught, bool uncaught) { |
| 319 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 307 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); |
| 320 debug->ChangeBreakOnException(v8::internal::BreakException, caught); | 308 debug->ChangeBreakOnException(v8::internal::BreakException, caught); |
| 321 debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); | 309 debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); |
| 322 } | 310 } |
| 323 | 311 |
| 324 | 312 |
| 325 // Change break on exception using the global Debug object. | 313 // Change break on exception using the global Debug object. |
| 326 static void ChangeBreakOnExceptionFromJS(v8::Isolate* isolate, bool caught, | 314 static void ChangeBreakOnExceptionFromJS(v8::Isolate* isolate, bool caught, |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 for (int i = 0; i < 10; i++) { | 1698 for (int i = 0; i < 10; i++) { |
| 1711 f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); | 1699 f->Call(env.context(), env->Global(), 0, NULL).ToLocalChecked(); |
| 1712 } | 1700 } |
| 1713 CHECK_EQ(5, break_point_hit_count); | 1701 CHECK_EQ(5, break_point_hit_count); |
| 1714 | 1702 |
| 1715 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 1703 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
| 1716 CheckDebuggerUnloaded(env->GetIsolate()); | 1704 CheckDebuggerUnloaded(env->GetIsolate()); |
| 1717 } | 1705 } |
| 1718 | 1706 |
| 1719 | 1707 |
| 1720 // Test ignore count on script break points. | |
| 1721 TEST(ScriptBreakPointIgnoreCount) { | |
| 1722 break_point_hit_count = 0; | |
| 1723 DebugLocalContext env; | |
| 1724 v8::HandleScope scope(env->GetIsolate()); | |
| 1725 env.ExposeDebug(); | |
| 1726 | |
| 1727 v8::Debug::SetDebugEventListener(env->GetIsolate(), | |
| 1728 DebugEventBreakPointHitCount); | |
| 1729 | |
| 1730 v8::Local<v8::String> script = v8_str(env->GetIsolate(), | |
| 1731 "function f() {\n" | |
| 1732 " a = 0; // line 1\n" | |
| 1733 "};"); | |
| 1734 | |
| 1735 // Compile the script and get function f. | |
| 1736 v8::Local<v8::Context> context = env.context(); | |
| 1737 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str(env->GetIsolate(), "test")); | |
| 1738 v8::Script::Compile(context, script, &origin) | |
| 1739 .ToLocalChecked() | |
| 1740 ->Run(context) | |
| 1741 .ToLocalChecked(); | |
| 1742 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( | |
| 1743 env->Global() | |
| 1744 ->Get(context, v8_str(env->GetIsolate(), "f")) | |
| 1745 .ToLocalChecked()); | |
| 1746 | |
| 1747 // Set script break point on line 1 (in function f). | |
| 1748 int sbp = SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test", 1, 0); | |
| 1749 | |
| 1750 // Call f with different ignores on the script break point. | |
| 1751 break_point_hit_count = 0; | |
| 1752 ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 1); | |
| 1753 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | |
| 1754 CHECK_EQ(0, break_point_hit_count); | |
| 1755 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | |
| 1756 CHECK_EQ(1, break_point_hit_count); | |
| 1757 | |
| 1758 ChangeScriptBreakPointIgnoreCountFromJS(env->GetIsolate(), sbp, 5); | |
| 1759 break_point_hit_count = 0; | |
| 1760 for (int i = 0; i < 10; i++) { | |
| 1761 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | |
| 1762 } | |
| 1763 CHECK_EQ(5, break_point_hit_count); | |
| 1764 | |
| 1765 // Reload the script and get f again checking that the ignore survives. | |
| 1766 v8::Script::Compile(context, script, &origin) | |
| 1767 .ToLocalChecked() | |
| 1768 ->Run(context) | |
| 1769 .ToLocalChecked(); | |
| 1770 f = v8::Local<v8::Function>::Cast( | |
| 1771 env->Global() | |
| 1772 ->Get(context, v8_str(env->GetIsolate(), "f")) | |
| 1773 .ToLocalChecked()); | |
| 1774 | |
| 1775 break_point_hit_count = 0; | |
| 1776 for (int i = 0; i < 10; i++) { | |
| 1777 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | |
| 1778 } | |
| 1779 CHECK_EQ(5, break_point_hit_count); | |
| 1780 | |
| 1781 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | |
| 1782 CheckDebuggerUnloaded(env->GetIsolate()); | |
| 1783 } | |
| 1784 | |
| 1785 | |
| 1786 // Test that script break points survive when a script is reloaded. | 1708 // Test that script break points survive when a script is reloaded. |
| 1787 TEST(ScriptBreakPointReload) { | 1709 TEST(ScriptBreakPointReload) { |
| 1788 break_point_hit_count = 0; | 1710 break_point_hit_count = 0; |
| 1789 DebugLocalContext env; | 1711 DebugLocalContext env; |
| 1790 v8::HandleScope scope(env->GetIsolate()); | 1712 v8::HandleScope scope(env->GetIsolate()); |
| 1791 env.ExposeDebug(); | 1713 env.ExposeDebug(); |
| 1792 | 1714 |
| 1793 v8::Debug::SetDebugEventListener(env->GetIsolate(), | 1715 v8::Debug::SetDebugEventListener(env->GetIsolate(), |
| 1794 DebugEventBreakPointHitCount); | 1716 DebugEventBreakPointHitCount); |
| 1795 | 1717 |
| (...skipping 6253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8049 CompileRun("function foo() {}; foo();"); | 7971 CompileRun("function foo() {}; foo();"); |
| 8050 --after_compile_handler_depth; | 7972 --after_compile_handler_depth; |
| 8051 } | 7973 } |
| 8052 | 7974 |
| 8053 | 7975 |
| 8054 TEST(NoInterruptsInDebugListener) { | 7976 TEST(NoInterruptsInDebugListener) { |
| 8055 DebugLocalContext env; | 7977 DebugLocalContext env; |
| 8056 v8::Debug::SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent); | 7978 v8::Debug::SetDebugEventListener(env->GetIsolate(), NoInterruptsOnDebugEvent); |
| 8057 CompileRun("void(0);"); | 7979 CompileRun("void(0);"); |
| 8058 } | 7980 } |
| OLD | NEW |