]> sourceware.org Git - systemtap.git/commitdiff
Give good error messages for inodes uprobes registration errors.
authorDavid Smith <dsmith@redhat.com>
Tue, 8 May 2012 21:07:08 +0000 (16:07 -0500)
committerDavid Smith <dsmith@redhat.com>
Tue, 8 May 2012 21:07:08 +0000 (16:07 -0500)
* translate.cxx (c_unparser::emit_module_init): Only print an error if
  'probe_point' isn't NULL.
* tapsets.cxx (uprobe_derived_probe_group::emit_module_inode_init): Let
  stapiu_init() handle reporting errors by setting 'probe_point' to NULL.
* runtime/uprobes-inode.c (stapiu_get): Print errors when needed.
  (stapiu_reg): Ditto.

runtime/uprobes-inode.c
tapsets.cxx
translate.cxx

index fc2dd058ed61d3ea69b1853527a8774180b63186..2dbaf063d7a9440db1be366cf982deb7e1869189 100644 (file)
@@ -222,15 +222,26 @@ stapiu_get(struct stapiu_target *targets, size_t ntargets)
                INIT_LIST_HEAD(&ut->consumers);
                INIT_LIST_HEAD(&ut->processes);
                ret = stap_register_task_finder_target(&ut->finder);
-               if (!ret)
-                       ret = kern_path(ut->filename, LOOKUP_FOLLOW, &path);
-               if (!ret) {
-                       ut->inode = igrab(path.dentry->d_inode);
-                       if (!ut->inode)
-                               ret = -EINVAL;
+               if (ret != 0) {
+                       _stp_error("Couldn't register task finder target for file '%s': %d\n",
+                                  ut->filename, ret);
+                       break;
                }
-               if (ret)
+
+               ret = kern_path(ut->filename, LOOKUP_FOLLOW, &path);
+               if (ret != 0) {
+                       _stp_error("Couldn't lookup file '%s': %d\n",
+                                  ut->filename, ret);
                        break;
+               }
+
+               ut->inode = igrab(path.dentry->d_inode);
+               if (!ut->inode) {
+                       _stp_error("Couldn't get inode for file '%s'\n",
+                                  ut->filename);
+                       ret = -EINVAL;
+                       break;
+               }
        }
        if (ret)
                stapiu_put(targets, i);
@@ -262,8 +273,11 @@ stapiu_reg(struct stapiu_consumer *consumers, size_t nconsumers)
                struct stapiu_consumer *uc = &consumers[i];
                ret = uprobe_register(uc->target->inode, uc->offset,
                                      &uc->consumer);
-               if (ret)
+               if (ret) {
+                       _stp_error("probe %s registration error (rc %d)",
+                                  uc->probe->pp, ret);
                        break;
+               }
                list_add(&uc->target_consumer, &uc->target->consumers);
        }
        if (ret)
index da4a12d9362aba2633f188733aeddd5a34aa16d8..5fa8cea77bd5940d0f2802596d66fe13a0217e0e 100644 (file)
@@ -7573,6 +7573,9 @@ uprobe_derived_probe_group::emit_module_inode_init (systemtap_session& s)
 {
   if (probes.empty()) return;
   s.op->newline() << "/* ---- inode uprobes ---- */";
+  // Let stapiu_init() handle reporting errors by setting probe_point
+  // to NULL.
+  s.op->newline() << "probe_point = NULL;";
   s.op->newline() << "rc = stapiu_init ("
                   << "stap_inode_uprobe_targets, "
                   << "ARRAY_SIZE(stap_inode_uprobe_targets), "
index 48aac6958201468c1c99a507b7cc01b0534f3127..330d145ba8eebaeeca500d3d1275ef94131b4dfc 100644 (file)
@@ -1661,7 +1661,11 @@ c_unparser::emit_module_init ()
       // NB: this gives O(N**2) amount of code, but luckily there
       // are only seven or eight derived_probe_groups, so it's ok.
       o->newline() << "if (rc) {";
+      // If a probe types's emit_module_init() wants to handle error
+      // messages itself, it should set probe_point to NULL, 
+      o->newline(1) << "if (probe_point)";
       o->newline(1) << "_stp_error (\"probe %s registration error (rc %d)\", probe_point, rc);";
+      o->indent(-1);
       // NB: we need to be in the error state so timers can shutdown cleanly,
       // and so end probes don't run.  OTOH, error probes can run.
       o->newline() << "atomic_set (&session_state, STAP_SESSION_ERROR);";
This page took 0.048905 seconds and 5 git commands to generate.