@@ -83,8 +83,8 @@ class Session
8383
8484 include Color
8585
86- def initialize ui
87- @ui = ui
86+ def initialize
87+ @ui = nil
8888 @sr = SourceRepository . new
8989 @bps = { } # bp.key => bp
9090 # [file, line] => LineBreakpoint
@@ -121,9 +121,6 @@ def initialize ui
121121 @tp_load_script . enable
122122
123123 @thread_stopper = thread_stopper
124-
125- activate
126-
127124 self . postmortem = CONFIG [ :postmortem ]
128125 end
129126
@@ -135,7 +132,9 @@ def break_at? file, line
135132 @bps . has_key? [ file , line ]
136133 end
137134
138- def activate on_fork : false
135+ def activate ui = nil , on_fork : false
136+ @ui = ui if ui
137+
139138 @tp_thread_begin &.disable
140139 @tp_thread_begin = nil
141140
@@ -1949,7 +1948,7 @@ def self.start nonstop: false, **kw
19491948
19501949 unless defined? SESSION
19511950 require_relative 'local'
1952- initialize_session UI_LocalConsole . new
1951+ initialize_session { UI_LocalConsole . new }
19531952 end
19541953
19551954 setup_initial_suspend unless nonstop
@@ -1972,7 +1971,7 @@ def self.open_tcp host: nil, port:, nonstop: false, **kw
19721971 if defined? SESSION
19731972 SESSION . reset_ui UI_TcpServer . new ( host : host , port : port )
19741973 else
1975- initialize_session UI_TcpServer . new ( host : host , port : port )
1974+ initialize_session { UI_TcpServer . new ( host : host , port : port ) }
19761975 end
19771976
19781977 setup_initial_suspend unless nonstop
@@ -1985,7 +1984,7 @@ def self.open_unix sock_path: nil, sock_dir: nil, nonstop: false, **kw
19851984 if defined? SESSION
19861985 SESSION . reset_ui UI_UnixDomainServer . new ( sock_dir : sock_dir , sock_path : sock_path )
19871986 else
1988- initialize_session UI_UnixDomainServer . new ( sock_dir : sock_dir , sock_path : sock_path )
1987+ initialize_session { UI_UnixDomainServer . new ( sock_dir : sock_dir , sock_path : sock_path ) }
19891988 end
19901989
19911990 setup_initial_suspend unless nonstop
@@ -2012,9 +2011,10 @@ def self.setup_initial_suspend
20122011 end
20132012
20142013 class << self
2015- define_method :initialize_session do |ui |
2014+ define_method :initialize_session do |& init_ui |
20162015 DEBUGGER__ . info "Session start (pid: #{ Process . pid } )"
2017- ::DEBUGGER__ . const_set ( :SESSION , Session . new ( ui ) )
2016+ ::DEBUGGER__ . const_set ( :SESSION , Session . new )
2017+ SESSION . activate init_ui . call
20182018 load_rc
20192019 end
20202020 end
0 commit comments