Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread James Carlson
Mehul Choube wrote:
 Hi,
  
 I want the guid in a variable. I tried stringof(), strjoin(),
 copyinstr() but none works L

As defined, it's a structure containing longs and binary data, not a
string.  Can you describe what sort of result you'd like to see?  Or
perhaps what sort of problem you'd like to solve?

 The output is:
 Id: 11E109F8702B323E9CAF5000568000D0

Is that output wrong ... ?

-- 
James Carlson 42.703N 71.076W carls...@workingcode.com
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread Mehul Choube
Hi,

I want to collect the performance information for each myFunc call. The program 
is multi-threaded and uses multiple queues which can be served by any thread. 
GUID is the unique handle for each request. I can collect the information and 
store it based on GUID something like:

@[guid] = ...

I think the ID is correct.



Thanks,
Mehul

-Original Message-
From: James Carlson [mailto:carls...@workingcode.com] 
Sent: 08 November 2011 18:15
To: Mehul Choube
Cc: dtrace-discuss@opensolaris.org
Subject: Re: [dtrace-discuss] concatenate structure members into one variable

Mehul Choube wrote:
 Hi,
  
 I want the guid in a variable. I tried stringof(), strjoin(),
 copyinstr() but none works L

As defined, it's a structure containing longs and binary data, not a
string.  Can you describe what sort of result you'd like to see?  Or
perhaps what sort of problem you'd like to solve?

 The output is:
 Id: 11E109F8702B323E9CAF5000568000D0

Is that output wrong ... ?

-- 
James Carlson 42.703N 71.076W carls...@workingcode.com
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread James Carlson
Mehul Choube wrote:
 Hi,
 
 I want to collect the performance information for each myFunc call. The 
 program is multi-threaded and uses multiple queues which can be served by any 
 thread. GUID is the unique handle for each request. I can collect the 
 information and store it based on GUID something like:
 
 @[guid] = ...
 
 I think the ID is correct.

Then just use the data as they are.  Dtrace doesn't have functions that
translate buffers into D strings.

(The trace() mechanism actually logs the raw data; the printing occurs
well after the fact when the user-space code gets ahold of the sampled
data.)

-- 
James Carlson 42.703N 71.076W carls...@workingcode.com
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread Mehul Choube
Hi,

Yes but that is my last resort.
Also, I have other values also like:

io::wait-done
/self-waits/
{
self-elapsed = ((timestamp - self-waits) / 100);
@[guid, pid, tid, args[2]-fi_pathname] = sum(this-elapsed);
self-waits = 0;
}

But now it will have to be:

@[self-Data1, self-Data2, self-Data3, self-Data4, pid, tid, 
args[2]-fi_pathname] = sum(this-elapsed);

Right?



Thanks,
Mehul

-Original Message-
From: Michael Schuster [mailto:michaelspriv...@gmail.com] 
Sent: 08 November 2011 18:40
To: Mehul Choube
Subject: Re: [dtrace-discuss] concatenate structure members into one variable

On Tue, Nov 8, 2011 at 14:02, Mehul Choube mehul_cho...@symantec.com wrote:
 Hi,

 I want to collect the performance information for each myFunc call. The 
 program is multi-threaded and uses multiple queues which can be served by any 
 thread. GUID is the unique handle for each request. I can collect the 
 information and store it based on GUID something like:

 @[guid] = ...


I could be mistaken (it's been a while since I've done any significant
work with DTrace), but can't you use more than one value as value to
hash on, eg @[a,b,c] (check the exact syntax)?

HTH
Michael
 I think the ID is correct.



 Thanks,
 Mehul

 -Original Message-
 From: James Carlson [mailto:carls...@workingcode.com]
 Sent: 08 November 2011 18:15
 To: Mehul Choube
 Cc: dtrace-discuss@opensolaris.org
 Subject: Re: [dtrace-discuss] concatenate structure members into one variable

 Mehul Choube wrote:
 Hi,

 I want the guid in a variable. I tried stringof(), strjoin(),
 copyinstr() but none works L

 As defined, it's a structure containing longs and binary data, not a
 string.  Can you describe what sort of result you'd like to see?  Or
 perhaps what sort of problem you'd like to solve?

 The output is:
 Id: 11E109F8702B323E9CAF5000568000D0

 Is that output wrong ... ?

 --
 James Carlson         42.703N 71.076W         carls...@workingcode.com
 ___
 dtrace-discuss mailing list
 dtrace-discuss@opensolaris.org




-- 
Michael Schuster
http://recursiveramblings.wordpress.com/
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread Mehul Choube
Hi,

self-d4 = ((GUID_t *)this-sptr)-Data4[0];

works but

self-d4 = ((GUID_t *)this-sptr)-Data4;

doesn't with following error:

dtrace: failed to compile script nums.d: line 20: operator = may not be applied 
to operand of type unsigned char [8]



Thanks,
Mehul

-Original Message-
From: James Carlson [mailto:carls...@workingcode.com] 
Sent: 08 November 2011 18:50
To: Mehul Choube
Cc: dtrace-discuss@opensolaris.org
Subject: Re: [dtrace-discuss] concatenate structure members into one variable

Mehul Choube wrote:
 Hi,
 
 I want to collect the performance information for each myFunc call. The 
 program is multi-threaded and uses multiple queues which can be served by any 
 thread. GUID is the unique handle for each request. I can collect the 
 information and store it based on GUID something like:
 
 @[guid] = ...
 
 I think the ID is correct.

Then just use the data as they are.  Dtrace doesn't have functions that
translate buffers into D strings.

(The trace() mechanism actually logs the raw data; the printing occurs
well after the fact when the user-space code gets ahold of the sampled
data.)

-- 
James Carlson 42.703N 71.076W carls...@workingcode.com
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread Chris Ridd

On 8 Nov 2011, at 13:20, James Carlson wrote:

 Mehul Choube wrote:
 Hi,
 
 I want to collect the performance information for each myFunc call. The 
 program is multi-threaded and uses multiple queues which can be served by 
 any thread. GUID is the unique handle for each request. I can collect the 
 information and store it based on GUID something like:
 
 @[guid] = ...
 
 I think the ID is correct.
 
 Then just use the data as they are.  Dtrace doesn't have functions that
 translate buffers into D strings.

It is a pity there's no sprintf; was the omission of sprintf from D a 
deliberate design decision?

Chris
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread James Carlson
Mehul Choube wrote:
 Hi,
 
 self-d4 = ((GUID_t *)this-sptr)-Data4[0];
 
 works but
 
 self-d4 = ((GUID_t *)this-sptr)-Data4;
 
 doesn't with following error:
 
 dtrace: failed to compile script nums.d: line 20: operator = may not be 
 applied to operand of type unsigned char [8]

Since it's an internal array, you should be able to cast it to unsigned
char *.  Or, if you really want to keep broken out values instead of a
structure (why?), you could individually address each byte.

It might be helpful to have something like:

#define DATA4(d4)   (((uint64_t)(d4)[0]56) \
 ((uint64_t)(d4)[1]48) \
 ((uint64_t)(d4)[2]40) \
 ((uint64_t)(d4)[3]32) \
 ((uint64_t)(d4)[4]24) \
 ((uint64_t)(d4)[5]16) \
 ((uint64_t)(d4)[6]8) \
 ((uint64_t)(d4)[7]))

so you can treat that last one as an integral quantity.

-- 
James Carlson 42.703N 71.076W carls...@workingcode.com
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread Jonathan Adams
On Tue, Nov 08, 2011 at 03:48:17AM -0800, Mehul Choube wrote:
 Hi,
 
 I want the guid in a variable. I tried stringof(), strjoin(), copyinstr() but 
 none works :(
 
 D script:
 
 ===
 
 #!/usr/sbin/dtrace -s
 
 #pragma D option quiet
 
 typedef struct GUID {
 unsigned long Data1;
 unsigned long Data2;
 unsigned long Data3;
 unsigned char Data4[8];
 }GUID_t;
 

Have you tried:

pid$1::*myFunc*:entry
{
this-ptr = arg1;
this-sptr = (GUID_t *)copyin(this-ptr, sizeof(GUID_t));

@a[*this-sptr] = count();
^
}

Cheers,
- jonathan

___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] concatenate structure members into one variable

2011-11-08 Thread Mehul Choube
Hi,

The output is:

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  0123456789abcdef
 0: 00 77 83 ef 87 0a e1 11 a4 7b 00 50 56 80 00 d0  .w...{.PV...
10: 00 00 00 00  
1



Thanks,
Mehul

-Original Message-
From: Jonathan Adams [mailto:jonathan.ad...@oracle.com] 
Sent: 09 November 2011 00:27
To: Mehul Choube
Cc: dtrace-discuss@opensolaris.org
Subject: Re: [dtrace-discuss] concatenate structure members into one variable

On Tue, Nov 08, 2011 at 03:48:17AM -0800, Mehul Choube wrote:
 Hi,
 
 I want the guid in a variable. I tried stringof(), strjoin(), copyinstr() but 
 none works :(
 
 D script:
 
 ===
 
 #!/usr/sbin/dtrace -s
 
 #pragma D option quiet
 
 typedef struct GUID {
 unsigned long Data1;
 unsigned long Data2;
 unsigned long Data3;
 unsigned char Data4[8];
 }GUID_t;
 

Have you tried:

pid$1::*myFunc*:entry
{
this-ptr = arg1;
this-sptr = (GUID_t *)copyin(this-ptr, sizeof(GUID_t));

@a[*this-sptr] = count();
^
}

Cheers,
- jonathan

___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org