Discussion:
concatenate structure members into one variable
(too old to reply)
Mehul Choube
2011-11-08 11:48:17 UTC
Permalink
Raw Message
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;

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

printf("Id: ");
printf("%8.8X%4.4X%4.4X%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X\\n",
((GUID_t *)this->sptr)->Data1, ((GUID_t *)this->sptr)->Data2, ((GUID_t *)this->sptr)->Data3,
((GUID_t *)this->sptr)->Data4[0], ((GUID_t *)this->sptr)->Data4[1], ((GUID_t *)this->sptr)->Data4[2],
((GUID_t *)this->sptr)->Data4[3], ((GUID_t *)this->sptr)->Data4[4], ((GUID_t *)this->sptr)->Data4[5],
((GUID_t *)this->sptr)->Data4[6], ((GUID_t *)this->sptr)->Data4[7]);
}

=======

The output is:
Id: 11E109F8702B323E9CAF5000568000D000000000

Any help is greatly appreciated.



Thanks,
Mehul
James Carlson
2011-11-08 12:44:45 UTC
Permalink
Raw Message
Post by Mehul Choube
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?
Post by Mehul Choube
Id: 11E109F8702B323E9CAF5000568000D000000000
Is that output wrong ... ?
--
James Carlson 42.703N 71.076W <carlsonj-dlRbGz2WjHhmlEb+***@public.gmane.org>
Mehul Choube
2011-11-08 13:02:55 UTC
Permalink
Raw Message
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:carlsonj-dlRbGz2WjHhmlEb+***@public.gmane.org]
Sent: 08 November 2011 18:15
To: Mehul Choube
Cc: dtrace-discuss-***@public.gmane.org
Subject: Re: [dtrace-discuss] concatenate structure members into one variable
Post by Mehul Choube
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?
Post by Mehul Choube
Id: 11E109F8702B323E9CAF5000568000D000000000
Is that output wrong ... ?
--
James Carlson 42.703N 71.076W <carlsonj-dlRbGz2WjHhmlEb+***@public.gmane.org>
James Carlson
2011-11-08 13:20:15 UTC
Permalink
Raw Message
Loading...