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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 buffer[bytes_read] = 0; | 279 buffer[bytes_read] = 0; |
280 LOG(SharedLibraryEvent(start_of_path, start, end)); | 280 LOG(SharedLibraryEvent(start_of_path, start, end)); |
281 } | 281 } |
282 close(fd); | 282 close(fd); |
283 #endif | 283 #endif |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 287 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
288 int frames_size = frames.length(); | 288 int frames_size = frames.length(); |
289 void** addresses = NewArray<void*>(frames_size); | 289 ScopedVector<void*> addresses(frames_size); |
290 | 290 |
291 int frames_count = backtrace(addresses, frames_size); | 291 int frames_count = backtrace(addresses.start(), frames_size); |
292 | 292 |
293 char** symbols; | 293 char** symbols = backtrace_symbols(addresses, frames_count); |
294 symbols = backtrace_symbols(addresses, frames_count); | |
295 if (symbols == NULL) { | 294 if (symbols == NULL) { |
296 DeleteArray(addresses); | |
297 return kStackWalkError; | 295 return kStackWalkError; |
298 } | 296 } |
299 | 297 |
300 for (int i = 0; i < frames_count; i++) { | 298 for (int i = 0; i < frames_count; i++) { |
301 frames[i].address = addresses[i]; | 299 frames[i].address = addresses[i]; |
302 // Format a text representation of the frame based on the information | 300 // Format a text representation of the frame based on the information |
303 // available. | 301 // available. |
304 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), | 302 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), |
305 "%s", | 303 "%s", |
306 symbols[i]); | 304 symbols[i]); |
307 // Make sure line termination is in place. | 305 // Make sure line termination is in place. |
308 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; | 306 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; |
309 } | 307 } |
310 | 308 |
311 DeleteArray(addresses); | |
312 free(symbols); | 309 free(symbols); |
313 | 310 |
314 return frames_count; | 311 return frames_count; |
315 } | 312 } |
316 | 313 |
317 | 314 |
318 // Constants used for mmap. | 315 // Constants used for mmap. |
319 static const int kMmapFd = -1; | 316 static const int kMmapFd = -1; |
320 static const int kMmapFdOffset = 0; | 317 static const int kMmapFdOffset = 0; |
321 | 318 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 } | 652 } |
656 | 653 |
657 // This sampler is no longer the active sampler. | 654 // This sampler is no longer the active sampler. |
658 active_sampler_ = NULL; | 655 active_sampler_ = NULL; |
659 active_ = false; | 656 active_ = false; |
660 } | 657 } |
661 | 658 |
662 #endif // ENABLE_LOGGING_AND_PROFILING | 659 #endif // ENABLE_LOGGING_AND_PROFILING |
663 | 660 |
664 } } // namespace v8::internal | 661 } } // namespace v8::internal |
OLD | NEW |