|
From: Bart V. A. <bar...@gm...> - 2008-03-29 09:35:02
|
On Fri, Mar 28, 2008 at 8:34 PM, Dirk Stoecker <val...@ds...> wrote: > On Fri, 28 Mar 2008, bar...@gm... wrote: > > >> P.S. Is there a tool telling me stack usage for threads (I use Linux). > > > > Is it sufficient if stack usage is reported for all threads at the > > time a process terminates ? I can add such functionality easily to > > exp-drd if you want. > > Actually I want to know the maximum stack size a thread used. Because I > need to set the maximum stack size to a defined value and currently this > is based on guessing+some security margin. And this is never a good way. > Measurement+security margin would be much better. By this time I have added a command-line option --show-stack-usage to exp-drd. If enabled it is reported how many bytes a thread has used on its stack at the time it finished. An example: $ ./vg-in-place --tool=exp-drd --show-stack-usage=yes exp-drd/tests/matinv 200 -t4 ==30241== exp-drd, a data race detector. ==30241== NOTE: This is an Experimental-Class Valgrind Tool. ==30241== Copyright (C) 2006-2008, and GNU GPL'd, by Bart Van Assche. ==30241== Using LibVEX rev 1811, a library for dynamic binary translation. ==30241== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP. ==30241== Using valgrind-3.4.0.SVN, a dynamic binary instrumentation framework. ==30241== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al. ==30241== For more details, rerun with: -v ==30241== ==30241== thread 2/2 finished and used 4776 bytes out of 28672 on its stack. Margin: 23896 bytes. ==30241== thread 3/3 finished and used 4280 bytes out of 28672 on its stack. Margin: 24392 bytes. ==30241== thread 4/4 finished and used 4280 bytes out of 28672 on its stack. Margin: 24392 bytes. ==30241== thread 5/5 finished and used 4280 bytes out of 28672 on its stack. Margin: 24392 bytes. error = 1.08926e-16; epsilon = 2.22045e-16; error / (epsilon * n) = 0.00490557 Error within bounds. ==30241== thread 1/1 finished and used 8992 bytes out of 8388608 on its stack. Margin: 8379616 bytes. ==30241== ==30241== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 32 from 1) You can run the exp-drd tool by building the latest Valgrind SVN sources. For instructions, see also http://www.valgrind.org/downloads/repository.html Bart. |