| 227 | |
| 228 | |
| 229 | class DwarfType: |
| 230 | def __init__(self): |
| 231 | self.isFundamental = False |
| 232 | self.fundType = 0 |
| 233 | self.udOffset = 0 |
| 234 | self.modifiers = [] |
| 235 | |
| 236 | def parse(self, attr: DwarfAttribute): |
| 237 | assert attr.name in [ |
| 238 | DW_AT.DW_AT_fund_type, |
| 239 | DW_AT.DW_AT_user_def_type, |
| 240 | DW_AT.DW_AT_mod_fund_type, |
| 241 | DW_AT.DW_AT_mod_u_d_type |
| 242 | ], "Unexpected attribute name" |
| 243 | |
| 244 | if attr.name == DW_AT.DW_AT_fund_type: |
| 245 | self.isFundamental = True |
| 246 | self.fundType = attr.value |
| 247 | |
| 248 | elif attr.name == DW_AT.DW_AT_user_def_type: |
| 249 | self.isFundamental = False |
| 250 | self.udOffset = attr.value |
| 251 | |
| 252 | elif attr.name == DW_AT.DW_AT_mod_fund_type: |
| 253 | self.isFundamental = True |
| 254 | assert isinstance(attr.value, list) and len(attr.value) >= 2, "Invalid block length for mod_fund_type" |
| 255 | |
| 256 | data = attr.value |
| 257 | type_data = data[:-2] |
| 258 | |
| 259 | for modifier in type_data: |
| 260 | self.modifiers.append(modifier) |
| 261 | |
| 262 | self.fundType = int.from_bytes(data[-2:], byteorder='big') |
| 263 | |
| 264 | elif attr.name == DW_AT.DW_AT_mod_u_d_type: |
| 265 | self.isFundamental = False |
| 266 | assert isinstance(attr.value, list) and len(attr.value) >= 4, "Invalid block length for mod_u_d_type" |
| 267 | |
| 268 | data = attr.value |
| 269 | type_data = data[:-4] |
| 270 | |
| 271 | for modifier in type_data: |
| 272 | self.modifiers.append(modifier) |
| 273 | |
| 274 | self.udOffset = int.from_bytes(data[-4:], byteorder='big') |
| 275 | |
| 276 | |
| 277 | class DwarfSubscriptDataItem: |