简体   繁体   English

将 WinDbg 插件移植到 Visual Studio 2019 扩展

[英]Porting WinDbg plugin to Visual Studio 2019 extension

I wrote a WinDbg plugin to assist my developers in debugging our applications.我编写了一个 WinDbg 插件来帮助我的开发人员调试我们的应用程序。 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.我现在正在考虑将此 WinDbg 移植到 Visual Studio 2019(作为 VSIX 扩展),但我不知道从哪里开始。 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.我可以研究如何编写这样的扩展,但我不知道从哪里开始在 Visual Studio 中寻找与调试器相关的 API。

  • Is there a simple way to reuse a WinDbg plugin in Visual Studio 2019?有没有一种简单的方法可以在 Visual Studio 2019 中重用 WinDbg 插件? That would make it very easy for me?这对我来说很容易吗?
  • If not, what is the API in Visual Studio to get debugging information?如果没有,Visual Studio 中获取调试信息的 API 是什么? Think about: reading memory, getting symbols, getting the address of a vtable, searching memory, getting the call stack, getting generic information?想一想:读取 memory,获取符号,获取 vtable 的地址,搜索 memory,获取调用堆栈,获取通用信息? I can do all of this in WinDbg via the IDebug... COM interfaces, but where do I start in Visual Studio 2019?我可以通过 IDebug 在 WinDbg 中完成所有这些操作... COM 接口,但是在 Visual Studio 2019 中我应该从哪里开始呢?

@Patrick i was googling after i wrote the comment but forgot to update @Patrick 我在写评论后正在谷歌搜索,但忘记更新了

it appears vs has its set of own IDebugInterfaces called IDebugEngine1,2 etc看起来 vs 有自己的一组 IDebugInterfaces,称为 IDebugEngine1,2 等

i never coded a vs extension but is trying to cobble one will update when i get time我从来没有编写过一个 vs 扩展,但我试图拼凑一个会在我有时间的时候更新

in the meanwhile you may read through this documentation同时您可以通读本文档

it appears to be c# and again that isnt my strong point either它似乎是 c#,这也不是我的强项

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并且看起来api与windbg完全不同,示例附件如下所示

/* 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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM