'Save current breakpoints to file as a script
Args:
- filename: target file (String)
Returns:
- True if success to save (Bool)'

def save_breakpoints(self, filename):

    result = self.execute_redirect(('save    breakpoints    %s' % filename))
    if (result == ''):
        return True
    bplist = self.get_breakpoints()
    if (not bplist):
        return False
    try:
        fd = open(filename, 'w')
        for (num, type, disp, enb, addr, what, commands) in bplist:
            m = re.match('(.*)point', type)
            if m:
                cmd = m.group(1).split()[(-1)]
            else:
                cmd = 'break'
            if (('hw' in type) and (cmd == 'break')):
                cmd = ('h' + cmd)
            if ('read' in type):
                cmd = ('r' + cmd)
            if ('acc' in type):
                cmd = ('a' + cmd)
            if (not disp):
                cmd = ('t' + cmd)
            if what:
                location = what
            else:
                location = ('*0x%x' % addr)
            text = ('%s    %s' % (cmd, location))
            if commands:
                if ('stop    only' not in commands):
                    text += ('\ncommands\n%s\nend' % commands)
                else:
                    text += commands.split('stop    only', 1)[1]
            fd.write((text + '\n'))
        fd.close()
        return True
    except:
        return False
