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

Side by Side Diff: util/mach/exc_server_variants_test.cc

Issue 567283002: Add exc_client_variants (UniversalRaiseException()) and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Rename to stay closer to the names traditionally used by Mach Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 26 matching lines...) Expand all
37 const mach_port_t kClientRemotePort = 0x01010101; 37 const mach_port_t kClientRemotePort = 0x01010101;
38 const mach_port_t kServerLocalPort = 0x02020202; 38 const mach_port_t kServerLocalPort = 0x02020202;
39 const mach_port_t kExceptionThreadPort = 0x03030303; 39 const mach_port_t kExceptionThreadPort = 0x03030303;
40 const mach_port_t kExceptionTaskPort = 0x04040404; 40 const mach_port_t kExceptionTaskPort = 0x04040404;
41 41
42 // Other fake exception values. 42 // Other fake exception values.
43 const exception_type_t kExceptionType = EXC_BAD_ACCESS; 43 const exception_type_t kExceptionType = EXC_BAD_ACCESS;
44 44
45 // Test using an exception code with the high bit set to ensure that it gets 45 // Test using an exception code with the high bit set to ensure that it gets
46 // promoted to the wider mach_exception_data_type_t type as a signed quantity. 46 // promoted to the wider mach_exception_data_type_t type as a signed quantity.
47 const exception_data_type_t kExceptionCodes[] = { 47 const exception_data_type_t kTestExceptonCodes[] = {
48 KERN_PROTECTION_FAILURE, 48 KERN_PROTECTION_FAILURE,
49 static_cast<exception_data_type_t>(0xfedcba98), 49 static_cast<exception_data_type_t>(0xfedcba98),
50 }; 50 };
51 51
52 const exception_data_type_t kMachExceptionCodes[] = { 52 const exception_data_type_t kTestMachExceptionCodes[] = {
53 KERN_PROTECTION_FAILURE, 53 KERN_PROTECTION_FAILURE,
54 static_cast<exception_data_type_t>(0xfedcba9876543210), 54 static_cast<exception_data_type_t>(0xfedcba9876543210),
55 }; 55 };
56 56
57 const thread_state_flavor_t kThreadStateFlavor = MACHINE_THREAD_STATE; 57 const thread_state_flavor_t kThreadStateFlavor = MACHINE_THREAD_STATE;
58 const mach_msg_type_number_t kThreadStateFlavorCount = 58 const mach_msg_type_number_t kThreadStateFlavorCount =
59 MACHINE_THREAD_STATE_COUNT; 59 MACHINE_THREAD_STATE_COUNT;
60 60
61 void InitializeMachMsgPortDescriptor(mach_msg_port_descriptor_t* descriptor, 61 void InitializeMachMsgPortDescriptor(mach_msg_port_descriptor_t* descriptor,
62 mach_port_t port) { 62 mach_port_t port) {
(...skipping 27 matching lines...) Expand all
90 Head.msgh_size = sizeof(*this); 90 Head.msgh_size = sizeof(*this);
91 Head.msgh_remote_port = kClientRemotePort; 91 Head.msgh_remote_port = kClientRemotePort;
92 Head.msgh_local_port = kServerLocalPort; 92 Head.msgh_local_port = kServerLocalPort;
93 Head.msgh_id = 2401; 93 Head.msgh_id = 2401;
94 msgh_body.msgh_descriptor_count = 2; 94 msgh_body.msgh_descriptor_count = 2;
95 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort); 95 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort);
96 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort); 96 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort);
97 NDR = NDR_record; 97 NDR = NDR_record;
98 exception = kExceptionType; 98 exception = kExceptionType;
99 codeCnt = 2; 99 codeCnt = 2;
100 code[0] = kExceptionCodes[0]; 100 code[0] = kTestExceptonCodes[0];
101 code[1] = kExceptionCodes[1]; 101 code[1] = kTestExceptonCodes[1];
102 } 102 }
103 }; 103 };
104 104
105 struct __attribute__((packed, aligned(4))) ExceptionRaiseReply { 105 struct __attribute__((packed, aligned(4))) ExceptionRaiseReply {
106 mach_msg_header_t Head; 106 mach_msg_header_t Head;
107 NDR_record_t NDR; 107 NDR_record_t NDR;
108 kern_return_t RetCode; 108 kern_return_t RetCode;
109 109
110 void InitializeForTesting() { 110 void InitializeForTesting() {
111 memset(this, 0x5a, sizeof(*this)); 111 memset(this, 0x5a, sizeof(*this));
112 RetCode = KERN_FAILURE; 112 RetCode = KERN_FAILURE;
113 } 113 }
114 114
115 // Verify accepts a |behavior| parameter because the same message format and 115 // Verify accepts a |behavior| parameter because the same message format and
116 // verification function is used for ExceptionRaiseReply and 116 // verification function is used for ExceptionRaiseReply and
117 // MachExceptionRaiseReply. Knowing which behavior is expected allows the 117 // MachExceptionRaiseReply. Knowing which behavior is expected allows the
118 // message ID to be checked. 118 // message ID to be checked.
119 void Verify(exception_behavior_t behavior) { 119 void Verify(exception_behavior_t behavior) {
120 EXPECT_EQ(static_cast<mach_msg_bits_t>( 120 EXPECT_EQ(static_cast<mach_msg_bits_t>(
121 MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0)), 121 MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0)),
122 Head.msgh_bits); 122 Head.msgh_bits);
123 EXPECT_EQ(sizeof(*this), Head.msgh_size); 123 EXPECT_EQ(sizeof(*this), Head.msgh_size);
124 EXPECT_EQ(kClientRemotePort, Head.msgh_remote_port); 124 EXPECT_EQ(kClientRemotePort, Head.msgh_remote_port);
125 EXPECT_EQ(kMachPortNull, Head.msgh_local_port); 125 EXPECT_EQ(kMachPortNull, Head.msgh_local_port);
126 switch (behavior) { 126 switch (behavior) {
127 case EXCEPTION_DEFAULT: 127 case EXCEPTION_DEFAULT:
128 EXPECT_EQ(2501, Head.msgh_id); 128 EXPECT_EQ(2501, Head.msgh_id);
129 break; 129 break;
130 case static_cast<exception_behavior_t>(EXCEPTION_DEFAULT | 130 case EXCEPTION_DEFAULT | kMachExceptionCodes:
131 MACH_EXCEPTION_CODES):
132 EXPECT_EQ(2505, Head.msgh_id); 131 EXPECT_EQ(2505, Head.msgh_id);
133 break; 132 break;
134 default: 133 default:
135 ADD_FAILURE() << "behavior " << behavior << ", Head.msgh_id " 134 ADD_FAILURE() << "behavior " << behavior << ", Head.msgh_id "
136 << Head.msgh_id; 135 << Head.msgh_id;
137 break; 136 break;
138 } 137 }
139 EXPECT_EQ(0, memcmp(&NDR, &NDR_record, sizeof(NDR))); 138 EXPECT_EQ(0, memcmp(&NDR, &NDR_record, sizeof(NDR)));
140 EXPECT_EQ(KERN_SUCCESS, RetCode); 139 EXPECT_EQ(KERN_SUCCESS, RetCode);
141 } 140 }
(...skipping 13 matching lines...) Expand all
155 memset(this, 0xa5, sizeof(*this)); 154 memset(this, 0xa5, sizeof(*this));
156 Head.msgh_bits = 155 Head.msgh_bits =
157 MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE); 156 MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE);
158 Head.msgh_size = sizeof(*this); 157 Head.msgh_size = sizeof(*this);
159 Head.msgh_remote_port = kClientRemotePort; 158 Head.msgh_remote_port = kClientRemotePort;
160 Head.msgh_local_port = kServerLocalPort; 159 Head.msgh_local_port = kServerLocalPort;
161 Head.msgh_id = 2402; 160 Head.msgh_id = 2402;
162 NDR = NDR_record; 161 NDR = NDR_record;
163 exception = kExceptionType; 162 exception = kExceptionType;
164 codeCnt = 2; 163 codeCnt = 2;
165 code[0] = kExceptionCodes[0]; 164 code[0] = kTestExceptonCodes[0];
166 code[1] = kExceptionCodes[1]; 165 code[1] = kTestExceptonCodes[1];
167 flavor = kThreadStateFlavor; 166 flavor = kThreadStateFlavor;
168 old_stateCnt = kThreadStateFlavorCount; 167 old_stateCnt = kThreadStateFlavorCount;
169 168
170 // Adjust the message size for the data that it’s actually carrying, which 169 // Adjust the message size for the data that it’s actually carrying, which
171 // may be smaller than the maximum that it can carry. 170 // may be smaller than the maximum that it can carry.
172 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state); 171 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state);
173 } 172 }
174 }; 173 };
175 174
176 struct __attribute__((packed, aligned(4))) ExceptionRaiseStateReply { 175 struct __attribute__((packed, aligned(4))) ExceptionRaiseStateReply {
(...skipping 21 matching lines...) Expand all
198 EXPECT_EQ(sizeof(*this), Head.msgh_size); 197 EXPECT_EQ(sizeof(*this), Head.msgh_size);
199 EXPECT_EQ(kClientRemotePort, Head.msgh_remote_port); 198 EXPECT_EQ(kClientRemotePort, Head.msgh_remote_port);
200 EXPECT_EQ(kMachPortNull, Head.msgh_local_port); 199 EXPECT_EQ(kMachPortNull, Head.msgh_local_port);
201 switch (behavior) { 200 switch (behavior) {
202 case EXCEPTION_STATE: 201 case EXCEPTION_STATE:
203 EXPECT_EQ(2502, Head.msgh_id); 202 EXPECT_EQ(2502, Head.msgh_id);
204 break; 203 break;
205 case EXCEPTION_STATE_IDENTITY: 204 case EXCEPTION_STATE_IDENTITY:
206 EXPECT_EQ(2503, Head.msgh_id); 205 EXPECT_EQ(2503, Head.msgh_id);
207 break; 206 break;
208 case static_cast<exception_behavior_t>(EXCEPTION_STATE | 207 case EXCEPTION_STATE | kMachExceptionCodes:
209 MACH_EXCEPTION_CODES):
210 EXPECT_EQ(2506, Head.msgh_id); 208 EXPECT_EQ(2506, Head.msgh_id);
211 break; 209 break;
212 case static_cast<exception_behavior_t>(EXCEPTION_STATE_IDENTITY | 210 case EXCEPTION_STATE_IDENTITY | kMachExceptionCodes:
213 MACH_EXCEPTION_CODES):
214 EXPECT_EQ(2507, Head.msgh_id); 211 EXPECT_EQ(2507, Head.msgh_id);
215 break; 212 break;
216 default: 213 default:
217 ADD_FAILURE() << "behavior " << behavior << ", Head.msgh_id " 214 ADD_FAILURE() << "behavior " << behavior << ", Head.msgh_id "
218 << Head.msgh_id; 215 << Head.msgh_id;
219 break; 216 break;
220 } 217 }
221 EXPECT_EQ(0, memcmp(&NDR, &NDR_record, sizeof(NDR))); 218 EXPECT_EQ(0, memcmp(&NDR, &NDR_record, sizeof(NDR)));
222 EXPECT_EQ(KERN_SUCCESS, RetCode); 219 EXPECT_EQ(KERN_SUCCESS, RetCode);
223 EXPECT_EQ(kThreadStateFlavor, flavor); 220 EXPECT_EQ(kThreadStateFlavor, flavor);
(...skipping 22 matching lines...) Expand all
246 Head.msgh_size = sizeof(*this); 243 Head.msgh_size = sizeof(*this);
247 Head.msgh_remote_port = kClientRemotePort; 244 Head.msgh_remote_port = kClientRemotePort;
248 Head.msgh_local_port = kServerLocalPort; 245 Head.msgh_local_port = kServerLocalPort;
249 Head.msgh_id = 2403; 246 Head.msgh_id = 2403;
250 msgh_body.msgh_descriptor_count = 2; 247 msgh_body.msgh_descriptor_count = 2;
251 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort); 248 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort);
252 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort); 249 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort);
253 NDR = NDR_record; 250 NDR = NDR_record;
254 exception = kExceptionType; 251 exception = kExceptionType;
255 codeCnt = 2; 252 codeCnt = 2;
256 code[0] = kExceptionCodes[0]; 253 code[0] = kTestExceptonCodes[0];
257 code[1] = kExceptionCodes[1]; 254 code[1] = kTestExceptonCodes[1];
258 flavor = kThreadStateFlavor; 255 flavor = kThreadStateFlavor;
259 old_stateCnt = kThreadStateFlavorCount; 256 old_stateCnt = kThreadStateFlavorCount;
260 257
261 // Adjust the message size for the data that it’s actually carrying, which 258 // Adjust the message size for the data that it’s actually carrying, which
262 // may be smaller than the maximum that it can carry. 259 // may be smaller than the maximum that it can carry.
263 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state); 260 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state);
264 } 261 }
265 }; 262 };
266 263
267 // The reply messages for exception_raise_state and 264 // The reply messages for exception_raise_state and
(...skipping 18 matching lines...) Expand all
286 Head.msgh_size = sizeof(*this); 283 Head.msgh_size = sizeof(*this);
287 Head.msgh_remote_port = kClientRemotePort; 284 Head.msgh_remote_port = kClientRemotePort;
288 Head.msgh_local_port = kServerLocalPort; 285 Head.msgh_local_port = kServerLocalPort;
289 Head.msgh_id = 2405; 286 Head.msgh_id = 2405;
290 msgh_body.msgh_descriptor_count = 2; 287 msgh_body.msgh_descriptor_count = 2;
291 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort); 288 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort);
292 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort); 289 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort);
293 NDR = NDR_record; 290 NDR = NDR_record;
294 exception = kExceptionType; 291 exception = kExceptionType;
295 codeCnt = 2; 292 codeCnt = 2;
296 code[0] = kMachExceptionCodes[0]; 293 code[0] = kTestMachExceptionCodes[0];
297 code[1] = kMachExceptionCodes[1]; 294 code[1] = kTestMachExceptionCodes[1];
298 } 295 }
299 }; 296 };
300 297
301 // The reply messages for exception_raise and mach_exception_raise are 298 // The reply messages for exception_raise and mach_exception_raise are
302 // identical. 299 // identical.
303 typedef ExceptionRaiseReply MachExceptionRaiseReply; 300 typedef ExceptionRaiseReply MachExceptionRaiseReply;
304 301
305 struct __attribute__((packed, aligned(4))) MachExceptionRaiseStateRequest { 302 struct __attribute__((packed, aligned(4))) MachExceptionRaiseStateRequest {
306 mach_msg_header_t Head; 303 mach_msg_header_t Head;
307 NDR_record_t NDR; 304 NDR_record_t NDR;
308 exception_type_t exception; 305 exception_type_t exception;
309 mach_msg_type_number_t codeCnt; 306 mach_msg_type_number_t codeCnt;
310 int64_t code[2]; 307 int64_t code[2];
311 int flavor; 308 int flavor;
312 mach_msg_type_number_t old_stateCnt; 309 mach_msg_type_number_t old_stateCnt;
313 natural_t old_state[THREAD_STATE_MAX]; 310 natural_t old_state[THREAD_STATE_MAX];
314 311
315 void InitializeForTesting() { 312 void InitializeForTesting() {
316 memset(this, 0xa5, sizeof(*this)); 313 memset(this, 0xa5, sizeof(*this));
317 Head.msgh_bits = 314 Head.msgh_bits =
318 MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE); 315 MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE);
319 Head.msgh_size = sizeof(*this); 316 Head.msgh_size = sizeof(*this);
320 Head.msgh_remote_port = kClientRemotePort; 317 Head.msgh_remote_port = kClientRemotePort;
321 Head.msgh_local_port = kServerLocalPort; 318 Head.msgh_local_port = kServerLocalPort;
322 Head.msgh_id = 2406; 319 Head.msgh_id = 2406;
323 NDR = NDR_record; 320 NDR = NDR_record;
324 exception = kExceptionType; 321 exception = kExceptionType;
325 codeCnt = 2; 322 codeCnt = 2;
326 code[0] = kMachExceptionCodes[0]; 323 code[0] = kTestMachExceptionCodes[0];
327 code[1] = kMachExceptionCodes[1]; 324 code[1] = kTestMachExceptionCodes[1];
328 flavor = kThreadStateFlavor; 325 flavor = kThreadStateFlavor;
329 old_stateCnt = kThreadStateFlavorCount; 326 old_stateCnt = kThreadStateFlavorCount;
330 327
331 // Adjust the message size for the data that it’s actually carrying, which 328 // Adjust the message size for the data that it’s actually carrying, which
332 // may be smaller than the maximum that it can carry. 329 // may be smaller than the maximum that it can carry.
333 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state); 330 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state);
334 } 331 }
335 }; 332 };
336 333
337 // The reply messages for exception_raise_state and mach_exception_raise_state 334 // The reply messages for exception_raise_state and mach_exception_raise_state
(...skipping 22 matching lines...) Expand all
360 Head.msgh_size = sizeof(*this); 357 Head.msgh_size = sizeof(*this);
361 Head.msgh_remote_port = kClientRemotePort; 358 Head.msgh_remote_port = kClientRemotePort;
362 Head.msgh_local_port = kServerLocalPort; 359 Head.msgh_local_port = kServerLocalPort;
363 Head.msgh_id = 2407; 360 Head.msgh_id = 2407;
364 msgh_body.msgh_descriptor_count = 2; 361 msgh_body.msgh_descriptor_count = 2;
365 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort); 362 InitializeMachMsgPortDescriptor(&thread, kExceptionThreadPort);
366 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort); 363 InitializeMachMsgPortDescriptor(&task, kExceptionTaskPort);
367 NDR = NDR_record; 364 NDR = NDR_record;
368 exception = kExceptionType; 365 exception = kExceptionType;
369 codeCnt = 2; 366 codeCnt = 2;
370 code[0] = kMachExceptionCodes[0]; 367 code[0] = kTestMachExceptionCodes[0];
371 code[1] = kMachExceptionCodes[1]; 368 code[1] = kTestMachExceptionCodes[1];
372 flavor = kThreadStateFlavor; 369 flavor = kThreadStateFlavor;
373 old_stateCnt = kThreadStateFlavorCount; 370 old_stateCnt = kThreadStateFlavorCount;
374 371
375 // Adjust the message size for the data that it’s actually carrying, which 372 // Adjust the message size for the data that it’s actually carrying, which
376 // may be smaller than the maximum that it can carry. 373 // may be smaller than the maximum that it can carry.
377 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state); 374 Head.msgh_size += sizeof(old_state[0]) * old_stateCnt - sizeof(old_state);
378 } 375 }
379 }; 376 };
380 377
381 // The reply messages for exception_raise_state_identity and 378 // The reply messages for exception_raise_state_identity and
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 554
558 const exception_behavior_t kExceptionBehavior = EXCEPTION_DEFAULT; 555 const exception_behavior_t kExceptionBehavior = EXCEPTION_DEFAULT;
559 556
560 EXPECT_CALL(server, 557 EXPECT_CALL(server,
561 MockCatchMachException( 558 MockCatchMachException(
562 kExceptionBehavior, 559 kExceptionBehavior,
563 kServerLocalPort, 560 kServerLocalPort,
564 kExceptionThreadPort, 561 kExceptionThreadPort,
565 kExceptionTaskPort, 562 kExceptionTaskPort,
566 kExceptionType, 563 kExceptionType,
567 AreExceptionCodes(kExceptionCodes[0], kExceptionCodes[1]), 564 AreExceptionCodes(
565 kTestExceptonCodes[0], kTestExceptonCodes[1]),
568 Pointee(Eq(THREAD_STATE_NONE)), 566 Pointee(Eq(THREAD_STATE_NONE)),
569 IsThreadStateCount(0u), 567 IsThreadStateCount(0u),
570 IsThreadStateCount(0u))) 568 IsThreadStateCount(0u)))
571 .WillOnce(Return(KERN_SUCCESS)) 569 .WillOnce(Return(KERN_SUCCESS))
572 .RetiresOnSaturation(); 570 .RetiresOnSaturation();
573 571
574 bool destroy_complex_request = false; 572 bool destroy_complex_request = false;
575 EXPECT_TRUE(server.MachMessageServerFunction( 573 EXPECT_TRUE(server.MachMessageServerFunction(
576 reinterpret_cast<mach_msg_header_t*>(&request), 574 reinterpret_cast<mach_msg_header_t*>(&request),
577 reinterpret_cast<mach_msg_header_t*>(&reply), 575 reinterpret_cast<mach_msg_header_t*>(&reply),
(...skipping 18 matching lines...) Expand all
596 594
597 const exception_behavior_t kExceptionBehavior = EXCEPTION_STATE; 595 const exception_behavior_t kExceptionBehavior = EXCEPTION_STATE;
598 596
599 EXPECT_CALL(server, 597 EXPECT_CALL(server,
600 MockCatchMachException( 598 MockCatchMachException(
601 kExceptionBehavior, 599 kExceptionBehavior,
602 kServerLocalPort, 600 kServerLocalPort,
603 MACH_PORT_NULL, 601 MACH_PORT_NULL,
604 MACH_PORT_NULL, 602 MACH_PORT_NULL,
605 kExceptionType, 603 kExceptionType,
606 AreExceptionCodes(kExceptionCodes[0], kExceptionCodes[1]), 604 AreExceptionCodes(
605 kTestExceptonCodes[0], kTestExceptonCodes[1]),
607 Pointee(Eq(kThreadStateFlavor)), 606 Pointee(Eq(kThreadStateFlavor)),
608 IsThreadStateCount(kThreadStateFlavorCount), 607 IsThreadStateCount(kThreadStateFlavorCount),
609 IsThreadStateCount(arraysize(reply.new_state)))) 608 IsThreadStateCount(arraysize(reply.new_state))))
610 .WillOnce(Return(KERN_SUCCESS)) 609 .WillOnce(Return(KERN_SUCCESS))
611 .RetiresOnSaturation(); 610 .RetiresOnSaturation();
612 611
613 bool destroy_complex_request = false; 612 bool destroy_complex_request = false;
614 EXPECT_TRUE(server.MachMessageServerFunction( 613 EXPECT_TRUE(server.MachMessageServerFunction(
615 reinterpret_cast<mach_msg_header_t*>(&request), 614 reinterpret_cast<mach_msg_header_t*>(&request),
616 reinterpret_cast<mach_msg_header_t*>(&reply), 615 reinterpret_cast<mach_msg_header_t*>(&reply),
(...skipping 21 matching lines...) Expand all
638 637
639 const exception_behavior_t kExceptionBehavior = EXCEPTION_STATE_IDENTITY; 638 const exception_behavior_t kExceptionBehavior = EXCEPTION_STATE_IDENTITY;
640 639
641 EXPECT_CALL(server, 640 EXPECT_CALL(server,
642 MockCatchMachException( 641 MockCatchMachException(
643 kExceptionBehavior, 642 kExceptionBehavior,
644 kServerLocalPort, 643 kServerLocalPort,
645 kExceptionThreadPort, 644 kExceptionThreadPort,
646 kExceptionTaskPort, 645 kExceptionTaskPort,
647 kExceptionType, 646 kExceptionType,
648 AreExceptionCodes(kExceptionCodes[0], kExceptionCodes[1]), 647 AreExceptionCodes(
648 kTestExceptonCodes[0], kTestExceptonCodes[1]),
649 Pointee(Eq(kThreadStateFlavor)), 649 Pointee(Eq(kThreadStateFlavor)),
650 IsThreadStateCount(kThreadStateFlavorCount), 650 IsThreadStateCount(kThreadStateFlavorCount),
651 IsThreadStateCount(arraysize(reply.new_state)))) 651 IsThreadStateCount(arraysize(reply.new_state))))
652 .WillOnce(Return(KERN_SUCCESS)) 652 .WillOnce(Return(KERN_SUCCESS))
653 .RetiresOnSaturation(); 653 .RetiresOnSaturation();
654 654
655 bool destroy_complex_request = false; 655 bool destroy_complex_request = false;
656 EXPECT_TRUE(server.MachMessageServerFunction( 656 EXPECT_TRUE(server.MachMessageServerFunction(
657 reinterpret_cast<mach_msg_header_t*>(&request), 657 reinterpret_cast<mach_msg_header_t*>(&request),
658 reinterpret_cast<mach_msg_header_t*>(&reply), 658 reinterpret_cast<mach_msg_header_t*>(&reply),
(...skipping 20 matching lines...) Expand all
679 EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES; 679 EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES;
680 680
681 EXPECT_CALL( 681 EXPECT_CALL(
682 server, 682 server,
683 MockCatchMachException( 683 MockCatchMachException(
684 kExceptionBehavior, 684 kExceptionBehavior,
685 kServerLocalPort, 685 kServerLocalPort,
686 kExceptionThreadPort, 686 kExceptionThreadPort,
687 kExceptionTaskPort, 687 kExceptionTaskPort,
688 kExceptionType, 688 kExceptionType,
689 AreExceptionCodes(kMachExceptionCodes[0], kMachExceptionCodes[1]), 689 AreExceptionCodes(
690 kTestMachExceptionCodes[0], kTestMachExceptionCodes[1]),
690 Pointee(Eq(THREAD_STATE_NONE)), 691 Pointee(Eq(THREAD_STATE_NONE)),
691 IsThreadStateCount(0u), 692 IsThreadStateCount(0u),
692 IsThreadStateCount(0u))) 693 IsThreadStateCount(0u)))
693 .WillOnce(Return(KERN_SUCCESS)) 694 .WillOnce(Return(KERN_SUCCESS))
694 .RetiresOnSaturation(); 695 .RetiresOnSaturation();
695 696
696 bool destroy_complex_request = false; 697 bool destroy_complex_request = false;
697 EXPECT_TRUE(server.MachMessageServerFunction( 698 EXPECT_TRUE(server.MachMessageServerFunction(
698 reinterpret_cast<mach_msg_header_t*>(&request), 699 reinterpret_cast<mach_msg_header_t*>(&request),
699 reinterpret_cast<mach_msg_header_t*>(&reply), 700 reinterpret_cast<mach_msg_header_t*>(&reply),
(...skipping 20 matching lines...) Expand all
720 EXCEPTION_STATE | MACH_EXCEPTION_CODES; 721 EXCEPTION_STATE | MACH_EXCEPTION_CODES;
721 722
722 EXPECT_CALL( 723 EXPECT_CALL(
723 server, 724 server,
724 MockCatchMachException( 725 MockCatchMachException(
725 kExceptionBehavior, 726 kExceptionBehavior,
726 kServerLocalPort, 727 kServerLocalPort,
727 MACH_PORT_NULL, 728 MACH_PORT_NULL,
728 MACH_PORT_NULL, 729 MACH_PORT_NULL,
729 kExceptionType, 730 kExceptionType,
730 AreExceptionCodes(kMachExceptionCodes[0], kMachExceptionCodes[1]), 731 AreExceptionCodes(
732 kTestMachExceptionCodes[0], kTestMachExceptionCodes[1]),
731 Pointee(Eq(kThreadStateFlavor)), 733 Pointee(Eq(kThreadStateFlavor)),
732 IsThreadStateCount(kThreadStateFlavorCount), 734 IsThreadStateCount(kThreadStateFlavorCount),
733 IsThreadStateCount(arraysize(reply.new_state)))) 735 IsThreadStateCount(arraysize(reply.new_state))))
734 .WillOnce(Return(KERN_SUCCESS)) 736 .WillOnce(Return(KERN_SUCCESS))
735 .RetiresOnSaturation(); 737 .RetiresOnSaturation();
736 738
737 bool destroy_complex_request = false; 739 bool destroy_complex_request = false;
738 EXPECT_TRUE(server.MachMessageServerFunction( 740 EXPECT_TRUE(server.MachMessageServerFunction(
739 reinterpret_cast<mach_msg_header_t*>(&request), 741 reinterpret_cast<mach_msg_header_t*>(&request),
740 reinterpret_cast<mach_msg_header_t*>(&reply), 742 reinterpret_cast<mach_msg_header_t*>(&reply),
(...skipping 23 matching lines...) Expand all
764 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES; 766 EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES;
765 767
766 EXPECT_CALL( 768 EXPECT_CALL(
767 server, 769 server,
768 MockCatchMachException( 770 MockCatchMachException(
769 kExceptionBehavior, 771 kExceptionBehavior,
770 kServerLocalPort, 772 kServerLocalPort,
771 kExceptionThreadPort, 773 kExceptionThreadPort,
772 kExceptionTaskPort, 774 kExceptionTaskPort,
773 kExceptionType, 775 kExceptionType,
774 AreExceptionCodes(kMachExceptionCodes[0], kMachExceptionCodes[1]), 776 AreExceptionCodes(
777 kTestMachExceptionCodes[0], kTestMachExceptionCodes[1]),
775 Pointee(Eq(kThreadStateFlavor)), 778 Pointee(Eq(kThreadStateFlavor)),
776 IsThreadStateCount(kThreadStateFlavorCount), 779 IsThreadStateCount(kThreadStateFlavorCount),
777 IsThreadStateCount(arraysize(reply.new_state)))) 780 IsThreadStateCount(arraysize(reply.new_state))))
778 .WillOnce(Return(KERN_SUCCESS)) 781 .WillOnce(Return(KERN_SUCCESS))
779 .RetiresOnSaturation(); 782 .RetiresOnSaturation();
780 783
781 bool destroy_complex_request = false; 784 bool destroy_complex_request = false;
782 EXPECT_TRUE(server.MachMessageServerFunction( 785 EXPECT_TRUE(server.MachMessageServerFunction(
783 reinterpret_cast<mach_msg_header_t*>(&request), 786 reinterpret_cast<mach_msg_header_t*>(&request),
784 reinterpret_cast<mach_msg_header_t*>(&reply), 787 reinterpret_cast<mach_msg_header_t*>(&reply),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 int sig = (code[0] >> 24) & 0xff; 920 int sig = (code[0] >> 24) & 0xff;
918 SetExpectedChildTermination(kTerminationSignal, sig); 921 SetExpectedChildTermination(kTerminationSignal, sig);
919 } 922 }
920 923
921 if (has_state) { 924 if (has_state) {
922 EXPECT_EQ(flavor_, *flavor); 925 EXPECT_EQ(flavor_, *flavor);
923 EXPECT_EQ(state_count_, old_state_count); 926 EXPECT_EQ(state_count_, old_state_count);
924 EXPECT_NE(static_cast<const natural_t*>(NULL), old_state); 927 EXPECT_NE(static_cast<const natural_t*>(NULL), old_state);
925 EXPECT_EQ(static_cast<mach_msg_type_number_t>(THREAD_STATE_MAX), 928 EXPECT_EQ(static_cast<mach_msg_type_number_t>(THREAD_STATE_MAX),
926 *new_state_count); 929 *new_state_count);
927 EXPECT_NE(static_cast<const natural_t*>(NULL), new_state); 930 EXPECT_NE(static_cast<natural_t*>(NULL), new_state);
928 } else { 931 } else {
929 EXPECT_EQ(THREAD_STATE_NONE, *flavor); 932 EXPECT_EQ(THREAD_STATE_NONE, *flavor);
930 EXPECT_EQ(0u, old_state_count); 933 EXPECT_EQ(0u, old_state_count);
931 EXPECT_EQ(NULL, old_state); 934 EXPECT_EQ(NULL, old_state);
932 EXPECT_EQ(0u, *new_state_count); 935 EXPECT_EQ(0u, *new_state_count);
933 EXPECT_EQ(NULL, new_state); 936 EXPECT_EQ(NULL, new_state);
934 } 937 }
935 938
936 // Even for an EXC_CRASH handler, returning KERN_SUCCESS with a 939 // Even for an EXC_CRASH handler, returning KERN_SUCCESS with a
937 // state-carrying reply will cause the kernel to try to set a new thread 940 // state-carrying reply will cause the kernel to try to set a new thread
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1081
1079 TestExcServerVariants test_exc_server_variants( 1082 TestExcServerVariants test_exc_server_variants(
1080 MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY, 1083 MACH_EXCEPTION_CODES | EXCEPTION_STATE_IDENTITY,
1081 test.flavor, 1084 test.flavor,
1082 test.count); 1085 test.count);
1083 test_exc_server_variants.Run(); 1086 test_exc_server_variants.Run();
1084 } 1087 }
1085 } 1088 }
1086 1089
1087 } // namespace 1090 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698