~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to compiler-rt/lib/sanitizer_common/sanitizer_printf.cc

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <stdio.h>
22
22
#include <stdarg.h>
23
23
 
 
24
#if SANITIZER_WINDOWS
 
25
# define va_copy(dst, src) ((dst) = (src))
 
26
#endif
 
27
 
24
28
namespace __sanitizer {
25
29
 
26
30
StaticSpinMutex CommonSanitizerReportMutex;
192
196
 
193
197
static void SharedPrintfCode(bool append_pid, const char *format,
194
198
                             va_list args) {
 
199
  va_list args2;
 
200
  va_copy(args2, args);
195
201
  const int kLen = 16 * 1024;
196
202
  // |local_buffer| is small enough not to overflow the stack and/or violate
197
203
  // the stack limit enforced by TSan (-Wframe-larger-than=512). On the other
205
211
  // mmaped buffer.
206
212
  for (int use_mmap = 0; use_mmap < 2; use_mmap++) {
207
213
    if (use_mmap) {
 
214
      va_end(args);
 
215
      va_copy(args, args2);
208
216
      buffer = (char*)MmapOrDie(kLen, "Report");
209
217
      buffer_size = kLen;
210
218
    }
211
219
    needed_length = 0;
212
220
    if (append_pid) {
213
 
      int pid = GetPid();
 
221
      int pid = internal_getpid();
214
222
      needed_length += internal_snprintf(buffer, buffer_size, "==%d==", pid);
215
223
      if (needed_length >= buffer_size) {
216
224
        // The pid doesn't fit into the current buffer.
235
243
  // If we had mapped any memory, clean up.
236
244
  if (buffer != local_buffer)
237
245
    UnmapOrDie((void *)buffer, buffer_size);
 
246
  va_end(args2);
238
247
}
239
248
 
240
249
void Printf(const char *format, ...) {