2
votes

I wrote a WinDbg plugin to assist my developers in debugging our applications. More specifically, it helps in running special diagnostics on the data structures found in our application, and prevents that developers have to manually check lots of data structure information.

I am now considering porting this WinDbg to Visual Studio 2019 (as a VSIX extension), but I don't know where to start. I can investigate how to write such an extension, but I don't know where to start looking for the debugger-related API in Visual Studio.

  • Is there a simple way to reuse a WinDbg plugin in Visual Studio 2019? That would make it very easy for me?
  • If not, what is the API in Visual Studio to get debugging information? Think about: reading memory, getting symbols, getting the address of a vtable, searching memory, getting the call stack, getting generic information? I can do all of this in WinDbg via the IDebug... COM interfaces, but where do I start in Visual Studio 2019?
1
iirc the complete functionality has been removed from vs earlier one could use !load ext.dll and then call !peb etc in the immediate window the Command Window can provide a subset of these methods like Debug.ListMemory dont tknow if it is scriptable - blabb
The last version of VS which had this feature built-in was VS 2010. More recent versions of VS required the WDK to be installed. The last WDK version which supports this feature is WDK for Windows 10 1507 (MSDN) - Thomas Weller
@ThomasWeller, thanks for the information. So simply reusing my WinDbg plugin in Visual Studio doesn't seem to be an option anymore. Any ideas on where to find information regarding the Visual Studio debugging API (similar to IDebugControl, … from WinDbg)? - Patrick

1 Answers

1
votes

@Patrick i was googling after i wrote the comment but forgot to update

it appears vs has its set of own IDebugInterfaces called IDebugEngine1,2 etc

i never coded a vs extension but is trying to cobble one will update when i get time

in the meanwhile you may read through this documentation

it appears to be c# and again that isnt my strong point either

Requirements

Header: Msdbg.h

Namespace: Microsoft.VisualStudio.Debugger.Interop

Assembly: Microsoft.VisualStudio.Debugger.Interop.dll

there are two samples provided which you can refer to here

i downloaded this sample but haven't given it enough time

and it appears the apis are completely different wrt windbg a sample Attach looks like below

/* static */
DebuggedProcess^ Worker::AttachToProcess(ISampleEngineCallback^ callback, int processId)
{
    ASSERT(Worker::MainThreadId != Worker::CurrentThreadId);

    HANDLE hProcess = Win32HandleCall( ::OpenProcess(
        PROCESS_ALL_ACCESS, 
        FALSE, 
        processId
        ));

    String^ nameFromHandle = GetProcessName(hProcess);

    String^ processName = System::IO::Path::GetFullPath(nameFromHandle);

    Win32BoolCall( ::DebugActiveProcess(
        processId
        ) );

    DebuggedProcess^ process = gcnew DebuggedProcess(Attach, callback, hProcess, processId, processName);

    return process;
}