I'm using puncover for Zephyr firmware (via the built-in west build -t puncover... command) and have gotten a ton of mileage out of it for determining safe stack sizes for different threads. One issue that's tripped us a number of times, though, is function pointers and callbacks. As an example, we've got a driver with code that looks like this:
static void hwt901b_event_task(const struct device *dev) {
[-- big while loop, this is the long-running function that a thread executes --]
if (data->data_cb) {
[-- do a bunch of processing to populate a struct --]
data->data_cb(dev, data->cb_user_data, &hwt901b);
}
In this case, I totally get that puncover can't know how much stack the callback function will need (I mean... whole program analysis might be able to determine that for a given ELF file it is only ever set to one value, but that's asking a lot). The issue that we've run into is that puncover does report a definitive worst-case stack usage number, but that number neither includes the callback function nor includes any indication that there's an unknown amount of stack required (which would flag to us that we need to manually do that math).
I'm honestly interested in potentially implementing this functionality myself and would make a PR for it but I:
- don't know how much the maintainers/community actually cares about this
- haven't dug into the actual source yet to start figuring out what might need to be done to support this
If the answers to those are: "yes, please!" and "this seems like it wouldn't be too much work to get through" then let me know and I can start digging over the Christmas break here.
I'm using puncover for Zephyr firmware (via the built-in
west build -t puncover...command) and have gotten a ton of mileage out of it for determining safe stack sizes for different threads. One issue that's tripped us a number of times, though, is function pointers and callbacks. As an example, we've got a driver with code that looks like this:In this case, I totally get that puncover can't know how much stack the callback function will need (I mean... whole program analysis might be able to determine that for a given ELF file it is only ever set to one value, but that's asking a lot). The issue that we've run into is that puncover does report a definitive worst-case stack usage number, but that number neither includes the callback function nor includes any indication that there's an unknown amount of stack required (which would flag to us that we need to manually do that math).
I'm honestly interested in potentially implementing this functionality myself and would make a PR for it but I:
If the answers to those are: "yes, please!" and "this seems like it wouldn't be too much work to get through" then let me know and I can start digging over the Christmas break here.