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
lldb_private::ExceptionRecord::IsContinuable
bool IsContinuable() const
Definition: ExceptionRecord.h:59
lldb_private::ExceptionRecord::GetThreadID
lldb::tid_t GetThreadID() const
Definition: ExceptionRecord.h:65
lldb_private::ExceptionRecord::GetExceptionArguments
const std::vector< ULONG_PTR > & GetExceptionArguments() const
Definition: ExceptionRecord.h:67
lldb_private::ExceptionRecord::ExceptionRecord
ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id)
Definition: ExceptionRecord.h:27
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ExceptionRecord::m_next_exception
std::shared_ptr< ExceptionRecord > m_next_exception
Definition: ExceptionRecord.h:72
lldb_private::ExceptionRecord::~ExceptionRecord
virtual ~ExceptionRecord()
Definition: ExceptionRecord.h:55
lldb_private::ExceptionRecord::m_exception_addr
lldb::addr_t m_exception_addr
Definition: ExceptionRecord.h:73
lldb_private::ExceptionRecord::m_continuable
bool m_continuable
Definition: ExceptionRecord.h:71
lldb_private::ExceptionRecord::GetExceptionCode
DWORD GetExceptionCode() const
Definition: ExceptionRecord.h:58
lldb_private::ExceptionRecord::m_code
DWORD m_code
Definition: ExceptionRecord.h:70
lldb_private::ExceptionRecord::GetExceptionAddress
lldb::addr_t GetExceptionAddress() const
Definition: ExceptionRecord.h:63
lldb_private::ExceptionRecord::GetNextException
const ExceptionRecord * GetNextException() const
Definition: ExceptionRecord.h:60
lldb_private::ExceptionRecord::ExceptionRecord
ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
Definition: ExceptionRecord.h:40
windows.h
lldb-forward.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ExceptionRecord::m_arguments
std::vector< ULONG_PTR > m_arguments
Definition: ExceptionRecord.h:75
lldb_private::ExceptionRecord::m_thread_id
lldb::tid_t m_thread_id
Definition: ExceptionRecord.h:74
lldb
Definition: SBAddress.h:15
lldb_private::ExceptionRecord
Definition: ExceptionRecord.h:25
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86