Exception: Tem::SecExecError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/tem/sec_exec_error.rb

Overview

Raised when executing a SEC.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secpack, tem_trace, buffer_state, key_state) ⇒ SecExecError

Returns a new instance of SecExecError.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tem/sec_exec_error.rb', line 7

def initialize(secpack, tem_trace, buffer_state, key_state)
  super 'SEC execution failed on the TEM'
  
  if tem_trace
    if tem_trace[:ip]
      @ip_line_info = secpack.line_info_for_addr tem_trace[:ip]
      @ip_label_info = secpack.label_info_for_addr tem_trace[:ip]
    end
    if tem_trace[:sp]
      @sp_line_info = secpack.line_info_for_addr tem_trace[:sp]
    end
  end
  @ip_line_info ||= [0, :unknown, []]
  @ip_label_info ||= [0, :unknown]
  @sp_line_info ||= [0, :unknown, []]
  
  line_ip, atom, backtrace = *@ip_line_info
  set_backtrace backtrace
  @ip_atom = atom
  @ip_label = @ip_label_info[1]
  if tem_trace and tem_trace[:ip]
    @ip_delta = tem_trace[:ip] - line_ip
    @ip_label_delta = tem_trace[:ip] - @ip_label_info[0]
  else
    @ip_delta = @ip_label_delta = 0
  end
  line_sp, atom, backtrace = *@sp_line_info
  @sp_atom = atom
  if tem_trace and tem_trace[:sp]
    @sp_delta = tem_trace[:sp] - line_sp
  else
    @sp_delta = 0
  end
  
  @trace = tem_trace
  @buffer_state = buffer_state
  @key_state = key_state
end

Instance Attribute Details

#buffer_stateObject (readonly)

Returns the value of attribute buffer_state.



4
5
6
# File 'lib/tem/sec_exec_error.rb', line 4

def buffer_state
  @buffer_state
end

#key_stateObject (readonly)

Returns the value of attribute key_state.



4
5
6
# File 'lib/tem/sec_exec_error.rb', line 4

def key_state
  @key_state
end

#line_infoObject (readonly)

Returns the value of attribute line_info.



3
4
5
# File 'lib/tem/sec_exec_error.rb', line 3

def line_info
  @line_info
end

#traceObject (readonly)

Returns the value of attribute trace.



5
6
7
# File 'lib/tem/sec_exec_error.rb', line 5

def trace
  @trace
end

Instance Method Details

#bstat_strObject



46
47
48
49
50
51
52
# File 'lib/tem/sec_exec_error.rb', line 46

def bstat_str
  if @buffer_state.nil?
    "no buffer state available"
  else
    @buffer_state.inspect
  end
end

#inspectObject



86
87
88
# File 'lib/tem/sec_exec_error.rb', line 86

def inspect
  trace_str + "\n" + bstat_str + "\n" + kstat_str
end

#kstat_strObject



54
55
56
57
58
59
60
# File 'lib/tem/sec_exec_error.rb', line 54

def kstat_str
  if @key_state.nil?
    "no key state available"
  else
    @key_state.inspect
  end
end

#to_sObject



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/tem/sec_exec_error.rb', line 73

def to_s
  string = <<ENDSTRING
SECpack execution generated an exception on the TEM

TEM Trace: #{trace_str}
TEM Buffer Status:#{bstat_str}
TEM Key Status:#{kstat_str}

TEM execution error at #{@ip_label}+0x#{'%x' % @ip_label_delta}:
ENDSTRING
  string.strip
end

#trace_strObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/tem/sec_exec_error.rb', line 62

def trace_str
  if @trace.nil?
    "no trace available"
  else
    "ip=#{'%04x' % @trace[:ip]} (#{@ip_atom}+0x#{'%x' % @ip_delta}) " +
    "sp=#{'%04x' % @trace[:sp]} (#{@sp_atom}+0x#{'%x' % @sp_delta}) " +
    "out=#{'%04x' % @trace[:out]} " +
    "pscell=#{'%04x' % @trace[:pscell]}"
  end
end