class
Cradare2::Lines::SourceMap
- Cradare2::Lines::SourceMap
- Reference
- Object
Overview
Bidirectional mapping engine between native assembly instructions and Crystal source code.
Defined in:
cradare2/lines/source_map.crConstructors
- .new(reader : SourceReader = SourceReader.new)
- .new(mappings : Array(InstructionMapping), reader : SourceReader = SourceReader.new)
Instance Method Summary
-
#add(address : UInt64, file : String, line : Int32, column : Int32 = 0, opcode : String = "", size : Int32 = 0, bytes : String | Nil = "", function_name : String | Nil = nil, source_text : String | Nil = nil) : InstructionMapping
Adds a mapping between an instruction address and a source location.
-
#add(mapping : InstructionMapping) : InstructionMapping
Adds a pre-constructed instruction mapping.
- #address_to_instruction : Hash(UInt64, InstructionMapping)
-
#clear : Nil
Clears all mappings.
-
#empty? : Bool
Returns true if no mappings exist.
-
#file_to_lines : Hash(String, Hash(Int32, Array(InstructionMapping)))
Normalized file => (Line => Array(InstructionMapping))
-
#files : Array(String)
Returns all unique source file paths recorded in the map.
-
#find_by_address(address : UInt64) : SourceLocation | Nil
Finds the source location for an instruction address.
-
#find_by_file(file : String) : Hash(Int32, Array(InstructionMapping))
Finds all line-to-instruction mappings for a given file.
-
#find_by_line(file : String, line : Int32) : Array(InstructionMapping)
Finds all instructions generated for a given file and line number.
-
#find_instruction(address : UInt64) : InstructionMapping | Nil
Finds the mapped instruction for an exact address.
-
#find_instruction_containing(address : UInt64) : InstructionMapping | Nil
Finds the instruction matching or containing the given address (within instruction size range).
-
#format_interleaved_view(fn_name : String, show_context : Bool = false, context_window : Int32 = 1) : String
Convenience overload to format interleaved view for a specific function name.
-
#format_interleaved_view(show_context : Bool = false, context_window : Int32 = 1) : String
Convenience overload to format interleaved view for all mapped instructions.
-
#format_interleaved_view(groups : Array(LineInstructionGroup), show_context : Bool = false, context_window : Int32 = 1) : String
Generates a formatted interleaved view displaying Crystal source code lines alongside the disassembled instructions that implement each line.
-
#groups_for_function_name(fn_name : String) : Array(LineInstructionGroup)
Groups instructions for a specific function name.
-
#groups_for_range(start_addr : UInt64, end_addr : UInt64) : Array(LineInstructionGroup)
Groups instructions within an address range or function into LineInstructionGroups.
-
#lines_for_file(file : String) : Array(Int32)
Returns all unique line numbers mapped for a given file.
- #reader : SourceReader
-
#size : Int32
Returns the number of mapped instructions.
-
#sync_to_r2(client : Client, annotate_comments : Bool = true) : Int32
Synchronizes all mappings into a running radare2 session.
Constructor Detail
Instance Method Detail
Adds a mapping between an instruction address and a source location.
Adds a pre-constructed instruction mapping.
Normalized file => (Line => Array(InstructionMapping))
Finds the source location for an instruction address.
Finds all line-to-instruction mappings for a given file.
Finds all instructions generated for a given file and line number.
Finds the mapped instruction for an exact address.
Finds the instruction matching or containing the given address (within instruction size range). Performs an O(log N) binary search over sorted address intervals.
Convenience overload to format interleaved view for a specific function name.
Convenience overload to format interleaved view for all mapped instructions.
Generates a formatted interleaved view displaying Crystal source code lines alongside the disassembled instructions that implement each line.
Groups instructions for a specific function name.
Groups instructions within an address range or function into LineInstructionGroups.
Returns all unique line numbers mapped for a given file.
Synchronizes all mappings into a running radare2 session.
Registers entries into radare2's CL codeline table and optionally sets CC comments.