| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "native_client/src/trusted/validator_arm/problem_reporter.h" | 7 #include "native_client/src/trusted/validator_arm/problem_reporter.h" |
| 8 | 8 |
| 9 | 9 |
| 10 #include <assert.h> | 10 #include <assert.h> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // Returns UNKNOWN if unable to convert. | 23 // Returns UNKNOWN if unable to convert. |
| 24 static nacl_arm_dec::SafetyLevel Int2SafetyLevel(uint32_t index) { | 24 static nacl_arm_dec::SafetyLevel Int2SafetyLevel(uint32_t index) { |
| 25 static nacl_arm_dec::SafetyLevel Int2SafetyLevelMap[] = { | 25 static nacl_arm_dec::SafetyLevel Int2SafetyLevelMap[] = { |
| 26 nacl_arm_dec::UNKNOWN, | 26 nacl_arm_dec::UNKNOWN, |
| 27 nacl_arm_dec::UNDEFINED, | 27 nacl_arm_dec::UNDEFINED, |
| 28 nacl_arm_dec::NOT_IMPLEMENTED, | 28 nacl_arm_dec::NOT_IMPLEMENTED, |
| 29 nacl_arm_dec::UNPREDICTABLE, | 29 nacl_arm_dec::UNPREDICTABLE, |
| 30 nacl_arm_dec::DEPRECATED, | 30 nacl_arm_dec::DEPRECATED, |
| 31 nacl_arm_dec::FORBIDDEN, | 31 nacl_arm_dec::FORBIDDEN, |
| 32 nacl_arm_dec::FORBIDDEN_OPERANDS, | 32 nacl_arm_dec::FORBIDDEN_OPERANDS, |
| 33 nacl_arm_dec::DECODER_ERROR, |
| 33 nacl_arm_dec::MAY_BE_SAFE, | 34 nacl_arm_dec::MAY_BE_SAFE, |
| 34 }; | 35 }; |
| 35 return (index < NACL_ARRAY_SIZE(Int2SafetyLevelMap)) | 36 return (index < NACL_ARRAY_SIZE(Int2SafetyLevelMap)) |
| 36 ? Int2SafetyLevelMap[index] : nacl_arm_dec::UNKNOWN; | 37 ? Int2SafetyLevelMap[index] : nacl_arm_dec::UNKNOWN; |
| 37 } | 38 } |
| 38 | 39 |
| 39 void ProblemReporter::ExtractProblemSafety( | 40 void ProblemReporter::ExtractProblemSafety( |
| 40 const ValidatorProblemUserData user_data, | 41 const ValidatorProblemUserData user_data, |
| 41 nacl_arm_dec::SafetyLevel* safety) { | 42 nacl_arm_dec::SafetyLevel* safety) { |
| 42 if (safety != NULL) | 43 if (safety != NULL) |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // UNPREDICTABLE - This instruction has unpredictable effects at | 168 // UNPREDICTABLE - This instruction has unpredictable effects at |
| 168 // runtime. | 169 // runtime. |
| 169 "Instruction has unpredictable effects at runtime.", | 170 "Instruction has unpredictable effects at runtime.", |
| 170 // DEPRECATED - This instruction is deprecated in ARMv7. | 171 // DEPRECATED - This instruction is deprecated in ARMv7. |
| 171 "Instruction is deprecated in ARMv7.", | 172 "Instruction is deprecated in ARMv7.", |
| 172 // FORBIDDEN - This instruction is forbidden by our SFI model. | 173 // FORBIDDEN - This instruction is forbidden by our SFI model. |
| 173 "Instruction not allowed by Native Client.", | 174 "Instruction not allowed by Native Client.", |
| 174 // FORBIDDEN_OPERANDS - This instruction's operands are forbidden by | 175 // FORBIDDEN_OPERANDS - This instruction's operands are forbidden by |
| 175 // our SFI model. | 176 // our SFI model. |
| 176 "Instruction has operand(s) forbidden by Native Client.", | 177 "Instruction has operand(s) forbidden by Native Client.", |
| 178 // DECODER_ERROR - This instruction was incorrectly decoded, and |
| 179 // should have been a different instruciton. |
| 180 "Instruction decoded incorrectly by NativeClient.", |
| 177 }; | 181 }; |
| 178 | 182 |
| 179 // Error message to print for each type of ValidatorProblem. See | 183 // Error message to print for each type of ValidatorProblem. See |
| 180 // member function Render (below) for an explanation of $X directives. | 184 // member function Render (below) for an explanation of $X directives. |
| 181 // TODO(karl): Add information from the collected | 185 // TODO(karl): Add information from the collected |
| 182 // ValidatorInstructionPairProblem (for instruction pairs) to the | 186 // ValidatorInstructionPairProblem (for instruction pairs) to the |
| 183 // error messages printed. | 187 // error messages printed. |
| 184 static const char* ValidatorProblemFormatDirective[kValidatorProblemSize] = { | 188 static const char* ValidatorProblemFormatDirective[kValidatorProblemSize] = { |
| 185 // kProblemUnsafe - An instruction is unsafe -- more information in | 189 // kProblemUnsafe - An instruction is unsafe -- more information in |
| 186 // the SafetyLevel. | 190 // the SafetyLevel. |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 assert(problem < kValidatorProblemSize); | 599 assert(problem < kValidatorProblemSize); |
| 596 RenderText("ncval: ", &buffer, &buffer_size); | 600 RenderText("ncval: ", &buffer, &buffer_size); |
| 597 RenderInstAddress(vaddr, &buffer, &buffer_size); | 601 RenderInstAddress(vaddr, &buffer, &buffer_size); |
| 598 RenderText(" ", &buffer, &buffer_size); | 602 RenderText(" ", &buffer, &buffer_size); |
| 599 Render(&buffer, &buffer_size, | 603 Render(&buffer, &buffer_size, |
| 600 ValidatorProblemFormatDirective[problem], | 604 ValidatorProblemFormatDirective[problem], |
| 601 problem, method, user_data); | 605 problem, method, user_data); |
| 602 } | 606 } |
| 603 | 607 |
| 604 } // namespace nacl_arm_val | 608 } // namespace nacl_arm_val |
| OLD | NEW |