From 882f2f0d6f0680990be5debde222cfd326afe0b8 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Thu, 4 Dec 2008 14:43:33 +1000 Subject: more edits --- .../en-US/Array-Operations.xml | 13 ++++- doc/SystemTap_Beginners_Guide/en-US/Arrays.xml | 60 ++++------------------ .../en-US/Understanding_How_SystemTap_Works.xml | 2 + 3 files changed, 24 insertions(+), 51 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide') diff --git a/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml b/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml index c053c329..9c5e5a9f 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml @@ -178,7 +178,18 @@ delta = gettimeofday_s() - foo[tid()] -In , the first statement sets a timestamp associated with the returned value of the handler function tid() as a reference point. The second statement computes a value for the variable delta by subtracting the associated value the reference point from the current gettimeofday_s(). Note that the first statement writes the value of gettimeofday_s() into the appropriate key of array foo, while in the second statement the value of foo[tid()] is read from the array in order to compute for delta. + + In , the first statement sets a timestamp associated + with the returned value of the handler function tid() as a + reference point. + The second statement computes a value for the variable + delta by subtracting the associated value the reference point from the + current gettimeofday_s(). Note that the first statement writes the value + of gettimeofday_s() into the appropriate key of array + foo, while in the second statement the value of + foo[tid()] is read from the array in order to compute + for delta. + reading values from arrays diff --git a/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml b/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml index fa81d7fc..36423fb4 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml @@ -13,7 +13,10 @@ associative arrays introduction -SystemTap also supports the use of associative arrays. While an ordinary variable represents a single value, associative arrays can represent a list of values. Simply put, an associative array is a collection of unique keys; each key in the array has a value associated with it. Illustrating this visually would be similar to creating a two-column table: the first column would have the unique key, while the second column would have each key's associated value. Each unique key and its associated value is referred to as a key pair. + +SystemTap also supports the use of associative arrays. While an ordinary variable represents a single value, associative arrays can represent a list of values. Simply put, an associative array is a collection of unique keys; each key in the array has a value associated with it. + + @@ -156,62 +159,19 @@ foo["harry"] = 25 - - Important - All associate arrays must be declared as global, regardless of whether the associate array is used in one or multiple probes. - - - -
- Array Slots - - - -arrays -introduction -slots - - - -associative arrays -introduction -slots - - - -slots -introduction -arrays - -Another important point to remember in arrays is that each element therein (i.e. the indexed expression) exists in a slot. A key pair's slot is defined by the order in which each pair's unique key is defined. In our sample array foo in , the key pair that uses the unique key tom is in the first slot, since tom was the first unique key to be defined. dick is in the second slot, and so on. - - - -For example, the array statements in set 23 as the associated value of the unique key tom. Given the same array foo, we can increment the associated value of tom by 1 using the operator ++, like so: +You can specify up to 5 index expressons in an array statement, each one delimited by a comma (,). This is useful if you wish to perform the same operation to a set of key pairs. For example, to increase the associated value of all the key pairs defined by , you can use the following statement: -foo["tom"] ++ +foo["tom","dick","harry"] ++ -The above statement will increase the associated value of unique key tom to 24. Now, looking back at , we know that dick was the first unique key to be defined. As such, we can perform the same operation (i.e. incrementing associated value by 1) to dick using the following statement: - - -foo[2] ++ - + + Important + All associate arrays must be declared as global, regardless of whether the associate array is used in one or multiple probes. + - - Note - You can specify up to 5 index expressons in an array statement, each one delimited by a comma (,). This is useful if you wish to perform the same operation to a set of key pairs. For example, to increase the associated value of all the key pairs defined by , you can use the following statement: - - -foo["tom",2,"harry"] ++ - - -
-