| 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, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (code_count >= 1) { | 93 if (code_count >= 1) { |
| 94 EXPECT_EQ(expect_code, code[0]); | 94 EXPECT_EQ(expect_code, code[0]); |
| 95 } | 95 } |
| 96 if (code_count >= 2) { | 96 if (code_count >= 2) { |
| 97 EXPECT_EQ(expect_subcode, code[1]); | 97 EXPECT_EQ(expect_subcode, code[1]); |
| 98 } | 98 } |
| 99 | 99 |
| 100 if (HasState()) { | 100 if (HasState()) { |
| 101 EXPECT_EQ(exception_ + 10, *flavor); | 101 EXPECT_EQ(exception_ + 10, *flavor); |
| 102 EXPECT_EQ(MACHINE_THREAD_STATE_COUNT, old_state_count); | 102 EXPECT_EQ(MACHINE_THREAD_STATE_COUNT, old_state_count); |
| 103 EXPECT_NE(static_cast<const natural_t*>(NULL), old_state); | 103 EXPECT_NE(nullptr, old_state); |
| 104 EXPECT_EQ(static_cast<mach_msg_type_number_t>(THREAD_STATE_MAX), | 104 EXPECT_EQ(static_cast<mach_msg_type_number_t>(THREAD_STATE_MAX), |
| 105 *new_state_count); | 105 *new_state_count); |
| 106 EXPECT_NE(static_cast<natural_t*>(NULL), new_state); | 106 EXPECT_NE(nullptr, new_state); |
| 107 | 107 |
| 108 for (size_t index = 0; index < old_state_count; ++index) { | 108 for (size_t index = 0; index < old_state_count; ++index) { |
| 109 EXPECT_EQ(index, old_state[index]); | 109 EXPECT_EQ(index, old_state[index]); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Use a flavor known to be different from the incoming flavor, for a test | 112 // Use a flavor known to be different from the incoming flavor, for a test |
| 113 // of the “out” side of the inout flavor parameter. | 113 // of the “out” side of the inout flavor parameter. |
| 114 *flavor = exception_ + 20; | 114 *flavor = exception_ + 20; |
| 115 *new_state_count = MACHINE_THREAD_STATE_COUNT; | 115 *new_state_count = MACHINE_THREAD_STATE_COUNT; |
| 116 | 116 |
| 117 // Send a new state back to the client. | 117 // Send a new state back to the client. |
| 118 for (size_t index = 0; index < *new_state_count; ++index) { | 118 for (size_t index = 0; index < *new_state_count; ++index) { |
| 119 EXPECT_EQ(0u, new_state[index]); | 119 EXPECT_EQ(0u, new_state[index]); |
| 120 new_state[index] = MACHINE_THREAD_STATE_COUNT - index; | 120 new_state[index] = MACHINE_THREAD_STATE_COUNT - index; |
| 121 } | 121 } |
| 122 } else { | 122 } else { |
| 123 EXPECT_EQ(THREAD_STATE_NONE, *flavor); | 123 EXPECT_EQ(THREAD_STATE_NONE, *flavor); |
| 124 EXPECT_EQ(0u, old_state_count); | 124 EXPECT_EQ(0u, old_state_count); |
| 125 EXPECT_EQ(NULL, old_state); | 125 EXPECT_EQ(nullptr, old_state); |
| 126 EXPECT_EQ(0u, *new_state_count); | 126 EXPECT_EQ(0u, *new_state_count); |
| 127 EXPECT_EQ(NULL, new_state); | 127 EXPECT_EQ(nullptr, new_state); |
| 128 } | 128 } |
| 129 | 129 |
| 130 return KERN_SUCCESS; | 130 return KERN_SUCCESS; |
| 131 } | 131 } |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 // MachMultiprocess: | 134 // MachMultiprocess: |
| 135 | 135 |
| 136 virtual void MachMultiprocessParent() override { | 136 virtual void MachMultiprocessParent() override { |
| 137 kern_return_t kr = MachMessageServer::Run(this, | 137 kern_return_t kr = MachMessageServer::Run(this, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 thread_t thread = THREAD_NULL; | 156 thread_t thread = THREAD_NULL; |
| 157 task_t task = TASK_NULL; | 157 task_t task = TASK_NULL; |
| 158 if (all_fields_ || HasIdentity()) { | 158 if (all_fields_ || HasIdentity()) { |
| 159 thread = MachThreadSelf(); | 159 thread = MachThreadSelf(); |
| 160 task = mach_task_self(); | 160 task = mach_task_self(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 thread_state_flavor_t flavor; | 163 thread_state_flavor_t flavor; |
| 164 thread_state_flavor_t* flavor_p = NULL; | 164 thread_state_flavor_t* flavor_p = nullptr; |
| 165 natural_t old_state[MACHINE_THREAD_STATE_COUNT]; | 165 natural_t old_state[MACHINE_THREAD_STATE_COUNT]; |
| 166 thread_state_t old_state_p = NULL; | 166 thread_state_t old_state_p = nullptr; |
| 167 mach_msg_type_number_t old_state_count = 0; | 167 mach_msg_type_number_t old_state_count = 0; |
| 168 natural_t new_state[THREAD_STATE_MAX]; | 168 natural_t new_state[THREAD_STATE_MAX]; |
| 169 thread_state_t new_state_p = NULL; | 169 thread_state_t new_state_p = nullptr; |
| 170 mach_msg_type_number_t new_state_count; | 170 mach_msg_type_number_t new_state_count; |
| 171 mach_msg_type_number_t* new_state_count_p = NULL; | 171 mach_msg_type_number_t* new_state_count_p = nullptr; |
| 172 if (all_fields_ || HasState()) { | 172 if (all_fields_ || HasState()) { |
| 173 // Pick a different flavor each time based on the value of exception_. | 173 // Pick a different flavor each time based on the value of exception_. |
| 174 // These aren’t real flavors, it’s just for testing. | 174 // These aren’t real flavors, it’s just for testing. |
| 175 flavor = exception_ + 10; | 175 flavor = exception_ + 10; |
| 176 flavor_p = &flavor; | 176 flavor_p = &flavor; |
| 177 for (size_t index = 0; index < arraysize(old_state); ++index) { | 177 for (size_t index = 0; index < arraysize(old_state); ++index) { |
| 178 old_state[index] = index; | 178 old_state[index] = index; |
| 179 } | 179 } |
| 180 old_state_p = reinterpret_cast<thread_state_t>(&old_state); | 180 old_state_p = reinterpret_cast<thread_state_t>(&old_state); |
| 181 old_state_count = arraysize(old_state); | 181 old_state_count = arraysize(old_state); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 TestExcClientVariants test_exc_client_variants(behavior, true); | 282 TestExcClientVariants test_exc_client_variants(behavior, true); |
| 283 test_exc_client_variants.Run(); | 283 test_exc_client_variants.Run(); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace | 288 } // namespace |
| 289 } // namespace test | 289 } // namespace test |
| 290 } // namespace crashpad | 290 } // namespace crashpad |
| OLD | NEW |