| OLD | NEW |
| 1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 // Our file format is "bucket, bucket, ..., bucket, proc_self_maps_info". | 336 // Our file format is "bucket, bucket, ..., bucket, proc_self_maps_info". |
| 337 // In the cases buf is too small, we'd rather leave out the last | 337 // In the cases buf is too small, we'd rather leave out the last |
| 338 // buckets than leave out the /proc/self/maps info. To ensure that, | 338 // buckets than leave out the /proc/self/maps info. To ensure that, |
| 339 // we actually print the /proc/self/maps info first, then move it to | 339 // we actually print the /proc/self/maps info first, then move it to |
| 340 // the end of the buffer, then write the bucket info into whatever | 340 // the end of the buffer, then write the bucket info into whatever |
| 341 // is remaining, and then move the maps info one last time to close | 341 // is remaining, and then move the maps info one last time to close |
| 342 // any gaps. Whew! | 342 // any gaps. Whew! |
| 343 int map_length = snprintf(buf, size, "%s", kProcSelfMapsHeader); | 343 int map_length = snprintf(buf, size, "%s", kProcSelfMapsHeader); |
| 344 if (map_length < 0 || map_length >= size) return 0; | 344 if (map_length < 0 || map_length >= size) return 0; |
| 345 map_length += FillProcSelfMaps(buf + map_length, size - map_length); | 345 bool dummy; // "wrote_all" -- did /proc/self/maps fit in its entirety? |
| 346 map_length += FillProcSelfMaps(buf + map_length, size - map_length, &dummy); |
| 346 RAW_DCHECK(map_length <= size, ""); | 347 RAW_DCHECK(map_length <= size, ""); |
| 347 char* const map_start = buf + size - map_length; // move to end | 348 char* const map_start = buf + size - map_length; // move to end |
| 348 memmove(map_start, buf, map_length); | 349 memmove(map_start, buf, map_length); |
| 349 size -= map_length; | 350 size -= map_length; |
| 350 | 351 |
| 351 Stats stats; | 352 Stats stats; |
| 352 memset(&stats, 0, sizeof(stats)); | 353 memset(&stats, 0, sizeof(stats)); |
| 353 int bucket_length = snprintf(buf, size, "%s", kProfileHeader); | 354 int bucket_length = snprintf(buf, size, "%s", kProfileHeader); |
| 354 if (bucket_length < 0 || bucket_length >= size) return 0; | 355 if (bucket_length < 0 || bucket_length >= size) return 0; |
| 355 bucket_length = UnparseBucket(total_, buf, bucket_length, size, | 356 bucket_length = UnparseBucket(total_, buf, bucket_length, size, |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 char* unused) { | 592 char* unused) { |
| 592 // Perhaps also log the allocation stack trace (unsymbolized) | 593 // Perhaps also log the allocation stack trace (unsymbolized) |
| 593 // on this line in case somebody finds it useful. | 594 // on this line in case somebody finds it useful. |
| 594 RAW_LOG(ERROR, "leaked %"PRIuS" byte object %p", v->bytes, ptr); | 595 RAW_LOG(ERROR, "leaked %"PRIuS" byte object %p", v->bytes, ptr); |
| 595 } | 596 } |
| 596 | 597 |
| 597 void HeapProfileTable::Snapshot::ReportIndividualObjects() { | 598 void HeapProfileTable::Snapshot::ReportIndividualObjects() { |
| 598 char unused; | 599 char unused; |
| 599 map_.Iterate(ReportObject, &unused); | 600 map_.Iterate(ReportObject, &unused); |
| 600 } | 601 } |
| OLD | NEW |