LLDB  mainline
ExceptionRecord.h
Go to the documentation of this file.
1 //===-- ExceptionRecord.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_Plugins_Process_Windows_ExceptionRecord_H_
10 #define liblldb_Plugins_Process_Windows_ExceptionRecord_H_
11 
13 #include "lldb/lldb-forward.h"
14 #include <dbghelp.h>
15 
16 #include <memory>
17 #include <vector>
18 
19 namespace lldb_private {
20 
21 // ExceptionRecord
22 //
23 // ExceptionRecord defines an interface which allows implementors to receive
24 // notification of events that happen in a debugged process.
26 public:
27  ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
28  m_code = record.ExceptionCode;
29  m_continuable = (record.ExceptionFlags == 0);
30  if (record.ExceptionRecord)
31  m_next_exception.reset(
32  new ExceptionRecord(*record.ExceptionRecord, thread_id));
33  m_exception_addr = reinterpret_cast<lldb::addr_t>(record.ExceptionAddress);
34  m_thread_id = thread_id;
35  m_arguments.assign(record.ExceptionInformation,
36  record.ExceptionInformation + record.NumberParameters);
37  }
38 
39  // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
40  ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
41  : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 0),
42  m_next_exception(nullptr),
43  m_exception_addr(static_cast<lldb::addr_t>(record.ExceptionAddress)),
44  m_thread_id(thread_id),
45  m_arguments(record.ExceptionInformation,
46  record.ExceptionInformation + record.NumberParameters) {
47  // Set up link to nested exception.
48  if (record.ExceptionRecord) {
50  *reinterpret_cast<const MINIDUMP_EXCEPTION *>(record.ExceptionRecord),
51  thread_id));
52  }
53  }
54 
55  virtual ~ExceptionRecord() {}
56 
57  DWORD
58  GetExceptionCode() const { return m_code; }
59  bool IsContinuable() const { return m_continuable; }
61  return m_next_exception.get();
62  }
64 
65  lldb::tid_t GetThreadID() const { return m_thread_id; }
66 
67  const std::vector<ULONG_PTR>& GetExceptionArguments() const { return m_arguments; }
68 
69 private:
70  DWORD m_code;
72  std::shared_ptr<ExceptionRecord> m_next_exception;
75  std::vector<ULONG_PTR> m_arguments;
76 };
77 }
78 
79 #endif
std::shared_ptr< ExceptionRecord > m_next_exception
const ExceptionRecord * GetNextException() const
A class that represents a running process on the host machine.
lldb::addr_t GetExceptionAddress() const
ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
std::vector< ULONG_PTR > m_arguments
ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id)
uint64_t tid_t
Definition: lldb-types.h:86
lldb::tid_t GetThreadID() const
const std::vector< ULONG_PTR > & GetExceptionArguments() const
uint64_t addr_t
Definition: lldb-types.h:83
Definition: SBAddress.h:15