Hi, Pierrick, October 21, 2024 at 8:00 PM, "Pierrick Bouvier" wrote: > I agree it would be useful. Beyond the scope of this series, it would be > nice if we could add a control flow related API instead of asking to > plugins to do it themselves. > > If we would provide something like this, is there still a value to add > an API to detect interrupt/exceptions/traps events? > > Note: It's not a critic against what you sent, just an open question on > *why* it's useful to access this QEMU implementation related information > vs something more generic.
The motivation for this API is a plugin that simulates a RISC-V tracing unit (and produces a trace). For that we actually also needed to track the "regular" control flow, i.e. find out whether a branch was taken or where a jump went. That wasn't hard, especially considering that the TCG API already gives you (more or less) basic blocks. Still, we ended up tracing every instruction because that made some of the logic much simpler and easier to reason about. We realized that we need a trap API because they: * can occur at any time/point of execusion * usually come with additional effects such as mode changes. Helpers for discerning whether an instruction is a jump, a branch instruction or something else would certainly be helpful if you wanted cross-platform control flow tracing of some sort, but afaik given such helpers you would just need to check the last instruction in a translation block and check where the PC goes after that. Additional callbacks for specifically this situation strike me as a bit excessive. But I could be wrong about that. Regards, Julian