| ... | ... | @@ -1251,13 +1251,12 @@ const FormValue = union(enum) { |
| 1251 | 1251 | }; |
| 1252 | 1252 | |
| 1253 | 1253 | const Constant = struct { |
| 1254 | | payload: []u8, |
| 1254 | payload: u64, |
| 1255 | 1255 | signed: bool, |
| 1256 | 1256 | |
| 1257 | 1257 | fn asUnsignedLe(self: *const Constant) !u64 { |
| 1258 | | if (self.payload.len > @sizeOf(u64)) return error.InvalidDebugInfo; |
| 1259 | 1258 | if (self.signed) return error.InvalidDebugInfo; |
| 1260 | | return mem.readVarInt(u64, self.payload, builtin.Endian.Little); |
| 1259 | return self.payload; |
| 1261 | 1260 | } |
| 1262 | 1261 | }; |
| 1263 | 1262 | |
| ... | ... | @@ -1442,11 +1441,18 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, size: usize) ! |
| 1442 | 1441 | return parseFormValueBlockLen(allocator, in_stream, block_len); |
| 1443 | 1442 | } |
| 1444 | 1443 | |
| 1445 | | fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, size: usize) !FormValue { |
| 1444 | fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, size: i32) !FormValue { |
| 1446 | 1445 | return FormValue{ |
| 1447 | 1446 | .Const = Constant{ |
| 1448 | 1447 | .signed = signed, |
| 1449 | | .payload = try readAllocBytes(allocator, in_stream, size), |
| 1448 | .payload = switch (size) { |
| 1449 | 1 => try in_stream.readIntLittle(u8), |
| 1450 | 2 => try in_stream.readIntLittle(u16), |
| 1451 | 4 => try in_stream.readIntLittle(u32), |
| 1452 | 8 => try in_stream.readIntLittle(u64), |
| 1453 | -1 => if (signed) try readULeb128(in_stream) else @intCast(u64, try readILeb128(in_stream)), |
| 1454 | else => unreachable, |
| 1455 | }, |
| 1450 | 1456 | }, |
| 1451 | 1457 | }; |
| 1452 | 1458 | } |
| ... | ... | @@ -1484,9 +1490,8 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64 |
| 1484 | 1490 | DW.FORM_data4 => parseFormValueConstant(allocator, in_stream, false, 4), |
| 1485 | 1491 | DW.FORM_data8 => parseFormValueConstant(allocator, in_stream, false, 8), |
| 1486 | 1492 | DW.FORM_udata, DW.FORM_sdata => { |
| 1487 | | const block_len = try readULeb128(in_stream); |
| 1488 | 1493 | const signed = form_id == DW.FORM_sdata; |
| 1489 | | return parseFormValueConstant(allocator, in_stream, signed, block_len); |
| 1494 | return parseFormValueConstant(allocator, in_stream, signed, -1); |
| 1490 | 1495 | }, |
| 1491 | 1496 | DW.FORM_exprloc => { |
| 1492 | 1497 | const size = try readULeb128(in_stream); |