]> sourceware.org Git - systemtap.git/commitdiff
Map std semaphores from probe->addr
authorJosh Stone <jistone@redhat.com>
Thu, 17 Sep 2009 23:37:36 +0000 (16:37 -0700)
committerJosh Stone <jistone@redhat.com>
Thu, 17 Sep 2009 23:52:31 +0000 (16:52 -0700)
Each probe needs to know the associated semaphore address, rather than
the other way around.

* session.h (sdt_semaphore_addr): Reverse the key-value types.
* tapsets.cxx (record_semaphore): Take an index to only record the
  semaphore for newly added results.
  (sdt_query::handle_query_module): Adjust accordingly.
  (uprobe_derived_probe_group::emit_module_decls): Now it's a simple map
  lookup for sdt_sem_address.
* tapset-utrace.cxx (utrace_derived_probe_group::emit_probe_decl): Ditto.

session.h
tapset-utrace.cxx
tapsets.cxx

index 4f50971433c80c31c5e5d794307255fcb8887247..760b610ab98b66ed4b66170f285cc876370af434 100644 (file)
--- a/session.h
+++ b/session.h
@@ -223,7 +223,7 @@ struct systemtap_session
 
 
   // Location of semaphores to activate sdt probes
-  std::map<Dwarf_Addr, derived_probe*> sdt_semaphore_addr;
+  std::map<derived_probe*, Dwarf_Addr> sdt_semaphore_addr;
 
   // NB: It is very important for all of the above (and below) fields
   // to be cleared in the systemtap_session ctor (elaborate.cxx)
index 639f0c20901dda048016e0b47661aa7f6c996826..9e5ce939bf2096d4ef1b114adad2fc93b3c036cd 100644 (file)
@@ -716,20 +716,14 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s,
       break;
     }
   s.op->line() << " .engine_attached=0,";
-  map<Dwarf_Addr, derived_probe*>::iterator its;
-  if (s.sdt_semaphore_addr.empty())
+
+  map<derived_probe*, Dwarf_Addr>::iterator its = s.sdt_semaphore_addr.find(p);
+  if (its == s.sdt_semaphore_addr.end())
     s.op->line() << " .sdt_sem_address=(unsigned long)0x0,";
   else
-    for (its = s.sdt_semaphore_addr.begin();
-        its != s.sdt_semaphore_addr.end();
-        its++)
-      {
-       if (p == ((struct utrace_derived_probe*)(its->second)))
-         {
-           s.op->line() << " .sdt_sem_address=(unsigned long)0x" << hex << its->first << dec << "ULL,";
-           break;
-         }
-      }
+    s.op->line() << " .sdt_sem_address=(unsigned long)0x"
+                 << hex << its->second << dec << "ULL,";
+
   s.op->line() << " .tsk=0,";
   s.op->line() << " },";
 }
index 53f8ace599671f9453899a04807201ab5f68b5be..4bede3c9b165690f91baa9cdbe558a3572b8118b 100644 (file)
@@ -3509,7 +3509,7 @@ private:
   bool get_next_probe();
 
   void convert_probe(probe *base);
-  void record_semaphore(vector<derived_probe *> & results);
+  void record_semaphore(vector<derived_probe *> & results, unsigned start);
   void convert_location(probe *base, probe_point *location);
 };
 
@@ -3560,11 +3560,8 @@ sdt_query::handle_query_module()
       unsigned i = results.size();
 
       if (probe_type == kprobe_type || probe_type == utrace_type)
-       {
-         derive_probes(sess, new_base, results);
-         record_semaphore(results);
-       }
-      
+        derive_probes(sess, new_base, results);
+
       else
         {
           literal_map_t params;
@@ -3577,9 +3574,10 @@ sdt_query::handle_query_module()
           dwarf_query q(new_base, new_location, dw, params, results);
           q.has_mark = true; // enables mid-statement probing
           dw.iterate_over_modules(&query_module, &q);
-         record_semaphore(results);
         }
 
+      record_semaphore(results, i);
+
       if (sess.listing_mode)
         {
           // restore the locations to print a nicer probe name
@@ -3709,7 +3707,7 @@ sdt_query::get_next_probe()
 
 
 void
-sdt_query::record_semaphore (vector<derived_probe *> & results)
+sdt_query::record_semaphore (vector<derived_probe *> & results, unsigned start)
 {
   int sym_count = dwfl_module_getsymtab(dw.module);
   assert (sym_count >= 0);
@@ -3722,8 +3720,8 @@ sdt_query::record_semaphore (vector<derived_probe *> & results)
        {
          string process_name;
          derived_probe_builder::get_param(params, TOK_PROCESS, process_name);
-          for (unsigned int i = 0; i < results.size(); ++i)
-             sess.sdt_semaphore_addr.insert(make_pair(sym.st_value, results[i]));
+          for (unsigned i = start; i < results.size(); ++i)
+            sess.sdt_semaphore_addr.insert(make_pair(results[i], sym.st_value));
          break;
        }
     }
@@ -4471,22 +4469,16 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s)
       s.op->line() << " .address=(unsigned long)0x" << hex << p->addr << dec << "ULL,";
       s.op->line() << " .pp=" << lex_cast_qstring (*p->sole_location()) << ",";
       s.op->line() << " .ph=&" << p->name << ",";
-      map<Dwarf_Addr, derived_probe*>::iterator its;
-      if (s.sdt_semaphore_addr.empty())
+
+      map<derived_probe*, Dwarf_Addr>::iterator its = s.sdt_semaphore_addr.find(p);
+      if (its == s.sdt_semaphore_addr.end())
        s.op->line() << " .sdt_sem_address=(unsigned long)0x0,";
       else
-       for (its = s.sdt_semaphore_addr.begin();
-            its != s.sdt_semaphore_addr.end();
-            its++)
-         {
-           if (p->module == ((struct uprobe_derived_probe*)(its->second))->module
-               && p->addr == ((struct uprobe_derived_probe*)(its->second))->addr)
-             {
-               s.op->line() << " .sdt_sem_address=(unsigned long)0x" << hex << its->first << dec << "ULL,";
-               break;
-             }
-         }
-      if (p->has_return) s.op->line() << " .return_p=1,";
+        s.op->line() << " .sdt_sem_address=(unsigned long)0x"
+                     << hex << its->second << dec << "ULL,";
+
+      if (p->has_return)
+        s.op->line() << " .return_p=1,";
       s.op->line() << " },";
     }
   s.op->newline(-1) << "};";
This page took 0.290061 seconds and 5 git commands to generate.