Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / validator / x86 / ncval_reg_sfi / ncvalidate_iter_verbose.c
1 /*
2  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 /*
8  * ncvalidate_iter.c
9  * Validate x86 instructions for Native Client
10  *
11  */
12
13 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter.h"
14
15 #include "native_client/src/shared/platform/nacl_log.h"
16 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state_internal.h"
17 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter_internal.h"
18
19 void NaClValidatorStateSetErrorReporter(NaClValidatorState *state,
20                                         NaClErrorReporter *reporter) {
21   switch (reporter->supported_reporter) {
22     case NaClNullErrorReporter:
23     case NaClInstStateErrorReporter:
24       state->error_reporter = reporter;
25       return;
26     default:
27       break;
28   }
29   (*reporter->printf)(
30       reporter,
31       "*** FATAL: using unsupported error reporter! ***\n",
32       "*** NaClInstStateErrorReporter expected but found %s ***\n",
33       NaClErrorReporterSupportedName(reporter->supported_reporter));
34   exit(1);
35 }
36
37 static void NaClVerboseErrorPrintInst(NaClErrorReporter* self,
38                                       struct NaClInstState* inst) {
39   NaClInstStateInstPrint(NaClLogGetGio(), inst);
40 }
41
42 NaClErrorReporter kNaClVerboseErrorReporter = {
43   NaClInstStateErrorReporter,
44   NaClVerboseErrorPrintf,
45   NaClVerboseErrorPrintfV,
46   (NaClPrintInst) NaClVerboseErrorPrintInst
47 };