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 @@
#include <dia2.h>
#include <stdio.h>
#include <wrl/client.h>
#include <algorithm>
#include <string>
......@@ -93,7 +94,7 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) {
std::vector<SymbolData> symbols;
std::vector<RepeatData> repeats;
CComPtr<IDiaEnumSymbols> enum_symbols;
Microsoft::WRL::ComPtr<IDiaEnumSymbols> enum_symbols;
HRESULT result =
global->findChildren(SymTagData, NULL, nsNone, &enum_symbols);
if (FAILED(result)) {
......@@ -101,12 +102,9 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) {
return false;
}
CComPtr<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.
Microsoft::WRL::ComPtr<IDiaSymbol> symbol;
for (ULONG celt = 0;
SUCCEEDED(enum_symbols->Next(1, &symbol, &celt)) && (celt == 1);
symbol.Release()) {
SUCCEEDED(enum_symbols->Next(1, &symbol, &celt)) && (celt == 1);) {
DWORD location_type = 0;
// If we can't get the location type then we assume the variable is not of
// interest.
......@@ -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
// data. For some reason for data we have to call get_type() to get
// 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))) {
wprintf(L"Get_type failed.\n");
continue;
......@@ -196,9 +194,9 @@ bool DumpInterestingGlobals(IDiaSymbol* global, const wchar_t* filename) {
}
bool Initialize(const wchar_t* filename,
CComPtr<IDiaDataSource>& source,
CComPtr<IDiaSession>& session,
CComPtr<IDiaSymbol>& global) {
Microsoft::WRL::ComPtr<IDiaDataSource>& source,
Microsoft::WRL::ComPtr<IDiaSession>& session,
Microsoft::WRL::ComPtr<IDiaSymbol>& global) {
// Initialize DIA2
HRESULT hr = CoCreateInstance(__uuidof(DiaSource), NULL, CLSCTX_INPROC_SERVER,
__uuidof(IDiaDataSource), (void**)&source);
......@@ -247,13 +245,13 @@ int wmain(int argc, wchar_t* argv[]) {
// Extra scope so that we can call CoUninitialize after we destroy our local
// variables.
{
CComPtr<IDiaDataSource> source;
CComPtr<IDiaSession> session;
CComPtr<IDiaSymbol> global;
Microsoft::WRL::ComPtr<IDiaDataSource> source;
Microsoft::WRL::ComPtr<IDiaSession> session;
Microsoft::WRL::ComPtr<IDiaSymbol> global;
if (!(Initialize(filename, source, session, global)))
return -1;
DumpInterestingGlobals(global, filename);
DumpInterestingGlobals(global.Get(), filename);
}
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