| ... | ... | @@ -318,6 +318,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 318 | 318 | |
| 319 | 319 | const opcode = try stream.reader().readByte(); |
| 320 | 320 | if (options.call_frame_context and !isOpcodeValidInCFA(opcode)) return error.InvalidCFAOpcode; |
| 321 | const operand = try readOperand(stream, opcode, context); |
| 321 | 322 | switch (opcode) { |
| 322 | 323 | |
| 323 | 324 | // 2.5.1.1: Literal Encodings |
| ... | ... | @@ -333,10 +334,10 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 333 | 334 | OP.const8s, |
| 334 | 335 | OP.constu, |
| 335 | 336 | OP.consts, |
| 336 | | => try self.stack.append(allocator, .{ .generic = (try readOperand(stream, opcode, context)).?.generic }), |
| 337 | => try self.stack.append(allocator, .{ .generic = operand.?.generic }), |
| 337 | 338 | |
| 338 | 339 | OP.const_type => { |
| 339 | | const const_type = (try readOperand(stream, opcode, context)).?.const_type; |
| 340 | const const_type = operand.?.const_type; |
| 340 | 341 | try self.stack.append(allocator, .{ .const_type = .{ |
| 341 | 342 | .type_offset = const_type.type_offset, |
| 342 | 343 | .value_bytes = const_type.value_bytes, |
| ... | ... | @@ -348,7 +349,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 348 | 349 | => { |
| 349 | 350 | if (context.compile_unit == null) return error.IncompleteExpressionContext; |
| 350 | 351 | if (context.debug_addr == null) return error.IncompleteExpressionContext; |
| 351 | | const debug_addr_index = (try readOperand(stream, opcode, context)).?.generic; |
| 352 | const debug_addr_index = operand.?.generic; |
| 352 | 353 | const offset = context.compile_unit.?.addr_base + debug_addr_index; |
| 353 | 354 | if (offset >= context.debug_addr.?.len) return error.InvalidExpression; |
| 354 | 355 | const value = mem.readIntSliceNative(usize, context.debug_addr.?[offset..][0..@sizeOf(usize)]); |
| ... | ... | @@ -360,7 +361,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 360 | 361 | if (context.compile_unit == null) return error.IncompleteExpressionContext; |
| 361 | 362 | if (context.compile_unit.?.frame_base == null) return error.IncompleteExpressionContext; |
| 362 | 363 | |
| 363 | | const offset: i64 = @intCast((try readOperand(stream, opcode, context)).?.generic); |
| 364 | const offset: i64 = @intCast(operand.?.generic); |
| 364 | 365 | _ = offset; |
| 365 | 366 | |
| 366 | 367 | switch (context.compile_unit.?.frame_base.?.*) { |
| ... | ... | @@ -384,7 +385,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 384 | 385 | => { |
| 385 | 386 | if (context.thread_context == null) return error.IncompleteExpressionContext; |
| 386 | 387 | |
| 387 | | const base_register = (try readOperand(stream, opcode, context)).?.base_register; |
| 388 | const base_register = operand.?.base_register; |
| 388 | 389 | var value: i64 = @intCast(mem.readIntSliceNative(usize, try abi.regBytes( |
| 389 | 390 | context.thread_context.?, |
| 390 | 391 | base_register.base_register, |
| ... | ... | @@ -394,7 +395,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 394 | 395 | try self.stack.append(allocator, .{ .generic = @intCast(value) }); |
| 395 | 396 | }, |
| 396 | 397 | OP.regval_type => { |
| 397 | | const register_type = (try readOperand(stream, opcode, context)).?.register_type; |
| 398 | const register_type = operand.?.register_type; |
| 398 | 399 | const value = mem.readIntSliceNative(usize, try abi.regBytes( |
| 399 | 400 | context.thread_context.?, |
| 400 | 401 | register_type.register, |
| ... | ... | @@ -418,7 +419,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 418 | 419 | _ = self.stack.pop(); |
| 419 | 420 | }, |
| 420 | 421 | OP.pick, OP.over => { |
| 421 | | const stack_index = if (opcode == OP.over) 1 else (try readOperand(stream, opcode, context)).?.generic; |
| 422 | const stack_index = if (opcode == OP.over) 1 else operand.?.generic; |
| 422 | 423 | if (stack_index >= self.stack.items.len) return error.InvalidExpression; |
| 423 | 424 | try self.stack.append(allocator, self.stack.items[self.stack.items.len - 1 - stack_index]); |
| 424 | 425 | }, |
| ... | ... | @@ -459,8 +460,6 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 459 | 460 | _ = addr_space_identifier; |
| 460 | 461 | |
| 461 | 462 | if (context.isValidMemory) |isValidMemory| if (!isValidMemory(addr)) return error.InvalidExpression; |
| 462 | | |
| 463 | | const operand = try readOperand(stream, opcode, context); |
| 464 | 463 | const size = switch (opcode) { |
| 465 | 464 | OP.deref, |
| 466 | 465 | OP.xderef, |
| ... | ... | @@ -594,7 +593,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 594 | 593 | }, |
| 595 | 594 | OP.plus_uconst => { |
| 596 | 595 | if (self.stack.items.len == 0) return error.InvalidExpression; |
| 597 | | const constant = (try readOperand(stream, opcode, context)).?.generic; |
| 596 | const constant = operand.?.generic; |
| 598 | 597 | self.stack.items[self.stack.items.len - 1] = .{ |
| 599 | 598 | .generic = try std.math.add(addr_type, try self.stack.items[self.stack.items.len - 1].asIntegral(), constant), |
| 600 | 599 | }; |
| ... | ... | @@ -663,7 +662,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 663 | 662 | } |
| 664 | 663 | }, |
| 665 | 664 | OP.skip, OP.bra => { |
| 666 | | const branch_offset = (try readOperand(stream, opcode, context)).?.branch_offset; |
| 665 | const branch_offset = operand.?.branch_offset; |
| 667 | 666 | const condition = if (opcode == OP.bra) blk: { |
| 668 | 667 | if (self.stack.items.len == 0) return error.InvalidExpression; |
| 669 | 668 | break :blk try self.stack.pop().asIntegral() != 0; |
| ... | ... | @@ -683,7 +682,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 683 | 682 | OP.call4, |
| 684 | 683 | OP.call_ref, |
| 685 | 684 | => { |
| 686 | | const debug_info_offset = (try readOperand(stream, opcode, context)).?.generic; |
| 685 | const debug_info_offset = operand.?.generic; |
| 687 | 686 | _ = debug_info_offset; |
| 688 | 687 | |
| 689 | 688 | // TODO: Load a DIE entry at debug_info_offset in a .debug_info section (the spec says that it |
| ... | ... | @@ -696,7 +695,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 696 | 695 | // 2.5.1.6: Type Conversions |
| 697 | 696 | OP.convert => { |
| 698 | 697 | if (self.stack.items.len == 0) return error.InvalidExpression; |
| 699 | | const type_offset = (try readOperand(stream, opcode, context)).?.generic; |
| 698 | const type_offset = operand.?.generic; |
| 700 | 699 | |
| 701 | 700 | // TODO: Load the DW_TAG_base_type entries in context.compile_unit and verify both types are the same size |
| 702 | 701 | const value = self.stack.items[self.stack.items.len - 1]; |
| ... | ... | @@ -710,7 +709,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 710 | 709 | }, |
| 711 | 710 | OP.reinterpret => { |
| 712 | 711 | if (self.stack.items.len == 0) return error.InvalidExpression; |
| 713 | | const type_offset = (try readOperand(stream, opcode, context)).?.generic; |
| 712 | const type_offset = operand.?.generic; |
| 714 | 713 | |
| 715 | 714 | // TODO: Load the DW_TAG_base_type entries in context.compile_unit and verify both types are the same size |
| 716 | 715 | const value = self.stack.items[self.stack.items.len - 1]; |
| ... | ... | @@ -745,7 +744,7 @@ pub fn StackMachine(comptime options: ExpressionOptions) type { |
| 745 | 744 | // 2.5.1.7: Special Operations |
| 746 | 745 | OP.nop => {}, |
| 747 | 746 | OP.entry_value => { |
| 748 | | const block = (try readOperand(stream, opcode, context)).?.block; |
| 747 | const block = operand.?.block; |
| 749 | 748 | if (block.len == 0) return error.InvalidSubExpression; |
| 750 | 749 | |
| 751 | 750 | // TODO: The spec states that this sub-expression needs to observe the state (ie. registers) |