| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 <semaphore.h> | 31 #include <semaphore.h> |
| 32 #include <signal.h> | 32 #include <signal.h> |
| 33 #include <sys/time.h> | 33 #include <sys/time.h> |
| 34 #include <sys/resource.h> | 34 #include <sys/resource.h> |
| 35 #include <stdlib.h> | 35 #include <stdlib.h> |
| 36 | 36 |
| 37 // Ubuntu Dapper requires memory pages to be marked as | 37 // Ubuntu Dapper requires memory pages to be marked as |
| 38 // executable. Otherwise, OS raises an exception when executing code | 38 // executable. Otherwise, OS raises an exception when executing code |
| 39 // in that page. | 39 // in that page. |
| 40 #include <sys/types.h> // mmap & munmap | 40 #include <sys/types.h> // mmap & munmap |
| 41 #include <sys/mman.h> // mmap & munmap | 41 #include <sys/mman.h> // mmap & munmap |
| 42 #include <sys/stat.h> // open | 42 #include <sys/stat.h> // open |
| 43 #include <sys/fcntl.h> // open | 43 #include <sys/fcntl.h> // open |
| 44 #include <unistd.h> // getpagesize | 44 #include <unistd.h> // getpagesize |
| 45 #include <execinfo.h> // backtrace, backtrace_symbols | 45 #include <execinfo.h> // backtrace, backtrace_symbols |
| 46 #include <strings.h> // index |
| 46 #include <errno.h> | 47 #include <errno.h> |
| 47 #include <stdarg.h> | 48 #include <stdarg.h> |
| 48 | 49 |
| 49 #undef MAP_TYPE | 50 #undef MAP_TYPE |
| 50 | 51 |
| 51 #include "v8.h" | 52 #include "v8.h" |
| 52 | 53 |
| 53 #include "platform.h" | 54 #include "platform.h" |
| 54 | 55 |
| 55 | 56 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 char buffer[MAP_LENGTH]; | 329 char buffer[MAP_LENGTH]; |
| 329 int bytes_read = -1; | 330 int bytes_read = -1; |
| 330 do { | 331 do { |
| 331 bytes_read++; | 332 bytes_read++; |
| 332 if (bytes_read >= MAP_LENGTH - 1) | 333 if (bytes_read >= MAP_LENGTH - 1) |
| 333 break; | 334 break; |
| 334 result = read(fd, buffer + bytes_read, 1); | 335 result = read(fd, buffer + bytes_read, 1); |
| 335 if (result < 1) break; | 336 if (result < 1) break; |
| 336 } while (buffer[bytes_read] != '\n'); | 337 } while (buffer[bytes_read] != '\n'); |
| 337 buffer[bytes_read] = 0; | 338 buffer[bytes_read] = 0; |
| 338 // There are 56 chars to ignore at this point in the line. | |
| 339 if (bytes_read < 56) continue; | |
| 340 // Ignore mappings that are not executable. | 339 // Ignore mappings that are not executable. |
| 341 if (buffer[3] != 'x') continue; | 340 if (buffer[3] != 'x') continue; |
| 341 char* start_of_path = index(buffer, '/'); |
| 342 // There may be no filename in this line. Skip to next. |
| 343 if (start_of_path == NULL) continue; |
| 342 buffer[bytes_read] = 0; | 344 buffer[bytes_read] = 0; |
| 343 LOG(SharedLibraryEvent(buffer + 56, start, end)); | 345 LOG(SharedLibraryEvent(start_of_path, start, end)); |
| 344 } | 346 } |
| 345 close(fd); | 347 close(fd); |
| 346 #endif | 348 #endif |
| 347 } | 349 } |
| 348 | 350 |
| 349 | 351 |
| 350 int OS::StackWalk(OS::StackFrame* frames, int frames_size) { | 352 int OS::StackWalk(OS::StackFrame* frames, int frames_size) { |
| 351 void** addresses = NewArray<void*>(frames_size); | 353 void** addresses = NewArray<void*>(frames_size); |
| 352 | 354 |
| 353 int frames_count = backtrace(addresses, frames_size); | 355 int frames_count = backtrace(addresses, frames_size); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 } | 679 } |
| 678 | 680 |
| 679 // This sampler is no longer the active sampler. | 681 // This sampler is no longer the active sampler. |
| 680 active_sampler_ = NULL; | 682 active_sampler_ = NULL; |
| 681 active_ = false; | 683 active_ = false; |
| 682 } | 684 } |
| 683 | 685 |
| 684 #endif // ENABLE_LOGGING_AND_PROFILING | 686 #endif // ENABLE_LOGGING_AND_PROFILING |
| 685 | 687 |
| 686 } } // namespace v8::internal | 688 } } // namespace v8::internal |
| OLD | NEW |