OLD | NEW |
1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 // Allocate 24 bytes = ("0x" + 8 bytes + "\n" + overhead) for each | 223 // Allocate 24 bytes = ("0x" + 8 bytes + "\n" + overhead) for each |
224 // address to feed to pprof. | 224 // address to feed to pprof. |
225 const int kOutBufSize = 24 * symbolization_table_.size(); | 225 const int kOutBufSize = 24 * symbolization_table_.size(); |
226 char *pprof_buffer = new char[kOutBufSize]; | 226 char *pprof_buffer = new char[kOutBufSize]; |
227 int written = 0; | 227 int written = 0; |
228 for (SymbolMap::const_iterator iter = symbolization_table_.begin(); | 228 for (SymbolMap::const_iterator iter = symbolization_table_.begin(); |
229 iter != symbolization_table_.end(); ++iter) { | 229 iter != symbolization_table_.end(); ++iter) { |
230 written += snprintf(pprof_buffer + written, kOutBufSize - written, | 230 written += snprintf(pprof_buffer + written, kOutBufSize - written, |
231 // pprof expects format to be 0xXXXXXX | 231 // pprof expects format to be 0xXXXXXX |
232 "0x%"PRIxPTR"\n", reinterpret_cast<uintptr_t>(iter->first)); | 232 "0x%" PRIxPTR "\n", reinterpret_cast<uintptr_t>(iter->first)); |
233 } | 233 } |
234 write(child_in[1], pprof_buffer, strlen(pprof_buffer)); | 234 write(child_in[1], pprof_buffer, strlen(pprof_buffer)); |
235 close(child_in[1]); // that's all we need to write | 235 close(child_in[1]); // that's all we need to write |
236 | 236 |
237 const int kSymbolBufferSize = kSymbolSize * symbolization_table_.size(); | 237 const int kSymbolBufferSize = kSymbolSize * symbolization_table_.size(); |
238 int total_bytes_read = 0; | 238 int total_bytes_read = 0; |
239 delete[] symbol_buffer_; | 239 delete[] symbol_buffer_; |
240 symbol_buffer_ = new char[kSymbolBufferSize]; | 240 symbol_buffer_ = new char[kSymbolBufferSize]; |
241 memset(symbol_buffer_, '\0', kSymbolBufferSize); | 241 memset(symbol_buffer_, '\0', kSymbolBufferSize); |
242 while (1) { | 242 while (1) { |
(...skipping 28 matching lines...) Expand all Loading... |
271 num_symbols++; | 271 num_symbols++; |
272 } | 272 } |
273 } | 273 } |
274 return num_symbols; | 274 return num_symbols; |
275 } | 275 } |
276 } | 276 } |
277 PrintError("Unkown error (should never occur!)"); | 277 PrintError("Unkown error (should never occur!)"); |
278 return 0; // shouldn't be reachable | 278 return 0; // shouldn't be reachable |
279 #endif | 279 #endif |
280 } | 280 } |
OLD | NEW |