OLD | NEW |
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 Loading... |
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__) |
| 42 #include <execinfo.h> |
| 43 #include <cxxabi.h> |
| 44 #endif |
| 45 |
41 // Ubuntu Dapper requires memory pages to be marked as | 46 // Ubuntu Dapper requires memory pages to be marked as |
42 // executable. Otherwise, OS raises an exception when executing code | 47 // executable. Otherwise, OS raises an exception when executing code |
43 // in that page. | 48 // in that page. |
44 #include <sys/types.h> // mmap & munmap | 49 #include <sys/types.h> // mmap & munmap |
45 #include <sys/mman.h> // mmap & munmap | 50 #include <sys/mman.h> // mmap & munmap |
46 #include <sys/stat.h> // open | 51 #include <sys/stat.h> // open |
47 #include <fcntl.h> // open | 52 #include <fcntl.h> // open |
48 #include <unistd.h> // sysconf | 53 #include <unistd.h> // sysconf |
49 #if defined(__GLIBC__) && !defined(__UCLIBC__) | 54 #if defined(__GLIBC__) && !defined(__UCLIBC__) |
50 #include <execinfo.h> // backtrace, backtrace_symbols | 55 #include <execinfo.h> // backtrace, backtrace_symbols |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 asm("bkpt 0"); | 413 asm("bkpt 0"); |
409 # endif | 414 # endif |
410 #elif defined(__mips__) | 415 #elif defined(__mips__) |
411 asm("break"); | 416 asm("break"); |
412 #else | 417 #else |
413 asm("int $3"); | 418 asm("int $3"); |
414 #endif | 419 #endif |
415 } | 420 } |
416 | 421 |
417 | 422 |
| 423 void OS::DumpBacktrace() { |
| 424 #if defined(__GLIBC__) |
| 425 void* trace[100]; |
| 426 int size = backtrace(trace, ARRAY_SIZE(trace)); |
| 427 char** symbols = backtrace_symbols(trace, size); |
| 428 fprintf(stderr, "\n==== C stack trace ===============================\n\n"); |
| 429 if (size == 0) { |
| 430 fprintf(stderr, "(empty)\n"); |
| 431 } else if (symbols == NULL) { |
| 432 fprintf(stderr, "(no symbols)\n"); |
| 433 } else { |
| 434 for (int i = 1; i < size; ++i) { |
| 435 fprintf(stderr, "%2d: ", i); |
| 436 char mangled[201]; |
| 437 if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { |
| 438 int status; |
| 439 size_t length; |
| 440 char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); |
| 441 fprintf(stderr, "%s\n", demangled ? demangled : mangled); |
| 442 free(demangled); |
| 443 } else { |
| 444 fprintf(stderr, "??\n"); |
| 445 } |
| 446 } |
| 447 } |
| 448 fflush(stderr); |
| 449 free(symbols); |
| 450 #endif |
| 451 } |
| 452 |
| 453 |
418 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 454 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
419 public: | 455 public: |
420 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 456 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
421 : file_(file), memory_(memory), size_(size) { } | 457 : file_(file), memory_(memory), size_(size) { } |
422 virtual ~PosixMemoryMappedFile(); | 458 virtual ~PosixMemoryMappedFile(); |
423 virtual void* memory() { return memory_; } | 459 virtual void* memory() { return memory_; } |
424 virtual int size() { return size_; } | 460 virtual int size() { return size_; } |
425 private: | 461 private: |
426 FILE* file_; | 462 FILE* file_; |
427 void* memory_; | 463 void* memory_; |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 | 1310 |
1275 | 1311 |
1276 void Sampler::Stop() { | 1312 void Sampler::Stop() { |
1277 ASSERT(IsActive()); | 1313 ASSERT(IsActive()); |
1278 SignalSender::RemoveActiveSampler(this); | 1314 SignalSender::RemoveActiveSampler(this); |
1279 SetActive(false); | 1315 SetActive(false); |
1280 } | 1316 } |
1281 | 1317 |
1282 | 1318 |
1283 } } // namespace v8::internal | 1319 } } // namespace v8::internal |
OLD | NEW |