Class: RubyDebugClient
- Inherits:
-
Object
- Object
- RubyDebugClient
- Includes:
- Observable
- Defined in:
- ext/ae-ruby-debug/ae-ruby-debug.rb
Defined Under Namespace
Classes: Var
Instance Method Summary collapse
- #add_listener(_caller, _method = :rdebug_client_update) ⇒ Object
- #debug_dump(_exp) ⇒ Object
- #debug_eval(_exp) ⇒ Object
-
#global_variables ⇒ Object
returns the global variables and there values.
-
#initialize(_controller, _server = 'localhost', _port = 8989, _timeout = 0) ⇒ RubyDebugClient
constructor
A new instance of RubyDebugClient.
-
#instance_variables_new(_this = 'self') ⇒ Object
returns the instance variables and there values.
- #is_alive? ⇒ Boolean
- #is_busy? ⇒ Boolean
- #is_debugging_ready? ⇒ Boolean
- #kill ⇒ Object
-
#local_variables ⇒ Object
returns the local variables and there values.
- #notify(_command, _result = nil) ⇒ Object
- #quit ⇒ Object
- #quit_no ⇒ Object
- #quit_yes ⇒ Object
- #resume ⇒ Object
- #set_breakpoint(_file, _line) ⇒ Object
- #socket_session ⇒ Object
-
#stacktrace ⇒ Object
return the current stack trace.
- #start_session ⇒ Object
- #step_into ⇒ Object
- #step_out ⇒ Object
- #step_over ⇒ Object
- #stop_session ⇒ Object
- #unset_breakpoint(_id) ⇒ Object
-
#variables(_type) ⇒ Object
returns the local variables and there values.
- #where ⇒ Object
- #yaml_pseudo_load(_obj) ⇒ Object
Constructor Details
#initialize(_controller, _server = 'localhost', _port = 8989, _timeout = 0) ⇒ RubyDebugClient
Returns a new instance of RubyDebugClient.
995 996 997 998 999 1000 1001 1002 1003 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 995 def initialize(_controller, _server='localhost', _port=8989, _timeout=0) @controller = _controller @session = nil @server = _server @port = _port @timeout = _timeout.to_i @busy = false @pend = false end |
Instance Method Details
#add_listener(_caller, _method = :rdebug_client_update) ⇒ Object
1005 1006 1007 1008 1009 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1005 def add_listener(_caller, _method=:rdebug_client_update) if _caller.respond_to? :rdebug_client_update ObserverCallback.new(self,_caller,:rdebug_client_update) end end |
#debug_dump(_exp) ⇒ Object
1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1261 def debug_dump(_exp) var = nil if @valuobjs.nil? @valuobjs = Array.new else @valuobjs.clear end begin _to_eval = read("eval YAML::dump(#{_exp})") if _to_eval.include?('Exception:') _to_eval = read("eval require 'pp';eval #{_exp}.pretty_inspect") var = eval(_to_eval) #var = "?" else _str = eval(_to_eval) _str.gsub!('!ruby/object:', '!') _obj = YAML::load(_str) var = yaml_pseudo_load(_obj) end rescue Exception => e Arcadia.console(self, 'msg'=>"exception on eval #{_exp} :#{e.inspect}") #Arcadia.new_msg(self,"exception on eval #{_exp} :#{e.inspect}") var = nil end return var end |
#debug_eval(_exp) ⇒ Object
1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1356 def debug_eval(_exp) if command("eval #{res=_exp}.to_s + '|||' + #{res}.class.to_s") begin _str = eval(read) _value, _class = _str.split('|||') rescue Exception => e _value = "?" _class = "?" end return Var.new(_value, _class) else return Var.new("?", "?") end end |
#global_variables ⇒ Object
returns the global variables and there values
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1392 def global_variables command("eval global_variables") variables = [] begin variables = eval(read) rescue Exception variables = [] end variable_values = Hash.new variables.each do |var| command("eval #{var}.to_s") variable_values[var] = read end return variable_values end |
#instance_variables_new(_this = 'self') ⇒ Object
returns the instance variables and there values
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1290 def instance_variables_new(_this='self') command("eval #{_this}.instance_variables") variables = [] begin variables = eval(read) rescue Exception variables = [] end @consider = Array.new variable_values = Hash.new variables.each do |var| #next if var != '@objs' # command("eval require 'pp'; #{var}.pretty_inspect() + '|||' + #{var}.class.to_s") command("eval YAML::dump(#{var})") _str = eval read #Arcadia.new_msg(self,"value passato 1 ="+_str) _str.gsub!('!ruby/object:', '!') #Arcadia.new_msg(self,"value passato 2 ="+_str) _obj = YAML::load(_str) _xvalue = yaml_pseudo_load(_obj) if _xvalue.class == Hash _xclass = _xvalue['__CLASS__'] else _xclass = _xvalue.class.to_s end #_vvv = eval(_value) #Arcadia.new_msg(self,"vvv class="+_vvv.class.to_s) #Arcadia.new_msg(self,"value="+_xvalue.inspect) #Arcadia.new_msg(self,"class="+_xclass) variable_values[var] = Var.new(_xvalue, _xclass) end return variable_values end |
#is_alive? ⇒ Boolean
1027 1028 1029 1030 1031 1032 1033 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1027 def is_alive? #p "===>@session=#{@session}" #p "===>@session.closed?=#{@session.closed?}" if @session #p "===>@pend=#{@pend}" !(@session.nil? || @session.closed? || @pend) #([email protected]? && [email protected]? && !@pend) end |
#is_busy? ⇒ Boolean
1023 1024 1025 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1023 def is_busy? @busy end |
#is_debugging_ready? ⇒ Boolean
1019 1020 1021 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1019 def is_debugging_ready? is_alive? && !is_busy? end |
#kill ⇒ Object
1065 1066 1067 1068 1069 1070 1071 1072 1073 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1065 def kill begin @session.close if is_alive? @session=nil rescue Exception => e Arcadia.console(self, 'msg'=>"Error on close session : #{e.class}:#{e.}", 'level'=>'debug') #Arcadia.new_debug_msg(self,"Error on close session : #{e.class}:#{e.message}") end end |
#local_variables ⇒ Object
returns the local variables and there values
1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1372 def local_variables command("eval local_variables") variables = [] begin variables = eval(read) rescue Exception variables = [] end variable_values = Hash.new variables.each do |var| command("eval #{var}.to_s + '|||' + #{var}.class.to_s") _str = eval(read) _value, _class = _str.split('|||') variable_values[var] = Var.new(_value, eval(_class)) end return variable_values end |
#notify(_command, _result = nil) ⇒ Object
1011 1012 1013 1014 1015 1016 1017 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1011 def notify(_command, _result=nil) #Arcadia.new_debug_msg(self,"notify=>#{_command}") @busy = false changed notify_observers(_command, _result) _result end |
#quit ⇒ Object
1177 1178 1179 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1177 def quit notify("quit", read("q")) end |
#quit_no ⇒ Object
1187 1188 1189 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1187 def quit_no notify("quit_no", read("n")) end |
#quit_yes ⇒ Object
1181 1182 1183 1184 1185 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1181 def quit_yes notify("quit_yes", read("y")) #DebugContract.instance.debug_end(self) kill end |
#resume ⇒ Object
1169 1170 1171 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1169 def resume notify("cont", read("cont")) end |
#set_breakpoint(_file, _line) ⇒ Object
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1409 def set_breakpoint(_file, _line) #_line = _line + 1 text = read("break #{_file}:#{_line}") return if text.nil? #p text breakpoint_no = -1 #matches = text.match(/Set breakpoint ([0-9]*)?/) matches = text.downcase.match(/breakpoint ([0-9]*)?/) #Arcadia.new_error_msg(self, "text=#{text}") #Arcadia.new_error_msg(self, "matches[1]=#{matches[1]}") breakpoint_no = matches[1].to_i if matches && (matches.length == 2) return breakpoint_no end |
#socket_session ⇒ Object
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1035 def socket_session #p "====>socket_session" #Arcadia.new_debug_msg(self,"socket_session : passo") if @session.nil? && @controller.rds.is_alive? begin #sleep(2) @session = TCPSocket.new(@server, @port) @pend = false rescue Errno::ECONNREFUSED,Errno::EBADF => e sleep(1) @t = @t -1 if @t > 0 socket_session else Arcadia.console(self, 'msg'=>"socket_session : #{e.inspect}", 'level'=>'debug') #Arcadia.new_debug_msg(self,"socket_session : #{e.inspect}") end rescue Exception => e @session = nil Arcadia.console(self, 'msg'=>"Error on socket_session : #{e.class}:#{e.}", 'level'=>'debug') #Arcadia.new_debug_msg(self,"Error on socket_session : #{e.class}:#{e.message}") end elsif !@controller.rds.is_alive? @session = nil end #Arcadia.new_debug_msg(self,"session : #{@session.inspect}") #p "@session=>#{@session}" return @session end |
#stacktrace ⇒ Object
return the current stack trace
1192 1193 1194 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1192 def stacktrace notify("backtrace", read("backtrace")) end |
#start_session ⇒ Object
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1075 def start_session begin #p "======>start session" @t = @timeout if socket_session #Arcadia.new_debug_msg(self,"session : #{@session.inspect}") notify('start', read) read("eval require 'yaml'") end return @session rescue Exception => e Arcadia.console(self, 'msg'=>"Error on start_session : #{e.class}:#{e.} #{e.backtrace.join('..')}", 'level'=>'debug') #Arcadia.new_debug_msg(self,"Error on start_session : #{e.class}:#{e.message}") end end |
#step_into ⇒ Object
1161 1162 1163 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1161 def step_into notify("step", read("step")) end |
#step_out ⇒ Object
1165 1166 1167 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1165 def step_out notify("fin", read("fin")) end |
#step_over ⇒ Object
1157 1158 1159 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1157 def step_over notify("next", read("next")) end |
#stop_session ⇒ Object
1091 1092 1093 1094 1095 1096 1097 1098 1099 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1091 def stop_session begin quit if is_debugging_ready? @session.close if is_alive? rescue Exception => e Arcadia.console(self, 'msg'=>"Error on stop_session : #{e.class}:#{e.inspect}", 'level'=>'debug') #Arcadia.new_debug_msg(self,"Error on stop_session : #{e.class}:#{e.inspect}") end end |
#unset_breakpoint(_id) ⇒ Object
1423 1424 1425 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1423 def unset_breakpoint(_id) read("delete #{_id}") end |
#variables(_type) ⇒ Object
returns the local variables and there values
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1331 def variables(_type) begin #variables = read[1..-2].split(', ').collect!{|x| x[1..-2]} to_eval = read("eval #{_type}") #Arcadia.console(self,'msg'=>"to_eval=#{to_eval.to_s}") variables = eval(to_eval) #Arcadia.console(self,'msg'=>"variables=#{variables.to_s}") rescue Exception => e variables = [] #p "on command eval #{_type}:#{e.inspect}" #Arcadia.new_debug_msg(self,"on command eval #{_type}:#{e.inspect}") end variables = [] if variables.nil? variable_values = Hash.new variables.each do |var| next if var.to_s=='$;' # command("eval #{var}.to_s + '|||' + #{var}.class.to_s") # _str = eval(read) # _value, _class = _str.split('|||') # variable_values[var] = Var.new(_value, _class) variable_values[var.to_s] = debug_eval(var.to_s) end return variable_values end |
#where ⇒ Object
1173 1174 1175 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1173 def where notify("where", read("where")) end |
#yaml_pseudo_load(_obj) ⇒ Object
1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
# File 'ext/ae-ruby-debug/ae-ruby-debug.rb', line 1197 def yaml_pseudo_load(_obj) just_present = @valuobjs.include?(_obj) @valuobjs << _obj if _obj.class == YAML::DomainType return _obj.type_id if just_present ret = Hash.new ret['__CLASS__']=_obj.type_id l = _obj.value.length ret['__LENGTH__']= l.to_s if l > 0 _obj.value.each{|k,v| ret["@#{k}"]=yaml_pseudo_load(v) } end ret elsif _obj.class == Hash #Arcadia.new_msg(self,"_obj Hash="+_obj.inspect) return 'Hash' if just_present ret = Hash.new ret['__CLASS__']= 'Hash' l = _obj.length ret['__LENGTH__']= l.to_s if l > 0 _obj.each{|k,v| ret[k]=yaml_pseudo_load(v) } end ret elsif _obj.class == Array #Arcadia.new_msg(self,"_obj Array="+_obj.inspect) return 'Array' if just_present ret = Hash.new ret['__CLASS__']= 'Array' l = _obj.length ret['__LENGTH__']= l.to_s if l > 0 _obj.each_with_index{|v,i| ret[i.to_s]=yaml_pseudo_load(v) } end ret elsif _obj.class == Struct #Arcadia.new_msg(self,"_obj Array="+_obj.inspect) return 'Struct' if just_present ret = Hash.new ret['__CLASS__']= 'Struct' l = _obj.length ret['__LENGTH__']= l.to_s if l > 0 _obj.members.each{|m| ret[m]=yaml_pseudo_load(_obj[m]) } end ret else #Arcadia.new_msg(self,"_obj ="+_obj.inspect) _obj end end |