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

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

Issue 693933002: Add MinidumpThreadListWriter::InitializeFromSnapshot() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@minidump_init_from_snapshot_context_new
Patch Set: Address review feedback 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_thread_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_THREAD_SNAPSHOT_H_
16 #define CRASHPAD_SNAPSHOT_TEST_TEST_THREAD_SNAPSHOT_H_
17
18 #include <stdint.h>
19
20 #include "base/basictypes.h"
21 #include "base/memory/scoped_ptr.h"
22 #include "snapshot/cpu_context.h"
23 #include "snapshot/memory_snapshot.h"
24 #include "snapshot/thread_snapshot.h"
25
26 namespace crashpad {
27 namespace test {
28
29 //! \brief A test ThreadSnapshot that can carry arbitrary data for testing
30 //! purposes.
31 class TestThreadSnapshot final : public ThreadSnapshot {
32 public:
33 TestThreadSnapshot();
34 ~TestThreadSnapshot();
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 //! \brief Sets the memory region to be returned by Stack().
52 //!
53 //! \param[in] stack The memory region that Stack() will return. The
54 //! TestThreadSnapshot object takes ownership of \a stack.
55 void SetStack(scoped_ptr<MemorySnapshot> stack) { stack_ = stack.Pass(); }
56
57 void SetThreadID(uint64_t thread_id) { thread_id_ = thread_id; }
58 void SetSuspendCount(int suspend_count) { suspend_count_ = suspend_count; }
59 void SetPriority(int priority) { priority_ = priority; }
60 void SetThreadSpecificDataAddress(uint64_t thread_specific_data_address) {
61 thread_specific_data_address_ = thread_specific_data_address;
62 }
63
64 // ThreadSnapshot:
65
66 const CPUContext* Context() const override;
67 const MemorySnapshot* Stack() const override;
68 uint64_t ThreadID() const override;
69 int SuspendCount() const override;
70 int Priority() const override;
71 uint64_t ThreadSpecificDataAddress() const override;
72
73 private:
74 union {
75 CPUContextX86 x86;
76 CPUContextX86_64 x86_64;
77 } context_union_;
78 CPUContext context_;
79 scoped_ptr<MemorySnapshot> stack_;
80 uint64_t thread_id_;
81 int suspend_count_;
82 int priority_;
83 uint64_t thread_specific_data_address_;
84
85 DISALLOW_COPY_AND_ASSIGN(TestThreadSnapshot);
86 };
87
88 } // namespace test
89 } // namespace crashpad
90
91 #endif // CRASHPAD_SNAPSHOT_TEST_TEST_THREAD_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « snapshot/snapshot.gyp ('k') | snapshot/test/test_thread_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698