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

Side by Side Diff: src/platform-linux.cc

Issue 23497009: Move DumpBacktrace() to checks.cc and cleanup both the code and the necessary platform checks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 20 matching lines...) Expand all
31 #include <pthread.h> 31 #include <pthread.h>
32 #include <semaphore.h> 32 #include <semaphore.h>
33 #include <signal.h> 33 #include <signal.h>
34 #include <sys/prctl.h> 34 #include <sys/prctl.h>
35 #include <sys/time.h> 35 #include <sys/time.h>
36 #include <sys/resource.h> 36 #include <sys/resource.h>
37 #include <sys/syscall.h> 37 #include <sys/syscall.h>
38 #include <sys/types.h> 38 #include <sys/types.h>
39 #include <stdlib.h> 39 #include <stdlib.h>
40 40
41 #if defined(__GLIBC__) && !defined(__UCLIBC__)
42 #include <execinfo.h>
43 #include <cxxabi.h>
44 #endif
45
46 // Ubuntu Dapper requires memory pages to be marked as 41 // Ubuntu Dapper requires memory pages to be marked as
47 // executable. Otherwise, OS raises an exception when executing code 42 // executable. Otherwise, OS raises an exception when executing code
48 // in that page. 43 // in that page.
49 #include <sys/types.h> // mmap & munmap 44 #include <sys/types.h> // mmap & munmap
50 #include <sys/mman.h> // mmap & munmap 45 #include <sys/mman.h> // mmap & munmap
51 #include <sys/stat.h> // open 46 #include <sys/stat.h> // open
52 #include <fcntl.h> // open 47 #include <fcntl.h> // open
53 #include <unistd.h> // sysconf 48 #include <unistd.h> // sysconf
54 #include <strings.h> // index 49 #include <strings.h> // index
55 #include <errno.h> 50 #include <errno.h>
56 #include <stdarg.h> 51 #include <stdarg.h>
57 52
58 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. 53 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
59 // Old versions of the C library <signal.h> didn't define the type. 54 // Old versions of the C library <signal.h> didn't define the type.
60 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ 55 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
61 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) 56 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
62 #include <asm/sigcontext.h> 57 #include <asm/sigcontext.h>
63 #endif 58 #endif
64 59
65 #undef MAP_TYPE 60 #undef MAP_TYPE
66 61
67 #include "v8.h" 62 #include "v8.h"
68 63
69 #include "platform-posix.h"
70 #include "platform.h" 64 #include "platform.h"
71 #include "v8threads.h" 65 #include "v8threads.h"
72 #include "vm-state-inl.h" 66 #include "vm-state-inl.h"
73 67
74 68
75 namespace v8 { 69 namespace v8 {
76 namespace internal { 70 namespace internal {
77 71
78 72
79 #ifdef __arm__ 73 #ifdef __arm__
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (mbase == MAP_FAILED) { 141 if (mbase == MAP_FAILED) {
148 LOG(i::Isolate::Current(), 142 LOG(i::Isolate::Current(),
149 StringEvent("OS::Allocate", "mmap failed")); 143 StringEvent("OS::Allocate", "mmap failed"));
150 return NULL; 144 return NULL;
151 } 145 }
152 *allocated = msize; 146 *allocated = msize;
153 return mbase; 147 return mbase;
154 } 148 }
155 149
156 150
157 void OS::DumpBacktrace() {
158 // backtrace is a glibc extension.
159 #if defined(__GLIBC__) && !defined(__UCLIBC__)
160 POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace();
161 #endif
162 }
163
164
165 class PosixMemoryMappedFile : public OS::MemoryMappedFile { 151 class PosixMemoryMappedFile : public OS::MemoryMappedFile {
166 public: 152 public:
167 PosixMemoryMappedFile(FILE* file, void* memory, int size) 153 PosixMemoryMappedFile(FILE* file, void* memory, int size)
168 : file_(file), memory_(memory), size_(size) { } 154 : file_(file), memory_(memory), size_(size) { }
169 virtual ~PosixMemoryMappedFile(); 155 virtual ~PosixMemoryMappedFile();
170 virtual void* memory() { return memory_; } 156 virtual void* memory() { return memory_; }
171 virtual int size() { return size_; } 157 virtual int size() { return size_; }
172 private: 158 private:
173 FILE* file_; 159 FILE* file_;
174 void* memory_; 160 void* memory_;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { 435 bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
450 return munmap(base, size) == 0; 436 return munmap(base, size) == 0;
451 } 437 }
452 438
453 439
454 bool VirtualMemory::HasLazyCommits() { 440 bool VirtualMemory::HasLazyCommits() {
455 return true; 441 return true;
456 } 442 }
457 443
458 } } // namespace v8::internal 444 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698