Skip to content

Commit 0dba1ef

Browse files
committed
logging added
1 parent e5d7d57 commit 0dba1ef

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/ruby-debug-ide/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def timeout(sec)
118118
def debug_eval(str, b = get_binding)
119119
begin
120120
str = str.to_s
121-
str.force_encoding('UTF-8') if(RUBY_VERSION > 2.0)
121+
str.force_encoding('UTF-8') if(RUBY_VERSION > '2.0')
122122
to_inspect = Command.unescape_incoming(str)
123123
max_time = Debugger.evaluation_timeout
124124
@printer.print_debug("Evaluating %s with timeout after %i sec", str, max_time)

lib/ruby-debug-ide/xml_printer.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def initialize(interface)
4545
end
4646

4747
def print_msg(*args)
48+
puts 'def print_msg(*args)'
4849
msg, *args = args
4950
xml_message = CGI.escapeHTML(msg % args)
5051
print "<message>#{xml_message}</message>"
@@ -384,7 +385,7 @@ def max_compact_name_size
384385
50
385386
end
386387

387-
def inspect_with_allocation_control(slice, memory_limit)
388+
def inspect_with_allocation_control(slice, memory_limit, obj_id)
388389
curr_thread = Thread.current
389390

390391
start_alloc_size = ObjectSpace.memsize_of_all
@@ -395,7 +396,7 @@ def inspect_with_allocation_control(slice, memory_limit)
395396
if(curr_alloc_size - start_alloc_size > 1e6 * memory_limit)
396397

397398
trace.disable
398-
curr_thread.raise MemoryLimitError, "Out of memory: evaluation took longer than #{memory_limit}mb." if curr_thread.alive?
399+
curr_thread.raise MemoryLimitError, "Out of memory: evaluation of inspect for obj(#{obj_id}) took more than #{memory_limit}mb." if curr_thread.alive?
399400
end
400401
end
401402

@@ -404,6 +405,7 @@ def inspect_with_allocation_control(slice, memory_limit)
404405
trace.disable
405406
result
406407
rescue MemoryLimitError => e
408+
print_msg(e.message)
407409
return nil
408410
end
409411

@@ -413,7 +415,7 @@ def compact_array_str(value)
413415
compact = if (defined?(JRUBY_VERSION) || ENV['DEBUGGER_MEMORY_LIMIT'].to_i <= 0)
414416
slice.inspect
415417
else
416-
compact = inspect_with_allocation_control(slice, ENV['DEBUGGER_MEMORY_LIMIT'].to_i)
418+
compact = inspect_with_allocation_control(slice, ENV['DEBUGGER_MEMORY_LIMIT'].to_i, value.object_id.to_s)
417419
end
418420

419421
if compact && value.size != slice.size

0 commit comments

Comments
 (0)