1 : /*
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
4 : * found in the LICENSE file.
5 : */
6 :
7 : #ifndef NATIVE_CLIENT_SOURCE_TRUSTED_VALIDATOR_ARM_PROBLEM_REPORTER_H_
8 : #define NATIVE_CLIENT_SOURCE_TRUSTED_VALIDATOR_ARM_PROBLEM_REPORTER_H_
9 :
10 : // Problem reporter utility that converts reported problems into C
11 : // strings.
12 :
13 : #include "native_client/src/trusted/validator_arm/validator.h"
14 :
15 : namespace nacl_arm_val {
16 :
17 : // ProblemSink that converts the (internal) user data into a string
18 : // error message, which is then processed using the (derived) method
19 : // ReportProblemMessage.
20 : class ProblemReporter : public ProblemSink {
21 : public:
22 0 : ProblemReporter() {}
23 0 : virtual ~ProblemReporter() {}
24 :
25 : // The following override inherited virtuals.
26 : virtual void ReportProblemDiagnostic(nacl_arm_dec::Violation violation,
27 : uint32_t vaddr,
28 : const char* format, ...)
29 : // Note: format is the 4th argument because of implicit this.
30 : ATTRIBUTE_FORMAT_PRINTF(4, 5);
31 :
32 : protected:
33 : // Virtual called once the diagnostic message of ReportProblemDiagnostic,
34 : // or ReportProblemInternal, has been generated.
35 : virtual void ReportProblemMessage(nacl_arm_dec::Violation violation,
36 : uint32_t vaddr,
37 : const char* message) = 0;
38 :
39 : private:
40 : // Define a buffer to generate error messages into.
41 : static const size_t kBufferSize = 256;
42 : char buffer[kBufferSize];
43 : NACL_DISALLOW_COPY_AND_ASSIGN(ProblemReporter);
44 : };
45 :
46 : } // namespace
47 :
48 : #endif // NATIVE_CLIENT_SOURCE_TRUSTED_VALIDATOR_ARM_PROBLEM_REPORTER_H_
|