[compiler-rt] r185326 - Change __sanitizer_symbolize_demangle hook return type to 'int'

Alexey Samsonov samsonov at google.com
Mon Jul 1 04:20:56 PDT 2013


Author: samsonov
Date: Mon Jul  1 06:20:56 2013
New Revision: 185326

URL: http://llvm.org/viewvc/llvm-project?rev=185326&view=rev
Log:
Change __sanitizer_symbolize_demangle hook return type to 'int'

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc?rev=185326&r1=185325&r2=185326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc Mon Jul  1 06:20:56 2013
@@ -191,8 +191,8 @@ bool __sanitizer_symbolize_data(const ch
 SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE
 void __sanitizer_symbolize_flush();
 SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE
-void __sanitizer_symbolize_demangle(const char *Name, char *Buffer,
-                                    int MaxLength);
+int __sanitizer_symbolize_demangle(const char *Name, char *Buffer,
+                                   int MaxLength);
 }  // extern "C"
 
 class InternalSymbolizer {
@@ -223,10 +223,18 @@ class InternalSymbolizer {
 
   const char *Demangle(const char *name) {
     if (__sanitizer_symbolize_demangle) {
-      char *res = static_cast<char*>(InternalAlloc(kMaxDemangledNameSize));
-      internal_memset(res, 0, kMaxDemangledNameSize);
-      __sanitizer_symbolize_demangle(name, res, kMaxDemangledNameSize);
-      return res;
+      for (uptr res_length = 1024;
+           res_length <= InternalSizeClassMap::kMaxSize;) {
+        char *res_buff = static_cast<char*>(InternalAlloc(res_length));
+        uptr req_length =
+            __sanitizer_symbolize_demangle(name, res_buff, res_length);
+        if (req_length > res_length) {
+          res_length = req_length + 1;
+          InternalFree(res_buff);
+          continue;
+        }
+        return res_buff;
+      }
     }
     return name;
   }





More information about the llvm-commits mailing list