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

Side by Side Diff: third_party/tcmalloc/chromium/src/windows/addr2line-pdb.c

Issue 9323026: [NOT TO COMMIT!] r109: Diff of the current tcmalloc from the original google-perftools r109. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* Copyright (c) 2008, Google Inc. 1 /* Copyright (c) 2008, 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 30 matching lines...) Expand all
41 41
42 #include <stdio.h> 42 #include <stdio.h>
43 #include <stdlib.h> 43 #include <stdlib.h>
44 44
45 #include <windows.h> 45 #include <windows.h>
46 #include <dbghelp.h> 46 #include <dbghelp.h>
47 47
48 #define SEARCH_CAP (1024*1024) 48 #define SEARCH_CAP (1024*1024)
49 #define WEBSYM "SRV*c:\\websymbols*http://msdl.microsoft.com/download/symbols" 49 #define WEBSYM "SRV*c:\\websymbols*http://msdl.microsoft.com/download/symbols"
50 50
51 void usage() {
52 fprintf(stderr, "usage: "
53 "addr2line-pdb [-f|--functions] [-C|--demangle] [-e filename]\n");
54 fprintf(stderr, "(Then list the hex addresses on stdin, one per line)\n");
55 }
56
57 int main(int argc, char *argv[]) { 51 int main(int argc, char *argv[]) {
58 DWORD error; 52 DWORD error;
59 HANDLE process; 53 HANDLE process;
60 ULONG64 module_base; 54 ULONG64 module_base;
61 int i; 55 int i;
62 char* search; 56 char* search;
63 char buf[256]; /* Enough to hold one hex address, I trust! */ 57 char buf[256]; /* Enough to hold one hex address, I trust! */
64 int rv = 0; 58 int rv = 0;
65 /* We may add SYMOPT_UNDNAME if --demangle is specified: */ 59 /* We may add SYMOPT_UNDNAME if --demangle is specified: */
66 DWORD symopts = SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG | SYMOPT_LOAD_LINES; 60 DWORD symopts = SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG | SYMOPT_LOAD_LINES;
67 char* filename = "a.out"; /* The default if -e isn't specified */ 61 char* filename = "a.out"; /* The default if -e isn't specified */
68 int print_function_name = 0; /* Set to 1 if -f is specified */ 62 int print_function_name = 0; /* Set to 1 if -f is specified */
69 63
70 for (i = 1; i < argc; i++) { 64 for (i = 1; i < argc; i++) {
71 if (strcmp(argv[i], "--functions") == 0 || strcmp(argv[i], "-f") == 0) { 65 if (strcmp(argv[i], "--functions") == 0 || strcmp(argv[i], "-f") == 0) {
72 print_function_name = 1; 66 print_function_name = 1;
73 } else if (strcmp(argv[i], "--demangle") == 0 || 67 } else if (strcmp(argv[i], "--demangle") == 0 ||
74 strcmp(argv[i], "-C") == 0) { 68 strcmp(argv[i], "-C") == 0) {
75 symopts |= SYMOPT_UNDNAME; 69 symopts |= SYMOPT_UNDNAME;
76 } else if (strcmp(argv[i], "-e") == 0) { 70 } else if (strcmp(argv[i], "-e") == 0) {
77 if (i + 1 >= argc) { 71 if (i + 1 >= argc) {
78 fprintf(stderr, "FATAL ERROR: -e must be followed by a filename\n"); 72 fprintf(stderr, "FATAL ERROR: -e must be followed by a filename\n");
79 return 1; 73 return 1;
80 } 74 }
81 filename = argv[i+1]; 75 filename = argv[i+1];
82 i++; /* to skip over filename too */ 76 i++; /* to skip over filename too */
83 } else if (strcmp(argv[i], "--help") == 0) {
84 usage();
85 exit(0);
86 } else { 77 } else {
87 usage(); 78 fprintf(stderr, "usage: "
79 "addr2line-pdb [-f|--functions] [-C|--demangle] [-e filename]\n");
80 fprintf(stderr, "(Then list the hex addresses on stdin, one per line)\n");
88 exit(1); 81 exit(1);
89 } 82 }
90 } 83 }
91 84
92 process = GetCurrentProcess(); 85 process = GetCurrentProcess();
93 86
94 if (!SymInitialize(process, NULL, FALSE)) { 87 if (!SymInitialize(process, NULL, FALSE)) {
95 error = GetLastError(); 88 error = GetLastError();
96 fprintf(stderr, "SymInitialize returned error : %d\n", error); 89 fprintf(stderr, "SymInitialize returned error : %d\n", error);
97 return 1; 90 return 1;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (SymGetLineFromAddr64(process, (DWORD64)addr, &dummy, &line)) { 147 if (SymGetLineFromAddr64(process, (DWORD64)addr, &dummy, &line)) {
155 printf("%s:%d\n", line.FileName, (int)line.LineNumber); 148 printf("%s:%d\n", line.FileName, (int)line.LineNumber);
156 } else { 149 } else {
157 printf("??:0\n"); 150 printf("??:0\n");
158 } 151 }
159 } 152 }
160 SymUnloadModule64(process, module_base); 153 SymUnloadModule64(process, module_base);
161 SymCleanup(process); 154 SymCleanup(process);
162 return rv; 155 return rv;
163 } 156 }
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/thread_cache.cc ('k') | third_party/tcmalloc/chromium/src/windows/google/tcmalloc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698