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

Side by Side Diff: src/base/logging.cc

Issue 501323002: Replace our homegrown ARRAY_SIZE() with Chrome's arraysize(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « src/ast.cc ('k') | src/base/macros.h » ('j') | src/base/macros.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/logging.h" 5 #include "src/base/logging.h"
6 6
7 #if V8_LIBC_GLIBC || V8_OS_BSD 7 #if V8_LIBC_GLIBC || V8_OS_BSD
8 # include <cxxabi.h> 8 # include <cxxabi.h>
9 # include <execinfo.h> 9 # include <execinfo.h>
10 #elif V8_OS_QNX 10 #elif V8_OS_QNX
11 # include <backtrace.h> 11 # include <backtrace.h>
12 #endif // V8_LIBC_GLIBC || V8_OS_BSD 12 #endif // V8_LIBC_GLIBC || V8_OS_BSD
13 #include <stdio.h> 13 #include <stdio.h>
14 #include <stdlib.h> 14 #include <stdlib.h>
15 15
16 #include "src/base/platform/platform.h" 16 #include "src/base/platform/platform.h"
17 17
18 namespace v8 { 18 namespace v8 {
19 namespace base { 19 namespace base {
20 20
21 // Attempts to dump a backtrace (if supported). 21 // Attempts to dump a backtrace (if supported).
22 void DumpBacktrace() { 22 void DumpBacktrace() {
23 #if V8_LIBC_GLIBC || V8_OS_BSD 23 #if V8_LIBC_GLIBC || V8_OS_BSD
24 void* trace[100]; 24 void* trace[100];
25 int size = backtrace(trace, ARRAY_SIZE(trace)); 25 int size = backtrace(trace, arraysize(trace));
26 char** symbols = backtrace_symbols(trace, size); 26 char** symbols = backtrace_symbols(trace, size);
27 OS::PrintError("\n==== C stack trace ===============================\n\n"); 27 OS::PrintError("\n==== C stack trace ===============================\n\n");
28 if (size == 0) { 28 if (size == 0) {
29 OS::PrintError("(empty)\n"); 29 OS::PrintError("(empty)\n");
30 } else if (symbols == NULL) { 30 } else if (symbols == NULL) {
31 OS::PrintError("(no symbols)\n"); 31 OS::PrintError("(no symbols)\n");
32 } else { 32 } else {
33 for (int i = 1; i < size; ++i) { 33 for (int i = 1; i < size; ++i) {
34 OS::PrintError("%2d: ", i); 34 OS::PrintError("%2d: ", i);
35 char mangled[201]; 35 char mangled[201];
(...skipping 11 matching lines...) Expand all
47 free(symbols); 47 free(symbols);
48 #elif V8_OS_QNX 48 #elif V8_OS_QNX
49 char out[1024]; 49 char out[1024];
50 bt_accessor_t acc; 50 bt_accessor_t acc;
51 bt_memmap_t memmap; 51 bt_memmap_t memmap;
52 bt_init_accessor(&acc, BT_SELF); 52 bt_init_accessor(&acc, BT_SELF);
53 bt_load_memmap(&acc, &memmap); 53 bt_load_memmap(&acc, &memmap);
54 bt_sprn_memmap(&memmap, out, sizeof(out)); 54 bt_sprn_memmap(&memmap, out, sizeof(out));
55 OS::PrintError(out); 55 OS::PrintError(out);
56 bt_addr_t trace[100]; 56 bt_addr_t trace[100];
57 int size = bt_get_backtrace(&acc, trace, ARRAY_SIZE(trace)); 57 int size = bt_get_backtrace(&acc, trace, arraysize(trace));
58 OS::PrintError("\n==== C stack trace ===============================\n\n"); 58 OS::PrintError("\n==== C stack trace ===============================\n\n");
59 if (size == 0) { 59 if (size == 0) {
60 OS::PrintError("(empty)\n"); 60 OS::PrintError("(empty)\n");
61 } else { 61 } else {
62 bt_sprnf_addrs(&memmap, trace, size, const_cast<char*>("%a\n"), 62 bt_sprnf_addrs(&memmap, trace, size, const_cast<char*>("%a\n"),
63 out, sizeof(out), NULL); 63 out, sizeof(out), NULL);
64 OS::PrintError(out); 64 OS::PrintError(out);
65 } 65 }
66 bt_unload_memmap(&memmap); 66 bt_unload_memmap(&memmap);
67 bt_release_accessor(&acc); 67 bt_release_accessor(&acc);
(...skipping 11 matching lines...) Expand all
79 line); 79 line);
80 va_list arguments; 80 va_list arguments;
81 va_start(arguments, format); 81 va_start(arguments, format);
82 v8::base::OS::VPrintError(format, arguments); 82 v8::base::OS::VPrintError(format, arguments);
83 va_end(arguments); 83 va_end(arguments);
84 v8::base::OS::PrintError("\n#\n"); 84 v8::base::OS::PrintError("\n#\n");
85 v8::base::DumpBacktrace(); 85 v8::base::DumpBacktrace();
86 fflush(stderr); 86 fflush(stderr);
87 v8::base::OS::Abort(); 87 v8::base::OS::Abort();
88 } 88 }
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/base/macros.h » ('j') | src/base/macros.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698