OLD | NEW |
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 #endif | 173 #endif |
174 | 174 |
175 /* Contents */ | 175 /* Contents */ |
176 #ifdef VC8_OR_ABOVE /* TODO(csilvers): figure out how to tell */ | 176 #ifdef VC8_OR_ABOVE /* TODO(csilvers): figure out how to tell */ |
177 PrintAvailability("Line numbers", module_info.LineNumbers); | 177 PrintAvailability("Line numbers", module_info.LineNumbers); |
178 PrintAvailability("Global symbols", module_info.GlobalSymbols); | 178 PrintAvailability("Global symbols", module_info.GlobalSymbols); |
179 PrintAvailability("Type information", module_info.TypeInfo); | 179 PrintAvailability("Type information", module_info.TypeInfo); |
180 #endif | 180 #endif |
181 } | 181 } |
182 | 182 |
183 void usage() { | |
184 fprintf(stderr, "usage: nm-pdb [-C|--demangle] <module or filename>\n"); | |
185 } | |
186 | |
187 int main(int argc, char *argv[]) { | 183 int main(int argc, char *argv[]) { |
188 DWORD error; | 184 DWORD error; |
189 HANDLE process; | 185 HANDLE process; |
190 ULONG64 module_base; | 186 ULONG64 module_base; |
191 SYM_CONTEXT ctx; | 187 SYM_CONTEXT ctx; |
192 int i; | 188 int i; |
193 char* search; | 189 char* search; |
194 char* filename = NULL; | 190 char* filename = NULL; |
195 int rv = 0; | 191 int rv = 0; |
196 /* We may add SYMOPT_UNDNAME if --demangle is specified: */ | 192 /* We may add SYMOPT_UNDNAME if --demangle is specified: */ |
197 DWORD symopts = SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG; | 193 DWORD symopts = SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG; |
198 | 194 |
199 for (i = 1; i < argc; i++) { | 195 for (i = 1; i < argc; i++) { |
200 if (strcmp(argv[i], "--demangle") == 0 || strcmp(argv[i], "-C") == 0) { | 196 if (strcmp(argv[i], "--demangle") == 0 || strcmp(argv[i], "-C") == 0) { |
201 symopts |= SYMOPT_UNDNAME; | 197 symopts |= SYMOPT_UNDNAME; |
202 } else if (strcmp(argv[i], "--help") == 0) { | |
203 usage(); | |
204 exit(0); | |
205 } else { | 198 } else { |
206 break; | 199 break; |
207 } | 200 } |
208 } | 201 } |
209 if (i != argc - 1) { | 202 if (i != argc - 1) { |
210 usage(); | 203 fprintf(stderr, "usage: nm-pdb [-C|--demangle] <module or filename>\n"); |
211 exit(1); | 204 exit(1); |
212 } | 205 } |
213 filename = argv[i]; | 206 filename = argv[i]; |
214 | 207 |
215 process = GetCurrentProcess(); | 208 process = GetCurrentProcess(); |
216 | 209 |
217 if (!SymInitialize(process, NULL, FALSE)) { | 210 if (!SymInitialize(process, NULL, FALSE)) { |
218 error = GetLastError(); | 211 error = GetLastError(); |
219 fprintf(stderr, "SymInitialize returned error : %d\n", error); | 212 fprintf(stderr, "SymInitialize returned error : %d\n", error); |
220 return 1; | 213 return 1; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 qsort(ctx.syms, ctx.syms_len, sizeof(ctx.syms[0]), sym_cmp); | 257 qsort(ctx.syms, ctx.syms_len, sizeof(ctx.syms[0]), sym_cmp); |
265 for (j = 0; j < ctx.syms_len; j++) { | 258 for (j = 0; j < ctx.syms_len; j++) { |
266 printf("%016I64x X %s\n", ctx.syms[j].addr, ctx.syms[j].name); | 259 printf("%016I64x X %s\n", ctx.syms[j].addr, ctx.syms[j].name); |
267 } | 260 } |
268 /* In a perfect world, maybe we'd clean up ctx's memory? */ | 261 /* In a perfect world, maybe we'd clean up ctx's memory? */ |
269 } | 262 } |
270 SymUnloadModule64(process, module_base); | 263 SymUnloadModule64(process, module_base); |
271 SymCleanup(process); | 264 SymCleanup(process); |
272 return rv; | 265 return rv; |
273 } | 266 } |
OLD | NEW |