A general observation: wouldn't it be better to properly report
the error at the failure site rather than try to interpret errors?

Much less error prone, the error propagation is less than 100%,
better info and less code.

To try to reconstruct some meaningful information about what
happened from a 32 bit value yields pretty nonsensical error
messages in general...



Instead of:

        switch (retval) {
        case ERROR_OK:
                break;
        case ERROR_TARGET_RESOURCE_NOT_AVAILABLE:
                reason = "resource not available";
                goto fail;
        case ERROR_TARGET_NOT_HALTED:
                reason = "target running";
                goto fail;
        default:
                reason = "unknown reason";
fail:
                LOG_ERROR("can't add breakpoint: %s", reason);
                free((*breakpoint_p)->orig_instr);
                free(*breakpoint_p);
                *breakpoint_p = NULL;
                return retval;
        }


Just:

        if (retval != ERROR_OK) {
                free((*breakpoint_p)->orig_instr);
                free(*breakpoint_p);
                *breakpoint_p = NULL;
                return retval;
        }


-- 
Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to