Note to self:
In functions like resume_go(), consider the use of the following:
explicit if for the debug module spec version
direct function calls to the 0.11 vs. 0.13 functions (do not use function pointers)
// Current code (excerpt from resume_go()):
if (!r->get_hart_state) {
struct target_type *tt = get_target_type(target);
result = tt->resume(target, current, address, handle_breakpoints,
debug_execution);
} else {
result = riscv_resume_go_all_harts(target);
}
// ------------------------------------------------------------------------
// Proposed code after re-factor:
if (r->version == DM_VERSION_0_11) { /* pseudo-code */
result = riscv011_resume(target, /* ... */ );
/* Use a direct call, drop all function pointers from struct target_type.
* Benefits:
* - Easier to read code,
* - easier to navigate,
* - possibility for static analysis tools to do better analysis when they know
* what function gets called in compile time already. */
} else if (r->version == DM_VERSION_0_13 || r->version == DM_VERSION_1_0) { /* pseudo-code */
result = riscv013_resume_go_all_harts(target);
}
else {
assert(0);
}
Note to self: In functions like resume_go(), consider the use of the following:
if
for the debug module spec version