Add binary name printing support to UBSan
authorSlava Barinov <v.barinov@samsung.com>
Tue, 30 Aug 2016 09:09:23 +0000 (12:09 +0300)
committerIvan Baravy <i.baravy@samsung.com>
Tue, 21 Feb 2017 18:14:15 +0000 (21:14 +0300)
The binary name is needed for reporting with log_path since PID is not
always enough to identify the process right.

Change-Id: Ibefe22bac9f4d2a89eaacb40e6d7dc860b08d5f9
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
libsanitizer/sanitizer_common/sanitizer_flags.inc
libsanitizer/ubsan/ubsan_diag.cc

index 360dabe..207b9fe 100644 (file)
@@ -194,4 +194,4 @@ COMMON_FLAG(bool, suppress_equal_pcs, true,
             "Deduplicate multiple reports for single source location in "
             "halt_on_error=false mode (asan only).")
 COMMON_FLAG(bool, print_cmdline, false, "Print command line on crash "
-            "(asan only).")
+            "(asan and ubsan only).")
index 1197f83..95efe6c 100644 (file)
@@ -20,6 +20,7 @@
 #include "sanitizer_common/sanitizer_stacktrace_printer.h"
 #include "sanitizer_common/sanitizer_suppressions.h"
 #include "sanitizer_common/sanitizer_symbolizer.h"
+#include "sanitizer_common/sanitizer_linux.h"
 #include <stdio.h>
 
 using namespace __ubsan;
@@ -330,6 +331,12 @@ Diag::~Diag() {
   Decorator Decor;
   Printf(Decor.Bold());
 
+  if (common_flags()->print_cmdline) {
+    char exePath[path_max];
+    ReadBinaryName(exePath, path_max);
+    Printf("program: %s\n", exePath);
+  }
+
   renderLocation(Loc);
 
   switch (Level) {