Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GetSymbolStoreFileName #50

Open
tmat opened this issue Dec 30, 2016 · 11 comments
Open

Implement GetSymbolStoreFileName #50

tmat opened this issue Dec 30, 2016 · 11 comments

Comments

@tmat
Copy link
Member

tmat commented Dec 30, 2016

Tracking TODO in source

@tmat tmat added this to the future milestone Dec 30, 2016
@KirillOsenkov
Copy link
Member

Do you have any tips on how this should be implemented?

public int GetSymbolStoreFileName(int bufferLength, out int count, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Out]char[] name)

Just return the full path to the .dll file?

@tmat
Copy link
Member Author

tmat commented May 21, 2018

Pretty much reverse-engineer native SymReader and do what it does.

@KirillOsenkov
Copy link
Member

Do you have a pointer to the native source of GetSymbolStoreFileName? Where can I find it?

This exception would be nice to fix soon, I'm running into this quite a bit.

@KirillOsenkov
Copy link
Member

Looks like it's just returning the full path to the .pdb file??

HRESULT
SymReader::GetSymbolStoreFileName(
    ULONG32 cchName,
    _Out_ ULONG32 *pcchName,
    _Out_capcount_(cchName) WCHAR szName[]
)
{
    HRESULT hr = S_OK;
    CDiaString dszName;
    ULONG32 tmpcchName;

    METHOD_ENTRY( SymReader::GetSymbolStoreFileName);

    IfFalseGo( m_cDiawr > 0, E_FAIL );

    IfFailGo( m_rgDiawr[0]->GetPdbName( &dszName ) );

    tmpcchName = (ULONG32)(wcslen(dszName) + 1);

    if (cchName)
    {
        if ( tmpcchName <= cchName )
        {
            if (pcchName)
                *pcchName = tmpcchName;
            wcsncpy_s( szName, cchName, dszName, tmpcchName );
        }
        else
        {
            if (pcchName)
                *pcchName = 0;
            hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
        }
    }
    else
    {
        if (pcchName)
            *pcchName = tmpcchName;
    }

Error:

    METHOD_EXIT( SymReader::GetSymbolStoreFileName, hr );

    return hr;
}

@KirillOsenkov
Copy link
Member

CDiaWrapper.GetPdbName does this:

HRESULT
CDiaWrapper::GetPdbName(
    _Deref_out_z_ wchar_t** pdszPdbName
)
{
    HRESULT hr = S_OK;
    CComPtr< IDiaSymbol > pSymbol;
    CDiaString pdbname;

    IfFailGo( GetExeSymbol( &pSymbol ) );

    IfFailGo( pSymbol->get_symbolsFileName( &pdbname ));
    *pdszPdbName = pdbname.Detach();

Error:
    return hr;
}

@KirillOsenkov
Copy link
Member

@KirillOsenkov
Copy link
Member

I poked around a little bit but couldn't find an easy way to get at the full path to the .pdb (or .dll/.exe in case of embedded .pdb).

Feels like to implement this one would need to thread the filepath through somehow. Not sure what's the best way to do it.

@tmat
Copy link
Member Author

tmat commented Jun 11, 2018

Where is this API used?

Some APIs on ISymUnmanagedBinder take the path. So they should probably pass it to SymReader ctor as an optional parameter, so that SymReader can return the path.

@KirillOsenkov
Copy link
Member

One sample usage is in Mdbg:

System.NotImplementedException: The method or operation is not implemented.
   at int Microsoft.DiaSymReader.PortablePdb.SymReader.GetSymbolStoreFileName(int bufferLength, out int count, out char[] name)
   at string Microsoft.Samples.Debugging.CorSymbolStore.SymReader.GetSymbolStoreFileName()
   at string Microsoft.Samples.Debugging.MdbgEngine.ManagedModule.get_SymbolFilename()

When creating a ManagedModule they access and store the .pdb file path.

I was thinking about passing through an optional path from the creators of SymReader. It felt a bit dirty as otherwise SymReader is fully isolated from where the symbols came from (stream, file, etc). Maybe still worth it.

@tmat
Copy link
Member Author

tmat commented Jun 11, 2018

ISymUnmanagedReader is all dirty API :(

You can also try to fix Mdbg to not use this API.

@KirillOsenkov
Copy link
Member

Yup, just worked around it. If I know that the API will throw, why call it in the first place. Going to live with a patched Mdbg for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants