node/lib/metasm/metasm/debug.rb
# parses the expression contained in arg, updates arg to point after the expr
parses the expression contained in arg, updates arg to point after the expr
parses the expression contained in arg updates arg to point after the expr
def parse_expr!(arg, &b)
		return if not e = IndExpression.parse_string!(arg) { |s|
			if s.length > 4 and not @disassembler.get_section_at(s.to_i) and @disassembler.get_section_at(s.to_i(16))
				s.to_i(16)
			else
				s.to_i
			end
		}
		bd = {}
		e.externals.grep(::String).each { |ex|
			if not v = register_list.find { |r| ex.downcase == r.to_s.downcase } ||
						(b && b.call(ex)) || symbols.index(ex)
				lst = symbols.values.find_all { |s| s.downcase.include? ex.downcase }
				case lst.length
				when 0
					if ex =~ /^[0-9a-f]+$/i and @disassembler.get_section_at(ex.to_i(16))
						v = ex.to_i(16)
					else
						raise "unknown symbol name #{ex}"
					end
				when 1
					v = symbols.index(lst.first)
					log "using #{lst.first} for #{ex}"
				else
					suggest = lst[0, 50].join(', ')
					suggest = suggest[0, 125] + '...' if suggest.length > 128
					raise "ambiguous symbol name #{ex}: #{suggest} ?"
				end
			end
			bd[ex] = v
		}
		e = e.bind(bd)
		e
	end
def parse_expr! ( arg , & b ) return if not e = IndExpression . parse_string! ( arg ) { | s | if s . length > 4 and not @disassembler . get_section_at ( s . to_i ) and @disassembler . get_section_at ( s . to_i ( 16 ) ) s . to_i ( 16 ) else s . to_i end } bd = { } e . externals . grep ( :: String ) . each { | ex | if not v = register_list . find { | r | ex . downcase == r . to_s . downcase } || ( b && b . call ( ex ) ) || symbols . index ( ex ) lst = symbols . values . find_all { | s | s . downcase . include? ex . downcase } case lst . length when 0 if ex =~ / ^[0-9a-f]+$ /i and @disassembler . get_section_at ( ex . to_i ( 16 ) ) v = ex . to_i ( 16 ) else raise "unknown symbol name #{ex}" end when 1 v = symbols . index ( lst . first ) log "using #{lst.first} for #{ex}" else suggest = lst [ 0 , 50 ] . join ( ', ' ) suggest = suggest [ 0 , 125 ] + '...' if suggest . length > 128 raise "ambiguous symbol name #{ex}: #{suggest} ?" end end bd [ ex ] = v } e = e . bind ( bd ) e end
parses the expression contained in arg, updates arg to point after the expr
parses the expression contained in arg updates arg to point after the expr
# handle 400000 -> 0x400000 # XXX no way to override and force decimal interpretation.. # resolve ambiguous symbol names/hex values
arg
b