[PATCH] D11981: [asan] On OS X, log reports to syslog and os_trace

Anna Zaks via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 17:49:01 PDT 2015


zaks.anna added a comment.

> So, does it mean that error_report_callback is invoked with ANSI escape sequences? Maybe, we don't need 

>  them there either?


Yes and I don't think it would be easy to change. Here is my understanding of how this works. The users of Printf decide how everything should be decorated. Sometimes the messages are added to a temporary buffer with the ANSI escape sequences already in place even before calling Printf. 
Ex:
static void DescribeAccessToHeapChunk(AsanChunkView chunk, uptr addr,

                                      uptr access_size) {
  sptr offset;
  Decorator d;
  InternalScopedString str(4096);
  str.append("%s", d.Location());
  str.append("%s", d.Location());
  if (chunk.AddrIsAtLeft(addr, access_size, &offset)) {
    str.append("%p is located %zd bytes to the left of", (void *)addr, offset);
  ...
  str.append("%s", d.EndLocation());
  Printf("%s", str.data());

}
The error_report_callback  callback is called at the last step in the implementation of SharedPrintfCode; we are passed the same buffer and have no control over the decoration at that point:

  RawWrite(buffer);
  if (common_flags()->log_to_syslog)
    WriteToSyslog(buffer);
  CallPrintfAndReportCallback(buffer);

Interesting.. looks like logging to syslog for Android is done directly right there on every Printf  and the logging is done with ANSI in place...

If we log there, everything not only "error reports", will be logged. 
Also, should we consider logging line by line, syslog does not work well with new line characters?


http://reviews.llvm.org/D11981





More information about the llvm-commits mailing list