Revision: 16890
Author: [email protected]
Date: Mon Sep 23 14:11:59 2013 UTC
Log: Move DumpBacktrace() to checks.cc and cleanup both the code and
the necessary platform checks.
This also removes the platform-posix.h header file.
[email protected]
Review URL: https://codereview.chromium.org/23497009
http://code.google.com/p/v8/source/detail?r=16890
Deleted:
/branches/bleeding_edge/src/platform-posix.h
Modified:
/branches/bleeding_edge/src/checks.cc
/branches/bleeding_edge/src/platform-cygwin.cc
/branches/bleeding_edge/src/platform-freebsd.cc
/branches/bleeding_edge/src/platform-linux.cc
/branches/bleeding_edge/src/platform-macos.cc
/branches/bleeding_edge/src/platform-openbsd.cc
/branches/bleeding_edge/src/platform-posix.cc
/branches/bleeding_edge/src/platform-solaris.cc
/branches/bleeding_edge/src/platform-win32.cc
/branches/bleeding_edge/src/platform.h
=======================================
--- /branches/bleeding_edge/src/platform-posix.h Fri Sep 13 10:35:35 2013
UTC
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef V8_PLATFORM_POSIX_H_
-#define V8_PLATFORM_POSIX_H_
-
-#if !defined(ANDROID)
-#include <cxxabi.h>
-#endif
-#include <stdio.h>
-
-#include "platform.h"
-
-namespace v8 {
-namespace internal {
-
-// Used by platform implementation files during OS::DumpBacktrace()
-template<int (*backtrace)(void**, int),
- char** (*backtrace_symbols)(void* const*, int)>
-struct POSIXBacktraceHelper {
- static void DumpBacktrace() {
- void* trace[100];
- int size = backtrace(trace, ARRAY_SIZE(trace));
- char** symbols = backtrace_symbols(trace, size);
- fprintf(stderr, "\n==== C stack trace
===============================\n\n");
- if (size == 0) {
- fprintf(stderr, "(empty)\n");
- } else if (symbols == NULL) {
- fprintf(stderr, "(no symbols)\n");
- } else {
- for (int i = 1; i < size; ++i) {
- fprintf(stderr, "%2d: ", i);
- char mangled[201];
- if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) {//
NOLINT
- char* demangled = NULL;
-#if !defined(ANDROID)
- int status;
- size_t length;
- demangled = abi::__cxa_demangle(mangled, NULL, &length, &status);
-#endif
- fprintf(stderr, "%s\n", demangled != NULL ? demangled : mangled);
- free(demangled);
- } else {
- fprintf(stderr, "??\n");
- }
- }
- }
- fflush(stderr);
- free(symbols);
- }
-};
-
-} } // namespace v8::internal
-
-#endif // V8_PLATFORM_POSIX_H_
=======================================
--- /branches/bleeding_edge/src/checks.cc Wed Sep 11 08:39:38 2013 UTC
+++ /branches/bleeding_edge/src/checks.cc Mon Sep 23 14:11:59 2013 UTC
@@ -25,11 +25,48 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdarg.h>
+#include "checks.h"
-#include "v8.h"
+#if V8_LIBC_GLIBC || V8_OS_BSD
+# include <cxxabi.h>
+# include <execinfo.h>
+#endif // V8_LIBC_GLIBC || V8_OS_BSD
+#include <stdio.h>
#include "platform.h"
+#include "v8.h"
+
+
+// Attempts to dump a backtrace (if supported).
+static V8_INLINE void DumpBacktrace() {
+#if V8_LIBC_GLIBC || V8_OS_BSD
+ void* trace[100];
+ int size = backtrace(trace, ARRAY_SIZE(trace));
+ char** symbols = backtrace_symbols(trace, size);
+ i::OS::PrintError("\n==== C stack trace
===============================\n\n");
+ if (size == 0) {
+ i::OS::PrintError("(empty)\n");
+ } else if (symbols == NULL) {
+ i::OS::PrintError("(no symbols)\n");
+ } else {
+ for (int i = 1; i < size; ++i) {
+ i::OS::PrintError("%2d: ", i);
+ char mangled[201];
+ if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { //
NOLINT
+ int status;
+ size_t length;
+ char* demangled = abi::__cxa_demangle(mangled, NULL, &length,
&status);
+ i::OS::PrintError("%s\n", demangled != NULL ? demangled : mangled);
+ free(demangled);
+ } else {
+ i::OS::PrintError("??\n");
+ }
+ }
+ }
+ free(symbols);
+#endif // V8_LIBC_GLIBC || V8_OS_BSD
+}
+
// Contains protection against recursive calls (faults while handling
faults).
extern "C" void V8_Fatal(const char* file, int line, const char*
format, ...) {
@@ -43,7 +80,8 @@
i::OS::VPrintError(format, arguments);
va_end(arguments);
i::OS::PrintError("\n#\n");
- i::OS::DumpBacktrace();
+ DumpBacktrace();
+ fflush(stderr);
i::OS::Abort();
}
=======================================
--- /branches/bleeding_edge/src/platform-cygwin.cc Fri Sep 13 10:35:35 2013
UTC
+++ /branches/bleeding_edge/src/platform-cygwin.cc Mon Sep 23 14:11:59 2013
UTC
@@ -41,7 +41,6 @@
#include "v8.h"
-#include "platform-posix.h"
#include "platform.h"
#include "simulator.h"
#include "v8threads.h"
@@ -86,11 +85,6 @@
*allocated = msize;
return mbase;
}
-
-
-void OS::DumpBacktrace() {
- // Currently unsupported.
-}
class PosixMemoryMappedFile : public OS::MemoryMappedFile {
=======================================
--- /branches/bleeding_edge/src/platform-freebsd.cc Fri Sep 13 10:35:35
2013 UTC
+++ /branches/bleeding_edge/src/platform-freebsd.cc Mon Sep 23 14:11:59
2013 UTC
@@ -43,7 +43,6 @@
#include <sys/fcntl.h> // open
#include <unistd.h> // getpagesize
// If you don't have execinfo.h then you need devel/libexecinfo from ports.
-#include <execinfo.h> // backtrace, backtrace_symbols
#include <strings.h> // index
#include <errno.h>
#include <stdarg.h>
@@ -54,7 +53,6 @@
#include "v8.h"
#include "v8threads.h"
-#include "platform-posix.h"
#include "platform.h"
#include "vm-state-inl.h"
@@ -95,11 +93,6 @@
*allocated = msize;
return mbase;
}
-
-
-void OS::DumpBacktrace() {
- POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace();
-}
class PosixMemoryMappedFile : public OS::MemoryMappedFile {
=======================================
--- /branches/bleeding_edge/src/platform-linux.cc Fri Sep 13 10:35:35 2013
UTC
+++ /branches/bleeding_edge/src/platform-linux.cc Mon Sep 23 14:11:59 2013
UTC
@@ -38,11 +38,6 @@
#include <sys/types.h>
#include <stdlib.h>
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
-#include <execinfo.h>
-#include <cxxabi.h>
-#endif
-
// Ubuntu Dapper requires memory pages to be marked as
// executable. Otherwise, OS raises an exception when executing code
// in that page.
@@ -66,7 +61,6 @@
#include "v8.h"
-#include "platform-posix.h"
#include "platform.h"
#include "v8threads.h"
#include "vm-state-inl.h"
@@ -152,14 +146,6 @@
*allocated = msize;
return mbase;
}
-
-
-void OS::DumpBacktrace() {
- // backtrace is a glibc extension.
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
- POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace();
-#endif
-}
class PosixMemoryMappedFile : public OS::MemoryMappedFile {
=======================================
--- /branches/bleeding_edge/src/platform-macos.cc Fri Sep 13 10:35:35 2013
UTC
+++ /branches/bleeding_edge/src/platform-macos.cc Mon Sep 23 14:11:59 2013
UTC
@@ -53,26 +53,14 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <cxxabi.h>
#undef MAP_TYPE
#include "v8.h"
-#include "platform-posix.h"
#include "platform.h"
#include "simulator.h"
#include "vm-state-inl.h"
-
-// Manually define these here as weak imports, rather than including
execinfo.h.
-// This lets us launch on 10.4 which does not have these calls.
-extern "C" {
- extern int backtrace(void**, int) __attribute__((weak_import));
- extern char** backtrace_symbols(void* const*, int)
- __attribute__((weak_import));
- extern void backtrace_symbols_fd(void* const*, int, int)
- __attribute__((weak_import));
-}
namespace v8 {
@@ -105,14 +93,6 @@
*allocated = msize;
return mbase;
}
-
-
-void OS::DumpBacktrace() {
- // If weak link to execinfo lib has failed, ie because we are on 10.4,
abort.
- if (backtrace == NULL) return;
-
- POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace();
-}
class PosixMemoryMappedFile : public OS::MemoryMappedFile {
=======================================
--- /branches/bleeding_edge/src/platform-openbsd.cc Fri Sep 13 10:35:35
2013 UTC
+++ /branches/bleeding_edge/src/platform-openbsd.cc Mon Sep 23 14:11:59
2013 UTC
@@ -42,7 +42,6 @@
#include <sys/stat.h> // open
#include <fcntl.h> // open
#include <unistd.h> // sysconf
-#include <execinfo.h> // backtrace, backtrace_symbols
#include <strings.h> // index
#include <errno.h>
#include <stdarg.h>
@@ -51,7 +50,6 @@
#include "v8.h"
-#include "platform-posix.h"
#include "platform.h"
#include "v8threads.h"
#include "vm-state-inl.h"
@@ -94,11 +92,6 @@
*allocated = msize;
return mbase;
}
-
-
-void OS::DumpBacktrace() {
- // Currently unsupported.
-}
class PosixMemoryMappedFile : public OS::MemoryMappedFile {
=======================================
--- /branches/bleeding_edge/src/platform-posix.cc Fri Sep 13 13:45:53 2013
UTC
+++ /branches/bleeding_edge/src/platform-posix.cc Mon Sep 23 14:11:59 2013
UTC
@@ -29,8 +29,6 @@
// own but contains the parts which are the same across POSIX platforms
Linux,
// Mac OS, FreeBSD and OpenBSD.
-#include "platform-posix.h"
-
#include <dlfcn.h>
#include <pthread.h>
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
=======================================
--- /branches/bleeding_edge/src/platform-solaris.cc Fri Sep 13 10:35:35
2013 UTC
+++ /branches/bleeding_edge/src/platform-solaris.cc Mon Sep 23 14:11:59
2013 UTC
@@ -51,7 +51,6 @@
#include "v8.h"
-#include "platform-posix.h"
#include "platform.h"
#include "v8threads.h"
#include "vm-state-inl.h"
@@ -110,11 +109,6 @@
*allocated = msize;
return mbase;
}
-
-
-void OS::DumpBacktrace() {
- // Currently unsupported.
-}
class PosixMemoryMappedFile : public OS::MemoryMappedFile {
=======================================
--- /branches/bleeding_edge/src/platform-win32.cc Fri Sep 13 13:45:53 2013
UTC
+++ /branches/bleeding_edge/src/platform-win32.cc Mon Sep 23 14:11:59 2013
UTC
@@ -889,11 +889,6 @@
::DebugBreak();
#endif
}
-
-
-void OS::DumpBacktrace() {
- // Currently unsupported.
-}
class Win32MemoryMappedFile : public OS::MemoryMappedFile {
=======================================
--- /branches/bleeding_edge/src/platform.h Tue Sep 17 15:26:18 2013 UTC
+++ /branches/bleeding_edge/src/platform.h Mon Sep 23 14:11:59 2013 UTC
@@ -256,9 +256,6 @@
// Debug break.
static void DebugBreak();
- // Dump C++ current stack trace (only functional on Linux).
- static void DumpBacktrace();
-
// Walk the stack.
static const int kStackWalkError = -1;
static const int kStackWalkMaxNameLen = 256;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.