On 09/27/2016 04:58 AM, Peter Lieven wrote: > this adds a knob to track the maximum stack usage of stacks > created by qemu_alloc_stack. > > Signed-off-by: Peter Lieven <p...@kamp.de> > --- > configure | 19 +++++++++++++++++++ > util/oslib-posix.c | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 54 insertions(+)
> @@ -534,10 +541,38 @@ void *qemu_alloc_stack(size_t *sz) > abort(); > } > > +#ifdef CONFIG_DEBUG_STACK_USAGE > + for (ptr2 = ptr + pagesz; ptr2 < ptr + *sz; ptr2 += sizeof(uint32_t)) { > + *(uint32_t *)ptr2 = 0xdeadbeaf; It's usually spelled 0xdeadbeef, if you want to tweak it. > + } > +#endif > + > return ptr; > } > > +#ifdef CONFIG_DEBUG_STACK_USAGE > +static __thread unsigned int max_stack_usage; > +#endif > + > void qemu_free_stack(void *stack, size_t sz) > { > +#ifdef CONFIG_DEBUG_STACK_USAGE > + unsigned int usage; > + void *ptr; > + > + for (ptr = stack + getpagesize(); ptr < stack + sz; > + ptr += sizeof(uint32_t)) { > + if (*(uint32_t *)ptr != 0xdeadbeaf) { Of course, you'd have to do it here, too. Either way, Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature