[PATCH] [ASan] Add process basename to log name and error message to simplify analysis of sanitized systems logs.

Yury Gribov tetra2005 at gmail.com
Thu Feb 19 21:47:34 PST 2015


REPOSITORY
  rL LLVM

================
Comment at: lib/sanitizer_common/sanitizer_common.cc:58
@@ -57,2 +57,3 @@
 
-  internal_snprintf(full_path, kMaxPathLength, "%s.%zu", path_prefix, pid);
+  const char *pname = StripModuleName(GetBinaryName());
+  internal_snprintf(full_path, kMaxPathLength, "%s.%s.%zu", path_prefix, pname,
----------------
kcc wrote:
> What's "pname"? Can this be more descriptive? 
> Also, if this does not change over time, we should just precompute it at start up
Ok.

================
Comment at: lib/sanitizer_common/sanitizer_common.cc:299
@@ +298,3 @@
+
+const char *GetBinaryName() {
+  BlockingMutexLock l(&binary_name_cache_lock);
----------------
kcc wrote:
> does binary name change over time? 
> If not, we should compute it at start up w/o any mutexes
> does binary name change over time?

You can mess with process name at least on some platforms. I'm not sure /proc/self/exe can be changed though.

> If not, we should compute it at start up w/o any mutexes

You mean initialize it in _asan_init, _msan_init, etc.? Ok.

================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:709
@@ -718,2 +708,3 @@
 #if SANITIZER_FREEBSD
-  const int Mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
+  const int Mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
+  const char *default_module_name = "kern.proc.pathname";
----------------
kcc wrote:
> I am lost here. What's being changed? 
I removed the redundant 4.

================
Comment at: lib/sanitizer_common/sanitizer_printf.cc:257
@@ +256,3 @@
+      const char *pname = StripModuleName(GetBinaryName());
+      needed_length += internal_snprintf(buffer, buffer_size,
+                                         "==%s %d==", pname, pid);
----------------
kcc wrote:
> So, now everyone will have the module name in their logs by default? 
> Not good. Make it an option. 
I could but is there a good reason not to make this default (besides legacy scripts)?

http://reviews.llvm.org/D7333

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list