class DEBUGGER__::Breakpoint

def delete

def delete
  disable
  @deleted = true
end

def deleted?

def deleted?
  @deleted
end

def description

def description
  to_s
end

def disable

def disable
  @tp&.disable
end

def duplicable?

def duplicable?
  false
end

def enable

def enable
  @tp.enable
end

def enabled?

def enabled?
  @tp.enabled?
end

def generate_label(name)

def generate_label(name)
  colorize(" BP - #{name} ", [:YELLOW, :BOLD, :REVERSE])
end

def initialize cond, command, path, do_enable: true

def initialize cond, command, path, do_enable: true
  @deleted = false
  @cond = cond
  @command = command
  @path = path
  setup
  enable if do_enable
end

def oneshot?

def oneshot?
  defined?(@oneshot) && @oneshot
end

def safe_eval b, expr

def safe_eval b, expr
  b.eval(expr)
rescue Exception => e
  puts "[EVAL ERROR]"
  puts "  expr: #{expr}"
  puts "  err: #{e} (#{e.class})"
  puts "Error caused by #{self}."
  nil
end

def setup

def setup
  raise "not implemented..."
end

def skip_path?(path)

def skip_path?(path)
  case @path
  when Regexp
    !path.match?(@path)
  when String
    !path.include?(@path)
  else
    super
  end
end

def suspend

def suspend
  if @command
    provider, pre_cmds, do_cmds = @command
    nonstop = true if do_cmds
    cmds = [*pre_cmds&.split(';;'), *do_cmds&.split(';;')]
    SESSION.add_preset_commands provider, cmds, kick: false, continue: nonstop
  end
  ThreadClient.current.on_breakpoint @tp, self
end

def to_s

def to_s
  s = ''.dup
  s << " if: #{@cond}"        if defined?(@cond) && @cond
  s << " pre: #{@command[1]}" if defined?(@command) && @command && @command[1]
  s << " do: #{@command[2]}"  if defined?(@command) && @command && @command[2]
  s
end