File: ExceptionRecord.h

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (79 lines) | stat: -rw-r--r-- 2,768 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//===-- ExceptionRecord.h ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_Plugins_Process_Windows_ExceptionRecord_H_
#define liblldb_Plugins_Process_Windows_ExceptionRecord_H_

#include "lldb/Host/windows/windows.h"
#include "lldb/lldb-forward.h"
#include <dbghelp.h>

#include <memory>
#include <vector>

namespace lldb_private {

// ExceptionRecord
//
// ExceptionRecord defines an interface which allows implementors to receive
// notification of events that happen in a debugged process.
class ExceptionRecord {
public:
  ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
    m_code = record.ExceptionCode;
    m_continuable = (record.ExceptionFlags == 0);
    if (record.ExceptionRecord)
      m_next_exception.reset(
          new ExceptionRecord(*record.ExceptionRecord, thread_id));
    m_exception_addr = reinterpret_cast<lldb::addr_t>(record.ExceptionAddress);
    m_thread_id = thread_id;
    m_arguments.assign(record.ExceptionInformation,
                       record.ExceptionInformation + record.NumberParameters);
  }

  // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
  ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
      : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 0),
        m_next_exception(nullptr),
        m_exception_addr(static_cast<lldb::addr_t>(record.ExceptionAddress)),
        m_thread_id(thread_id),
        m_arguments(record.ExceptionInformation,
                    record.ExceptionInformation + record.NumberParameters) {
    // Set up link to nested exception.
    if (record.ExceptionRecord) {
      m_next_exception.reset(new ExceptionRecord(
          *reinterpret_cast<const MINIDUMP_EXCEPTION *>(record.ExceptionRecord),
          thread_id));
    }
  }

  virtual ~ExceptionRecord() {}

  DWORD
  GetExceptionCode() const { return m_code; }
  bool IsContinuable() const { return m_continuable; }
  const ExceptionRecord *GetNextException() const {
    return m_next_exception.get();
  }
  lldb::addr_t GetExceptionAddress() const { return m_exception_addr; }

  lldb::tid_t GetThreadID() const { return m_thread_id; }

  const std::vector<ULONG_PTR>& GetExceptionArguments() const { return m_arguments; }

private:
  DWORD m_code;
  bool m_continuable;
  std::shared_ptr<ExceptionRecord> m_next_exception;
  lldb::addr_t m_exception_addr;
  lldb::tid_t m_thread_id;
  std::vector<ULONG_PTR> m_arguments;
};
}

#endif