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

Side by Side Diff: test/cctest/test-debug.cc

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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 | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-declarative-accessors.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 using ::v8::internal::StepAction; 63 using ::v8::internal::StepAction;
64 using ::v8::internal::StepIn; // From StepAction enum 64 using ::v8::internal::StepIn; // From StepAction enum
65 using ::v8::internal::StepNext; // From StepAction enum 65 using ::v8::internal::StepNext; // From StepAction enum
66 using ::v8::internal::StepOut; // From StepAction enum 66 using ::v8::internal::StepOut; // From StepAction enum
67 using ::v8::internal::Vector; 67 using ::v8::internal::Vector;
68 using ::v8::internal::StrLength; 68 using ::v8::internal::StrLength;
69 69
70 // Size of temp buffer for formatting small strings. 70 // Size of temp buffer for formatting small strings.
71 #define SMALL_STRING_BUFFER_SIZE 80 71 #define SMALL_STRING_BUFFER_SIZE 80
72 72
73 // --- A d d i t i o n a l C h e c k H e l p e r s
74
75
76 // Helper function used by the CHECK_EQ function when given Address
77 // arguments. Should not be called directly.
78 static inline void CheckEqualsHelper(const char* file, int line,
79 const char* expected_source,
80 ::v8::internal::Address expected,
81 const char* value_source,
82 ::v8::internal::Address value) {
83 if (expected != value) {
84 V8_Fatal(file, line, "CHECK_EQ(%s, %s) failed\n# "
85 "Expected: %i\n# Found: %i",
86 expected_source, value_source, expected, value);
87 }
88 }
89
90
91 // Helper function used by the CHECK_NE function when given Address
92 // arguments. Should not be called directly.
93 static inline void CheckNonEqualsHelper(const char* file, int line,
94 const char* unexpected_source,
95 ::v8::internal::Address unexpected,
96 const char* value_source,
97 ::v8::internal::Address value) {
98 if (unexpected == value) {
99 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %i",
100 unexpected_source, value_source, value);
101 }
102 }
103
104
105 // Helper function used by the CHECK function when given code
106 // arguments. Should not be called directly.
107 static inline void CheckEqualsHelper(const char* file, int line,
108 const char* expected_source,
109 const Code* expected,
110 const char* value_source,
111 const Code* value) {
112 if (expected != value) {
113 V8_Fatal(file, line, "CHECK_EQ(%s, %s) failed\n# "
114 "Expected: %p\n# Found: %p",
115 expected_source, value_source, expected, value);
116 }
117 }
118
119
120 static inline void CheckNonEqualsHelper(const char* file, int line,
121 const char* expected_source,
122 const Code* expected,
123 const char* value_source,
124 const Code* value) {
125 if (expected == value) {
126 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %p",
127 expected_source, value_source, value);
128 }
129 }
130
131
132 // --- H e l p e r C l a s s e s 73 // --- H e l p e r C l a s s e s
133 74
134 75
135 // Helper class for creating a V8 enviromnent for running tests 76 // Helper class for creating a V8 enviromnent for running tests
136 class DebugLocalContext { 77 class DebugLocalContext {
137 public: 78 public:
138 inline DebugLocalContext( 79 inline DebugLocalContext(
139 v8::ExtensionConfiguration* extensions = 0, 80 v8::ExtensionConfiguration* extensions = 0,
140 v8::Handle<v8::ObjectTemplate> global_template = 81 v8::Handle<v8::ObjectTemplate> global_template =
141 v8::Handle<v8::ObjectTemplate>(), 82 v8::Handle<v8::ObjectTemplate>(),
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 " var len = a.length;\n" 2856 " var len = a.length;\n"
2916 " for (var i = 0; i < len; i++) {\n" 2857 " for (var i = 0; i < len; i++) {\n"
2917 " y = 1;\n" 2858 " y = 1;\n"
2918 " x = a[i];\n" 2859 " x = a[i];\n"
2919 " }\n" 2860 " }\n"
2920 "}\n" 2861 "}\n"
2921 "y=0\n", 2862 "y=0\n",
2922 "foo"); 2863 "foo");
2923 2864
2924 // Create array [0,1,2,3,4,5,6,7,8,9] 2865 // Create array [0,1,2,3,4,5,6,7,8,9]
2925 v8::Local<v8::Array> a = v8::Array::New(10); 2866 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
2926 for (int i = 0; i < 10; i++) { 2867 for (int i = 0; i < 10; i++) {
2927 a->Set(v8::Number::New(i), v8::Number::New(i)); 2868 a->Set(v8::Number::New(i), v8::Number::New(i));
2928 } 2869 }
2929 2870
2930 // Call function without any break points to ensure inlining is in place. 2871 // Call function without any break points to ensure inlining is in place.
2931 const int kArgc = 1; 2872 const int kArgc = 1;
2932 v8::Handle<v8::Value> args[kArgc] = { a }; 2873 v8::Handle<v8::Value> args[kArgc] = { a };
2933 foo->Call(env->Global(), kArgc, args); 2874 foo->Call(env->Global(), kArgc, args);
2934 2875
2935 // Set up break point and step through the function. 2876 // Set up break point and step through the function.
(...skipping 26 matching lines...) Expand all
2962 " var len = a.length;\n" 2903 " var len = a.length;\n"
2963 " for (var i = 0; i < len; i++) {\n" 2904 " for (var i = 0; i < len; i++) {\n"
2964 " y = 1;\n" 2905 " y = 1;\n"
2965 " a[i] = 42;\n" 2906 " a[i] = 42;\n"
2966 " }\n" 2907 " }\n"
2967 "}\n" 2908 "}\n"
2968 "y=0\n", 2909 "y=0\n",
2969 "foo"); 2910 "foo");
2970 2911
2971 // Create array [0,1,2,3,4,5,6,7,8,9] 2912 // Create array [0,1,2,3,4,5,6,7,8,9]
2972 v8::Local<v8::Array> a = v8::Array::New(10); 2913 v8::Local<v8::Array> a = v8::Array::New(env->GetIsolate(), 10);
2973 for (int i = 0; i < 10; i++) { 2914 for (int i = 0; i < 10; i++) {
2974 a->Set(v8::Number::New(i), v8::Number::New(i)); 2915 a->Set(v8::Number::New(i), v8::Number::New(i));
2975 } 2916 }
2976 2917
2977 // Call function without any break points to ensure inlining is in place. 2918 // Call function without any break points to ensure inlining is in place.
2978 const int kArgc = 1; 2919 const int kArgc = 1;
2979 v8::Handle<v8::Value> args[kArgc] = { a }; 2920 v8::Handle<v8::Value> args[kArgc] = { a };
2980 foo->Call(env->Global(), kArgc, args); 2921 foo->Call(env->Global(), kArgc, args);
2981 2922
2982 // Set up break point and step through the function. 2923 // Set up break point and step through the function.
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
3936 // of debug event exception callbacks and message callbacks are collected. The 3877 // of debug event exception callbacks and message callbacks are collected. The
3937 // number of debug event exception callbacks are used to check that the 3878 // number of debug event exception callbacks are used to check that the
3938 // debugger is called correctly and the number of message callbacks is used to 3879 // debugger is called correctly and the number of message callbacks is used to
3939 // check that uncaught exceptions are still returned even if there is a break 3880 // check that uncaught exceptions are still returned even if there is a break
3940 // for them. 3881 // for them.
3941 TEST(BreakOnException) { 3882 TEST(BreakOnException) {
3942 DebugLocalContext env; 3883 DebugLocalContext env;
3943 v8::HandleScope scope(env->GetIsolate()); 3884 v8::HandleScope scope(env->GetIsolate());
3944 env.ExposeDebug(); 3885 env.ExposeDebug();
3945 3886
3946 CcTest::i_isolate()->TraceException(false);
3947
3948 // Create functions for testing break on exception. 3887 // Create functions for testing break on exception.
3949 CompileFunction(&env, "function throws(){throw 1;}", "throws"); 3888 CompileFunction(&env, "function throws(){throw 1;}", "throws");
3950 v8::Local<v8::Function> caught = 3889 v8::Local<v8::Function> caught =
3951 CompileFunction(&env, 3890 CompileFunction(&env,
3952 "function caught(){try {throws();} catch(e) {};}", 3891 "function caught(){try {throws();} catch(e) {};}",
3953 "caught"); 3892 "caught");
3954 v8::Local<v8::Function> notCaught = 3893 v8::Local<v8::Function> notCaught =
3955 CompileFunction(&env, "function notCaught(){throws();}", "notCaught"); 3894 CompileFunction(&env, "function notCaught(){throws();}", "notCaught");
3956 3895
3957 v8::V8::AddMessageListener(MessageCallbackCount); 3896 v8::V8::AddMessageListener(MessageCallbackCount);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 // Test break on exception from compiler errors. When compiling using 4021 // Test break on exception from compiler errors. When compiling using
4083 // v8::Script::Compile there is no JavaScript stack whereas when compiling using 4022 // v8::Script::Compile there is no JavaScript stack whereas when compiling using
4084 // eval there are JavaScript frames. 4023 // eval there are JavaScript frames.
4085 TEST(BreakOnCompileException) { 4024 TEST(BreakOnCompileException) {
4086 DebugLocalContext env; 4025 DebugLocalContext env;
4087 v8::HandleScope scope(env->GetIsolate()); 4026 v8::HandleScope scope(env->GetIsolate());
4088 4027
4089 // For this test, we want to break on uncaught exceptions: 4028 // For this test, we want to break on uncaught exceptions:
4090 ChangeBreakOnException(false, true); 4029 ChangeBreakOnException(false, true);
4091 4030
4092 CcTest::i_isolate()->TraceException(false);
4093
4094 // Create a function for checking the function when hitting a break point. 4031 // Create a function for checking the function when hitting a break point.
4095 frame_count = CompileFunction(&env, frame_count_source, "frame_count"); 4032 frame_count = CompileFunction(&env, frame_count_source, "frame_count");
4096 4033
4097 v8::V8::AddMessageListener(MessageCallbackCount); 4034 v8::V8::AddMessageListener(MessageCallbackCount);
4098 v8::Debug::SetDebugEventListener2(DebugEventCounter); 4035 v8::Debug::SetDebugEventListener2(DebugEventCounter);
4099 4036
4100 DebugEventCounterClear(); 4037 DebugEventCounterClear();
4101 MessageCallbackCountClear(); 4038 MessageCallbackCountClear();
4102 4039
4103 // Check initial state. 4040 // Check initial state.
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
4349 // Check that no DebugBreak events occured during the context creation. 4286 // Check that no DebugBreak events occured during the context creation.
4350 CHECK_EQ(0, break_point_hit_count); 4287 CHECK_EQ(0, break_point_hit_count);
4351 4288
4352 // Get rid of the debug event listener. 4289 // Get rid of the debug event listener.
4353 v8::Debug::SetDebugEventListener2(NULL); 4290 v8::Debug::SetDebugEventListener2(NULL);
4354 CheckDebuggerUnloaded(); 4291 CheckDebuggerUnloaded();
4355 } 4292 }
4356 4293
4357 4294
4358 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4295 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4359 v8::Handle<v8::Array> result = v8::Array::New(3); 4296 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
4360 result->Set(v8::Integer::New(0), 4297 result->Set(v8::Integer::New(0),
4361 v8::String::NewFromUtf8(info.GetIsolate(), "a")); 4298 v8::String::NewFromUtf8(info.GetIsolate(), "a"));
4362 result->Set(v8::Integer::New(1), 4299 result->Set(v8::Integer::New(1),
4363 v8::String::NewFromUtf8(info.GetIsolate(), "b")); 4300 v8::String::NewFromUtf8(info.GetIsolate(), "b"));
4364 result->Set(v8::Integer::New(2), 4301 result->Set(v8::Integer::New(2),
4365 v8::String::NewFromUtf8(info.GetIsolate(), "c")); 4302 v8::String::NewFromUtf8(info.GetIsolate(), "c"));
4366 info.GetReturnValue().Set(result); 4303 info.GetReturnValue().Set(result);
4367 } 4304 }
4368 4305
4369 4306
4370 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4307 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4371 v8::Handle<v8::Array> result = v8::Array::New(2); 4308 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
4372 result->Set(v8::Integer::New(0), v8::Number::New(1)); 4309 result->Set(v8::Integer::New(0), v8::Number::New(1));
4373 result->Set(v8::Integer::New(1), v8::Number::New(10)); 4310 result->Set(v8::Integer::New(1), v8::Number::New(10));
4374 info.GetReturnValue().Set(result); 4311 info.GetReturnValue().Set(result);
4375 } 4312 }
4376 4313
4377 4314
4378 static void NamedGetter(v8::Local<v8::String> name, 4315 static void NamedGetter(v8::Local<v8::String> name,
4379 const v8::PropertyCallbackInfo<v8::Value>& info) { 4316 const v8::PropertyCallbackInfo<v8::Value>& info) {
4380 v8::String::Utf8Value n(name); 4317 v8::String::Utf8Value n(name);
4381 if (strcmp(*n, "a") == 0) { 4318 if (strcmp(*n, "a") == 0) {
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
6120 listening_(0) { 6057 listening_(0) {
6121 } 6058 }
6122 ~DebuggerAgentProtocolServerThread() { 6059 ~DebuggerAgentProtocolServerThread() {
6123 // Close both sockets. 6060 // Close both sockets.
6124 delete client_; 6061 delete client_;
6125 delete server_; 6062 delete server_;
6126 } 6063 }
6127 6064
6128 void Run(); 6065 void Run();
6129 void WaitForListening() { listening_.Wait(); } 6066 void WaitForListening() { listening_.Wait(); }
6130 char* body() { return *body_; } 6067 char* body() { return body_.get(); }
6131 6068
6132 private: 6069 private:
6133 int port_; 6070 int port_;
6134 i::SmartArrayPointer<char> body_; 6071 i::SmartArrayPointer<char> body_;
6135 i::Socket* server_; // Server socket used for bind/accept. 6072 i::Socket* server_; // Server socket used for bind/accept.
6136 i::Socket* client_; // Single client connection used by the test. 6073 i::Socket* client_; // Single client connection used by the test.
6137 i::Semaphore listening_; // Signalled when the server is in listen mode. 6074 i::Semaphore listening_; // Signalled when the server is in listen mode.
6138 }; 6075 };
6139 6076
6140 6077
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
6244 ::v8::internal::EmbeddedVector<uint16_t, 1> empty_; 6181 ::v8::internal::EmbeddedVector<uint16_t, 1> empty_;
6245 }; 6182 };
6246 6183
6247 6184
6248 TEST(DebugGetLoadedScripts) { 6185 TEST(DebugGetLoadedScripts) {
6249 DebugLocalContext env; 6186 DebugLocalContext env;
6250 v8::HandleScope scope(env->GetIsolate()); 6187 v8::HandleScope scope(env->GetIsolate());
6251 env.ExposeDebug(); 6188 env.ExposeDebug();
6252 6189
6253 EmptyExternalStringResource source_ext_str; 6190 EmptyExternalStringResource source_ext_str;
6254 v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str); 6191 v8::Local<v8::String> source =
6192 v8::String::NewExternal(env->GetIsolate(), &source_ext_str);
6255 v8::Handle<v8::Script> evil_script(v8::Script::Compile(source)); 6193 v8::Handle<v8::Script> evil_script(v8::Script::Compile(source));
6256 // "use" evil_script to make the compiler happy. 6194 // "use" evil_script to make the compiler happy.
6257 (void) evil_script; 6195 (void) evil_script;
6258 Handle<i::ExternalTwoByteString> i_source( 6196 Handle<i::ExternalTwoByteString> i_source(
6259 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); 6197 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)));
6260 // This situation can happen if source was an external string disposed 6198 // This situation can happen if source was an external string disposed
6261 // by its owner. 6199 // by its owner.
6262 i_source->set_resource(0); 6200 i_source->set_resource(0);
6263 6201
6264 bool allow_natives_syntax = i::FLAG_allow_natives_syntax; 6202 bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
7507 // Test that setting the terminate execution flag during debug break processing. 7445 // Test that setting the terminate execution flag during debug break processing.
7508 static void TestDebugBreakInLoop(const char* loop_head, 7446 static void TestDebugBreakInLoop(const char* loop_head,
7509 const char** loop_bodies, 7447 const char** loop_bodies,
7510 const char* loop_tail) { 7448 const char* loop_tail) {
7511 // Receive 100 breaks for each test and then terminate JavaScript execution. 7449 // Receive 100 breaks for each test and then terminate JavaScript execution.
7512 static const int kBreaksPerTest = 100; 7450 static const int kBreaksPerTest = 100;
7513 7451
7514 for (int i = 0; loop_bodies[i] != NULL; i++) { 7452 for (int i = 0; loop_bodies[i] != NULL; i++) {
7515 // Perform a lazy deoptimization after various numbers of breaks 7453 // Perform a lazy deoptimization after various numbers of breaks
7516 // have been hit. 7454 // have been hit.
7517 for (int j = 0; j < 11; j++) { 7455 for (int j = 0; j < 7; j++) {
7518 break_point_hit_count_deoptimize = j; 7456 break_point_hit_count_deoptimize = j;
7519 if (j == 10) { 7457 if (j == 6) {
7520 break_point_hit_count_deoptimize = kBreaksPerTest; 7458 break_point_hit_count_deoptimize = kBreaksPerTest;
7521 } 7459 }
7522 7460
7523 break_point_hit_count = 0; 7461 break_point_hit_count = 0;
7524 max_break_point_hit_count = kBreaksPerTest; 7462 max_break_point_hit_count = kBreaksPerTest;
7525 terminate_after_max_break_point_hit = true; 7463 terminate_after_max_break_point_hit = true;
7526 7464
7527 EmbeddedVector<char, 1024> buffer; 7465 EmbeddedVector<char, 1024> buffer;
7528 OS::SNPrintF(buffer, 7466 OS::SNPrintF(buffer,
7529 "function f() {%s%s%s}", 7467 "function f() {%s%s%s}",
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
7724 v8::HandleScope scope(env->GetIsolate()); 7662 v8::HandleScope scope(env->GetIsolate());
7725 v8::Debug::SetLiveEditEnabled(true, env->GetIsolate()); 7663 v8::Debug::SetLiveEditEnabled(true, env->GetIsolate());
7726 CompileRun("%LiveEditCompareStrings('', '')"); 7664 CompileRun("%LiveEditCompareStrings('', '')");
7727 } 7665 }
7728 7666
7729 7667
7730 TEST(LiveEditDisabled) { 7668 TEST(LiveEditDisabled) {
7731 v8::internal::FLAG_allow_natives_syntax = true; 7669 v8::internal::FLAG_allow_natives_syntax = true;
7732 LocalContext env; 7670 LocalContext env;
7733 v8::HandleScope scope(env->GetIsolate()); 7671 v8::HandleScope scope(env->GetIsolate());
7734 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); 7672 v8::Debug::SetLiveEditEnabled(false, env->GetIsolate());
7735 CompileRun("%LiveEditCompareStrings('', '')"); 7673 CompileRun("%LiveEditCompareStrings('', '')");
7736 } 7674 }
7737 7675
7738 7676
7739 #endif // ENABLE_DEBUGGER_SUPPORT 7677 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | test/cctest/test-declarative-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698