From f02d561e798f1c599c4c622983946a6e6fb53395 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Tue, 9 Dec 2008 15:14:40 +1000 Subject: revised discussion on multiple index expressions --- .../en-US/Array-Operations.xml | 38 ++++++++++++++++++++++ doc/SystemTap_Beginners_Guide/en-US/Arrays.xml | 4 +-- 2 files changed, 40 insertions(+), 2 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 987e2b29..8fe46721 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Array-Operations.xml @@ -1148,6 +1148,44 @@ reads[execname()] <<< count --> + + + When using statistical aggregates, you can also build array constructs that use multiple index + expressions (to a maximum of 5). This is helpful in capturing additional contextual information + during a probe. For example: + + + + Multiple Array Indexes + +global reads +probe vfs.read +{ +reads[execname(),pid()] <<< 1 +} +probe timer.s(3) +{ +foreach([var1,var2] in reads) + printf("%s (%d) : %d \n", var1, var2, @count(reads[var1,var2])) +} + + + + + In , the first probe tracks how many times each process + performs a VFS read. What makes this different from earlier examples is that this array associates + a performed read to both a process name and its corresponding process ID. + + + + The second probe in demonstrates how to process and print + the information collected by the array reads. Note how the + foreach statement uses the same number of variables (i.e. + var1 and var2) contained in the first instance of the array + reads from the first probe. + + + \ No newline at end of file diff --git a/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml b/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml index 36423fb4..04e34de3 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Arrays.xml @@ -158,13 +158,13 @@ foo["dick"] = 24 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. -- cgit