| ... | @@ -1243,9 +1243,7 @@ const FormValue = union(enum) { | ... | @@ -1243,9 +1243,7 @@ const FormValue = union(enum) { |
| 1243 | ExprLoc: []u8, | 1243 | ExprLoc: []u8, |
| 1244 | Flag: bool, | 1244 | Flag: bool, |
| 1245 | SecOffset: u64, | 1245 | SecOffset: u64, |
| 1246 | Ref: []u8, | | |
| 1247 | RefAddr: u64, | 1246 | RefAddr: u64, |
| 1248 | RefSig8: u64, | | |
| 1249 | String: []u8, | 1247 | String: []u8, |
| 1250 | StrPtr: u64, | 1248 | StrPtr: u64, |
| 1251 | }; | 1249 | }; |
| ... | @@ -1465,14 +1463,17 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 { | ... | @@ -1465,14 +1463,17 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 { |
| 1465 | return if (@sizeOf(usize) == 4) u64(try in_stream.readIntLittle(u32)) else if (@sizeOf(usize) == 8) try in_stream.readIntLittle(u64) else unreachable; | 1463 | return if (@sizeOf(usize) == 4) u64(try in_stream.readIntLittle(u32)) else if (@sizeOf(usize) == 8) try in_stream.readIntLittle(u64) else unreachable; |
| 1466 | } | 1464 | } |
| 1467 | | 1465 | |
| 1468 | fn parseFormValueRefLen(allocator: *mem.Allocator, in_stream: var, size: usize) !FormValue { | 1466 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, size: i32) !FormValue { |
| 1469 | const buf = try readAllocBytes(allocator, in_stream, size); | 1467 | return FormValue{ |
| 1470 | return FormValue{ .Ref = buf }; | 1468 | .RefAddr = switch (size) { |
| 1471 | } | 1469 | 1 => try in_stream.readIntLittle(u8), |
| 1472 | | 1470 | 2 => try in_stream.readIntLittle(u16), |
| 1473 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, comptime T: type) !FormValue { | 1471 | 4 => try in_stream.readIntLittle(u32), |
| 1474 | const block_len = try in_stream.readIntLittle(T); | 1472 | 8 => try in_stream.readIntLittle(u64), |
| 1475 | return parseFormValueRefLen(allocator, in_stream, block_len); | 1473 | -1 => try readULeb128(in_stream), |
| | 1474 | else => unreachable, |
| | 1475 | }, |
| | 1476 | }; |
| 1476 | } | 1477 | } |
| 1477 | | 1478 | |
| 1478 | fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64: bool) anyerror!FormValue { | 1479 | fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64: bool) anyerror!FormValue { |
| ... | @@ -1502,17 +1503,14 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64 | ... | @@ -1502,17 +1503,14 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64 |
| 1502 | DW.FORM_flag_present => FormValue{ .Flag = true }, | 1503 | DW.FORM_flag_present => FormValue{ .Flag = true }, |
| 1503 | DW.FORM_sec_offset => FormValue{ .SecOffset = try parseFormValueDwarfOffsetSize(in_stream, is_64) }, | 1504 | DW.FORM_sec_offset => FormValue{ .SecOffset = try parseFormValueDwarfOffsetSize(in_stream, is_64) }, |
| 1504 | | 1505 | |
| 1505 | DW.FORM_ref1 => parseFormValueRef(allocator, in_stream, u8), | 1506 | DW.FORM_ref1 => parseFormValueRef(allocator, in_stream, 1), |
| 1506 | DW.FORM_ref2 => parseFormValueRef(allocator, in_stream, u16), | 1507 | DW.FORM_ref2 => parseFormValueRef(allocator, in_stream, 2), |
| 1507 | DW.FORM_ref4 => parseFormValueRef(allocator, in_stream, u32), | 1508 | DW.FORM_ref4 => parseFormValueRef(allocator, in_stream, 4), |
| 1508 | DW.FORM_ref8 => parseFormValueRef(allocator, in_stream, u64), | 1509 | DW.FORM_ref8 => parseFormValueRef(allocator, in_stream, 8), |
| 1509 | DW.FORM_ref_udata => { | 1510 | DW.FORM_ref_udata => parseFormValueRef(allocator, in_stream, -1), |
| 1510 | const ref_len = try readULeb128(in_stream); | | |
| 1511 | return parseFormValueRefLen(allocator, in_stream, ref_len); | | |
| 1512 | }, | | |
| 1513 | | 1511 | |
| 1514 | DW.FORM_ref_addr => FormValue{ .RefAddr = try parseFormValueDwarfOffsetSize(in_stream, is_64) }, | 1512 | DW.FORM_ref_addr => FormValue{ .RefAddr = try parseFormValueDwarfOffsetSize(in_stream, is_64) }, |
| 1515 | DW.FORM_ref_sig8 => FormValue{ .RefSig8 = try in_stream.readIntLittle(u64) }, | 1513 | DW.FORM_ref_sig8 => FormValue{ .RefAddr = try in_stream.readIntLittle(u64) }, |
| 1516 | | 1514 | |
| 1517 | DW.FORM_string => FormValue{ .String = try readStringRaw(allocator, in_stream) }, | 1515 | DW.FORM_string => FormValue{ .String = try readStringRaw(allocator, in_stream) }, |
| 1518 | DW.FORM_strp => FormValue{ .StrPtr = try parseFormValueDwarfOffsetSize(in_stream, is_64) }, | 1516 | DW.FORM_strp => FormValue{ .StrPtr = try parseFormValueDwarfOffsetSize(in_stream, is_64) }, |