The Pedigree Project  0.1
DwarfCfiAutomaton.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef DWARFCFIAUTOMATON_H
21 #define DWARFCFIAUTOMATON_H
22 
23 #include "pedigree/kernel/debugger/DwarfState.h"
24 #include "pedigree/kernel/processor/types.h"
25 
29 // These three are different - they have a delta/register number stored in the
30 // lower 6 bits.
31 #define DW_CFA_advance_loc 0x40
32 #define DW_CFA_offset 0x80
33 #define DW_CFA_restore 0xc0
34 
35 #define DW_CFA_nop 0x00
36 #define DW_CFA_set_loc 0x01
37 #define DW_CFA_advance_loc1 0x02
38 #define DW_CFA_advance_loc2 0x03
39 #define DW_CFA_advance_loc4 0x04
40 #define DW_CFA_offset_extended 0x05
41 #define DW_CFA_restore_extended 0x06
42 #define DW_CFA_undefined 0x07
43 #define DW_CFA_same_value 0x08
44 #define DW_CFA_register 0x09
45 #define DW_CFA_remember_state 0x0a
46 #define DW_CFA_restore_state 0x0b
47 #define DW_CFA_def_cfa 0x0c
48 #define DW_CFA_def_cfa_register 0x0d
49 #define DW_CFA_def_cfa_offset 0x0e
50 #define DW_CFA_def_cfa_expression 0x0f
51 #define DW_CFA_expression 0x10
52 #define DW_CFA_offset_extended_sf 0x11
53 #define DW_CFA_def_cfa_sf 0x12
54 #define DW_CFA_def_cfa_offset_sf 0x13
55 #define DW_CFA_val_offset 0x14
56 #define DW_CFA_val_offset_sf 0x15
57 #define DW_CFA_val_expression 0x16
58 #define DW_CFA_lo_user 0x1c
59 #define DW_CFA_hi_user 0x3f
60 #define DW_CFA_GNU_args_size 0x2e // GNU extension
61 
74 {
75  public:
85 
93  void initialise(
94  const DwarfState &startingState, uintptr_t nCodeLocation,
95  size_t nCodeLen, int32_t nCodeAlignmentFactor,
96  int32_t nDataAlignmentFactor, uintptr_t nStartingPc);
97 
106  DwarfState *
107  execute(uintptr_t nCodeLocation, size_t nCodeLen, uintptr_t nBreakAt);
108 
109  private:
114  void executeInstruction(uintptr_t &nLocation, uintptr_t &nPc);
115 
120 
125 
130 
135 
139  uintptr_t m_nStartingPc;
140 };
141 
144 #endif
void initialise(const DwarfState &startingState, uintptr_t nCodeLocation, size_t nCodeLen, int32_t nCodeAlignmentFactor, int32_t nDataAlignmentFactor, uintptr_t nStartingPc)
DwarfState * execute(uintptr_t nCodeLocation, size_t nCodeLen, uintptr_t nBreakAt)
void executeInstruction(uintptr_t &nLocation, uintptr_t &nPc)