blob: 289429d0c25a975684be583af39645fba98cee71 [file] [log] [blame]
Jason Molenda3a4ea242010-09-10 07:49:16 +00001//===-- ArchDefaultUnwindPlan-x86.cpp --------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "ArchDefaultUnwindPlan-x86.h"
Chris Lattner2fcb13e2010-10-04 21:24:01 +000011#include "llvm/Support/MachO.h"
Jason Molenda3a4ea242010-09-10 07:49:16 +000012#include "lldb/lldb-private.h"
13#include "lldb/Utility/ArchDefaultUnwindPlan.h"
14#include "lldb/Core/ArchSpec.h"
15#include "lldb/Core/PluginManager.h"
16#include "lldb/lldb-enumerations.h"
17
18using namespace lldb;
19using namespace lldb_private;
20
21lldb_private::UnwindPlan*
22ArchDefaultUnwindPlan_x86::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc)
23{
Chris Lattner2fcb13e2010-10-04 21:24:01 +000024 if (m_cpu == llvm::MachO::CPUTypeX86_64)
Jason Molenda3a4ea242010-09-10 07:49:16 +000025 {
26 return &m_64bit_default;
27 }
Chris Lattner2fcb13e2010-10-04 21:24:01 +000028 if (m_cpu == llvm::MachO::CPUTypeI386)
Jason Molenda3a4ea242010-09-10 07:49:16 +000029 {
30 return &m_32bit_default;
31 }
32 return NULL;
33}
34
35lldb_private::ArchDefaultUnwindPlan *
36ArchDefaultUnwindPlan_x86::CreateInstance (const lldb_private::ArchSpec &arch)
37{
38 uint32_t cpu = arch.GetCPUType ();
Chris Lattner2fcb13e2010-10-04 21:24:01 +000039 if (cpu != llvm::MachO::CPUTypeX86_64 && cpu != llvm::MachO::CPUTypeI386)
Jason Molenda3a4ea242010-09-10 07:49:16 +000040 return NULL;
41
42 return new ArchDefaultUnwindPlan_x86 (cpu);
43}
44
45ArchDefaultUnwindPlan_x86::ArchDefaultUnwindPlan_x86(int cpu) :
46 lldb_private::ArchDefaultUnwindPlan(),
47 m_cpu(cpu),
48 m_32bit_default(),
49 m_64bit_default()
50{
51 UnwindPlan::Row row;
52 UnwindPlan::Row::RegisterLocation regloc;
53
54 m_32bit_default.SetRegisterKind (eRegisterKindGeneric);
55 row.SetCFARegister (LLDB_REGNUM_GENERIC_FP);
56 row.SetCFAOffset (2 * 4);
57 row.SetOffset (0);
58
59 regloc.SetAtCFAPlusOffset (2 * -4);
60 row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc);
61 regloc.SetAtCFAPlusOffset (1 * -4);
62 row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc);
63 regloc.SetIsCFAPlusOffset (0);
64 row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc);
65
66 m_32bit_default.AppendRow (row);
Jason Molenda8280cbe2010-10-25 11:12:07 +000067 m_32bit_default.SetSourceName ("architectural default");
Jason Molenda3a4ea242010-09-10 07:49:16 +000068
69 row.Clear();
70
71 m_64bit_default.SetRegisterKind (eRegisterKindGeneric);
72 row.SetCFARegister (LLDB_REGNUM_GENERIC_FP);
73 row.SetCFAOffset (2 * 8);
74 row.SetOffset (0);
75
76 regloc.SetAtCFAPlusOffset (2 * -8);
77 row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc);
78 regloc.SetAtCFAPlusOffset (1 * -8);
79 row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc);
80 regloc.SetIsCFAPlusOffset (0);
81 row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc);
82
83 m_64bit_default.AppendRow (row);
Jason Molenda8280cbe2010-10-25 11:12:07 +000084 m_64bit_default.SetSourceName ("architectural default");
Jason Molenda3a4ea242010-09-10 07:49:16 +000085}
86
87
88
89
90//------------------------------------------------------------------
91// PluginInterface protocol in UnwindAssemblyParser_x86
92//------------------------------------------------------------------
93
94const char *
95ArchDefaultUnwindPlan_x86::GetPluginName()
96{
97 return "ArchDefaultUnwindPlan_x86";
98}
99
100const char *
101ArchDefaultUnwindPlan_x86::GetShortPluginName()
102{
103 return "archdefaultunwindplan.x86";
104}
105
106
107uint32_t
108ArchDefaultUnwindPlan_x86::GetPluginVersion()
109{
110 return 1;
111}
112
113void
114ArchDefaultUnwindPlan_x86::GetPluginCommandHelp (const char *command, Stream *strm)
115{
116}
117
118Error
119ArchDefaultUnwindPlan_x86::ExecutePluginCommand (Args &command, Stream *strm)
120{
121 Error error;
122 error.SetErrorString("No plug-in command are currently supported.");
123 return error;
124}
125
126Log *
127ArchDefaultUnwindPlan_x86::EnablePluginLogging (Stream *strm, Args &command)
128{
129 return NULL;
130}
131
132void
133ArchDefaultUnwindPlan_x86::Initialize()
134{
135 PluginManager::RegisterPlugin (GetPluginNameStatic(),
136 GetPluginDescriptionStatic(),
137 CreateInstance);
138}
139
140void
141ArchDefaultUnwindPlan_x86::Terminate()
142{
143 PluginManager::UnregisterPlugin (CreateInstance);
144}
145
146
147const char *
148ArchDefaultUnwindPlan_x86::GetPluginNameStatic()
149{
150 return "ArchDefaultUnwindPlan_x86";
151}
152
153const char *
154ArchDefaultUnwindPlan_x86::GetPluginDescriptionStatic()
155{
156 return "i386 and x86_64 architecture default unwind plan assembly plugin.";
157}