From: Mark Volkmann Date: 2006-02-28T23:23:33+09:00 Subject: Re: Q: How to initialize debugger's state when starting On 2/23/06, Matthias Georgi wrote: > A short hack. > Make a copy of debug.rb and put these lines right after the Context > class. > > class Context > alias original_readline readline > def readline(prompt, hist) > @rc_file ||= File.readlines("debug.rc") > if @rc_file.empty? > original_readline(prompt, hist) > else > @rc_file.shift > end > end > end > > Now create a file debug.rc with your desired breakpoint: > b 100 > b 200 > > Start the debugger: > ruby -r./debug myscript.rb Cool idea! However, if you don't have a debug.rc file, this doesn't work. I tried to change it to handle that case as follows, but it's still not quite right. Breakpoints I set in debug.rc are listed when I run "b", but when I run "c" to continue execution, it doesn't stop at them. However, if I issue the same break commands in the debugger, they work. Can you see what I'm doing wrong? class Context alias original_readline readline def readline(prompt, history) # If config file exists and hasn't been read yet, read it. if not @rc_file and File.exists?('debug.rc') @rc_file = File.readlines('debug.rc') end if @rc_file and not @rc_file.empty? @rc_file.shift else original_readline(prompt, history) end end end -- R. Mark Volkmann Partner, Object Computing, Inc.