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 19 matching lines...) Expand all Loading... | |
30 | 30 |
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 #include <execinfo.h> | |
ulan_google
2012/12/14 12:40:31
This should be guarded by GLIBC too, otherwise it
rossberg
2012/12/14 13:53:20
Done.
| |
41 | |
42 #if defined(__GLIBC__) | |
43 #include <cxxabi.h> | |
44 #endif | |
40 | 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__) |
(...skipping 358 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 void* trace[100]; | |
ulan_google
2012/12/14 12:40:31
This should be guarded by GLIBC
rossberg
2012/12/14 13:53:20
Done.
| |
425 int size = backtrace(trace, ARRAY_SIZE(trace)); | |
426 char** symbols = backtrace_symbols(trace, size); | |
427 fprintf(stderr, "\n==== C stack trace ===============================\n\n"); | |
428 if (size == 0) { | |
429 fprintf(stderr, "(empty)\n"); | |
430 } else if (symbols == NULL) { | |
431 fprintf(stderr, "(no symbols)\n"); | |
432 } else { | |
433 for (int i = 1; i < size; ++i) { | |
434 fprintf(stderr, "%2d: ", i); | |
435 #if defined(__GLIBC__) | |
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 #else | |
447 fprintf(stderr, "%s\n", symbols[i]); | |
448 #endif | |
449 } | |
450 } | |
451 fflush(stderr); | |
452 free(symbols); | |
453 } | |
454 | |
455 | |
418 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 456 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
419 public: | 457 public: |
420 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 458 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
421 : file_(file), memory_(memory), size_(size) { } | 459 : file_(file), memory_(memory), size_(size) { } |
422 virtual ~PosixMemoryMappedFile(); | 460 virtual ~PosixMemoryMappedFile(); |
423 virtual void* memory() { return memory_; } | 461 virtual void* memory() { return memory_; } |
424 virtual int size() { return size_; } | 462 virtual int size() { return size_; } |
425 private: | 463 private: |
426 FILE* file_; | 464 FILE* file_; |
427 void* memory_; | 465 void* memory_; |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1274 | 1312 |
1275 | 1313 |
1276 void Sampler::Stop() { | 1314 void Sampler::Stop() { |
1277 ASSERT(IsActive()); | 1315 ASSERT(IsActive()); |
1278 SignalSender::RemoveActiveSampler(this); | 1316 SignalSender::RemoveActiveSampler(this); |
1279 SetActive(false); | 1317 SetActive(false); |
1280 } | 1318 } |
1281 | 1319 |
1282 | 1320 |
1283 } } // namespace v8::internal | 1321 } } // namespace v8::internal |
OLD | NEW |