| 148 | |
| 149 | |
| 150 | class DwarfAttribute: |
| 151 | def __init__(self): |
| 152 | self.name: int = 0 |
| 153 | self.value: int | List[int] = None |
| 154 | |
| 155 | def parse(self, data: List[int], index: int) -> int: |
| 156 | self.name = int.from_bytes(data[index:index+2], byteorder='big') |
| 157 | index += 2 |
| 158 | at_form = self.name & 0xF |
| 159 | if at_form == DW_FORM.DATA2: |
| 160 | self.value = int.from_bytes(data[index:index+2], byteorder='big') |
| 161 | index += 2 |
| 162 | elif at_form == DW_FORM.REF: |
| 163 | self.value = int.from_bytes(data[index:index+4], byteorder='big') |
| 164 | index += 4 |
| 165 | elif at_form == DW_FORM.BLOCK2: |
| 166 | block_len = int.from_bytes(data[index:index+2], byteorder='big') |
| 167 | index += 2 |
| 168 | self.value = data[index:index+block_len] |
| 169 | index += block_len |
| 170 | else: |
| 171 | print("Unhandled form:", at_form) |
| 172 | exit(0) |
| 173 | return index |
| 174 | |
| 175 | |
| 176 | class DwarfLocationAtom: |