View | Details | Raw Unified | Return to bug 209994
Collapse All | Expand All

(-)debugger/dbgp/stack.rb (-41 / +22 lines)
Lines 1-42 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2005, 2007 IBM Corporation and others.
2
# Copyright (c) 2005, 2007 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
7
#
8
8
9
###############################################################################
9
###############################################################################
10
10
 
11
def get_function_name(binding)
11
12
	s = <<-EOS
12
module XoredDebugger
13
			begin
13
    class StackLevelInfo
14
				 raise ''
14
        def initialize(file, line, method = nil)
15
			rescue
15
            @file = file
16
				$!.backtrace[0] =~/.*\`(.*)\'/
16
            @line = line
17
				$1
17
			@method = method
18
			end
18
			@type = :source
19
		EOS
19
        end
20
	
20
        
21
	function = Kernel.eval(s, binding)
21
        attr_reader :file, :line, :method, :type
22
	object = Kernel.eval('self.class.name', binding)
22
    end # class StackLevelInfo
23
		
24
	if function.nil? or function.empty?
25
		object
26
	else
27
		object + '::' + function
28
	end
29
end
30
31
module XoredDebugger
32
    class StackLevelInfo
33
        def initialize(file, line, method = nil)
34
            @file = file
35
            @line = line
36
			@method = method
37
			@type = :source
38
        end
39
        
40
        attr_reader :file, :line, :method, :type
41
    end # class StackLevelInfo
42
end # module XoredDebugger
23
end # module XoredDebugger
(-)debugger/simple_debugger.rb (-9 / +22 lines)
Lines 17-22 Link Here
17
require 'dbgp/thread_manager'
17
require 'dbgp/thread_manager'
18
require 'context'
18
require 'context'
19
19
20
module Kernel
21
    alias_method(:xored_debugger_set_trace_func, :set_trace_func)
22
    def set_trace_func(proc)
23
        raise "Cannot call 'set_trace_func' method during debugging session."
24
    end
25
end
26
20
module XoredDebugger 
27
module XoredDebugger 
21
    class DebuggerThread < Thread
28
    class DebuggerThread < Thread
22
    end    
29
    end    
Lines 85-92 Link Here
85
            @depth = 0
92
            @depth = 0
86
            catch(:done) do 
93
            catch(:done) do 
87
                begin                  
94
                begin                  
88
   		            log("Setting trace function...")
95
   		            log("Setting trace function...")                  
89
		            set_trace_func proc { |event, file, line, id, binding, klass, *rest|
96
		            xored_debugger_set_trace_func proc { |event, file, line, id, binding, klass, *rest|
90
		                trace(event, file, line, id, binding, klass)
97
		                trace(event, file, line, id, binding, klass)
91
		            }
98
		            }
92
	            end              
99
	            end              
Lines 95-101 Link Here
95
102
96
        
103
        
97
        def terminate
104
        def terminate
98
            set_trace_func nil
105
            xored_debugger_set_trace_func nil
99
            log("Tracing function was unset")             
106
            log("Tracing function was unset")             
100
            super
107
            super
101
        end
108
        end
Lines 122-135 Link Here
122
                # Absolute path
129
                # Absolute path
123
                ex_file = File.expand_path(file) # Absolute file path                         
130
                ex_file = File.expand_path(file) # Absolute file path                         
124
131
125
                # Skipping startup and shutdown code
126
                if (skip_startup_and_shutdown?(ex_file))
127
                    return      
128
                end     
129
130
                # Output handling
132
                # Output handling
131
                case event
133
                case event
132
                    when 'line'                         
134
                    when 'line'                         
135
                        # Skipping startup and shutdown code
136
                        if (skip_startup_and_shutdown?(ex_file))
137
                            return      
138
                        end     
139
133
                        # Don't debug debugger :)                          
140
                        # Don't debug debugger :)                          
134
                        if (in_debugger_code?(thread))
141
                        if (in_debugger_code?(thread))
135
                            return
142
                            return
Lines 158-166 Link Here
158
                        
165
                        
159
                    when 'call'                       
166
                    when 'call'                       
160
                        thread.stack_manager.stack.push(binding, ex_file, line)
167
                        thread.stack_manager.stack.push(binding, ex_file, line)
161
    
168
                        if (Thread.current == Thread.main)
169
	                        @depth += 1
170
                        end    
171
                        
162
                    when 'return' 
172
                    when 'return' 
163
                        thread.stack_manager.stack.pop                                           
173
                        thread.stack_manager.stack.pop                                           
174
                        if (Thread.current == Thread.main)
175
	                        @depth -= 1
176
                        end
164
177
165
                    when 'c-call'
178
                    when 'c-call'
166
                        if (Thread.current == Thread.main)
179
                        if (Thread.current == Thread.main)
(-)debugger/stack_manager.rb (+18 lines)
Lines 10-15 Link Here
10
10
11
require 'dbgp/managers/stack'
11
require 'dbgp/managers/stack'
12
12
13
module Kernel
14
    def xored_debugger_current_method
15
        caller[0] =~ /\d:in `([^']+)'/
16
        $1
17
    end 
18
end
19
13
module XoredDebugger
20
module XoredDebugger
14
	
21
	
15
    # DBGP stack model, depth = N, zero-index is for top-level frame
22
    # DBGP stack model, depth = N, zero-index is for top-level frame
Lines 87-92 Link Here
87
					
94
					
88
			StackLevelInfo.new(level[:file], level[:line], get_function_name(level[:binding]))
95
			StackLevelInfo.new(level[:file], level[:line], get_function_name(level[:binding]))
89
		end
96
		end
97
        
98
        def get_function_name(binding)
99
            function = Kernel.eval("xored_debugger_current_method", binding)
100
            object = Kernel.eval('self.class.name', binding)
101
                
102
            if function.nil? or function.empty?
103
                object
104
            else
105
                object + '::' + function
106
            end
107
        end        
90
	end # class FullStackManager
108
	end # class FullStackManager
91
109
92
end # module
110
end # module

Return to bug 209994