| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 fclose(file_); | 226 fclose(file_); |
| 227 } | 227 } |
| 228 | 228 |
| 229 | 229 |
| 230 void OS::LogSharedLibraryAddresses() { | 230 void OS::LogSharedLibraryAddresses() { |
| 231 } | 231 } |
| 232 | 232 |
| 233 | 233 |
| 234 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 234 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
| 235 int frames_size = frames.length(); | 235 int frames_size = frames.length(); |
| 236 void** addresses = NewArray<void*>(frames_size); | 236 ScopedVector<void*> addresses(frames_size); |
| 237 | 237 |
| 238 int frames_count = backtrace(addresses, frames_size); | 238 int frames_count = backtrace(addresses.start(), frames_size); |
| 239 | 239 |
| 240 char** symbols; | 240 char** symbols = backtrace_symbols(addresses.start(), frames_count); |
| 241 symbols = backtrace_symbols(addresses, frames_count); | |
| 242 if (symbols == NULL) { | 241 if (symbols == NULL) { |
| 243 DeleteArray(addresses); | |
| 244 return kStackWalkError; | 242 return kStackWalkError; |
| 245 } | 243 } |
| 246 | 244 |
| 247 for (int i = 0; i < frames_count; i++) { | 245 for (int i = 0; i < frames_count; i++) { |
| 248 frames[i].address = addresses[i]; | 246 frames[i].address = addresses[i]; |
| 249 // Format a text representation of the frame based on the information | 247 // Format a text representation of the frame based on the information |
| 250 // available. | 248 // available. |
| 251 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), | 249 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), |
| 252 "%s", | 250 "%s", |
| 253 symbols[i]); | 251 symbols[i]); |
| 254 // Make sure line termination is in place. | 252 // Make sure line termination is in place. |
| 255 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; | 253 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; |
| 256 } | 254 } |
| 257 | 255 |
| 258 DeleteArray(addresses); | |
| 259 free(symbols); | 256 free(symbols); |
| 260 | 257 |
| 261 return frames_count; | 258 return frames_count; |
| 262 } | 259 } |
| 263 | 260 |
| 264 | 261 |
| 265 // Constants used for mmap. | 262 // Constants used for mmap. |
| 266 static const int kMmapFd = -1; | 263 static const int kMmapFd = -1; |
| 267 static const int kMmapFdOffset = 0; | 264 static const int kMmapFdOffset = 0; |
| 268 | 265 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 } | 595 } |
| 599 | 596 |
| 600 // This sampler is no longer the active sampler. | 597 // This sampler is no longer the active sampler. |
| 601 active_sampler_ = NULL; | 598 active_sampler_ = NULL; |
| 602 active_ = false; | 599 active_ = false; |
| 603 } | 600 } |
| 604 | 601 |
| 605 #endif // ENABLE_LOGGING_AND_PROFILING | 602 #endif // ENABLE_LOGGING_AND_PROFILING |
| 606 | 603 |
| 607 } } // namespace v8::internal | 604 } } // namespace v8::internal |
| OLD | NEW |