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

Side by Side Diff: Source/wtf/Assertions.cpp

Issue 23494018: Add optional parameter to WTFReportBacktrace for stackframe count (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment explaining why alloca is being used Created 7 years, 3 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
« no previous file with comments | « Source/wtf/Assertions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007-2009 Torch Mobile, Inc. 3 * Copyright (C) 2007-2009 Torch Mobile, Inc.
4 * Copyright (C) 2011 University of Szeged. All rights reserved. 4 * Copyright (C) 2011 University of Szeged. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 ::GetProcAddress(kernel32, "RtlCaptureStackBackTrace")); 242 ::GetProcAddress(kernel32, "RtlCaptureStackBackTrace"));
243 if (captureStackBackTraceFunc) 243 if (captureStackBackTraceFunc)
244 *size = captureStackBackTraceFunc(0, *size, stack, 0); 244 *size = captureStackBackTraceFunc(0, *size, stack, 0);
245 else 245 else
246 *size = 0; 246 *size = 0;
247 #else 247 #else
248 *size = 0; 248 *size = 0;
249 #endif 249 #endif
250 } 250 }
251 251
252 void WTFReportBacktrace() 252 void WTFReportBacktrace(int framesToShow)
253 { 253 {
254 static const int framesToShow = 31;
255 static const int framesToSkip = 2; 254 static const int framesToSkip = 2;
256 void* samples[framesToShow + framesToSkip]; 255 // Use alloca to allocate on the stack since this function is used in OOM si tuations.
256 void** samples = static_cast<void**>(alloca((framesToShow + framesToSkip) * sizeof(void *)));
257 int frames = framesToShow + framesToSkip; 257 int frames = framesToShow + framesToSkip;
258 258
259 WTFGetBacktrace(samples, &frames); 259 WTFGetBacktrace(samples, &frames);
260 WTFPrintBacktrace(samples + framesToSkip, frames - framesToSkip); 260 WTFPrintBacktrace(samples + framesToSkip, frames - framesToSkip);
261 } 261 }
262 262
263 void WTFPrintBacktrace(void** stack, int size) 263 void WTFPrintBacktrace(void** stack, int size)
264 { 264 {
265 for (int i = 0; i < size; ++i) { 265 for (int i = 0; i < size; ++i) {
266 const char* mangledName = 0; 266 const char* mangledName = 0;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 void WTFLogAlways(const char* format, ...) 377 void WTFLogAlways(const char* format, ...)
378 { 378 {
379 va_list args; 379 va_list args;
380 va_start(args, format); 380 va_start(args, format);
381 vprintf_stderr_with_trailing_newline(format, args); 381 vprintf_stderr_with_trailing_newline(format, args);
382 va_end(args); 382 va_end(args);
383 } 383 }
384 384
385 } // extern "C" 385 } // extern "C"
OLDNEW
« no previous file with comments | « Source/wtf/Assertions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698