]> sourceware.org Git - systemtap.git/commitdiff
Double-check DW_AT_comp_dir before we try to use it
authorJosh Stone <jistone@redhat.com>
Wed, 29 May 2013 20:52:58 +0000 (13:52 -0700)
committerJosh Stone <jistone@redhat.com>
Wed, 29 May 2013 20:52:58 +0000 (13:52 -0700)
In building tracepoints, we try a late search for the kernel source tree
using DW_AT_comp_dir, and add extra includes based on that path.  That
comp_dir is not always reliable though; for instance, Ubuntu leaves it
something like "/build/buildd/linux...", which is not an installed path.

(See also http://brainstorm.ubuntu.com/idea/11327)

* tapsets.cxx (tracepoint_builder::init_dw): Verify that the given
  DW_AT_comp_dir actually exists before we use it.

tapsets.cxx

index 04ff3490ee2b12704f30ddd9731d77754343e29d..6bede4ca7e4d2fc27a1bac1c74e5e85a56340e0c 100644 (file)
@@ -9940,12 +9940,21 @@ tracepoint_builder::init_dw(systemtap_session& s)
               assert_no_interrupts();
               Dwarf_Attribute attr;
               const char* name = dwarf_formstring (dwarf_attr (cudie, DW_AT_comp_dir, &attr));
-              if (name) 
+              if (name)
                 {
-                  if (s.verbose > 2)
-                    clog << _F("Located kernel source tree (DW_AT_comp_dir) at '%s'", name) << endl;
+                  // check that the path actually exists locally before we try to use it
+                  if (file_exists(name))
+                    {
+                      if (s.verbose > 2)
+                        clog << _F("Located kernel source tree (DW_AT_comp_dir) at '%s'", name) << endl;
+                      s.kernel_source_tree = name;
+                    }
+                  else
+                    {
+                      if (s.verbose > 2)
+                        clog << _F("Ignoring inaccessible kernel source tree (DW_AT_comp_dir) at '%s'", name) << endl;
+                    }
 
-                  s.kernel_source_tree = name;
                   break; // skip others; modern Kbuild uses same comp_dir for them all
                 }
             }
This page took 0.045586 seconds and 5 git commands to generate.