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  // Notes about the `record.ExceptionRecord` field:
29  // In the past, some code tried to parse the nested exception with it, but
30  // in practice, that code just causes Access Violation. I suspect
31  // `ExceptionRecord` here actually points to the address space of the
32  // debuggee process. However, I did not manage to find any official or
33  // unofficial reference that clarifies this point. If anyone would like to
34  // reimplement this, please also keep in mind to check how this behaves when
35  // debugging a WOW64 process. I suspect you may have to use the explicit
36  // `EXCEPTION_RECORD32` and `EXCEPTION_RECORD64` structs.
37  m_code = record.ExceptionCode;
38  m_continuable = (record.ExceptionFlags == 0);
39  m_exception_addr = reinterpret_cast<lldb::addr_t>(record.ExceptionAddress);
40  m_thread_id = thread_id;
41  m_arguments.assign(record.ExceptionInformation,
42  record.ExceptionInformation + record.NumberParameters);
43  }
44 
45  // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
46  ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
47  : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 0),
48  m_exception_addr(static_cast<lldb::addr_t>(record.ExceptionAddress)),
49  m_thread_id(thread_id),
50  m_arguments(record.ExceptionInformation,
51  record.ExceptionInformation + record.NumberParameters) {}
52 
53  virtual ~ExceptionRecord() {}
54 
55  DWORD
56  GetExceptionCode() const { return m_code; }
57  bool IsContinuable() const { return m_continuable; }
59 
60  lldb::tid_t GetThreadID() const { return m_thread_id; }
61 
62  const std::vector<ULONG_PTR>& GetExceptionArguments() const { return m_arguments; }
63 
64 private:
65  DWORD m_code;
69  std::vector<ULONG_PTR> m_arguments;
70 };
71 }
72 
73 #endif
lldb_private::ExceptionRecord::IsContinuable
bool IsContinuable() const
Definition: ExceptionRecord.h:57
lldb_private::ExceptionRecord::GetThreadID
lldb::tid_t GetThreadID() const
Definition: ExceptionRecord.h:60
lldb_private::ExceptionRecord::GetExceptionArguments
const std::vector< ULONG_PTR > & GetExceptionArguments() const
Definition: ExceptionRecord.h:62
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::~ExceptionRecord
virtual ~ExceptionRecord()
Definition: ExceptionRecord.h:53
lldb_private::ExceptionRecord::m_exception_addr
lldb::addr_t m_exception_addr
Definition: ExceptionRecord.h:67
lldb_private::ExceptionRecord::m_continuable
bool m_continuable
Definition: ExceptionRecord.h:66
lldb_private::ExceptionRecord::GetExceptionCode
DWORD GetExceptionCode() const
Definition: ExceptionRecord.h:56
lldb_private::ExceptionRecord::m_code
DWORD m_code
Definition: ExceptionRecord.h:65
lldb_private::ExceptionRecord::GetExceptionAddress
lldb::addr_t GetExceptionAddress() const
Definition: ExceptionRecord.h:58
lldb_private::ExceptionRecord::ExceptionRecord
ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
Definition: ExceptionRecord.h:46
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:69
lldb_private::ExceptionRecord::m_thread_id
lldb::tid_t m_thread_id
Definition: ExceptionRecord.h:68
lldb
Definition: SBAddress.h:15
lldb_private::ExceptionRecord
Definition: ExceptionRecord.h:25
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86