'Append code to a user-defined command, define new command if not exist
Args:
- cmd: user-defined command (String)
- code: gdb script code to append (String)
Returns:
- True if success to append (Bool)'

def append_user_command(self, cmd, code):

    commands = self.execute_redirect(('show    user    %s' % cmd))
    if (not commands):
        return self.define_user_command(cmd, code)
    commands = '\n'.join(commands.splitlines()[1:])
    if (code in commands):
        return True
    commands = (((('define    %s\n' % cmd) + commands) + code) + '\nend\n')
    tmp = tmpfile()
    tmp.write(commands)
    tmp.flush()
    result = self.execute(('source    %s' % tmp.name))
    tmp.close()
    return result
