// the result doesn't have to be free()d but is only valid until the next call to this function static const char *GetTypeName(IDiaSymbol *symbol) { static str::Str<char> strTmp; BSTR name = NULL; symbol->get_name(&name); BStrToString(strTmp, name, "<noname>", true); SysFreeStringSafe(name); return strTmp.Get(); }
static const char *GetSourceFileName(IDiaSymbol *symbol) { static str::Str<char> strTmp; BSTR name = 0; symbol->get_sourceFileName(&name); BStrToString(strTmp, name, "<nosrcfile>"); SysFreeStringSafe(name); return strTmp.Get(); }
static const char *GetLibraryName(IDiaSymbol *symbol) { static str::Str<char> strTmp; BSTR name = 0; symbol->get_libraryName(&name); BStrToString(strTmp, name, "<nolibfile>"); SysFreeStringSafe(name); return strTmp.Get(); }
void GetProgramInfo(str::Str<char>& s) { s.AppendFmt("Ver: %s", CURR_VERSION_STRA); #ifdef SVN_PRE_RELEASE_VER s.AppendFmt(" pre-release"); #endif #ifdef DEBUG if (!str::EndsWith(s.Get(), " (dbg)")) s.Append(" (dbg)"); #endif s.Append("\r\n"); }
// the result doesn't have to be free()d but is only valid until the next call to this function static const char *GetUndecoratedSymbolName(IDiaSymbol *symbol, const char *defName = "<noname>") { static str::Str<char> strTmp; BSTR name = NULL; #if 0 DWORD undecorateOptions = UNDNAME_COMPLETE; #else DWORD undecorateOptions = UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_FUNCTION_RETURNS | UNDNAME_NO_ALLOCATION_MODEL | UNDNAME_NO_ALLOCATION_LANGUAGE | UNDNAME_NO_THISTYPE | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NO_THROW_SIGNATURES | UNDNAME_NO_MEMBER_TYPE | UNDNAME_NO_RETURN_UDT_MODEL | UNDNAME_NO_ECSU; #endif if (S_OK == symbol->get_undecoratedNameEx(undecorateOptions, &name)) { BStrToString(strTmp, name, "", true); if (str::Eq(strTmp.Get(), "`string'")) return "*str"; strTmp.Replace("(void)", "()"); // more ideas for undecoration: // http://google-breakpad.googlecode.com/svn/trunk/src/common/windows/pdb_source_line_writer.cc } else { // Unfortunately it does happen that get_undecoratedNameEx() fails // e.g. for RememberDefaultWindowPosition() in Sumatra code symbol->get_name(&name); BStrToString(strTmp, name, defName, true); } SysFreeStringSafe(name); return strTmp.Get(); }
// the result doesn't have to be free()d but is only valid until the next call to this function static const char *GetObjFileName(IDiaSectionContrib *item) { static str::Str<char> strTmp; BSTR name = 0; IDiaSymbol * compiland = 0; item->get_compiland(&compiland); if (compiland) { compiland->get_name(&name); compiland->Release(); } BStrToString(strTmp, name, "<noobjfile>"); SysFreeStringSafe(name); return strTmp.Get(); }
void GetProgramInfo(str::Str<char>& s) { s.AppendFmt("Ver: %s", CURR_VERSION_STRA); #ifdef SVN_PRE_RELEASE_VER s.AppendFmt(" pre-release"); #endif if (IsProcess64()) { s.Append(" 64-bit"); } #ifdef DEBUG if (!str::Find(s.Get(), " (dbg)")) s.Append(" (dbg)"); #endif s.Append("\r\n"); #if defined(GIT_COMMIT_ID) const char* gitSha1 = QM(GIT_COMMIT_ID); s.AppendFmt("Git: %s (https://github.com/sumatrapdfreader/sumatrapdf/tree/%s)\r\n", gitSha1, gitSha1); #endif }
static void ProcessPdbFile(const char *fileNameA) { HRESULT hr; IDiaDataSource * dia = NULL; IDiaSession * session = NULL; str::Str<char> report; dia = LoadDia(); if (!dia) return; ScopedMem<WCHAR> fileName(str::conv::FromAnsi(fileNameA)); hr = dia->loadDataForExe(fileName, 0, 0); if (FAILED(hr)) { logf(" failed to load %s or its debug symbols from .pdb file\n", fileNameA); goto Exit; } hr = dia->openSession(&session); if (FAILED(hr)) { log(" failed to open DIA session\n"); goto Exit; } if (g_dumpTypes) DumpTypes(session); if (g_dumpSections) DumpSections(session); if (g_dumpSymbols) DumpSymbols(session); fputs("Format: 1\n", stdout); if (g_compact) { str::Str<char> res; GetInternedStringsReport(res); fputs(res.Get(), stdout); } fputs(g_report.Get(), stdout); Exit: UnkReleaseSafe(session); }