Re: [dtrace-discuss] tracing recursive functions

2009-12-24 Thread Hillel (Sabba) Markowitz
An interesting case occurred because of recursion. for (i = 1; istrlen(printarg); i++) { printone(printarg[i]); } became optimised with strict recursion so that it never actually returned to the calling function. As a result, ustackdepth never got incremented and I needed to

Re: [dtrace-discuss] tracing recursive functions

2009-12-22 Thread Jonathan Adams
On Thu, Dec 17, 2009 at 04:18:21PM -0500, Hillel (Sabba) Markowitz wrote: On Wed, Dec 16, 2009 at 2:44 PM, Chad Mynhier cmynh...@gmail.com wrote: #define STACKDEPTHBASE 2 It appears that instead of doing this, I would have to set up BEGIN { self-startdepth = ustackdepth; }

Re: [dtrace-discuss] tracing recursive functions

2009-12-22 Thread Hillel (Sabba) Markowitz
On Tue, Dec 22, 2009 at 1:27 PM, Jonathan Adams jonathan.ad...@sun.com wrote: On Thu, Dec 17, 2009 at 04:18:21PM -0500, Hillel (Sabba) Markowitz wrote: On Wed, Dec 16, 2009 at 2:44 PM, Chad Mynhier cmynh...@gmail.com wrote: #define STACKDEPTHBASE 2 It appears that instead of doing this, I

Re: [dtrace-discuss] tracing recursive functions

2009-12-21 Thread Hillel (Sabba) Markowitz
On Fri, Dec 18, 2009 at 1:12 PM, Chad Mynhier cmynh...@gmail.com wrote: On Thu, Dec 17, 2009 at 3:08 PM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: On Wed, Dec 16, 2009 at 2:44 PM, Chad Mynhier cmynh...@gmail.com wrote: #define STACKDEPTHBASE 2 I don't follow why this is set to

Re: [dtrace-discuss] tracing recursive functions

2009-12-21 Thread Chad Mynhier
On Mon, Dec 21, 2009 at 8:47 AM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: When I tried to set up with a probe at pid$target::main:entry with a printf inside it, I got no output. However, I did get a main:return from pid:target:hello::return I do not understand why that is

Re: [dtrace-discuss] tracing recursive functions

2009-12-21 Thread Hillel (Sabba) Markowitz
On Mon, Dec 21, 2009 at 9:45 AM, Chad Mynhier cmynh...@gmail.com wrote: On Mon, Dec 21, 2009 at 8:47 AM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: When I tried to set up with a probe at pid$target::main:entry with a printf inside it, I got no output. However, I did get a

Re: [dtrace-discuss] tracing recursive functions

2009-12-18 Thread Hillel (Sabba) Markowitz
In testing the code that you sent I did find a slight problem. It did not work with the STACKDEPTHBASE definition. However, I defined a variable self-mydepth[probemod, ustackdepth] = ustackdepth; This gets defined when self-func[probemod, ustackdepth] gets defined and zeroed when self-func gets

Re: [dtrace-discuss] tracing recursive functions

2009-12-18 Thread Chad Mynhier
On Thu, Dec 17, 2009 at 3:08 PM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: On Wed, Dec 16, 2009 at 2:44 PM, Chad Mynhier cmynh...@gmail.com wrote: #define STACKDEPTHBASE 2 I don't follow why this is set to 2. I included a syscall count to also see how many times a function is

Re: [dtrace-discuss] tracing recursive functions

2009-12-18 Thread Hillel (Sabba) Markowitz
On Fri, Dec 18, 2009 at 1:12 PM, Chad Mynhier cmynh...@gmail.com wrote: This was just an observation that ustackdepth showed up as 2 on entry to main().  What I really should have done would be to set the base as a thread-local variable in the pid$target::main:entry probe. And this would

Re: [dtrace-discuss] tracing recursive functions

2009-12-17 Thread Hillel (Sabba) Markowitz
On Wed, Dec 16, 2009 at 2:44 PM, Chad Mynhier cmynh...@gmail.com wrote: #define STACKDEPTHBASE 2 I don't follow why this is set to 2. I included a syscall count to also see how many times a function is entered and the initialization function did not show up in the time. Shouldn't the index be

Re: [dtrace-discuss] tracing recursive functions

2009-12-17 Thread Hillel (Sabba) Markowitz
On Wed, Dec 16, 2009 at 2:44 PM, Chad Mynhier cmynh...@gmail.com wrote: #define STACKDEPTHBASE 2 It appears that instead of doing this, I would have to set up BEGIN { self-startdepth = ustackdepth; } This would allow the depth to be whatever the actual base depth is. The value used here

[dtrace-discuss] tracing recursive functions

2009-12-16 Thread Hillel (Sabba) Markowitz
When tracing user functions, how are recursive functions handled. For example, the following code processes the time spent within user dynamic modules. The modules have user created dynamic libraries : MyLib1.so, MyLib2.so, ... I would also like to know if there is someting already in the dtrace

Re: [dtrace-discuss] tracing recursive functions

2009-12-16 Thread Angelo Rajadurai
Hi Sabba: You can use the ustackdepth variable. This has the stack depth in the user land. So use that as the array index. -Angelo On Dec 16, 2009, at 1:52 PM, Hillel (Sabba) Markowitz wrote: When tracing user functions, how are recursive functions handled. For example, the following code

Re: [dtrace-discuss] tracing recursive functions

2009-12-16 Thread Chad Mynhier
On Wed, Dec 16, 2009 at 1:52 PM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: As can be seen, if recursive code is used, the self-ts gets reset to timestamp with every entry, and the innermost exit causes a time to be calculated and the ts to be reset. The rest of the returns within

Re: [dtrace-discuss] tracing recursive functions

2009-12-16 Thread Hillel (Sabba) Markowitz
On Wed, Dec 16, 2009 at 2:13 PM, Chad Mynhier cmynh...@gmail.com wrote: On Wed, Dec 16, 2009 at 1:52 PM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: As can be seen, if recursive code is used, the self-ts gets reset to timestamp with every entry, and the innermost exit causes a time

Re: [dtrace-discuss] tracing recursive functions

2009-12-16 Thread Chad Mynhier
On Wed, Dec 16, 2009 at 2:17 PM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: On Wed, Dec 16, 2009 at 2:13 PM, Chad Mynhier cmynh...@gmail.com wrote: You'll need to keep an array of timestamps indexed on ustackdepth. Something like this (it appears that ustackdepth on entry doesn't

Re: [dtrace-discuss] tracing recursive functions

2009-12-16 Thread Hillel (Sabba) Markowitz
On Wed, Dec 16, 2009 at 2:44 PM, Chad Mynhier cmynh...@gmail.com wrote: Actually, there's a bug in the above.  For this case: - A    - B        - C        - C    - B - A The time for B will include the time spent in C, and the time for A will include the entire time. Actually, the

Re: [dtrace-discuss] tracing recursive functions

2009-12-16 Thread Chad Mynhier
On Wed, Dec 16, 2009 at 3:19 PM, Hillel (Sabba) Markowitz sabbahil...@gmail.com wrote: However, what I am worried about is a set where -A  -B     -C     -C   -B -A -D  -C  -C -D This would seem to not aggregate the C as the ustackdepth for the two usages of C would be different.

Re: [dtrace-discuss] tracing recursive functions

2009-12-16 Thread Hillel (Sabba) Markowitz
On Wed, Dec 16, 2009 at 4:01 PM, Chad Mynhier cmynh...@gmail.com wrote: So here you want to see the exclusive time spent in A at each level of recursion?  Then you'd need to add ustackdepth (or some variable of your own that's keeping track of recursion depth) as in index to your aggregation.