Class: Debase::Context

Inherits:
Object show all
Defined in:
lib/debase/context.rb,
lib/debase/rbx/context.rb

Constant Summary collapse

@@max_thread_num =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thread) ⇒ Context

Returns a new instance of Context.



8
9
10
11
12
# File 'lib/debase/rbx/context.rb', line 8

def initialize(thread)
  @thread = thread
  @thnum = @@max_thread_num
  @@max_thread_num = @@max_thread_num + 1
end

Instance Attribute Details

#thnumObject (readonly)

Returns the value of attribute thnum.



6
7
8
# File 'lib/debase/rbx/context.rb', line 6

def thnum
  @thnum
end

#threadObject (readonly)

Returns the value of attribute thread.



6
7
8
# File 'lib/debase/rbx/context.rb', line 6

def thread
  @thread
end

Instance Method Details

#at_breakpoint(breakpoint) ⇒ Object



21
22
23
# File 'lib/debase/context.rb', line 21

def at_breakpoint(breakpoint)
  handler.at_breakpoint(self, breakpoint)
end

#at_catchpoint(excpt) ⇒ Object



25
26
27
# File 'lib/debase/context.rb', line 25

def at_catchpoint(excpt)
  handler.at_catchpoint(self, excpt)
end

#at_line(file, line) ⇒ Object



34
35
36
# File 'lib/debase/context.rb', line 34

def at_line(file, line)
  handler.at_line(self, file, line)
end

#at_return(file, line) ⇒ Object



38
39
40
# File 'lib/debase/context.rb', line 38

def at_return(file, line)
  handler.at_return(self, file, line)
end

#at_tracing(file, line) ⇒ Object



29
30
31
32
# File 'lib/debase/context.rb', line 29

def at_tracing(file, line)
  @tracing_started = true if File.identical?(file, File.join(Debugger::INITIAL_DIR, Debugger::PROG_SCRIPT))
  handler.at_tracing(self, file, line) if @tracing_started
end

#clear_frame_infoObject



42
43
44
# File 'lib/debase/rbx/context.rb', line 42

def clear_frame_info
  @frames = nil
end

#dead?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/debase/rbx/context.rb', line 54

def dead?
  !@thread.alive?
end

#fill_frame_info(locations) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/debase/rbx/context.rb', line 34

def fill_frame_info(locations)
  @frames = []
  locations.each do |loc|
    @frames << Frame.new(loc)
  end
  @frames
end

#frame_args_info(frame_no = 0) ⇒ Object



13
14
15
# File 'lib/debase/context.rb', line 13

def frame_args_info(frame_no=0)
  nil
end

#frame_binding(frame = 0) ⇒ Object



22
23
24
# File 'lib/debase/rbx/context.rb', line 22

def frame_binding(frame=0)
  @frames[frame].binding
end

#frame_class(frame_no = 0) ⇒ Object



9
10
11
# File 'lib/debase/context.rb', line 9

def frame_class(frame_no=0)
  frame_self(frame_no).class
end

#frame_file(frame = 0) ⇒ Object



14
15
16
# File 'lib/debase/rbx/context.rb', line 14

def frame_file(frame=0)
  @frames[frame].file
end

#frame_line(frame = 0) ⇒ Object



18
19
20
# File 'lib/debase/rbx/context.rb', line 18

def frame_line(frame=0)
  @frames[frame].line
end

#frame_locals(frame_no = 0) ⇒ Object



3
4
5
6
7
# File 'lib/debase/context.rb', line 3

def frame_locals(frame_no=0)
  frame_binding(frame_no).eval('local_variables.inject({}){|__h, __v| __h[__v.to_s] = eval(__v.to_s); __h}')
rescue => e
  {'debase-debug' => "*Evaluation error: '#{e}'" }
end

#frame_self(frame = 0) ⇒ Object



26
27
28
# File 'lib/debase/rbx/context.rb', line 26

def frame_self(frame=0)
  @frames[frame].self
end

#handlerObject



17
18
19
# File 'lib/debase/context.rb', line 17

def handler
  Debase.handler or raise "No interface loaded"
end

#ignored?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/debase/rbx/context.rb', line 50

def ignored?
  thread.is_a? DebugThread
end

#stack_sizeObject



30
31
32
# File 'lib/debase/rbx/context.rb', line 30

def stack_size
  @frames.size
end

#stop_reasonObject



46
47
48
# File 'lib/debase/rbx/context.rb', line 46

def stop_reason
  :breakpoint
end