OLD | NEW |
---|---|
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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "util/mach/exc_server_variants.h" | 15 #include "util/mach/exc_server_variants.h" |
16 | 16 |
17 #include <algorithm> | 17 #include <algorithm> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
22 #include "util/mach/exc.h" | 22 #include "util/mach/exc.h" |
23 #include "util/mach/exception_behaviors.h" | |
23 #include "util/mach/excServer.h" | 24 #include "util/mach/excServer.h" |
24 #include "util/mach/mach_exc.h" | 25 #include "util/mach/mach_exc.h" |
25 #include "util/mach/mach_excServer.h" | 26 #include "util/mach/mach_excServer.h" |
26 | 27 |
27 extern "C" { | 28 extern "C" { |
28 | 29 |
29 // These six functions are not used, and are in fact obsoleted by the other | 30 // These six functions are not used, and are in fact obsoleted by the other |
30 // functionality implemented in this file. The standard MIG-generated exc_server | 31 // functionality implemented in this file. The standard MIG-generated exc_server |
31 // (in excServer.c) and mach_exc_server (in mach_excServer.c) server dispatch | 32 // (in excServer.c) and mach_exc_server (in mach_excServer.c) server dispatch |
32 // routines usable with the standard mach_msg_server() function call out to | 33 // routines usable with the standard mach_msg_server() function call out to |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 return __MIG_check__Request__mach_exception_raise_state_identity_t( | 195 return __MIG_check__Request__mach_exception_raise_state_identity_t( |
195 const_cast<Request*>(in_request), const_cast<Request**>(in_request_1)); | 196 const_cast<Request*>(in_request), const_cast<Request**>(in_request_1)); |
196 } | 197 } |
197 | 198 |
198 } // namespace | 199 } // namespace |
199 | 200 |
200 namespace crashpad { | 201 namespace crashpad { |
201 namespace internal { | 202 namespace internal { |
202 | 203 |
203 ExcServer::ExcServer(ExcServer::Interface* interface) | 204 ExcServer::ExcServer(ExcServer::Interface* interface) |
204 : MachMessageServer::Interface(), | 205 : MachMessageServer::Interface(), interface_(interface) { |
Robert Sesek
2014/09/17 15:29:38
Not sure these clang-format changes are improvemen
Mark Mentovai
2014/09/17 15:35:38
rsesek wrote:
| |
205 interface_(interface) { | |
206 } | 206 } |
207 | 207 |
208 bool ExcServer::MachMessageServerFunction(const mach_msg_header_t* in_header, | 208 bool ExcServer::MachMessageServerFunction(const mach_msg_header_t* in_header, |
209 mach_msg_header_t* out_header, | 209 mach_msg_header_t* out_header, |
210 bool* destroy_complex_request) { | 210 bool* destroy_complex_request) { |
211 PrepareReplyFromRequest(in_header, out_header); | 211 PrepareReplyFromRequest(in_header, out_header); |
212 | 212 |
213 switch (in_header->msgh_id) { | 213 switch (in_header->msgh_id) { |
214 case kMachMessageIDExceptionRaise: { | 214 case kMachMessageIDExceptionRaise: { |
215 // exception_raise(), catch_exception_raise(). | 215 // exception_raise(), catch_exception_raise(). |
(...skipping 24 matching lines...) Expand all Loading... | |
240 } | 240 } |
241 | 241 |
242 case kMachMessageIDExceptionRaiseState: { | 242 case kMachMessageIDExceptionRaiseState: { |
243 // exception_raise_state(), catch_exception_raise_state(). | 243 // exception_raise_state(), catch_exception_raise_state(). |
244 typedef __Request__exception_raise_state_t Request; | 244 typedef __Request__exception_raise_state_t Request; |
245 const Request* in_request = reinterpret_cast<const Request*>(in_header); | 245 const Request* in_request = reinterpret_cast<const Request*>(in_header); |
246 | 246 |
247 // in_request_1 is used for the portion of the request after the codes, | 247 // in_request_1 is used for the portion of the request after the codes, |
248 // which in theory can be variable-length. The check function will set it. | 248 // which in theory can be variable-length. The check function will set it. |
249 const Request* in_request_1; | 249 const Request* in_request_1; |
250 kern_return_t kr = MIGCheckRequestExceptionRaiseState( | 250 kern_return_t kr = |
251 in_request, &in_request_1); | 251 MIGCheckRequestExceptionRaiseState(in_request, &in_request_1); |
252 if (kr != MACH_MSG_SUCCESS) { | 252 if (kr != MACH_MSG_SUCCESS) { |
253 SetReplyError(out_header, kr); | 253 SetReplyError(out_header, kr); |
254 return true; | 254 return true; |
255 } | 255 } |
256 | 256 |
257 typedef __Reply__exception_raise_state_t Reply; | 257 typedef __Reply__exception_raise_state_t Reply; |
258 Reply* out_reply = reinterpret_cast<Reply*>(out_header); | 258 Reply* out_reply = reinterpret_cast<Reply*>(out_header); |
259 out_reply->flavor = in_request_1->flavor; | 259 out_reply->flavor = in_request_1->flavor; |
260 out_reply->new_stateCnt = arraysize(out_reply->new_state); | 260 out_reply->new_stateCnt = arraysize(out_reply->new_state); |
261 out_reply->RetCode = | 261 out_reply->RetCode = |
(...skipping 18 matching lines...) Expand all Loading... | |
280 | 280 |
281 case kMachMessageIDExceptionRaiseStateIdentity: { | 281 case kMachMessageIDExceptionRaiseStateIdentity: { |
282 // exception_raise_state_identity(), | 282 // exception_raise_state_identity(), |
283 // catch_exception_raise_state_identity(). | 283 // catch_exception_raise_state_identity(). |
284 typedef __Request__exception_raise_state_identity_t Request; | 284 typedef __Request__exception_raise_state_identity_t Request; |
285 const Request* in_request = reinterpret_cast<const Request*>(in_header); | 285 const Request* in_request = reinterpret_cast<const Request*>(in_header); |
286 | 286 |
287 // in_request_1 is used for the portion of the request after the codes, | 287 // in_request_1 is used for the portion of the request after the codes, |
288 // which in theory can be variable-length. The check function will set it. | 288 // which in theory can be variable-length. The check function will set it. |
289 const Request* in_request_1; | 289 const Request* in_request_1; |
290 kern_return_t kr = MIGCheckRequestExceptionRaiseStateIdentity( | 290 kern_return_t kr = |
291 in_request, &in_request_1); | 291 MIGCheckRequestExceptionRaiseStateIdentity(in_request, &in_request_1); |
292 if (kr != MACH_MSG_SUCCESS) { | 292 if (kr != MACH_MSG_SUCCESS) { |
293 SetReplyError(out_header, kr); | 293 SetReplyError(out_header, kr); |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 typedef __Reply__exception_raise_state_identity_t Reply; | 297 typedef __Reply__exception_raise_state_identity_t Reply; |
298 Reply* out_reply = reinterpret_cast<Reply*>(out_header); | 298 Reply* out_reply = reinterpret_cast<Reply*>(out_header); |
299 out_reply->flavor = in_request_1->flavor; | 299 out_reply->flavor = in_request_1->flavor; |
300 out_reply->new_stateCnt = arraysize(out_reply->new_state); | 300 out_reply->new_stateCnt = arraysize(out_reply->new_state); |
301 out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity( | 301 out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity( |
(...skipping 26 matching lines...) Expand all Loading... | |
328 | 328 |
329 mach_msg_size_t ExcServer::MachMessageServerRequestSize() { | 329 mach_msg_size_t ExcServer::MachMessageServerRequestSize() { |
330 return sizeof(__RequestUnion__exc_subsystem); | 330 return sizeof(__RequestUnion__exc_subsystem); |
331 } | 331 } |
332 | 332 |
333 mach_msg_size_t ExcServer::MachMessageServerReplySize() { | 333 mach_msg_size_t ExcServer::MachMessageServerReplySize() { |
334 return sizeof(__ReplyUnion__exc_subsystem); | 334 return sizeof(__ReplyUnion__exc_subsystem); |
335 } | 335 } |
336 | 336 |
337 MachExcServer::MachExcServer(MachExcServer::Interface* interface) | 337 MachExcServer::MachExcServer(MachExcServer::Interface* interface) |
338 : MachMessageServer::Interface(), | 338 : MachMessageServer::Interface(), interface_(interface) { |
339 interface_(interface) { | |
340 } | 339 } |
341 | 340 |
342 bool MachExcServer::MachMessageServerFunction( | 341 bool MachExcServer::MachMessageServerFunction( |
343 const mach_msg_header_t* in_header, | 342 const mach_msg_header_t* in_header, |
344 mach_msg_header_t* out_header, | 343 mach_msg_header_t* out_header, |
345 bool* destroy_complex_request) { | 344 bool* destroy_complex_request) { |
346 PrepareReplyFromRequest(in_header, out_header); | 345 PrepareReplyFromRequest(in_header, out_header); |
347 | 346 |
348 switch (in_header->msgh_id) { | 347 switch (in_header->msgh_id) { |
349 case kMachMessageIDMachExceptionRaise: { | 348 case kMachMessageIDMachExceptionRaise: { |
(...skipping 25 matching lines...) Expand all Loading... | |
375 } | 374 } |
376 | 375 |
377 case kMachMessageIDMachExceptionRaiseState: { | 376 case kMachMessageIDMachExceptionRaiseState: { |
378 // mach_exception_raise_state(), catch_mach_exception_raise_state(). | 377 // mach_exception_raise_state(), catch_mach_exception_raise_state(). |
379 typedef __Request__mach_exception_raise_state_t Request; | 378 typedef __Request__mach_exception_raise_state_t Request; |
380 const Request* in_request = reinterpret_cast<const Request*>(in_header); | 379 const Request* in_request = reinterpret_cast<const Request*>(in_header); |
381 | 380 |
382 // in_request_1 is used for the portion of the request after the codes, | 381 // in_request_1 is used for the portion of the request after the codes, |
383 // which in theory can be variable-length. The check function will set it. | 382 // which in theory can be variable-length. The check function will set it. |
384 const Request* in_request_1; | 383 const Request* in_request_1; |
385 kern_return_t kr = MIGCheckRequestMachExceptionRaiseState( | 384 kern_return_t kr = |
386 in_request, &in_request_1); | 385 MIGCheckRequestMachExceptionRaiseState(in_request, &in_request_1); |
387 if (kr != MACH_MSG_SUCCESS) { | 386 if (kr != MACH_MSG_SUCCESS) { |
388 SetReplyError(out_header, kr); | 387 SetReplyError(out_header, kr); |
389 return true; | 388 return true; |
390 } | 389 } |
391 | 390 |
392 typedef __Reply__mach_exception_raise_state_t Reply; | 391 typedef __Reply__mach_exception_raise_state_t Reply; |
393 Reply* out_reply = reinterpret_cast<Reply*>(out_header); | 392 Reply* out_reply = reinterpret_cast<Reply*>(out_header); |
394 out_reply->flavor = in_request_1->flavor; | 393 out_reply->flavor = in_request_1->flavor; |
395 out_reply->new_stateCnt = arraysize(out_reply->new_state); | 394 out_reply->new_stateCnt = arraysize(out_reply->new_state); |
396 out_reply->RetCode = | 395 out_reply->RetCode = |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 mach_msg_size_t MachExcServer::MachMessageServerRequestSize() { | 463 mach_msg_size_t MachExcServer::MachMessageServerRequestSize() { |
465 return sizeof(__RequestUnion__mach_exc_subsystem); | 464 return sizeof(__RequestUnion__mach_exc_subsystem); |
466 } | 465 } |
467 | 466 |
468 mach_msg_size_t MachExcServer::MachMessageServerReplySize() { | 467 mach_msg_size_t MachExcServer::MachMessageServerReplySize() { |
469 return sizeof(__ReplyUnion__mach_exc_subsystem); | 468 return sizeof(__ReplyUnion__mach_exc_subsystem); |
470 } | 469 } |
471 | 470 |
472 SimplifiedExcServer::SimplifiedExcServer( | 471 SimplifiedExcServer::SimplifiedExcServer( |
473 SimplifiedExcServer::Interface* interface) | 472 SimplifiedExcServer::Interface* interface) |
474 : ExcServer(this), | 473 : ExcServer(this), ExcServer::Interface(), interface_(interface) { |
475 ExcServer::Interface(), | |
476 interface_(interface) { | |
477 } | 474 } |
478 | 475 |
479 kern_return_t SimplifiedExcServer::CatchExceptionRaise( | 476 kern_return_t SimplifiedExcServer::CatchExceptionRaise( |
480 exception_handler_t exception_port, | 477 exception_handler_t exception_port, |
481 thread_t thread, | 478 thread_t thread, |
482 task_t task, | 479 task_t task, |
483 exception_type_t exception, | 480 exception_type_t exception, |
484 const exception_data_type_t* code, | 481 const exception_data_type_t* code, |
485 mach_msg_type_number_t code_count, | 482 mach_msg_type_number_t code_count, |
486 bool* destroy_request) { | 483 bool* destroy_request) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 flavor, | 547 flavor, |
551 old_state, | 548 old_state, |
552 old_state_count, | 549 old_state_count, |
553 new_state, | 550 new_state, |
554 new_state_count, | 551 new_state_count, |
555 destroy_request); | 552 destroy_request); |
556 } | 553 } |
557 | 554 |
558 SimplifiedMachExcServer::SimplifiedMachExcServer( | 555 SimplifiedMachExcServer::SimplifiedMachExcServer( |
559 SimplifiedMachExcServer::Interface* interface) | 556 SimplifiedMachExcServer::Interface* interface) |
560 : MachExcServer(this), | 557 : MachExcServer(this), MachExcServer::Interface(), interface_(interface) { |
561 MachExcServer::Interface(), | |
562 interface_(interface) { | |
563 } | 558 } |
564 | 559 |
565 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaise( | 560 kern_return_t SimplifiedMachExcServer::CatchMachExceptionRaise( |
566 exception_handler_t exception_port, | 561 exception_handler_t exception_port, |
567 thread_t thread, | 562 thread_t thread, |
568 task_t task, | 563 task_t task, |
569 exception_type_t exception, | 564 exception_type_t exception, |
570 const mach_exception_data_type_t* code, | 565 const mach_exception_data_type_t* code, |
571 mach_msg_type_number_t code_count, | 566 mach_msg_type_number_t code_count, |
572 bool* destroy_request) { | 567 bool* destroy_request) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 code_count ? &mach_codes[0] : NULL, | 710 code_count ? &mach_codes[0] : NULL, |
716 code_count, | 711 code_count, |
717 flavor, | 712 flavor, |
718 old_state, | 713 old_state, |
719 old_state_count, | 714 old_state_count, |
720 new_state, | 715 new_state, |
721 new_state_count, | 716 new_state_count, |
722 destroy_complex_request); | 717 destroy_complex_request); |
723 } | 718 } |
724 | 719 |
720 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, | |
721 bool set_thread_state) { | |
722 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) { | |
723 return MACH_RCV_PORT_DIED; | |
724 } | |
725 | |
726 return KERN_SUCCESS; | |
727 } | |
728 | |
725 } // namespace crashpad | 729 } // namespace crashpad |
OLD | NEW |