int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,

                          target_ulong len, int type)

{

    struct kvm_sw_breakpoint *bp;

    CPUState *env;

    int err;



    if (type == GDB_BREAKPOINT_SW) {

        bp = kvm_find_sw_breakpoint(current_env, addr);

        if (bp) {

            bp->use_count++;

            return 0;

        }



        bp = qemu_malloc(sizeof(struct kvm_sw_breakpoint));

        if (!bp)

            return -ENOMEM;



        bp->pc = addr;

        bp->use_count = 1;

        err = kvm_arch_insert_sw_breakpoint(current_env, bp);

        if (err) {

            free(bp);

            return err;

        }



        QTAILQ_INSERT_HEAD(&current_env->kvm_state->kvm_sw_breakpoints,

                          bp, entry);

    } else {

        err = kvm_arch_insert_hw_breakpoint(addr, len, type);

        if (err)

            return err;

    }



    for (env = first_cpu; env != NULL; env = env->next_cpu) {

        err = kvm_update_guest_debug(env, 0);

        if (err)

            return err;

    }

    return 0;

}

int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,

                          target_ulong len, int type)

{

    struct kvm_sw_breakpoint *bp;

    CPUState *env;

    int err;



    if (type == GDB_BREAKPOINT_SW) {

        bp = kvm_find_sw_breakpoint(current_env, addr);

        if (bp) {

            bp->use_count++;

            return 0;

        }



        bp = qemu_malloc(sizeof(struct kvm_sw_breakpoint));

        if (!bp)

            return -ENOMEM;



        bp->pc = addr;

        bp->use_count = 1;

        err = kvm_arch_insert_sw_breakpoint(current_env, bp);

        if (err) {

            free(bp);

            return err;

        }



        QTAILQ_INSERT_HEAD(&current_env->kvm_state->kvm_sw_breakpoints,

                          bp, entry);

    } else {

        err = kvm_arch_insert_hw_breakpoint(addr, len, type);

        if (err)

            return err;

    }



    for (env = first_cpu; env != NULL; env = env->next_cpu) {

        err = kvm_update_guest_debug(env, 0);

        if (err)

            return err;

    }

    return 0;

}

int FUNC_0(CPUState *VAR_0, target_ulong VAR_1,

                          target_ulong VAR_2, int VAR_3)

{

    struct kvm_sw_breakpoint *VAR_4;

    CPUState *env;

    int VAR_5;



    if (VAR_3 == GDB_BREAKPOINT_SW) {

        VAR_4 = kvm_find_sw_breakpoint(VAR_0, VAR_1);

        if (VAR_4) {

            VAR_4->use_count++;

            return 0;

        }



        VAR_4 = qemu_malloc(sizeof(struct kvm_sw_breakpoint));

        if (!VAR_4)

            return -ENOMEM;



        VAR_4->pc = VAR_1;

        VAR_4->use_count = 1;

        VAR_5 = kvm_arch_insert_sw_breakpoint(VAR_0, VAR_4);

        if (VAR_5) {

            free(VAR_4);

            return VAR_5;

        }



        QTAILQ_INSERT_HEAD(&VAR_0->kvm_state->kvm_sw_breakpoints,

                          VAR_4, entry);

    } else {

        VAR_5 = kvm_arch_insert_hw_breakpoint(VAR_1, VAR_2, VAR_3);

        if (VAR_5)

            return VAR_5;

    }



    for (env = first_cpu; env != NULL; env = env->next_cpu) {

        VAR_5 = kvm_update_guest_debug(env, 0);

        if (VAR_5)

            return VAR_5;

    }

    return 0;

}

int FUNC_0(CPUState *VAR_0, target_ulong VAR_1,
target_ulong VAR_2, int VAR_3)
{ struct kvm_sw_breakpoint *VAR_4; CPUState *env; int VAR_5; if (VAR_3 == GDB_BREAKPOINT_SW) { VAR_4 = kvm_find_sw_breakpoint(VAR_0, VAR_1); if (VAR_4) { VAR_4->use_count++; return 0; } VAR_4 = qemu_malloc(sizeof(struct kvm_sw_breakpoint)); if (!VAR_4)
return -ENOMEM; VAR_4->pc = VAR_1; VAR_4->use_count = 1; VAR_5 = kvm_arch_insert_sw_breakpoint(VAR_0, VAR_4); if (VAR_5) { free(VAR_4); return VAR_5; } QTAILQ_INSERT_HEAD(&VAR_0->kvm_state->kvm_sw_breakpoints,
VAR_4, entry); } else { VAR_5 = kvm_arch_insert_hw_breakpoint(VAR_1, VAR_2, VAR_3); if (VAR_5)
return VAR_5; } for (env = first_cpu; env != NULL; env = env->next_cpu) { VAR_5 = kvm_update_guest_debug(env, 0); if (VAR_5)
return VAR_5; } return 0; }