• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _LIBUNWINDSTACK_REGS_X86_H
18 #define _LIBUNWINDSTACK_REGS_X86_H
19 
20 #include <stdint.h>
21 
22 #include <functional>
23 
24 #include <unwindstack/Elf.h>
25 #include <unwindstack/Regs.h>
26 
27 namespace unwindstack {
28 
29 // Forward declarations.
30 class Memory;
31 struct x86_ucontext_t;
32 
33 class RegsX86 : public RegsImpl<uint32_t> {
34  public:
35   RegsX86();
36   virtual ~RegsX86() = default;
37 
38   ArchEnum Arch() override final;
39 
40   bool SetPcFromReturnAddress(Memory* process_memory) override;
41 
42   bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override;
43 
44   void SetFromUcontext(x86_ucontext_t* ucontext);
45 
46   void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
47 
48   uint64_t pc() override;
49   uint64_t sp() override;
50 
51   void set_pc(uint64_t pc) override;
52   void set_sp(uint64_t sp) override;
53 
54   Regs* Clone() override final;
55 
56   static Regs* Read(void* data);
57 
58   static Regs* CreateFromUcontext(void* ucontext);
59 };
60 
61 }  // namespace unwindstack
62 
63 #endif  // _LIBUNWINDSTACK_REGS_X86_H
64