From e91b23bc1b375d7ffb3395aa6909713bd1f23c10 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 26 Sep 2008 16:22:43 -0400 Subject: sort arrays by value- subject to automagic foreach/printf --- ChangeLog | 4 ++++ elaborate.cxx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d62f154f..0683cce2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-09-26 Frank Ch. Eigler + + * elaborate.cxx (add_global_var_display): Implicitly sort arrays. + 2008-09-26 Frank Ch. Eigler PR 6916 diff --git a/elaborate.cxx b/elaborate.cxx index 94bfd1c5..afdc796e 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1234,7 +1234,8 @@ void add_global_var_display (systemtap_session& s) vardecl* idx_v[idx_count]; // Create a foreach loop foreach_loop* fe = new foreach_loop; - fe->sort_direction = 0; + fe->sort_direction = -1; // imply decreasing sort on value + fe->sort_column = 0; // as in foreach ([a,b,c] in array-) { } fe->limit = NULL; // Create indices for the foreach loop -- cgit From a3de5d6e615aafb9528e22db5eeb6ddc12823256 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 30 Sep 2008 16:35:13 +0200 Subject: Don't crash when reporting an error if getting alternatives fails. --- ChangeLog | 6 ++++++ tapsets.cxx | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d62f154f..ea1d51d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-09-30 Mark Wielaard + + * tapsets.cxx (literal_stmt_for_local): Check if alternatives can be + provided after calling dwarf_formref_die. + (literal_stmt_for_return): Likewise. + 2008-09-26 Frank Ch. Eigler PR 6916 diff --git a/tapsets.cxx b/tapsets.cxx index b1475997..a5a62c7a 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2241,7 +2241,8 @@ struct dwflpp { die = dwarf_formref_die (&attr_mem, &vardie); stringstream alternatives; - print_members(die,alternatives); + if (die != NULL) + print_members(die,alternatives); throw semantic_error("unable to find local '" + local + "'" + " near pc " + lex_cast_hex(pc) + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")"))); @@ -2317,7 +2318,8 @@ struct dwflpp { die = dwarf_formref_die (&attr_mem, vardie); stringstream alternatives; - print_members(die,alternatives); + if (die != NULL) + print_members(die,alternatives); throw semantic_error("unable to find return value" " near pc " + lex_cast_hex(pc) + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")"))); -- cgit From f12c75dd38c4990b9410410cc23e33004d3677ed Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Mon, 29 Sep 2008 17:58:31 +0200 Subject: Fix race condition in addr-map; simplify allocation logic --- runtime/ChangeLog | 5 +++ runtime/addr-map.c | 99 +++++++++++++++++++++++++++++------------------------- 2 files changed, 58 insertions(+), 46 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 6672dbb5..677b32ee 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2008-09-30 Tim Moore + + * addr-map.c (add_bad_addr_entry): Rewrite allocation of address + table to simplify locking and eliminate a race condition. + 2008-09-26 David Smith * task_finder.c (__STP_ATTACHED_TASK_EVENTS): Removed UTRACE_STOP, diff --git a/runtime/addr-map.c b/runtime/addr-map.c index 8231b57f..c215b744 100644 --- a/runtime/addr-map.c +++ b/runtime/addr-map.c @@ -113,64 +113,71 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, struct addr_map_entry* max_entry = 0; struct addr_map_entry* new_entry = 0; size_t existing = 0; - + + /* Loop allocating memory for a new entry in the map. */ while (1) { - size_t old_size; + size_t old_size = 0; spin_lock(&addr_map_lock); old_map = blackmap; - if (!blackmap) - { - existing = 0; - old_size = 0; - } - else + if (old_map) + old_size = old_map->size; + /* Either this is the first time through the loop, or we + allocated a map previous time, but someone has come in and + added an entry while we were sleeping. */ + if (!new_map || (new_map && new_map->size < old_size + 1)) { - min_entry = lookup_addr_aux(min_addr, blackmap); - max_entry = lookup_addr_aux(max_addr, blackmap); - if (min_entry || max_entry) + spin_unlock(&addr_map_lock); + if (new_map) { - if (existing_min) - *existing_min = min_entry; - if (existing_max) - *existing_max = max_entry; - spin_unlock(&addr_map_lock); - return 1; + kfree(new_map); + new_map = 0; } - existing = upper_bound(min_addr, old_map); - old_size = old_map->size; - } - spin_unlock(&addr_map_lock); - new_map = kmalloc(sizeof(*new_map) - + sizeof(*new_entry) * (old_size + 1), - GFP_KERNEL); - if (!new_map) - return -ENOMEM; - spin_lock(&addr_map_lock); - if (blackmap != old_map) - { - kfree(new_map); - spin_unlock(&addr_map_lock); + new_map = kmalloc(sizeof(*new_map) + + sizeof(*new_entry) * (old_size + 1), + GFP_KERNEL); + if (!new_map) + return -ENOMEM; + new_map->size = old_size + 1; continue; } - new_entry = &new_map->entries[existing]; - new_entry->min = min_addr; - new_entry->max = max_addr; - if (old_map) + } + if (!blackmap) + { + existing = 0; + } + else + { + min_entry = lookup_addr_aux(min_addr, blackmap); + max_entry = lookup_addr_aux(max_addr, blackmap); + if (min_entry || max_entry) { - memcpy(&new_map->entries, old_map->entries, - existing * sizeof(*new_entry)); - if (old_map->size > existing) - memcpy(new_entry + 1, &old_map->entries[existing + 1], - (old_map->size - existing) * sizeof(*new_entry)); + if (existing_min) + *existing_min = min_entry; + if (existing_max) + *existing_max = max_entry; + spin_unlock(&addr_map_lock); + kfree(new_map); + return 1; } - new_map->size = blackmap->size + 1; - blackmap = new_map; - spin_unlock(&addr_map_lock); - if (old_map) - kfree(old_map); - return 0; + existing = upper_bound(min_addr, old_map); + } + new_entry = &new_map->entries[existing]; + new_entry->min = min_addr; + new_entry->max = max_addr; + if (old_map) + { + memcpy(&new_map->entries, old_map->entries, + existing * sizeof(*new_entry)); + if (old_map->size > existing) + memcpy(new_entry + 1, &old_map->entries[existing + 1], + (old_map->size - existing) * sizeof(*new_entry)); } + blackmap = new_map; + spin_unlock(&addr_map_lock); + if (old_map) + kfree(old_map); + return 0; } void -- cgit From 7115de8281be8cb68880210572ba0a0141509fb9 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 30 Sep 2008 14:49:43 -0400 Subject: PR6925: add more information about installing and running stap --- README | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/README b/README index 6b62c772..5732cf63 100644 --- a/README +++ b/README @@ -23,12 +23,12 @@ Installation steps: Build steps: -- Install the kernel-debuginfo, kernel-[smp-]devel, gcc and libcap-devel +- Install the kernel-debuginfo, kernel-devel, gcc and dependent packages (or see below if you are building your own kernels from source). - If available, install your distribution's copy of elfutils and its - development headers/libraries. -- Or if desired, download an elfutils source release to build in +- If available, install your distribution's copy of elfutils and its + development headers/libraries. + Or if desired, download an elfutils source release to build in "bundled mode" (below), and untar it into some new directory. Or if desired, build elfutils separately one time, and install it to /usr/local. @@ -45,15 +45,36 @@ Build steps: % .../configure [other autoconf options] Or, with build it with a bundled internal copy of elfutils: % .../configure --with-elfutils=ELFUTILS-SOURCE-DIR [other autoconf options] + Consider configuring with "--enable-dejazilla" to automatically contribute to our public test result database. + Consider configuring with "--prefix=DIRECTORY" to specify an + installation directory other than /usr/local. It can be an ordinary + personal directory. + % make all % sudo make install - To run the full test suite: + To uninstall systemtap: + % sudo make uninstall + +- Run systemtap: + + To run the full test suite from the build tree. % sudo make installcheck + To run systemtap, add $prefix/bin to your $PATH, or refer to + $prefix/bin/stap directly. Some samples should be available under + $prefix/share/doc/systemtap/examples. Normally, run "stap" as root. + + If desired, create "stapdev" and "stapusr" entries in /etc/groups. + Any users in "stapdev" will be able to run systemtap as if with root + privileges. Users in "stapusr" can only launch (with "staprun") + pre-compiled probe modules (created by "stap -p4 ...") that a system + administrator copied under /lib/modules/`uname -r`/systemtap. + + Tips: - By default, systemtap looks for the debug info in these locations: -- cgit From b586f21fc0dbd1e195ece774f02334589a10ddb1 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 30 Sep 2008 14:51:26 -0400 Subject: PR6925: mention the possibility of running the build tree "stap" after "make install" --- README | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README b/README index 5732cf63..13b3aa5f 100644 --- a/README +++ b/README @@ -64,9 +64,12 @@ Build steps: To run the full test suite from the build tree. % sudo make installcheck - To run systemtap, add $prefix/bin to your $PATH, or refer to - $prefix/bin/stap directly. Some samples should be available under - $prefix/share/doc/systemtap/examples. Normally, run "stap" as root. + To run systemtap after installation, add $prefix/bin to your $PATH, or + refer to $prefix/bin/stap directly. If you keep your build tree + around, you can also use the "stap" binary there. + + Some samples should be available under $prefix/share/doc/systemtap/examples. + Normally, run "stap" as root. If desired, create "stapdev" and "stapusr" entries in /etc/groups. Any users in "stapdev" will be able to run systemtap as if with root -- cgit From d90adf0dff664bfe6a7f9b7e6ba0e008ca261a40 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 30 Sep 2008 19:26:39 -0400 Subject: More README text tweaks for run options --- README | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README b/README index 13b3aa5f..b7434256 100644 --- a/README +++ b/README @@ -10,10 +10,10 @@ See the INSTALL file for generic build instructions. Prerequisites: - linux kernel with kprobes (mainline 2.6.11+ or backport) -- kernel module build environment (kernel-devel or kernel-smp-devel rpm) +- kernel module build environment (kernel-devel rpm) - kernel debugging information (kernel-debuginfo rpm) - C compiler (same as what kernel was compiled with) -- elfutils with libdwfl for debugging informatin parsing +- elfutils with libdwfl for debugging information parsing - root privileges Installation steps: @@ -61,21 +61,21 @@ Build steps: - Run systemtap: - To run the full test suite from the build tree. - % sudo make installcheck - To run systemtap after installation, add $prefix/bin to your $PATH, or refer to $prefix/bin/stap directly. If you keep your build tree around, you can also use the "stap" binary there. Some samples should be available under $prefix/share/doc/systemtap/examples. - Normally, run "stap" as root. - If desired, create "stapdev" and "stapusr" entries in /etc/groups. - Any users in "stapdev" will be able to run systemtap as if with root - privileges. Users in "stapusr" can only launch (with "staprun") - pre-compiled probe modules (created by "stap -p4 ...") that a system - administrator copied under /lib/modules/`uname -r`/systemtap. + Normally, run "stap" as root. If desired, create "stapdev" and + "stapusr" entries in /etc/groups. Any users in "stapdev" will be + able to run systemtap as if with root privileges. Users in "stapusr" + can only launch (with "staprun") pre-compiled probe modules (created + by "stap -p4 ...") that a system administrator copied under + /lib/modules/`uname -r`/systemtap. + + To run the full test suite from the build tree. + % sudo make installcheck Tips: -- cgit From 94c98493aea16a4ef49b2eff31cf6ca98e92fddc Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 1 Oct 2008 07:07:39 -0400 Subject: fix test suite regression due to commit e91b23bc Reported-By: mjw --- testsuite/systemtap.base/optim_arridx.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp index bef4d2b4..1f3f4371 100644 --- a/testsuite/systemtap.base/optim_arridx.exp +++ b/testsuite/systemtap.base/optim_arridx.exp @@ -58,7 +58,7 @@ end /* <- end */ # locals idx0:long { -foreach ([idx0] in arr3) printf("arr3[%#d]=%#x\\n", idx0, arr3[idx0]) +foreach ([idx0] in arr3-) printf("arr3[%#d]=%#x\\n", idx0, arr3[idx0]) } end /* <- end */ { -- cgit From dd4918442a55569175bda0575f746e84c99cee58 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 1 Oct 2008 13:38:16 +0200 Subject: Adjust semok/thirtythree.stp test to pass on older kernels. --- testsuite/ChangeLog | 5 +++++ testsuite/semok/thirtythree.stp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index f3fad077..4825cd27 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-10-01 Mark Wielaard + + * semok/thirtythree.stp: Use page->mapping instead of page->inuse + as annonymous struct value (also available in older kernels). + 2008-09-26 Frank Ch. Eigler PR 6916. diff --git a/testsuite/semok/thirtythree.stp b/testsuite/semok/thirtythree.stp index d5171f66..90070370 100755 --- a/testsuite/semok/thirtythree.stp +++ b/testsuite/semok/thirtythree.stp @@ -1,5 +1,5 @@ #! stap -p2 # Per bz3016, this should get through the semantic pass without warnings. probe kernel.function("do_mpage_readpage") { - printf("\n page ->inuse %u",$page->inuse) + printf("\n page->mapping %p",$page->mapping) } -- cgit From caf566cb319004a314b09ea6fd6781941db89f8e Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 2 Oct 2008 10:31:49 +0200 Subject: fix bugs in add_bad_addr_entry --- runtime/ChangeLog | 5 +++++ runtime/addr-map.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 677b32ee..e22bee26 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2008-10-02 Tim Moore + + * addr-map.c (add_bad_addr_entry): Fix bugs in allocating a new + table and copying old entries into the new table. + 2008-09-30 Tim Moore * addr-map.c (add_bad_addr_entry): Rewrite allocation of address diff --git a/runtime/addr-map.c b/runtime/addr-map.c index c215b744..706da454 100644 --- a/runtime/addr-map.c +++ b/runtime/addr-map.c @@ -139,8 +139,9 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, if (!new_map) return -ENOMEM; new_map->size = old_size + 1; - continue; } + else + break; } if (!blackmap) { @@ -170,7 +171,7 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, memcpy(&new_map->entries, old_map->entries, existing * sizeof(*new_entry)); if (old_map->size > existing) - memcpy(new_entry + 1, &old_map->entries[existing + 1], + memcpy(new_entry + 1, &old_map->entries[existing], (old_map->size - existing) * sizeof(*new_entry)); } blackmap = new_map; -- cgit