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

Side by Side Diff: tools/android/heap_profiler/heap_dump.c

Issue 1549203002: Switch to standard integer types in tools/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « tools/android/forwarder2/socket.cc ('k') | tools/android/heap_profiler/heap_profiler.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The client dump tool for libheap_profiler. It attaches to a process (given 5 // The client dump tool for libheap_profiler. It attaches to a process (given
6 // its pid) and dumps all the libheap_profiler tracking information in JSON. 6 // its pid) and dumps all the libheap_profiler tracking information in JSON.
7 // The JSON output looks like this: 7 // The JSON output looks like this:
8 // { 8 // {
9 // "total_allocated": 908748493, # Total bytes allocated and not freed. 9 // "total_allocated": 908748493, # Total bytes allocated and not freed.
10 // "num_allocs": 37542, # Number of allocations. 10 // "num_allocs": 37542, # Number of allocations.
(...skipping 15 matching lines...) Expand all
26 // ^ ^ ^ 26 // ^ ^ ^
27 // | | +-----> Stack frames (absolute virtual addresses). 27 // | | +-----> Stack frames (absolute virtual addresses).
28 // | +--------------> Bytes allocated and not freed by the call site. 28 // | +--------------> Bytes allocated and not freed by the call site.
29 // +---------------------> Index of the entry (as for "allocs" xref). 29 // +---------------------> Index of the entry (as for "allocs" xref).
30 // Indexes are hex and might not be monotonic. 30 // Indexes are hex and might not be monotonic.
31 31
32 #include <errno.h> 32 #include <errno.h>
33 #include <fcntl.h> 33 #include <fcntl.h>
34 #include <inttypes.h> 34 #include <inttypes.h>
35 #include <stdbool.h> 35 #include <stdbool.h>
36 #include <stddef.h>
37 #include <stdint.h>
36 #include <stdio.h> 38 #include <stdio.h>
37 #include <stdlib.h> 39 #include <stdlib.h>
38 #include <string.h> 40 #include <string.h>
39 #include <time.h>
40 #include <unistd.h>
41 #include <sys/ptrace.h> 41 #include <sys/ptrace.h>
42 #include <sys/stat.h> 42 #include <sys/stat.h>
43 #include <sys/wait.h> 43 #include <sys/wait.h>
44 #include <time.h>
45 #include <unistd.h>
44 46
45 #include "tools/android/heap_profiler/heap_profiler.h" 47 #include "tools/android/heap_profiler/heap_profiler.h"
46 48
47
48 static void lseek_abs(int fd, size_t off); 49 static void lseek_abs(int fd, size_t off);
49 static void read_proc_cmdline(char* cmdline, int size); 50 static void read_proc_cmdline(char* cmdline, int size);
50 static ssize_t read_safe(int fd, void* buf, size_t count); 51 static ssize_t read_safe(int fd, void* buf, size_t count);
51 52
52 static int pid; 53 static int pid;
53 54
54 55
55 static int dump_process_heap( 56 static int dump_process_heap(
56 int mem_fd, 57 int mem_fd,
57 FILE* fmaps, 58 FILE* fmaps,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 ret = dump_process_heap(mem_fd, fmaps, dump_also_allocs, pedantic, comment); 341 ret = dump_process_heap(mem_fd, fmaps, dump_also_allocs, pedantic, comment);
341 342
342 ptrace(PTRACE_DETACH, pid, NULL, NULL); 343 ptrace(PTRACE_DETACH, pid, NULL, NULL);
343 344
344 // Cleanup. 345 // Cleanup.
345 fflush(stdout); 346 fflush(stdout);
346 close(mem_fd); 347 close(mem_fd);
347 fclose(fmaps); 348 fclose(fmaps);
348 return ret; 349 return ret;
349 } 350 }
OLDNEW
« no previous file with comments | « tools/android/forwarder2/socket.cc ('k') | tools/android/heap_profiler/heap_profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698