Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: snapshot/test/test_exception_snapshot.h

Issue 698673002: Add MinidumpExceptionWriter::InitializeFromSnapshot() and test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@minidump_init_from_snapshot_thread_new
Patch Set: Rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « snapshot/snapshot.gyp ('k') | snapshot/test/test_exception_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef CRASHPAD_SNAPSHOT_TEST_TEST_EXCEPTION_SNAPSHOT_H_
16 #define CRASHPAD_SNAPSHOT_TEST_TEST_EXCEPTION_SNAPSHOT_H_
17
18 #include <stdint.h>
19
20 #include <vector>
21
22 #include "base/basictypes.h"
23 #include "snapshot/cpu_context.h"
24 #include "snapshot/exception_snapshot.h"
25
26 namespace crashpad {
27 namespace test {
28
29 //! \brief A test ExceptionSnapshot that can carry arbitrary data for testing
30 //! purposes.
31 class TestExceptionSnapshot final : public ExceptionSnapshot {
32 public:
33 TestExceptionSnapshot();
34 ~TestExceptionSnapshot();
35
36 //! \brief Obtains a pointer to the underlying mutable CPUContext structure.
37 //!
38 //! This method is intended to be used by callers to populate the CPUContext
39 //! structure.
40 //!
41 //! \return The same pointer that Context() does, while treating the data as
42 //! mutable.
43 //!
44 //! \attention This returns a non-`const` pointer to this object’s private
45 //! data so that a caller can populate the context structure directly.
46 //! This is done because providing setter interfaces to each field in the
47 //! context structure would be unwieldy and cumbersome. Care must be taken
48 //! to populate the context structure correctly.
49 CPUContext* MutableContext() { return &context_; }
50
51 void SetThreadID(uint64_t thread_id) { thread_id_ = thread_id; }
52 void SetException(uint32_t exception) { exception_ = exception; }
53 void SetExceptionInfo(uint32_t exception_info) {
54 exception_info_ = exception_info;
55 }
56 void SetExceptionAddress(uint64_t exception_address) {
57 exception_address_ = exception_address;
58 }
59 void SetCodes(const std::vector<uint64_t>& codes) { codes_ = codes; }
60
61 // ExceptionSnapshot:
62
63 const CPUContext* Context() const override;
64 uint64_t ThreadID() const override;
65 uint32_t Exception() const override;
66 uint32_t ExceptionInfo() const override;
67 uint64_t ExceptionAddress() const override;
68 const std::vector<uint64_t>& Codes() const override;
69
70 private:
71 union {
72 CPUContextX86 x86;
73 CPUContextX86_64 x86_64;
74 } context_union_;
75 CPUContext context_;
76 uint64_t thread_id_;
77 uint32_t exception_;
78 uint32_t exception_info_;
79 uint64_t exception_address_;
80 std::vector<uint64_t> codes_;
81
82 DISALLOW_COPY_AND_ASSIGN(TestExceptionSnapshot);
83 };
84
85 } // namespace test
86 } // namespace crashpad
87
88 #endif // CRASHPAD_SNAPSHOT_TEST_TEST_EXCEPTION_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « snapshot/snapshot.gyp ('k') | snapshot/test/test_exception_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698