Commit 50ac68a3 authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Convert ShowGlobals Uses of CComPtr to Microsoft::WRL::ComPtr

BUG=5027

Change-Id: Ia828554114412a760cc3d6e5c768ce8202ccfa5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1885509
Auto-Submit: Robert Liao <robliao@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711386}
parent 684f29e9
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <dia2.h> #include <dia2.h>
#include <stdio.h> #include <stdio.h>
#include <wrl/client.h>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
...@@ -93,7 +94,7 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) { ...@@ -93,7 +94,7 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) {
std::vector<SymbolData> symbols; std::vector<SymbolData> symbols;
std::vector<RepeatData> repeats; std::vector<RepeatData> repeats;
CComPtr<IDiaEnumSymbols> enum_symbols; Microsoft::WRL::ComPtr<IDiaEnumSymbols> enum_symbols;
HRESULT result = HRESULT result =
global->findChildren(SymTagData, NULL, nsNone, &enum_symbols); global->findChildren(SymTagData, NULL, nsNone, &enum_symbols);
if (FAILED(result)) { if (FAILED(result)) {
...@@ -101,12 +102,9 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) { ...@@ -101,12 +102,9 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) {
return false; return false;
} }
CComPtr<IDiaSymbol> symbol; Microsoft::WRL::ComPtr<IDiaSymbol> symbol;
// Must call symbol.Release() at end of loop to prepare for reuse of symbol
// smart pointer, because DIA2 is not smart-pointer aware.
for (ULONG celt = 0; for (ULONG celt = 0;
SUCCEEDED(enum_symbols->Next(1, &symbol, &celt)) && (celt == 1); SUCCEEDED(enum_symbols->Next(1, &symbol, &celt)) && (celt == 1);) {
symbol.Release()) {
DWORD location_type = 0; DWORD location_type = 0;
// If we can't get the location type then we assume the variable is not of // If we can't get the location type then we assume the variable is not of
// interest. // interest.
...@@ -121,7 +119,7 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) { ...@@ -121,7 +119,7 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) {
// If we call get_length on symbol it works for functions but not for // If we call get_length on symbol it works for functions but not for
// data. For some reason for data we have to call get_type() to get // data. For some reason for data we have to call get_type() to get
// another IDiaSymbol object which we can query for length. // another IDiaSymbol object which we can query for length.
CComPtr<IDiaSymbol> type_symbol; Microsoft::WRL::ComPtr<IDiaSymbol> type_symbol;
if (FAILED(symbol->get_type(&type_symbol))) { if (FAILED(symbol->get_type(&type_symbol))) {
wprintf(L"Get_type failed.\n"); wprintf(L"Get_type failed.\n");
continue; continue;
...@@ -196,9 +194,9 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) { ...@@ -196,9 +194,9 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) {
} }
bool Initialize(const wchar_t* filename, bool Initialize(const wchar_t* filename,
CComPtr<IDiaDataSource>& source, Microsoft::WRL::ComPtr<IDiaDataSource>& source,
CComPtr<IDiaSession>& session, Microsoft::WRL::ComPtr<IDiaSession>& session,
CComPtr<IDiaSymbol>& global) { Microsoft::WRL::ComPtr<IDiaSymbol>& global) {
// Initialize DIA2 // Initialize DIA2
HRESULT hr = CoCreateInstance(__uuidof(DiaSource), NULL, CLSCTX_INPROC_SERVER, HRESULT hr = CoCreateInstance(__uuidof(DiaSource), NULL, CLSCTX_INPROC_SERVER,
__uuidof(IDiaDataSource), (void**)&source); __uuidof(IDiaDataSource), (void**)&source);
...@@ -247,13 +245,13 @@ int wmain(int argc, wchar_t* argv[]) { ...@@ -247,13 +245,13 @@ int wmain(int argc, wchar_t* argv[]) {
// Extra scope so that we can call CoUninitialize after we destroy our local // Extra scope so that we can call CoUninitialize after we destroy our local
// variables. // variables.
{ {
CComPtr<IDiaDataSource> source; Microsoft::WRL::ComPtr<IDiaDataSource> source;
CComPtr<IDiaSession> session; Microsoft::WRL::ComPtr<IDiaSession> session;
CComPtr<IDiaSymbol> global; Microsoft::WRL::ComPtr<IDiaSymbol> global;
if (!(Initialize(filename, source, session, global))) if (!(Initialize(filename, source, session, global)))
return -1; return -1;
DumpInterestingGlobals(global, filename); DumpInterestingGlobals(global.Get(), filename);
} }
CoUninitialize(); CoUninitialize();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment