| OLD | NEW |
| 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 #include <dia2.h> | 5 #include <dia2.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 // Create an IDiaData source and open a PDB file. | 10 // Create an IDiaData source and open a PDB file. |
| 11 static bool LoadDataFromPdb(const wchar_t* filename, | 11 static bool LoadDataFromPdb(const wchar_t* filename, |
| 12 IDiaDataSource** source, | 12 IDiaDataSource** source, |
| 13 IDiaSession** session, | 13 IDiaSession** session, |
| 14 IDiaSymbol** global, | 14 IDiaSymbol** global, |
| 15 DWORD* machine_type) { | 15 DWORD* machine_type) { |
| 16 // Alternate path to search for debug data. | 16 // Alternate path to search for debug data. |
| 17 const wchar_t search_path[] = L"SRV**\\\\symbols\\symbols"; | 17 const wchar_t search_path[] = L"SRV**\\\\symbols\\symbols"; |
| 18 DWORD mach_type = 0; | 18 DWORD mach_type = 0; |
| 19 HRESULT hr = CoInitialize(NULL); | 19 HRESULT hr = CoInitialize(NULL); |
| 20 | 20 |
| 21 // Obtain access to the provider. | 21 // Obtain access to the provider. |
| 22 hr = CoCreateInstance(__uuidof(DiaSource), | 22 hr = CoCreateInstance(__uuidof(DiaSource), |
| 23 NULL, | 23 NULL, |
| 24 CLSCTX_INPROC_SERVER, | 24 CLSCTX_INPROC_SERVER, |
| 25 __uuidof(IDiaDataSource), | 25 __uuidof(IDiaDataSource), |
| 26 (void**)source); | 26 (void**)source); |
| 27 | 27 |
| 28 if (FAILED(hr)) { | 28 if (FAILED(hr)) { |
| 29 printf("CoCreateInstance failed - HRESULT = %08X\n", hr); | 29 printf("CoCreateInstance failed - HRESULT = %08lX\n", hr); |
| 30 return false; | 30 return false; |
| 31 } | 31 } |
| 32 | 32 |
| 33 wchar_t ext[MAX_PATH]; | 33 wchar_t ext[MAX_PATH]; |
| 34 _wsplitpath_s(filename, NULL, 0, NULL, 0, NULL, 0, ext, MAX_PATH); | 34 _wsplitpath_s(filename, NULL, 0, NULL, 0, NULL, 0, ext, MAX_PATH); |
| 35 | 35 |
| 36 // Open and prepare the debug data associated with the executable. | 36 // Open and prepare the debug data associated with the executable. |
| 37 hr = (*source)->loadDataForExe(filename, search_path, NULL); | 37 hr = (*source)->loadDataForExe(filename, search_path, NULL); |
| 38 if (FAILED(hr)) { | 38 if (FAILED(hr)) { |
| 39 printf("loadDataForExe failed - HRESULT = %08X\n", hr); | 39 printf("loadDataForExe failed - HRESULT = %08lX\n", hr); |
| 40 return false; | 40 return false; |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Open a session for querying symbols. | 43 // Open a session for querying symbols. |
| 44 hr = (*source)->openSession(session); | 44 hr = (*source)->openSession(session); |
| 45 | 45 |
| 46 if (FAILED(hr)) { | 46 if (FAILED(hr)) { |
| 47 printf("openSession failed - HRESULT = %08X\n", hr); | 47 printf("openSession failed - HRESULT = %08lX\n", hr); |
| 48 return false; | 48 return false; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Retrieve a reference to the global scope. | 51 // Retrieve a reference to the global scope. |
| 52 hr = (*session)->get_globalScope(global); | 52 hr = (*session)->get_globalScope(global); |
| 53 | 53 |
| 54 if (FAILED(hr)) { | 54 if (FAILED(hr)) { |
| 55 printf("get_globalScope failed\n"); | 55 printf("get_globalScope failed\n"); |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 wprintf(L"Static initializers in %s:\n", argv[1]); | 170 wprintf(L"Static initializers in %s:\n", argv[1]); |
| 171 | 171 |
| 172 if (!DumpStaticInitializers(global_symbol)) | 172 if (!DumpStaticInitializers(global_symbol)) |
| 173 return 1; | 173 return 1; |
| 174 | 174 |
| 175 Cleanup(global_symbol, dia_session); | 175 Cleanup(global_symbol, dia_session); |
| 176 | 176 |
| 177 return 0; | 177 return 0; |
| 178 } | 178 } |
| OLD | NEW |