Re: [dtrace-discuss] Invalid address error when using stringof to convert a pointer to a string

2010-05-05 Thread Michael Schuster, Oracle

On 04.05.10 21:13, Yossi Lev wrote:

No, this-entry-pc is not a user-space pointer --- it is not a pointer at all, 
it is an unsigned integer that I would like to convert to a string.

Here is what I'm trying to do:

- I have a structure of type ReadAcqEntry at userspace with various
   numeric fields (unsigned long long type).

- I would like to convert a few of these fields to a string (e.g. for
   the purpose of concatenating it with other strings), and use the
   numerical value of the others.

What I was doing so far is copying the whole structure with:

   this-entry = 
(ReadAcqEntry*)copyin((uintptr_t)(this-rAcqArr[this-numEntries-1]) , 
sizeof(ReadAcqEntry));

so now this-entry points to the local copy of the structure.  Now I can
access all of the structure's fields as integers (I tested this part and
it works fine), but I am not sure how I can convert some of the fields
to strings.  What I really need is the equivalent of sprintf or itoa...

It seems like stringof requires a pointer, so I am not sure that this is
what I need to use here.


no, you don't, regular printf will work:

printf(%d, somenumber);

stringof(p) returns string pointer to character array(p) (strings and 
character arrays are not the same in DTrace), but it does not do the 
integer-string conversion you're looking for.


I can't think of a way of doing the exact equivalent of sprintf(s, %d, 
number) and then continue using 's' within your D script. what do you need 
a string for here that the numbers themselves won't solve?


Michael
--
Michael SchusterOracle
Recursion, n.: see 'Recursion'
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] ?: DTrace of connection establishment attempts for destination address/port

2010-05-05 Thread Jim Mauro

Hi Steffen - I actually think that code did change quite a bit
from s10 to nv.

I'm not sure what you need to do, but you may want to grab
Brendan's DTraceToolKit and have a look at tcptop and
tcpsnoop, and have a look at how Brendan did it for s10.

Thanks,
/jim

On May 5, 2010, at 8:21 AM, Steffen Weiberle wrote:

 Using Solaris 10, so no IP provider, I am trying to figure out when a
 connection attempt is failing in a client. The connect() statement takes
 a file descriptor, which is an integer and has no connection details.
 Since I don't know if the connect is closely preceded with a bind() or a new 
 connection may be attempted with the same socket, and thus I won't be 
 capturing the bin, I can't rely on it to get the sockaddr structure.
 
 (The event happens very infrequently, maybe once a day)
 
 So I am trying tcp_connect FBT probe.
 
 fbt::tcp_connect:entry
 {
   printf(execname: %s \n, execname);
   self-sockaddr = args[1];
 
   printf(family: %x \n, self-sockaddr-sa_family);
 }
 
 However, I get
 
 # /var/tmp/connect.d
 dtrace: failed to compile script /var/tmp/connect.d: line 32: sa_family
 is not a member of struct msgb
 
 Note is says 'msgb', not 'sockaddr'.
 
 I got the args[1] from the OpenSolaris source code (and maybe that is my
 problem, since I am running on Solaris 10--did the code change that
 much?--seems unlikely)
 
 http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/inet/tcp/tcp_socket.c#232
 
 Any good way to grab the IPv4 address and port number on an entry so I
 can have it in the situation the connect() fails?
 
 Thanks
 Steffen
 
 
 ___
 dtrace-discuss mailing list
 dtrace-discuss@opensolaris.org

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


Re: [dtrace-discuss] ?: DTrace of connection establishment attempts for destination address/port

2010-05-05 Thread m...@bruningsystems.com

Hi,

Steffen Weiberle wrote:

Using Solaris 10, so no IP provider, I am trying to figure out when a
connection attempt is failing in a client. The connect() statement takes
a file descriptor, which is an integer and has no connection details.
Since I don't know if the connect is closely preceded with a bind() or 
a new connection may be attempted with the same socket, and thus I 
won't be capturing the bin, I can't rely on it to get the sockaddr 
structure.


(The event happens very infrequently, maybe once a day)

So I am trying tcp_connect FBT probe.

fbt::tcp_connect:entry
{
   printf(execname: %s \n, execname);
   self-sockaddr = args[1];

   printf(family: %x \n, self-sockaddr-sa_family);
}

However, I get

# /var/tmp/connect.d
dtrace: failed to compile script /var/tmp/connect.d: line 32: sa_family
is not a member of struct msgb

Note is says 'msgb', not 'sockaddr'.

Try:

   self-sockaddr = (struct sockaddr *) args[1]-b_rptr;

struct msgb is a STREAMS mblk_t.

max



I got the args[1] from the OpenSolaris source code (and maybe that is my
problem, since I am running on Solaris 10--did the code change that
much?--seems unlikely)

http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/inet/tcp/tcp_socket.c#232 



Any good way to grab the IPv4 address and port number on an entry so I
can have it in the situation the connect() fails?

Thanks
Steffen


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



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


Re: [dtrace-discuss] Invalid address error when using stringof to convert a pointer to a string

2010-05-05 Thread Yossi Lev
Hi Michael

I just found a function that (sort of) does what I need: it is called lltostr 
and it takes a long long integer, and returns a string that represents it.  
(Unfortunately I didn't find an option to do the translation in hexadecimal, 
but I can live with that...)

 As for your question, I need to use the numbers as a key to an aggregation, 
but I need to concatenate a few of those.  In particular, I have a sequence of 
N numbers where N  9, and I need to count how many times I'm getting each 
sequence.  The value of N may be different in separate invocations of the probe 
function, so I would like to use an unrolled loop to concatenate the N numbers 
to single string representing the sequence, and then use the string as the key 
to my aggregation.  

Do you see any other option but to use the lltostr function to and concatenate 
the resulted strings?

Thanks,
Yossi
-- 
This message posted from opensolaris.org
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] Invalid address error when using stringof to convert a pointer to a string

2010-05-05 Thread Michael Schuster

On 05.05.10 18:11, Yossi Lev wrote:

Hi Michael

I just found a function that (sort of) does what I need: it is called lltostr 
and it takes a long long integer, and returns a string that represents it.  
(Unfortunately I didn't find an option to do the translation in hexadecimal, 
but I can live with that...)

  As for your question, I need to use the numbers as a key to an aggregation, but 
I need to concatenate a few of those.  In particular, I have a sequence of N 
numbers where N  9, and I need to count how many times I'm getting each 
sequence.  The value of N may be different in separate invocations of the probe 
function, so I would like to use an unrolled loop to concatenate the N numbers to 
single string representing the sequence, and then use the string as the key to my 
aggregation.

Do you see any other option but to use the lltostr function to and concatenate 
the resulted strings?


does this answer your question:

$ pfexec dtrace -n 'syscall:::ent...@c[execname,pid] = count()}'
dtrace: description 'syscall:::entry' matched 227 probes

look closely at the [...] part :-)

HTH
Michael
--
michael.schus...@oracle.com http://blogs.sun.com/recursion
Recursion, n.: see 'Recursion'
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] Invalid address error when using stringof to convert a pointer to a string

2010-05-05 Thread Nicolas Williams
On Wed, May 05, 2010 at 09:11:27AM -0700, Yossi Lev wrote:
 I just found a function that (sort of) does what I need: it is called
 lltostr and it takes a long long integer, and returns a string that
 represents it.  (Unfortunately I didn't find an option to do the
 translation in hexadecimal, but I can live with that...)
 
  As for your question, I need to use the numbers as a key to an
  aggregation, but I need to concatenate a few of those.  In
  particular, I have a sequence of N numbers where N  9, and I need to
  count how many times I'm getting each sequence.  The value of N may
  be different in separate invocations of the probe function, so I
  would like to use an unrolled loop to concatenate the N numbers to
  single string representing the sequence, and then use the string as
  the key to my aggregation.  
 
 Do you see any other option but to use the lltostr function to and
 concatenate the resulted strings?

Yes: aggregations take multiple keys, not just one, so rather than
format a string with all the key content that you need: use a comma-
separated list of expressions of various types as the key.  See:

http://docs.sun.com/app/docs/doc/819-5488/gcggh?a=view

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


Re: [dtrace-discuss] Invalid address error when using stringof to convert a pointer to a string

2010-05-05 Thread Yossi Lev
Thanks, I know that I can provide multiple keys, but the number of keys for an 
aggregation must be constant, and I didn't want to pad with zeros all missing 
keys as in the common case my sequence has 2 or 3 keys (and not the maximum 
number of 8).  These are minor issues that have to do with how the data looks 
when it is printed at the end --- I'm trying to use DTrace to generate a 
performance profiling report that the users can read, so do not want to add 
many trailing zeros to everything.

I guess I could store the information on different aggregations depending on 
the number of keys that I get, but an integer--string translation results in a 
much simpler/cleaner script, which is why I posted this message asking whether 
there is a function that does it.

Thanks for all the help!
Yossi
-- 
This message posted from opensolaris.org
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org


Re: [dtrace-discuss] Invalid address error when using stringof to convert a pointer to a string

2010-05-05 Thread Michael Schuster

On 05.05.10 18:40, Yossi Lev wrote:

Thanks, I know that I can provide multiple keys, but the number of keys
for an aggregation must be constant, and I didn't want to pad with zeros
all missing keys as in the common case my sequence has 2 or 3 keys (and
not the maximum number of 8).  These are minor issues that have to do
with how the data looks when it is printed at the end --- I'm trying to
use DTrace to generate a performance profiling report that the users can
read, so do not want to add many trailing zeros to everything.


you may want to consider post-processing with your favourite string 
manipulation tool for the looks of your output.


Michael
--
michael.schus...@oracle.com http://blogs.sun.com/recursion
Recursion, n.: see 'Recursion'
___
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org