2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2018 The Crashpad Authors
|
2018-10-12 13:12:01 -07:00
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#ifndef CRASHPAD_SNAPSHOT_MINIDUMP_THREAD_SNAPSHOT_MINIDUMP_H_
|
|
|
|
|
#define CRASHPAD_SNAPSHOT_MINIDUMP_THREAD_SNAPSHOT_MINIDUMP_H_
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
2022-06-13 14:44:24 -06:00
|
|
|
|
#include <map>
|
|
|
|
|
|
2018-10-12 13:12:01 -07:00
|
|
|
|
#include "minidump/minidump_extensions.h"
|
2018-10-16 12:23:21 -07:00
|
|
|
|
#include "snapshot/cpu_context.h"
|
2018-10-24 13:22:00 -07:00
|
|
|
|
#include "snapshot/minidump/memory_snapshot_minidump.h"
|
2019-08-13 15:14:20 -07:00
|
|
|
|
#include "snapshot/minidump/minidump_context_converter.h"
|
2018-10-24 13:22:00 -07:00
|
|
|
|
#include "snapshot/thread_snapshot.h"
|
2018-10-12 13:12:01 -07:00
|
|
|
|
#include "util/file/file_reader.h"
|
|
|
|
|
#include "util/misc/initialization_state_dcheck.h"
|
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
//! \brief A ThreadSnapshot based on a thread in a minidump file.
|
|
|
|
|
class ThreadSnapshotMinidump : public ThreadSnapshot {
|
|
|
|
|
public:
|
|
|
|
|
ThreadSnapshotMinidump();
|
2021-09-20 12:55:12 -07:00
|
|
|
|
|
|
|
|
|
ThreadSnapshotMinidump(const ThreadSnapshotMinidump&) = delete;
|
|
|
|
|
ThreadSnapshotMinidump& operator=(const ThreadSnapshotMinidump&) = delete;
|
|
|
|
|
|
2018-10-12 13:12:01 -07:00
|
|
|
|
~ThreadSnapshotMinidump() override;
|
|
|
|
|
|
|
|
|
|
//! \brief Initializes the object.
|
|
|
|
|
//!
|
|
|
|
|
//! \param[in] file_reader A file reader corresponding to a minidump file.
|
|
|
|
|
//! The file reader must support seeking.
|
|
|
|
|
//! \param[in] minidump_thread_rva The file offset in \a file_reader at which
|
|
|
|
|
//! the thread’s MINIDUMP_THREAD structure is located.
|
2018-10-16 12:23:21 -07:00
|
|
|
|
//! \param[in] arch The architecture of the system this thread is running on.
|
|
|
|
|
//! Used to decode CPU Context.
|
2022-06-13 14:44:24 -06:00
|
|
|
|
//! \param[in] thread_names Map from thread ID to thread name previously read
|
|
|
|
|
//! from the minidump's MINIDUMP_THREAD_NAME_LIST.
|
2018-10-12 13:12:01 -07:00
|
|
|
|
//!
|
|
|
|
|
//! \return `true` if the snapshot could be created, `false` otherwise with
|
|
|
|
|
//! an appropriate message logged.
|
2019-08-13 15:14:20 -07:00
|
|
|
|
bool Initialize(FileReaderInterface* file_reader,
|
|
|
|
|
RVA minidump_thread_rva,
|
2022-06-13 14:44:24 -06:00
|
|
|
|
CPUArchitecture arch,
|
|
|
|
|
const std::map<uint32_t, std::string>& thread_names);
|
2018-10-12 13:12:01 -07:00
|
|
|
|
|
|
|
|
|
const CPUContext* Context() const override;
|
|
|
|
|
const MemorySnapshot* Stack() const override;
|
|
|
|
|
uint64_t ThreadID() const override;
|
2022-06-13 14:44:24 -06:00
|
|
|
|
std::string ThreadName() const override;
|
2018-10-12 13:12:01 -07:00
|
|
|
|
int SuspendCount() const override;
|
|
|
|
|
int Priority() const override;
|
|
|
|
|
uint64_t ThreadSpecificDataAddress() const override;
|
|
|
|
|
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
|
|
|
|
|
|
|
|
|
private:
|
2018-10-16 12:23:21 -07:00
|
|
|
|
//! \brief Initializes the CPU Context
|
|
|
|
|
//!
|
|
|
|
|
//! \param[in] minidump_context the raw bytes of the context data from the
|
|
|
|
|
//! minidump file.
|
|
|
|
|
//!
|
|
|
|
|
//! \return `true` if the context could be decoded without error.
|
|
|
|
|
bool InitializeContext(const std::vector<unsigned char>& minidump_context);
|
|
|
|
|
|
2018-10-12 13:12:01 -07:00
|
|
|
|
MINIDUMP_THREAD minidump_thread_;
|
2022-06-13 14:44:24 -06:00
|
|
|
|
std::string thread_name_;
|
2019-08-13 15:14:20 -07:00
|
|
|
|
MinidumpContextConverter context_;
|
2018-10-24 13:22:00 -07:00
|
|
|
|
MemorySnapshotMinidump stack_;
|
2018-10-12 13:12:01 -07:00
|
|
|
|
InitializationStateDcheck initialized_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
|
|
|
|
#endif // CRASHPAD_SNAPSHOT_MINIDUMP_THREAD_SNAPSHOT_MINIDUMP_H_
|