summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_printf.cc
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2017-07-20 18:47:01 +0000
committerVitaly Buka <vitalybuka@google.com>2017-07-20 18:47:01 +0000
commit75ed905e2dc63208af04d37b782e54941e331897 (patch)
tree66d340132adf2cd02f25aa496b894c621941f100 /lib/sanitizer_common/sanitizer_printf.cc
parentd4b10e1df682ce22888b197a907e7ceb08cd3539 (diff)
[compiler-rt] Reorder functions to shrink stack frames
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308652 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_printf.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_printf.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/sanitizer_common/sanitizer_printf.cc b/lib/sanitizer_common/sanitizer_printf.cc
index b14675a06..f36eba55d 100644
--- a/lib/sanitizer_common/sanitizer_printf.cc
+++ b/lib/sanitizer_common/sanitizer_printf.cc
@@ -229,19 +229,14 @@ static void CallPrintfAndReportCallback(const char *str) {
PrintfAndReportCallback(str);
}
-static void SharedPrintfCode(bool append_pid, const char *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;
- // |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];
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++) {
@@ -291,6 +286,17 @@ static void SharedPrintfCode(bool append_pid, const char *format,
va_end(args2);
}
+static void SharedPrintfCode(bool append_pid, const char *format,
+ va_list args) {
+ // |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, args);
+}
+
FORMAT(1, 2)
void Printf(const char *format, ...) {
va_list args;