c++ - Determine stack usage of a posix pthread? -
how determine current amount of stack space used current thread in multi-threaded c++ program? i'm using posix pthreads.
i have multi-threaded program 1 of stacks blowing up, can't figure out one. i'm interested in having each thread report log file current stack usage, should difference between thread's start of stack , current stack pointer. know how in assembly language i'm looking portable approach using pthreads
call or similar.
thanks.
i have multi-threaded program 1 of stacks blowing up, can't figure out one.
let program crash , leave core
file. load core
debugger, , it tell right away thread crashed.
the thread crashed not 1 overflow.
it's true there scenarios 1 thread overflows stack, thread crashes because of it.
however, such scenarios exceedingly rare (at least non-user allocated thread stacks -- pthread library provide stack guard page(s) protect agains this). can think of 1 such scenario, , it's unlikely in practice.
i'm looking portable approach using pthreads call or similar.
there no portable way achieve want. on linux, use pthread_getattr_np
, pthread_attr_getstack
find boundaries of current thread stack, , compute current stack use there.
Comments
Post a Comment