@@ -144,19 +144,36 @@ def print_array(array)
144144 end
145145 end
146146
147- def print_hash ( hash )
147+ def do_print_hash_key_value ( hash )
148+ print_element ( "variables" , { :type => 'hashItem' } ) do
149+ hash . each { |( k , v ) |
150+ print_variable ( 'key' , k , 'instance' )
151+ print_variable ( 'value' , v , 'instance' )
152+ }
153+ end
154+ end
155+
156+ def do_print_hash ( hash )
148157 print_element ( "variables" ) do
149- hash . keys . each { |k |
158+ hash . each { |( k , v ) |
150159 if k . class . name == "String"
151160 name = '\'' + k + '\''
152161 else
153162 name = exec_with_allocation_control ( k , :to_s , OverflowMessageType ::EXCEPTION_MESSAGE )
154163 end
155- print_variable ( name , hash [ k ] , 'instance' )
164+ print_variable ( name , v , 'instance' )
156165 }
157166 end
158167 end
159168
169+ def print_hash ( hash )
170+ if Debugger . key_value_mode
171+ do_print_hash_key_value ( hash )
172+ else
173+ do_print_hash ( hash )
174+ end
175+ end
176+
160177 def print_string ( string )
161178 print_element ( "variables" ) do
162179 if string . respond_to? ( 'bytes' )
@@ -243,6 +260,7 @@ def exec_with_allocation_control(value, exec_method, overflow_message_type)
243260
244261 def print_variable ( name , value , kind )
245262 name = name . to_s
263+
246264 if value . nil?
247265 print ( "<variable name=\" %s\" kind=\" %s\" />" , CGI . escapeHTML ( name ) , kind )
248266 return
@@ -280,6 +298,7 @@ def print_variable(name, value, kind)
280298 CGI . escapeHTML ( name ) , build_compact_value_attr ( value , value_str ) , kind ,
281299 build_value_attr ( escaped_value_str ) , value . class ,
282300 has_children , value . object_id )
301+
283302 print ( "<value><![CDATA[%s]]></value>" , escaped_value_str ) if Debugger . value_as_nested_element
284303 print ( '</variable>' )
285304 rescue StandardError => e
@@ -439,8 +458,11 @@ def print_load_result(file, exception = nil)
439458 end
440459 end
441460
442- def print_element ( name )
443- print ( "<#{ name } >" )
461+ def print_element ( name , additional_tags = nil )
462+ additional_tags_presentation = additional_tags . nil? ? ''
463+ : additional_tags . map { |tag , value | " #{ tag } =\" #{ value } \" " } . reduce ( :+ )
464+
465+ print ( "<#{ name } #{ additional_tags_presentation } >" )
444466 begin
445467 yield if block_given?
446468 ensure
0 commit comments