Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: src/platform-linux.cc

Issue 1737023: Turn some usages of NewArray with DeleteArray in the same scope into ScopedVector or SmartPointer. (Closed)
Patch Set: Disabling implicit constructors Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 free(lib_name); 369 free(lib_name);
370 fclose(fp); 370 fclose(fp);
371 #endif 371 #endif
372 } 372 }
373 373
374 374
375 int OS::StackWalk(Vector<OS::StackFrame> frames) { 375 int OS::StackWalk(Vector<OS::StackFrame> frames) {
376 // backtrace is a glibc extension. 376 // backtrace is a glibc extension.
377 #ifdef __GLIBC__ 377 #ifdef __GLIBC__
378 int frames_size = frames.length(); 378 int frames_size = frames.length();
379 void** addresses = NewArray<void*>(frames_size); 379 ScopedVector<void*> addresses(frames_size);
380 380
381 int frames_count = backtrace(addresses, frames_size); 381 int frames_count = backtrace(addresses.start(), frames_size);
382 382
383 char** symbols; 383 char** symbols = backtrace_symbols(addresses.start(), frames_count);
384 symbols = backtrace_symbols(addresses, frames_count);
385 if (symbols == NULL) { 384 if (symbols == NULL) {
386 DeleteArray(addresses);
387 return kStackWalkError; 385 return kStackWalkError;
388 } 386 }
389 387
390 for (int i = 0; i < frames_count; i++) { 388 for (int i = 0; i < frames_count; i++) {
391 frames[i].address = addresses[i]; 389 frames[i].address = addresses[i];
392 // Format a text representation of the frame based on the information 390 // Format a text representation of the frame based on the information
393 // available. 391 // available.
394 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), 392 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen),
395 "%s", 393 "%s",
396 symbols[i]); 394 symbols[i]);
397 // Make sure line termination is in place. 395 // Make sure line termination is in place.
398 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; 396 frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
399 } 397 }
400 398
401 DeleteArray(addresses);
402 free(symbols); 399 free(symbols);
403 400
404 return frames_count; 401 return frames_count;
405 #else // ndef __GLIBC__ 402 #else // ndef __GLIBC__
406 return 0; 403 return 0;
407 #endif // ndef __GLIBC__ 404 #endif // ndef __GLIBC__
408 } 405 }
409 406
410 407
411 // Constants used for mmap. 408 // Constants used for mmap.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 830
834 // This sampler is no longer the active sampler. 831 // This sampler is no longer the active sampler.
835 active_sampler_ = NULL; 832 active_sampler_ = NULL;
836 active_ = false; 833 active_ = false;
837 } 834 }
838 835
839 836
840 #endif // ENABLE_LOGGING_AND_PROFILING 837 #endif // ENABLE_LOGGING_AND_PROFILING
841 838
842 } } // namespace v8::internal 839 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698