1254721Semaste//===-- UnwindMacOSXFrameBackchain.h ----------------------------*- C++ -*-===//
2254721Semaste//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6254721Semaste//
7254721Semaste//===----------------------------------------------------------------------===//
8254721Semaste
9254721Semaste#ifndef lldb_UnwindMacOSXFrameBackchain_h_
10254721Semaste#define lldb_UnwindMacOSXFrameBackchain_h_
11254721Semaste
12254721Semaste#include <vector>
13254721Semaste
14314564Sdim#include "lldb/Target/Unwind.h"
15254721Semaste#include "lldb/lldb-private.h"
16254721Semaste
17314564Sdimclass UnwindMacOSXFrameBackchain : public lldb_private::Unwind {
18314564Sdimpublic:
19314564Sdim  UnwindMacOSXFrameBackchain(lldb_private::Thread &thread);
20296417Sdim
21314564Sdim  ~UnwindMacOSXFrameBackchain() override = default;
22296417Sdim
23254721Semasteprotected:
24314564Sdim  void DoClear() override { m_cursors.clear(); }
25254721Semaste
26314564Sdim  uint32_t DoGetFrameCount() override;
27254721Semaste
28314564Sdim  bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
29360784Sdim                             lldb::addr_t &pc,
30360784Sdim                             bool &behaves_like_zeroth_frame) override;
31254721Semaste
32314564Sdim  lldb::RegisterContextSP
33314564Sdim  DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
34254721Semaste
35314564Sdim  friend class RegisterContextMacOSXFrameBackchain;
36254721Semaste
37314564Sdim  struct Cursor {
38314564Sdim    lldb::addr_t pc; // Program counter
39314564Sdim    lldb::addr_t fp; // Frame pointer for us with backchain
40314564Sdim  };
41314564Sdim
42254721Semasteprivate:
43314564Sdim  std::vector<Cursor> m_cursors;
44254721Semaste
45314564Sdim  size_t GetStackFrameData_i386(const lldb_private::ExecutionContext &exe_ctx);
46254721Semaste
47314564Sdim  size_t
48314564Sdim  GetStackFrameData_x86_64(const lldb_private::ExecutionContext &exe_ctx);
49254721Semaste
50314564Sdim  // For UnwindMacOSXFrameBackchain only
51314564Sdim  DISALLOW_COPY_AND_ASSIGN(UnwindMacOSXFrameBackchain);
52254721Semaste};
53254721Semaste
54296417Sdim#endif // lldb_UnwindMacOSXFrameBackchain_h_
55