| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 241 } |
| 241 | 242 |
| 242 case kMachMessageIDExceptionRaiseState: { | 243 case kMachMessageIDExceptionRaiseState: { |
| 243 // exception_raise_state(), catch_exception_raise_state(). | 244 // exception_raise_state(), catch_exception_raise_state(). |
| 244 typedef __Request__exception_raise_state_t Request; | 245 typedef __Request__exception_raise_state_t Request; |
| 245 const Request* in_request = reinterpret_cast<const Request*>(in_header); | 246 const Request* in_request = reinterpret_cast<const Request*>(in_header); |
| 246 | 247 |
| 247 // in_request_1 is used for the portion of the request after the codes, | 248 // 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. | 249 // which in theory can be variable-length. The check function will set it. |
| 249 const Request* in_request_1; | 250 const Request* in_request_1; |
| 250 kern_return_t kr = MIGCheckRequestExceptionRaiseState( | 251 kern_return_t kr = |
| 251 in_request, &in_request_1); | 252 MIGCheckRequestExceptionRaiseState(in_request, &in_request_1); |
| 252 if (kr != MACH_MSG_SUCCESS) { | 253 if (kr != MACH_MSG_SUCCESS) { |
| 253 SetReplyError(out_header, kr); | 254 SetReplyError(out_header, kr); |
| 254 return true; | 255 return true; |
| 255 } | 256 } |
| 256 | 257 |
| 257 typedef __Reply__exception_raise_state_t Reply; | 258 typedef __Reply__exception_raise_state_t Reply; |
| 258 Reply* out_reply = reinterpret_cast<Reply*>(out_header); | 259 Reply* out_reply = reinterpret_cast<Reply*>(out_header); |
| 259 out_reply->flavor = in_request_1->flavor; | 260 out_reply->flavor = in_request_1->flavor; |
| 260 out_reply->new_stateCnt = arraysize(out_reply->new_state); | 261 out_reply->new_stateCnt = arraysize(out_reply->new_state); |
| 261 out_reply->RetCode = | 262 out_reply->RetCode = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 280 | 281 |
| 281 case kMachMessageIDExceptionRaiseStateIdentity: { | 282 case kMachMessageIDExceptionRaiseStateIdentity: { |
| 282 // exception_raise_state_identity(), | 283 // exception_raise_state_identity(), |
| 283 // catch_exception_raise_state_identity(). | 284 // catch_exception_raise_state_identity(). |
| 284 typedef __Request__exception_raise_state_identity_t Request; | 285 typedef __Request__exception_raise_state_identity_t Request; |
| 285 const Request* in_request = reinterpret_cast<const Request*>(in_header); | 286 const Request* in_request = reinterpret_cast<const Request*>(in_header); |
| 286 | 287 |
| 287 // in_request_1 is used for the portion of the request after the codes, | 288 // 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. | 289 // which in theory can be variable-length. The check function will set it. |
| 289 const Request* in_request_1; | 290 const Request* in_request_1; |
| 290 kern_return_t kr = MIGCheckRequestExceptionRaiseStateIdentity( | 291 kern_return_t kr = |
| 291 in_request, &in_request_1); | 292 MIGCheckRequestExceptionRaiseStateIdentity(in_request, &in_request_1); |
| 292 if (kr != MACH_MSG_SUCCESS) { | 293 if (kr != MACH_MSG_SUCCESS) { |
| 293 SetReplyError(out_header, kr); | 294 SetReplyError(out_header, kr); |
| 294 return true; | 295 return true; |
| 295 } | 296 } |
| 296 | 297 |
| 297 typedef __Reply__exception_raise_state_identity_t Reply; | 298 typedef __Reply__exception_raise_state_identity_t Reply; |
| 298 Reply* out_reply = reinterpret_cast<Reply*>(out_header); | 299 Reply* out_reply = reinterpret_cast<Reply*>(out_header); |
| 299 out_reply->flavor = in_request_1->flavor; | 300 out_reply->flavor = in_request_1->flavor; |
| 300 out_reply->new_stateCnt = arraysize(out_reply->new_state); | 301 out_reply->new_stateCnt = arraysize(out_reply->new_state); |
| 301 out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity( | 302 out_reply->RetCode = interface_->CatchExceptionRaiseStateIdentity( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 } | 376 } |
| 376 | 377 |
| 377 case kMachMessageIDMachExceptionRaiseState: { | 378 case kMachMessageIDMachExceptionRaiseState: { |
| 378 // mach_exception_raise_state(), catch_mach_exception_raise_state(). | 379 // mach_exception_raise_state(), catch_mach_exception_raise_state(). |
| 379 typedef __Request__mach_exception_raise_state_t Request; | 380 typedef __Request__mach_exception_raise_state_t Request; |
| 380 const Request* in_request = reinterpret_cast<const Request*>(in_header); | 381 const Request* in_request = reinterpret_cast<const Request*>(in_header); |
| 381 | 382 |
| 382 // in_request_1 is used for the portion of the request after the codes, | 383 // 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. | 384 // which in theory can be variable-length. The check function will set it. |
| 384 const Request* in_request_1; | 385 const Request* in_request_1; |
| 385 kern_return_t kr = MIGCheckRequestMachExceptionRaiseState( | 386 kern_return_t kr = |
| 386 in_request, &in_request_1); | 387 MIGCheckRequestMachExceptionRaiseState(in_request, &in_request_1); |
| 387 if (kr != MACH_MSG_SUCCESS) { | 388 if (kr != MACH_MSG_SUCCESS) { |
| 388 SetReplyError(out_header, kr); | 389 SetReplyError(out_header, kr); |
| 389 return true; | 390 return true; |
| 390 } | 391 } |
| 391 | 392 |
| 392 typedef __Reply__mach_exception_raise_state_t Reply; | 393 typedef __Reply__mach_exception_raise_state_t Reply; |
| 393 Reply* out_reply = reinterpret_cast<Reply*>(out_header); | 394 Reply* out_reply = reinterpret_cast<Reply*>(out_header); |
| 394 out_reply->flavor = in_request_1->flavor; | 395 out_reply->flavor = in_request_1->flavor; |
| 395 out_reply->new_stateCnt = arraysize(out_reply->new_state); | 396 out_reply->new_stateCnt = arraysize(out_reply->new_state); |
| 396 out_reply->RetCode = | 397 out_reply->RetCode = |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 code_count ? &mach_codes[0] : NULL, | 716 code_count ? &mach_codes[0] : NULL, |
| 716 code_count, | 717 code_count, |
| 717 flavor, | 718 flavor, |
| 718 old_state, | 719 old_state, |
| 719 old_state_count, | 720 old_state_count, |
| 720 new_state, | 721 new_state, |
| 721 new_state_count, | 722 new_state_count, |
| 722 destroy_complex_request); | 723 destroy_complex_request); |
| 723 } | 724 } |
| 724 | 725 |
| 726 kern_return_t ExcServerSuccessfulReturnValue(exception_behavior_t behavior, |
| 727 bool set_thread_state) { |
| 728 if (!set_thread_state && ExceptionBehaviorHasState(behavior)) { |
| 729 return MACH_RCV_PORT_DIED; |
| 730 } |
| 731 |
| 732 return KERN_SUCCESS; |
| 733 } |
| 734 |
| 725 } // namespace crashpad | 735 } // namespace crashpad |
| OLD | NEW |