Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: third_party/tcmalloc/chromium/src/internal_logging.cc

Issue 10384117: Add a chromium version abort function for tcmalloc: Abort(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 #include "internal_logging.h" 34 #include "internal_logging.h"
35 #include <stdarg.h> // for va_end, va_start 35 #include <stdarg.h> // for va_end, va_start
36 #include <stdio.h> // for vsnprintf, va_list, etc 36 #include <stdio.h> // for vsnprintf, va_list, etc
37 #include <stdlib.h> // for abort 37 #include <stdlib.h> // for abort
38 #include <string.h> // for strlen, memcpy 38 #include <string.h> // for strlen, memcpy
39 #ifdef HAVE_UNISTD_H 39 #ifdef HAVE_UNISTD_H
40 #include <unistd.h> // for write() 40 #include <unistd.h> // for write()
41 #endif 41 #endif
42 42
43 #include <gperftools/malloc_extension.h> 43 #include <gperftools/malloc_extension.h>
44 #include "base/abort.h"
44 #include "base/logging.h" // for perftools_vsnprintf 45 #include "base/logging.h" // for perftools_vsnprintf
45 #include "base/spinlock.h" // for SpinLockHolder, SpinLock 46 #include "base/spinlock.h" // for SpinLockHolder, SpinLock
46 47
47 static const int kLogBufSize = 800; 48 static const int kLogBufSize = 800;
48 49
49 // Variables for storing crash output. Allocated statically since we 50 // Variables for storing crash output. Allocated statically since we
50 // may not be able to heap-allocate while crashing. 51 // may not be able to heap-allocate while crashing.
51 static SpinLock crash_lock(base::LINKER_INITIALIZED); 52 static SpinLock crash_lock(base::LINKER_INITIALIZED);
52 static bool crashed = false; 53 static bool crashed = false;
53 static const int kStatsBufferSize = 16 << 10; 54 static const int kStatsBufferSize = 16 << 10;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 first_crash = true; 110 first_crash = true;
110 } 111 }
111 } 112 }
112 113
113 (*log_message_writer)(state.buf_, msglen); 114 (*log_message_writer)(state.buf_, msglen);
114 if (first_crash && mode == kCrashWithStats) { 115 if (first_crash && mode == kCrashWithStats) {
115 MallocExtension::instance()->GetStats(stats_buffer, kStatsBufferSize); 116 MallocExtension::instance()->GetStats(stats_buffer, kStatsBufferSize);
116 (*log_message_writer)(stats_buffer, strlen(stats_buffer)); 117 (*log_message_writer)(stats_buffer, strlen(stats_buffer));
117 } 118 }
118 119
119 abort(); 120 Abort();
120 } 121 }
121 122
122 bool Logger::Add(const LogItem& item) { 123 bool Logger::Add(const LogItem& item) {
123 // Separate items with spaces 124 // Separate items with spaces
124 if (p_ < end_) { 125 if (p_ < end_) {
125 *p_ = ' '; 126 *p_ = ' ';
126 p_++; 127 p_++;
127 } 128 }
128 129
129 switch (item.tag_) { 130 switch (item.tag_) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 left_ = 0; 185 left_ = 0;
185 } else if (r > left_) { 186 } else if (r > left_) {
186 // Truncation 187 // Truncation
187 left_ = 0; 188 left_ = 0;
188 } else { 189 } else {
189 left_ -= r; 190 left_ -= r;
190 buf_ += r; 191 buf_ += r;
191 } 192 }
192 } 193 }
193 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698