class DEBUGGER__::Session

def on_load iseq, src

def on_load iseq, src
  DEBUGGER__.info "Load #{iseq.absolute_path || iseq.path}"
  file_path, reloaded = @sr.add(iseq, src)
  @ui.event :load, file_path, reloaded
  # check breakpoints
  if file_path
    @bps.find_all do |_key, bp|
      LineBreakpoint === bp && bp.path_is?(file_path) && (iseq.first_lineno..iseq.last_line).cover?(bp.line)
    end.each do |_key, bp|
      if !bp.iseq
        bp.try_activate iseq
      elsif reloaded
        @bps.delete bp.key # to allow duplicate
        # When we delete a breakpoint from the @bps hash, we also need to deactivate it or else its tracepoint event
        # will continue to be enabled and we'll suspend on ghost breakpoints
        bp.delete
        nbp = LineBreakpoint.copy(bp, iseq)
        add_bp nbp
      end
    end
  else # !file_path => file_path is not existing
    @bps.find_all do |_key, bp|
      LineBreakpoint === bp && !bp.iseq && DEBUGGER__.compare_path(bp.path, (iseq.absolute_path || iseq.path))
    end.each do |_key, bp|
      bp.try_activate iseq
    end
  end
end