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 28 matching lines...) Expand all Loading... |
39 #include <stdlib.h> | 39 #include <stdlib.h> |
40 | 40 |
41 // Ubuntu Dapper requires memory pages to be marked as | 41 // Ubuntu Dapper requires memory pages to be marked as |
42 // executable. Otherwise, OS raises an exception when executing code | 42 // executable. Otherwise, OS raises an exception when executing code |
43 // in that page. | 43 // in that page. |
44 #include <sys/types.h> // mmap & munmap | 44 #include <sys/types.h> // mmap & munmap |
45 #include <sys/mman.h> // mmap & munmap | 45 #include <sys/mman.h> // mmap & munmap |
46 #include <sys/stat.h> // open | 46 #include <sys/stat.h> // open |
47 #include <fcntl.h> // open | 47 #include <fcntl.h> // open |
48 #include <unistd.h> // sysconf | 48 #include <unistd.h> // sysconf |
49 #ifdef __GLIBC__ | 49 #if defined(__GLIBC__) && !defined(__UCLIBC__) |
50 #include <execinfo.h> // backtrace, backtrace_symbols | 50 #include <execinfo.h> // backtrace, backtrace_symbols |
51 #endif // def __GLIBC__ | 51 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) |
52 #include <strings.h> // index | 52 #include <strings.h> // index |
53 #include <errno.h> | 53 #include <errno.h> |
54 #include <stdarg.h> | 54 #include <stdarg.h> |
55 | 55 |
56 #undef MAP_TYPE | 56 #undef MAP_TYPE |
57 | 57 |
58 #include "v8.h" | 58 #include "v8.h" |
59 | 59 |
60 #include "platform-posix.h" | 60 #include "platform-posix.h" |
61 #include "platform.h" | 61 #include "platform.h" |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 fileno(f), | 557 fileno(f), |
558 0); | 558 0); |
559 ASSERT(addr != MAP_FAILED); | 559 ASSERT(addr != MAP_FAILED); |
560 OS::Free(addr, size); | 560 OS::Free(addr, size); |
561 fclose(f); | 561 fclose(f); |
562 } | 562 } |
563 | 563 |
564 | 564 |
565 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 565 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
566 // backtrace is a glibc extension. | 566 // backtrace is a glibc extension. |
567 #ifdef __GLIBC__ | 567 #if defined(__GLIBC__) && !defined(__UCLIBC__) |
568 int frames_size = frames.length(); | 568 int frames_size = frames.length(); |
569 ScopedVector<void*> addresses(frames_size); | 569 ScopedVector<void*> addresses(frames_size); |
570 | 570 |
571 int frames_count = backtrace(addresses.start(), frames_size); | 571 int frames_count = backtrace(addresses.start(), frames_size); |
572 | 572 |
573 char** symbols = backtrace_symbols(addresses.start(), frames_count); | 573 char** symbols = backtrace_symbols(addresses.start(), frames_count); |
574 if (symbols == NULL) { | 574 if (symbols == NULL) { |
575 return kStackWalkError; | 575 return kStackWalkError; |
576 } | 576 } |
577 | 577 |
578 for (int i = 0; i < frames_count; i++) { | 578 for (int i = 0; i < frames_count; i++) { |
579 frames[i].address = addresses[i]; | 579 frames[i].address = addresses[i]; |
580 // Format a text representation of the frame based on the information | 580 // Format a text representation of the frame based on the information |
581 // available. | 581 // available. |
582 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), | 582 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), |
583 "%s", | 583 "%s", |
584 symbols[i]); | 584 symbols[i]); |
585 // Make sure line termination is in place. | 585 // Make sure line termination is in place. |
586 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; | 586 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; |
587 } | 587 } |
588 | 588 |
589 free(symbols); | 589 free(symbols); |
590 | 590 |
591 return frames_count; | 591 return frames_count; |
592 #else // ndef __GLIBC__ | 592 #else // defined(__GLIBC__) && !defined(__UCLIBC__) |
593 return 0; | 593 return 0; |
594 #endif // ndef __GLIBC__ | 594 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 // Constants used for mmap. | 598 // Constants used for mmap. |
599 static const int kMmapFd = -1; | 599 static const int kMmapFd = -1; |
600 static const int kMmapFdOffset = 0; | 600 static const int kMmapFdOffset = 0; |
601 | 601 |
602 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 602 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
603 | 603 |
604 VirtualMemory::VirtualMemory(size_t size) { | 604 VirtualMemory::VirtualMemory(size_t size) { |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 | 1257 |
1258 | 1258 |
1259 void Sampler::Stop() { | 1259 void Sampler::Stop() { |
1260 ASSERT(IsActive()); | 1260 ASSERT(IsActive()); |
1261 SignalSender::RemoveActiveSampler(this); | 1261 SignalSender::RemoveActiveSampler(this); |
1262 SetActive(false); | 1262 SetActive(false); |
1263 } | 1263 } |
1264 | 1264 |
1265 | 1265 |
1266 } } // namespace v8::internal | 1266 } } // namespace v8::internal |
OLD | NEW |