qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V9 6/7] oslib-posix: add a configure switch to d


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH V9 6/7] oslib-posix: add a configure switch to debug stack usage
Date: Tue, 27 Sep 2016 10:48:57 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

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 <address@hidden>
> ---
>  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 <address@hidden>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]