summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_printf.cc
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2017-07-20 18:43:09 +0000
committerVitaly Buka <vitalybuka@google.com>2017-07-20 18:43:09 +0000
commite2c4c417be08a7314b178e772dfdea4d10c27f81 (patch)
tree9b0f7a9a1325a9daf59a6f272b4a6898567adbd0 /lib/sanitizer_common/sanitizer_printf.cc
parent8d06014e5dd7cdfa69d9fb2389f311ffa5a0b25f (diff)
[compiler-rt] Reorder functions to have smaller stack frames
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308650 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_printf.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_printf.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/sanitizer_common/sanitizer_printf.cc b/lib/sanitizer_common/sanitizer_printf.cc
index b14675a06..101c3fb79 100644
--- a/lib/sanitizer_common/sanitizer_printf.cc
+++ b/lib/sanitizer_common/sanitizer_printf.cc
@@ -231,17 +231,23 @@ static void CallPrintfAndReportCallback(const char *str) {
static void SharedPrintfCode(bool append_pid, const char *format,
va_list args) {
- va_list args2;
- va_copy(args2, args);
- const int kLen = 16 * 1024;
// |local_buffer| is small enough not to overflow the stack and/or violate
// the stack limit enforced by TSan (-Wframe-larger-than=512). On the other
// hand, the bigger the buffer is, the more the chance the error report will
// fit into it.
char local_buffer[400];
+ SharedPrintfCodeNoBuffer(append_pid, local_buffer, ARRAY_SIZE(local_buffer),
+ format, va_list args);
+}
+
+static void SharedPrintfCodeNoBuffer(bool append_pid, char *local_buffer,
+ int buffer_size, const char *format,
+ va_list args) {
+ va_list args2;
+ va_copy(args2, args);
+ const int kLen = 16 * 1024;
int needed_length;
char *buffer = local_buffer;
- int buffer_size = ARRAY_SIZE(local_buffer);
// First try to print a message using a local buffer, and then fall back to
// mmaped buffer.
for (int use_mmap = 0; use_mmap < 2; use_mmap++) {