windbg 调试指南,英文版
Windows调试工具入门-6(WinDbg内核调试常用命令2)
WinDbg内核调试常用命令(2)接上一章继续介绍内核调试下的常用命令,这一章主要涉及内存相关、对象相关、驱动设备相关以及蓝屏Dump 相关命令。
介绍每个命令的主要作用,以及常用方式,不会涉及详细的命令参数,目的是能快速上手熟悉内核调试下的常用操作,而不是替代帮助文件。
内存相关内存操作应该是调试最常用的,比如查看内存、修改内存等。
本节介绍内核模式下常用的内存操作命令,大部分是内核模式下特有的命令,诸如db/eb/dt/s等基本内存命令则不会介绍。
!address!address命令显示内存信息,如内存范围、内存权限等。
这条命令在用户模式下也能用,而且显示的信息比较丰富。
!address命令不带参数时,显示所有内存信息。
kd>!address80800000-0026b000Usage KernelSpaceUsageImageImageName ntoskrnl.exe80a6b000-0001f000Usage KernelSpaceUsageImageImageName halacpi.dll......f51d9000-00005000Usage KernelSpaceUsageKernelStackKernelStack81827020:340.7ac......f894f000-00002000Usage KernelSpaceUsageImageImageName swenum.sysf8951000-00256000Usage KernelSpaceUsageNonPagedSystemf8ba8000-07038000Usage KernelSpaceUsageNonPagedPoolExpansionUsage表示内存用途,如内核映像、非分页内存、内核栈、会话空间等。
通过Usage就能大概了解某段内存的使用情况,也为进一步分析内存指明了方向。
!address xxxxxxxx显示指定地址的内存信息。
WinDbg 调试入门
WinDbg 调试入门Living1 使用方式1.1 启动进程通过菜单File->Open Executable启动,为了接近常用启动环境,最好把Start directory 设置为进程所在目录。
1.2 注入进程通过菜单File->Attach to a Process注入到当前运行的进程中。
1.3 系统默认调试器HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\AeDebug修改其中的Debugger项""C:\WinDbg\windbg.exe"" -p %ld -e %ld如果系统中任意进程发生崩溃,则自动调用系统默认调试器注入到该进程中。
如果Auto 取值为1,不提示用户直接进入。
1.4 程序启动时自动加载调试器当任意进程以任意方式启动时,自动加载调试器并注入到该进程中。
例如有loader.exe加载game.exe,而且game.exe必须由loader加载才能正常运行。
如果game.exe在启动过程中出现错误,希望调试game.exe的启动过程,可使用本方法。
运行WinDbg所附带的工具Global Flags。
请注意,在Image编辑框中只能输入进程的文件名,不能包括路径信息。
1.5 使用AdPlus脚本自动捕捉错误使用WinDbg附带的AdPlus脚本监视进程,如果进程发生崩溃则自动写入到Dump文件中。
adplus –crash –pn notepad.exe –o c:\dumps –quiet说明:-crash 表示监测进程中的崩溃情况-pn 对notepad.exe进行监测,系统中必须有notepad.exe在运行。
也可使用-p <PID>参数,通过进程ID指定要监视的进程。
-o C:\dumps 把日志与捕捉到的dump文件保存到该目录中。
WinDbg用户指南说明书
Table of ContentsAbout1 Chapter 1: Getting started with WinDbg2 Remarks2 Versions2 Examples2 Installation or Setup2 Debuggers3 Chapter 2: Crash analysis4 Examples4 Basic user mode crash analysis4 Chapter 3: DML(Debugger Mark Language)5 Examples5 Turn on/off5 Chapter 4: Extensions6 Examples6 SOS6 SOSex6 PyKD6 Getting started with PyKd6 NetExt7 Extensions overview7 CoSOS7 Chapter 5: Kernel debugging9 Examples9 Important commands9 Chapter 6: Remote debugging10 Examples10 Important commands10 Chapter 7: User mode / application debugging11 Examples11Important commands11 Documenting your work11 Working with symbols11 Crash analysis12 The environment12 Threads, call stacks, registers and memory12 Controlling the target13 Working with extensions13 Stop debugging13 Attach and detach14 Behavior of WinDbg14 Usability Commands14 Getting Helps14 Create Custom Command Window in Windbg14 Credits16AboutYou can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: windbgIt is an unofficial and free WinDbg ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official WinDbg.The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners.Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to ********************Chapter 1: Getting started with WinDbg RemarksThis section provides an overview of what windbg is, and why a developer might want to use it.It should also mention any large subjects within windbg, and link out to the related topics. Since the Documentation for windbg is new, you may need to create initial versions of those related topics.VersionsImportant versions of WinDbg, for supported versions of WinDbg. See also a detailed list with historical versions online.It's important to note that there's a versioning scheme change from older 6.12 to the newer 6.1 version. The older versions have low numbers (<100) in the third place while newer versions have high numbers (>6000).In many cases, WinDbg versions provided for newer Windows versions still work on older versions on Windows, e.g. Version 10 of WinDbg can still be used on Windows 7. However, some commands may make use of API calls that are not available and thus fail. Therefore it's good to have several versions of WinDbg available.ExamplesInstallation or SetupMicrosoft describes 3 ways of installing WinDbg:•as part of the WDK (Windows Driver Kit)•as part of the SDK (Software Development Kit)with the installer of the SDK and deselecting everything else but "Debugging Tools for•Windows"To get the installer, visit Download the WDK, WinDbg, and associated tools and scroll down to a section called "Get debugging tools".A well-known and convenient but inofficial source is Codemachine where you can also download older versions of the Debugging Tools directly.The setup itself is straight-forward. Click through the installer until it finishes.DebuggersWinDbg is often used as an abbreviation of "Debugging tools for Windows". It contains different debuggers:The commands are identical, except that there may be GUI related commands which don't work in the console versions.Read Getting started with WinDbg online: https:///windbg/topic/1833/getting-started-with-windbgChapter 2: Crash analysisExamplesBasic user mode crash analysis.exr -1 gives you details about the last exception thrown.!analyze -v usually does a good job as well.For .NET, the command !pe of the SOS extension shows details about the .NET exception that was thrown.Read Crash analysis online: https:///windbg/topic/5389/crash-analysisChapter 3: DML(Debugger Mark Language) ExamplesTurn on/off.prefer_dml 1 turn on dmlformat output.prefer_dml 0 turn off dmlformat outputRead DML(Debugger Mark Language) online: https:///windbg/topic/7987/dml-debugger-mark-language-Chapter 4: ExtensionsExamplesSOSSOS (son of strike) is the official WinDbg extension from Microsoft for .NET. It gets installed as part of the .NET framework and thus is available by default.Like any extension, it can be loaded using .load x:\full\path\to\sos.dll, but there are easier ways. Depending on the version of .NET, the extension is located side by side to mscorwks.dll(.NET CLR 2), clr.dll (.NET CLR 4) or coreclr.dll (Silverlight and Universal apps), so one of the following commands should work:.loadby sos clr.loadby sos coreclr.loadby sos mscorwksFor a list of available commands, consult !help.SOSexSOSex is an extension to SOS, written by Steve Johnson, a Microsoft employee. He provides SOSex for download for free, but it's not open source.Typically, the extension is not available side by side to any other DLL, so it is usually loaded with .load x:\full\path\to\sosex.dll.Besides simplifying debugging of .NET, the command !dlk can also be used in native environments for checking deadlocks of critical sections.For a list of available commands, consult !help of SOSex.PyKDPyKD is a WinDbg extension that enables you writing Python scripts. It's open source.Typically, the extension is not available side by side to any other DLL, so it is usually loaded with .load x:\full\path\to\pykd.pyd, where PYD is the extension for a python DLL, but you can rename it to DLL if you like.Getting started with PyKdPyKD does not offer !help, so look up the documentation at Codeplex. Many developers seem to be from Russia and the most up-to-date and complete documentation is probably in Russian. The Google translater does a decent job.Like other extensions, use the correct bitness of the extension that corresponds to that of WinDbg. In addition to that you must have Python installed with the same bitness as well.!py runs an REPL interpreter and !py x:\path\to\script.py runs a python script. Scripts should usefrom pykd import *as the first line in order to make use of PyKD's functionality, while this line is not needed in the REPL interpreter. The interpreter can be exited using exit().NetExtNetExt is an extension for .NET which provides•LINQ-like queries for objects on the heap (!wselect, !wfrom)•display capabilities for special objects like dictionaries and hash tables (!wdict, !whash) / HTTP related commands (!wcookie, !wruntime, !whttp)••several other network related commandsTypically, the extension is not available side by side to any other DLL, so it is usually loaded with .load x:\full\path\to\netext.dllExtensions overviewAn incomplete list of WinDbg extensions that are not installed with WinDbg itself:CoSOSCoSOS (cousin of SOS) is an open source extension for WinDbg focusing on .NET memory fragmentation (!gcview) and threading issues (!wfo, !tn).Typically, the extension is not available side by side to any other DLL, so it is usually loaded with .load x:\full\path\to\cosos.dll. It requires that SOS is loaded and currently works with 32 bit applications only.Read Extensions online: https:///windbg/topic/5391/extensionsExamplesImportant commands•!process - list user mode processes•.process - set process context•!peb - show process environment block•!teb - show thread environment block•!locks - deadlock analysis.dump - save a crash dump file to disk•Read Kernel debugging online: https:///windbg/topic/6076/kernel-debuggingExamplesImportant commands•.server - create a debugging server•.clients - list debugging clients connected to the server•.endsrv - end a debugging server•.servers - list debugging server connections•.remote - start a remote.exe server.noshell - prevent shell commands•Read Remote debugging online: https:///windbg/topic/5977/remote-debuggingChapter 7: User mode / application debuggingExamplesImportant commandsDocumenting your workRemember what you've done and retain long outputs which can't be kept in WinDbg's buffer. It's always good to have a log available for reproducing debugging steps, e.g. to ask questions on Stack Overflow.Working with symbolsWithout or with incorrect symbols, you may receive wrong information and be misled. Make sure you're familiar with these commands before starting work in WinDbg. See also How to set up symbols in WinDbg.Crash analysisFind out what has happened (in crash dumps) and how to handle events (in live debugging).The environmentCheck the process name and version information.Threads, call stacks, registers and memoryInspect the details.Controlling the targetIn live debugging, take control the execution.Working with extensionsExtensions may provide significant advantages and enhancements.Stop debuggingAttach and detachBehavior of WinDbgUsability CommandsGetting HelpsCreate Custom Command Window in WindbgThe .cmdtree command allows to open a .txt file with predefined commands which you can simply double click to execute.How to create command fileCreate the file using this templatewindbg ANSI Command Tree 1.0title {"Window title"}body{"Group Heading"}{"Name of command to display"} {"command"}{"Name of command to display"} {"command"}{"Group Heading"}{"Name of command to display"} {"command"}Things to take care1.The template format should be followed precisely for opening the file in Windbg.2.The newline is required after each {Group Heading}.3.Each {Name of command to display} {command} pair should be in one line and should be followed by a new line.Example of custom command filewindbg ANSI Command Tree 1.0title {"Your title goes here"}body{"Basic commands"}{"Show CLR Version"} {"lmv m clr"}{"Load SOS from CLR"} {".loadby sos clr "}{"Symbols"}{"Load my symbols"} {".sympath+ "c:\DebugSymbols" ; .reload"}How to open command UI from command windowExecute .cmdtree <path of your .txt file> to open the window. You will see a window like thisDouble click on the command to execute.Read User mode / application debugging online: https:///windbg/topic/5384/user-mode---application-debuggingCredits。
windbg使用方法
windbg使用方法Windbg是一款由Microsoft开发的强大的调试工具,它可以帮助开发人员诊断和解决Windows平台上的各种软件问题。
本文将介绍Windbg的基本使用方法,希望能够帮助读者更好地利用这一工具进行调试和分析。
首先,我们需要下载并安装Windbg工具。
可以在Microsoft官方网站上找到Windbg的安装包,并按照提示进行安装。
安装完成后,我们可以在开始菜单或者桌面上找到Windbg的快捷方式,双击打开即可进入工具界面。
在使用Windbg进行调试之前,我们需要先了解一些基本概念和操作。
首先是符号文件的设置,符号文件包含了程序中各个函数和变量的调试信息,可以帮助我们更好地进行调试。
在Windbg中,可以通过设置符号路径和加载符号文件来进行符号文件的管理。
接着是源代码的设置,如果我们有程序的源代码,可以通过设置源代码路径来进行源代码级别的调试。
最后是调试目标的设置,可以通过Attach或者Open Crash Dump来加载需要调试的程序。
接下来,我们来看一下Windbg的一些常用命令和功能。
在Windbg的命令行窗口中,可以输入各种命令来进行调试操作,比如设置断点、查看变量的值、跟踪函数的调用等。
此外,Windbg还提供了丰富的图形化界面,可以通过菜单栏和工具栏来进行各种调试操作,比如查看内存、查看寄存器、查看线程信息等。
除了基本的调试功能,Windbg还提供了一些高级的调试工具和扩展,比如分析内存泄漏、分析崩溃转储、分析性能问题等。
通过这些工具和扩展,我们可以更深入地了解程序的运行情况,找出潜在的问题并加以解决。
在使用Windbg进行调试的过程中,我们可能会遇到各种各样的问题和挑战,比如调试信息不够详细、调试速度太慢、调试过程中出现崩溃等。
针对这些问题,我们可以通过调整符号文件的设置、优化调试环境、使用合适的调试工具等方式来进行解决。
总的来说,Windbg是一款功能强大的调试工具,可以帮助我们更好地进行程序调试和分析。
windbg gflags操作流程
windbg gflags操作流程Windbg是一种Windows操作系统的调试工具,它可以帮助开发人员分析和调试应用程序的崩溃和性能问题。
Gflags是Windbg的一个重要组成部分,它提供了一种简便的方式来配置系统的全局标志和调试标志。
本文将介绍如何使用Windbg和Gflags进行调试和性能分析的操作流程。
第一步:安装Windbg和配置符号文件路径我们需要安装Windbg调试工具,并配置符号文件路径。
符号文件包含了应用程序的调试信息,可以帮助开发人员更方便地分析崩溃和性能问题。
在Windbg安装目录下,找到“sym”文件夹,将符号文件下载到该文件夹中。
然后,在Windbg的命令行中输入以下命令来配置符号文件路径:.sympath+ C:\Sym其中,C:\Sym是符号文件路径的根目录,可以根据实际情况进行修改。
第二步:启动Windbg并加载应用程序打开Windbg,选择“文件”菜单中的“打开进程”选项,然后在弹出的对话框中输入应用程序的可执行文件路径。
点击“确定”按钮后,Windbg会加载该应用程序并暂停在入口点处。
第三步:设置断点和观察点在Windbg的命令行中,输入以下命令来设置断点:bp symbol其中,symbol是要设置断点的函数名或地址。
通过设置断点,我们可以在应用程序执行到特定位置时中断程序的执行,以便进行调试和分析。
除了设置断点,我们还可以设置观察点来监视特定的变量或内存地址的值。
在Windbg的命令行中,输入以下命令来设置观察点:ba r/w size address其中,size是要监视的内存块的大小,address是要监视的内存地址。
通过设置观察点,我们可以在特定的内存地址发生变化时中断程序的执行,以便进行调试和分析。
第四步:运行应用程序并触发断点和观察点在Windbg的命令行中,输入“g”命令来继续执行应用程序。
当应用程序执行到设置的断点或观察点处时,Windbg会中断程序的执行,并显示相关的调试信息。
蓝屏修复工具Windbg使用教程
蓝屏修复工具Windbg使用教程电脑蓝屏原因很多,但是大都是硬件和驱动程序不兼容所引起的,要想修复蓝屏问题我们通过Windbag来对蓝屏原因进行定位,Windbg 是一款强大的调试工具,可能有很多小伙伴还不知道Windbg工具的使用方法,那就来看一下使用Windbg进行蓝屏原因定位的使用教程吧。
蓝屏修复工具Windbg使用教程1、要使用Windbg,首先要设置好蓝屏转储,这样当蓝屏时系统会以.dmp文件方式保留蓝屏故障原因。
右键单击桌面计算机图标--选择属性,单击高级系统设置,在启动和故障恢复栏中单击设置,在写入调试信息栏中选择小内存转储(如果已经设置了可忽略此步骤),小转储目录为%SystemRoot%\\Minidump(蓝屏文件存放位置),也就是C:\\Windows\\Minidump文件夹。
2、搜索下载安装Windbg。
3、安装成功后,启动Windbg。
4、先为Windbg软件设置符号表路径,作为蓝屏原因分析数据库,否则软件将没有作用。
单击File--选择Symbol File Path。
5、在弹出的对话框Symbol Path文本框中输入SRV*C:\\Symbols*/download/symbols,单击OK。
6、设置完毕后单击File--选择Open Crash Dump来打开蓝屏文件,在弹出的对话框中点选到C:\\Windows\\Minidump文件夹,单击我们要分析的蓝屏文件,单击打开。
7、接下来就是对文件进行分析,这需要一定的经验和知识。
这里我们着重可以看一下System Uptime(开机时间)和Probably Caused By(可能引起故障的原因是)。
8、需要进一步分析,可以单击!analyze -v9、可以从中提取到蓝屏错误代码和引起蓝屏的程序名称,再通过网络搜索这些程序名和代码等方式弄清原因。
以上就是蓝屏修复工具Windbg使用教程的全部内容,通过使用Windbg,我们就能比较容易的确定导致电脑蓝屏的原因了。
windbg使用方法
windbg使用方法Windbg是一款由微软公司开发的调试工具,它可以帮助开发人员分析和诊断Windows操作系统和应用程序的问题。
本文将介绍Windbg的基本使用方法,希望能够帮助读者更好地利用这个工具进行调试和分析。
首先,我们需要了解如何安装Windbg。
通常情况下,Windbg是作为Windows驱动程序开发工具包(Windows Driver Kit)的一部分发布的,也可以在微软的官方网站上下载到独立安装包。
安装完成后,我们可以在开始菜单或者安装目录中找到Windbg的可执行文件。
接下来,我们需要了解如何打开并配置Windbg。
在打开Windbg 后,我们可以通过“文件”菜单中的“符号文件路径”选项来设置符号文件的路径,以便Windbg能够正确地加载符号文件。
符号文件对于调试非常重要,它包含了源代码和可执行文件之间的映射关系,能够帮助我们更好地理解程序的运行状态。
在Windbg中,我们可以通过“文件”菜单中的“打开转储文件”选项来打开需要分析的转储文件(dump file)。
转储文件是程序崩溃时生成的一种内存快照,包含了程序崩溃时的内存状态和调用栈信息。
通过分析转储文件,我们可以找出程序崩溃的原因,并进行相应的调试和修复。
除了分析转储文件外,我们还可以通过“调试”菜单中的“附加到进程”选项来附加到正在运行的进程,以实时地监视和分析程序的运行状态。
这对于调试一些无法通过转储文件分析的问题非常有帮助,比如内存泄漏、死锁等问题。
在Windbg中,我们可以使用各种命令来进行调试和分析。
比如,通过“!analyze”命令可以自动分析转储文件,并给出可能的崩溃原因;通过“kb”命令可以查看当前线程的调用栈信息;通过“!heap”命令可以查看进程的堆内存分配情况等等。
熟练掌握这些命令对于高效地进行调试和分析非常重要。
除了命令之外,Windbg还提供了丰富的调试工具,比如内存窗口、寄存器窗口、线程窗口等,这些工具可以帮助我们更直观地了解程序的运行状态。
Windbg调试驱动
be[id] 启用断点,e=Enable,id为断点编号
来个简单的实践过程,步骤如下:
1.编译好你的驱动,假设名为ShowSSDT.sys,并把驱动符号文件ShowSSDT.pdb发送到MySysSymbols文件夹下(之前设定的自己的调试符号文件夹)
键入!thread和Kp,查看当前的线程详细信息和堆栈(或者Alt+6也可以看stack).
!process [PID] 0, 查到当前进程:
ቤተ መጻሕፍቲ ባይዱ
在lm命令列出的信息中,start是模块的起始地址,通过键入"u 驱动起始地址",我们可以反汇编出它的代码
fffff800`044d51b2 4c8d1587e72300 lea r10,[nt!KeServiceDescriptorTable (fffff800`04713940)]
6.把ShowSSDT.sys拖到虚拟机中,在虚拟机系统中启动InstDrv,加载此驱动
7.回到Windbg窗口,如果一切正常的话,你会看到已经中断在ShowSSDT.sys的入口代码处了
接下来,要单步还是要下断点、要继续执行什么的,就全由你来作主了~~
指定需要查看的变量的名字
dv /V VariableName
fffff800`044d51b9 4c8d1dc0e72300 lea r11,[nt!KeServiceDescriptorTableShadow (fffff800`04713980)]
bl 列出所有断点,L=List
bc[id] 清除断点,c=Clear,id是bl查看时的断点编号
2.启动虚拟机,选择调试方式进入系统
windbg 驱动调试
本文主要记录个人安装VMware+Windgb+Win7内核驱动调试的笔记。
一、安装环境1主机:Windows Vista Bussiness2虚拟机:VMware 73GUestOS: Win74Windbg: 6.11二、虚拟机配置打开相应vmware 虚拟机上的“Virtaul Machine Settings“2.“Hardware”选项中—-> 点击“Add”添加一个串口设备SeriallPort .3.”Next”,在“Serial Port”里选中“Output to named pipe”4.”next”,然后如下设置:5.确定之后,回到如下界面,在右脚”Virtual Machine Settings”页面时,在“I/O Mode”里选中“Yield CPU on poll“6. Ok之后就设定完毕了。
三、Windbg设置下载地址:Windbg安装之后,设置一个桌面快捷方式,然后,右键->属性,在Target中的引号后面添加如下:-b -k com:pipe,port=\\.\pipe\com_1,resets=0或者是:-b -k com:port=\\.\pipe\com_1,baud=115200,pipe 【二者似乎皆可】四、GuestOS设置Vista和XP不同, 没有boot.ini文件, 需要用bcdedit进行启动设置。
1. 在administrator权限下, 进入command line模式, 键入bcdedit命令, 会出现以下界面:2. 然后, 设置端口COM1, baudrate为115200 (除COM1外, 也可以用1394或USB. 1394用起来比COM口快多了, 当然前提是你需要有1394卡及其驱动. 很恶心的是Vista不再支持1394的文件传输协议, 但是用windbg双机调试还是可以的)命令为:bcdedit /dbgsettings {serial [baudrate:value][debugport:value] | 1394 [channel:value] | usb }3.接着, 我们需要复制一个开机选项, 以进入OS的debug模式命令为:bcdedit /copy {current} /d DebugEntyDebugPoint 为选项名称, 名字可以自己定义. 然后复制得到的ID号.4. 接着增加一个新的选项到引导菜单bcdedit /displayorder {current} {ID}这里的{ID}的ID值是刚生成的ID值.5. 激活DEBUG : bcdedit /debug {ID} ON这里的{ID} 的ID值还是刚才的ID值.6. 命令执行成功后, 重新启动机器.或者更简单的图形界面设置:在msconfig界面中,选Boot,再选Advanced options,在选择Debug、Debug port、Baud rate都打上钩。
WINDBG内存调试
WINDBG调试.NET内存进入WinDBG,检查托管代码●打开WinDbg命令窗口(ALT+1)●输入.load sos.dll查看占用了空间的托管对象MT Count TotalSize ClassNameMT-Method TableFree代表被GC回收常用参数-type某一特定类型;如:!dumpheap –type System.String,列出堆上所有的String -mt列出某一特定MethodTable的所有Object所有具有终结/析构器的都被注册到终结器队列中,当对象被垃圾收集时,终结器会运行析构函数,否则在dispose函数中终结过程会挂起如果Read for finalization>0则说明中终结器线程被堵塞,会消耗很多内存13000 ( 76) : 00.00% 00.01% : RegionUsageTeb9b22000 ( 158856) : 07.58% 25.24% : RegionUsageHeap0 ( 0) : 00.00% 00.00% : RegionUsagePageHeap1000 ( 4) : 00.00% 00.00% : RegionUsagePeb1000 ( 4) : 00.00% 00.00% : RegionUsageProcessParametrs1000 ( 4) : 00.00% 00.00% : RegionUsageEnvironmentBlockTot: 7fff0000 (2097088 KB)总共有2GB的虚拟内容空间(通常典型的是2GB的用户模式内容空间,在64位机上获得到4GB 的内容控件)Busy: 266a2000 (629384 KB)已经使用了629M内存空间-------------------- Type SUMMARY --------------------------TotSize ( KB) Pct(Tots) Usage5994e000 ( 1467704) : 69.99% : <free>eacf000 ( 240444) : 11.47% : MEM_IMAGE表示一个可执行的映射文件的一部分映射到内存,就是dll或一个exe的内存映射5a59000 ( 92516) : 04.41% : MEM_MAPPED1217a000 ( 296424) : 14.14% : MEM_PRIVATE私有内存,不合其他进程共享内存,不是映射到文件的内存;MEM_PRIVATE是保留+已提交(即以分配的)(Reserved+Committed)-------------------- State SUMMARY --------------------------TotSize ( KB) Pct(Tots) Usage1b624000 ( 448656) : 21.39% : MEM_COMMIT5994e000 ( 1467704) : 69.99% : MEM_FREEb07e000 ( 180728) : 08.62% : MEM_RESERVE已保留(但没有实际分配未提交)的内存Largest free region: Base 2203c000 - Size 1e234000 (493776 KB)VAD = Virtual AllocImage =dlls和exes查看内存使用情况。
windebug使用方法
windebug使用方法WinDbg 使用方法WinDbg 是一款强大的 Windows 调试工具,被广泛应用于开发人员和调试专家之间。
它提供了一系列功能,帮助用户分析和调试 Windows 操作系统、驱动程序和应用程序中的问题。
以下是 WinDbg 的使用方法。
1. 下载和安装 WinDbg:您可以从微软官方网站下载最新版本的 WinDbg。
安装过程很简单,按照向导提示逐步进行即可。
2. 配置符号路径:符号文件包含了源代码的调试信息,是进行高级调试的关键。
在 WinDbg 中,您需要配置符号路径以便正确加载符号文件。
您可以通过 "File" 菜单下的 "Symbol File Path" 选项来配置符号路径。
3. 载入调试目标:在 WinDbg 中,可以通过多种方式来载入调试目标。
您可以通过 "File" 菜单下的 "Open Crash Dump" 选项来打开崩溃转储文件,或者通过"File" 菜单下的 "Attach to Process" 选项来附加到正在运行的进程。
4. 设置断点:断点是调试过程中非常有用的工具,可以帮助您在应用程序中指定的位置停止执行。
在 WinDbg 中,可以通过输入 "bp <地址>" 命令来设置断点。
例如,"bp 0x00400000" 命令将在指定地址处设置一个断点。
5. 运行调试:一旦设置了断点并准备好调试,您可以通过 "Debug" 菜单下的"Go" 命令来开始运行调试过程。
当应用程序执行到断点处时,调试过程会自动停止。
6. 分析调试信息:当调试过程中断时,您可以使用 WinDbg 提供的各种命令和功能来分析调试信息。
例如,您可以使用 "p" 命令来显示变量的值,使用 "k" 命令查看调用栈,使用 "lm" 命令列出模块信息等。
windbg 内核调试原理(一)
windbg 内核调试原理(一)windbg 内核调试什么是 windbg 内核调试?•windbg 是一款强大的调试工具,可以用来调试 Windows 操作系统及其应用程序。
•内核调试是 windbg 的一个功能,用于调试操作系统内核,可以帮助开发人员定位和解决系统崩溃、死锁、性能问题等。
内核调试原理1.内核调试利用 Windows 的调试接口和调试驱动程序实现。
2.它通过在目标系统中安装一个调试驱动程序,与 windbg 配合使用,来进行调试。
3.此外,还需要使用串行线缆或网络连接将目标系统和调试主机连接起来。
准备工作•在进行内核调试之前,需要安装 windbg 和调试符号文件。
•调试符号文件包含了操作系统的调试信息,是进行调试的必要文件。
配置目标系统1.在目标系统中配置调试选项:•打开“控制面板”,找到“系统和安全”。
•点击“系统”,然后选择“高级系统设置”。
•在“高级” 选项卡下,点击“设置” 按钮。
•在“启动和故障恢复” 对话框中,点击“设置”。
•将“调试信息” 设置为“完全内存转储”。
2.进行启动选项配置:•打开“命令提示符”,输入以下命令:bcdedit /debug onbcdedit /dbgsettings serial debugport:1 baudrate:115200•这样将启用调试,并配置串行端口为 COM1,波特率为 115200。
配置调试主机1.在调试主机上打开 windbg:•首先,确保已经安装了 windbg。
•然后,在开始菜单中找到 windbg,并打开它。
2.配置串口调试选项:•点击“文件” -> “选项” -> “调试选项”。
•在“调试选项” 对话框中,选择“串行” 选项卡。
•选择正确的串行端口和波特率(与目标系统配置一致)。
连接目标系统和调试主机•使用串行线缆或网络连接将目标系统和调试主机连接起来。
开始内核调试•在 windbg 中,点击“调试” -> “启动调试”。
WinBUGs使用手册(英文版)
WinBUGS User ManualVersion 1.4,January 2003David Spiegelhalter 1Andrew Thomas 2Nicky Best 2Dave Lunn 21MRC Biostatistics Unit,Institute of Public Health,Robinson Way,Cambridge CB22SR,UK2Department of Epidemiology &Public Health,Imperial College School of Medicine,Norfolk Place,London W21PG,UKe-mail:bugs@ [general]andrew.thomas@ [technical]internet:/bugsPermission and Disclaimer please click here to read the legal bitMore informally,potential users are reminded to be extremely careful if using this program for serious statistical analysis.We have tested the program on quite a wide set of examples,but be particularly careful with types of model that are currently not featured.If there is a problem,WinBUGS might just crash,which is not very good,but it might well carry on and produce answers that are wrong,which is even worse.Please let us know of any successes or failures.Beware:MCMC sampling can be dangerous!Contents Introduction This manual Advice for new users MCMC methods How WinBUGS syntax differs from that of ClassicBUGS Changes from WinBUGS 1.3Compound Documents What is a compound document?Working with compound documentsEditing compound documentsŁŁCompound documents and e-mail Printing compound documents and Doodles Reading in text files Model Specification Graphical models Graphs as a formal language The BUGS language: stochastic nodes Censoring and truncation Constraints on using certain distributions Logical nodes Arrays and indexing Repeated structures Data transformations Nested indexing and mixtures Formatting of data DoodleBUGS: The Doodle Editor General properties Creating a node Selecting a node Deleting a node Moving a node Creating a plate Selecting a plate Deleting a plate Moving a plate Resizing a plate Creating an edge Deleting an edge Moving a Doodle Resizing a Doodle Printing a Doodle The Model Menu General properties Specification...Update...Monitor Metropolis Save State Seed...Script The Inference Menu General properties pare...Correlations...Summary...Rank...DIC...ŁŁŁŁThe Info Menu General properties Open Log Clear Log Node ponents The Options Menu Output options...Blocking options...Update options...Batch-mode: Scripts Tricks: Advanced Use of the BUGS Language Specifying a new sampling distribution Specifying a new prior distribution Specifying a discrete prior on a set of values Using pD and DIC Mixtures of models of different complexity Where the size of a set is a random quantity Assessing sensitivity to prior assumptions Modelling unknown denominators Handling unbalanced datasets Learning about the parameters of a Dirichlet distribution Use of the "cut" function WinBUGS Graphics General properties Margins Axis Bounds Titles All Plots Fonts Specific properties (via Special...)Density plot Box plot Caterpillar plot Model fit plot Scatterplot Tips and Troubleshooting Restrictions when modelling Some error messages Some Trap messages The program hangs Speeding up sampling Improving convergenceŁŁŁ ŁŁTutorial Introduction Specifying a model in the BUGS language Running a model in WinBUGS Monitoring parameter values Checking convergence How many iterations after convergence?Obtaining summaries of the posterior distribution Changing MCMC Defaults (advanced users only)Defaults for numbers of iterations Defaults for sampling methods Distributions Discrete Univariate Continuous Univariate Discrete Multivariate Continuous Multivariate ReferencesIntroductionContents This manual Advice for new users MCMC methods How WinBUGS syntax differs from that of Classic BUGS Changes from WinBUGS 1.3This manual[top |home ]This manual describes the WinBUGS software −an interactive Windows version of the BUGS program for Bayesian analysis of complex statistical models using Markov chain Monte Carlo (MCMC)techniques.WinBUGS allows models to be described using a slightly amended version of the BUGS language,or as Doodles (graphical representations of models)which can,if desired,be translated to a text-based description.The BUGS language is more flexible than the Doodles.The sections cover the following topics:Introduction :the software and how a new user can start using WinBUGS .Differences with previous incarnations of BUGS and WinBUGS are pound Documents :the use of the compound document interface that underlies the program,showing how documents can be created,edited and manipulated.Model Specification :the role of graphical models and the specification of the BUGS language.DoodleBUGS: The Doodle Editor :the DoodleBUGS software which allows complex Bayesian models to be ŁŁŁspecified as Doodles using a graphical interface.The Model Menu:the Model Menu permits models expressed as either Doodles or in the BUGS language to be parsed,checked and compiled.The Inference Menu:the Inference Menu controls the monitoring,display and summary of the simulated variables:tools include specialized graphics and space-saving short-cuts for simple summaries of large numbers of variables.The Info Menu:the Info menu provides a log of the run and other information.The Options Menu:facility that allows the user some control over where the output is displayed and the various available MCMC algorithms.Batch-mode: Scripts:how to run WinBUGS in batch-mode using'scripts'.Tricks: Advanced Use of the BUGS Language:special tricks for dealing with non-standard problems,e.g. specification of arbitrary likelihood functions.WinBUGS Graphics:how to display and change the format of graphical output.Tips and Troubleshooting:tips and troubleshooting advice for frequently experienced problems.Tutorial:a tutorial for new users.Changing MCMC Defaults (advanced users only):how to change some of the default settings for the MCMC algorithms used in WinBUGS.Distributions:lists the various(closed-form)distributions available in WinBUGS.References:references to relevant publications.Users are advised that this manual only concerns the syntax and functionality of WinBUGS,and does not deal with issues of Bayesian reasoning,prior distributions,statistical modelling,monitoring convergence,and so on.If you are new to MCMC,you are strongly advised to use this software in conjunction with a course in which the strengths and weaknesses of this procedure are described.Please note the disclaimer at the beginning of this manual.There is a large literature on Bayesian analysis and MCMC methods.For further reading,see,for example, Carlin and Louis(1996),Gelman et al(1995),Gilks,Richardson and Spiegelhalter(1996):Brooks(1998) provides an excellent introduction to MCMC.Chapter9of the Classic BUGS manual,'Topics in Modelling', discusses'non-informative'priors,model criticism,ranking,measurement error,conditional likelihoods, parameterisation,spatial models and so on,while the CODA documentation considers convergence diagnostics.Congdon(2001)shows how to analyse a very wide range of models using WinBUGS.The BUGS website provides additional links to sites of interest,some of which provide extensive examples and tutorial material.Note that WinBUGS simulates each node in turn:this can make convergence very slow and the program very inefficient for models with strongly related parameters,such as hidden-Markov and other time series structures. If you have the educational version of WinBUGS,you can run any model on the example data-sets provided (except possibly some of the newer examples).If you want to analyse your own data you will only be able to build models with less than100nodes(including logical nodes).However,the key for removing this restriction can be obtained by registering via the BUGS website,from which the current distribution policy can also be obtained.Advice for new users[top|home]Although WinBUGS can be used without further reference to any of the BUGS project,experience with using Classic BUGS may be an advantage,and certainly the documentation on BUGS Version0.5and0.6(available from /bugs)contains examples and discussion on wider issues in modelling using MCMC methods.If you are using WinBUGS for the first time,the following stages might be reasonable:1.Step through the simple worked example in the tutorial.2.Try other examples provided with this release(see Examples Volume 1and Examples Volume 2)3.Edit the BUGS language to fit an example of your own.If you are interested in using Doodles:4.Try editing an existing Doodle(e.g.from Examples Volume 1),perhaps to fit a problem of your own.5.Try constructing a Doodle from scratch.Note that there are many features in the BUGS language that cannot be expressed with Doodles.If you wish to proceed to serious,non-educational use,you may want to dispense with DoodleBUGS entirely,or just use it for initially setting up a simplified model that can be elaborated later using the BUGS language.Unfortunately we do not have a program to back-translate from a text-based model description to a Doodle!MCMC methods[top|home]Users should already be aware of the background to Bayesian Markov chain Monte Carlo methods:see for example Gilks et al(1996).Having specified the model as a full joint distribution on all quantities,whether parameters or observables,we wish to sample values of the unknown parameters from their conditional (posterior)distribution given those stochastic nodes that have been observed.The basic idea behind the Gibbs sampling algorithm is to successively sample from the conditional distribution of each node given all the others in the graph(these are known as full conditional distributions):the Metropolis-within-Gibbs algorithm is appropriate for difficult full conditional distributions and does not necessarily generate a new value at each iteration.It can be shown that under broad conditions this process eventually provides samples from the joint posterior distribution of the unknown quantities.Empirical summary statistics can be formed from these samples and used to draw inferences about their true values.The sampling methods are used in the following hierarchies(in each case a method is only used if no previous method in the hierarchy is appropriate):Continuous target distribution MethodConjugate Direct sampling using standard algorithmsLog-concave Derivative-free adaptive rejection sampling(Gilks,1992)Restricted range Slice sampling(Neal,1997)Unrestricted range Current point MetropolisDiscrete target distribution MethodFinite upper bound InversionShifted Poisson Direct sampling using standard algorithmIn cases where the graph contains a Generalized Linear Model(GLM)component,it is possible to request(see Blocking options...)that WinBUGS groups(or'blocks')together the fixed-effect parameters and updates them via the multivariate sampling technique described in Gamerman (1997).This is essentially a Metropolis-Hastings algorithm where at each iteration the proposal distribution is formed by performing one iteration, starting at the current point,of Iterative Weighted Least Squares(IWLS).If WinBUGS is unable to classify the full conditional for a particular parameter(p,say)according to the above hierarchy,then an error message will be returned saying"Unable to choose update method for p". Simulations are carried out univariately,except for explicitly defined multivariate nodes and,if requested,blocks of fixed-effect parameters in GLMs(see above).There is also the option of using ordered over-relaxation(Neal, 1998),which generates multiple samples at each iteration and then selects one that is negatively correlated with the current value.The time per iteration will be increased,but the within-chain correlations should be reduced and hence fewer iterations may be necessary.However,this method is not always effective and should be used with caution.A slice-sampling algorithm is used for non log-concave densities on a restricted range.This has an adaptive phase of500iterations which will be discarded from all summary statistics.The current Metropolis MCMC algorithm is based on a symmetric normal proposal distribution,whose standard deviation is tuned over the first4000iterations in order to get an acceptance rate of between20%and40%.All summary statistics for the model will ignore information from this adapting phase.It is possible for the user to change some aspects of the various available MCMC updating algorithms,such as the length of an adaptive phase−please see Update options...for details.It is also now possible to change the sampling methods for certain classes of distribution,although this is delicate and should be done carefully−see Changing MCMC Defaults (advanced users only)for details.The shifted Poisson distribution occurs when a Poisson prior is placed on the order of a single binomial observation.How WinBUGS syntax differs from that of Classic BUGS[top|home]Changes to the BUGS syntax have been kept,as far as possible,to simplifications.There is now:-No need for constants(these are declared as part of the data).-No need for variable declaration(but all names used to declare data must appear in the model).-No need to specify files for data and initial values.-No limitation on dimensionality of arrays.-No limitation on size of problems(except those dictated by hardware).-No need for semi-colons at end of statements(these were never necessary anyway!)A major change from the Classic BUGS syntax is that when defining multivariate nodes,the range of the variable must be explicitly defined:for examplex[1:K]~dmnorm(mu[],tau[,])must be used instead of x[]~dmnorm(mu[],tau[,]),and for precision matrices you must write, saytau[1:K,1:K]~dwish(R[,],3)rather than tau[,]~dwish(R[,],3).The following format must now be used to invert a matrix:sigma[1:K,1:K]<-inverse(tau[,])Note that inverse(.)is now a vector-valued function as opposed to the relatively inefficient component-wise evaluation required in previous versions of the software.To convert Classic BUGS files to run under WinBUGS:a)Open the.bug file as a text file,delete unnecessary declarations,and save as an.odc document.b)Open.dat files:data has to be formatted as described in Formatting of data:eg*matrices in data files need to have the full'.structure'format*all data in datafile need to be described in the model*need data list of constants and file sizes*need column headings on rectangular arraysThe data can be copied into the.odc file,or kept as a separate file.c)Copy the contents of the.in file into the.odc file.Changes from WinBUGS1.3[top|home]-modular on-line manual;-ability to run in batch-mode using scripts;-running of default script on start-up to allow calling from other programs;-new graphics(see here,for example)and editing of graphics−note that graphics from previous versions of the software will be incompatible with this version(1.4);-missing data and range constraints allowed for multivariate normal;-new distributions:negative binomial,generalized gamma,multivariate Student-t;-DIC menu option for model comparison;-Options menu,for advanced control of MCMC algorithms,for example;-new syntax for(more efficient)'inverse'function;-"interp.lin"interpolation function,"cut"function;-recursively-(and thus efficiently-)calculated running quantiles;-MCMC algorithms:block updating of fixed effects−see here and/or here for details;-non-integer binomial and Poisson data;-Poisson as prior for continuous quantity;-'coverage' of random number generator;-additional restrictions:END command for rectangular arrays;-spatial(CAR)models moved to GeoBUGS;-new display options;-now possible to print out posterior correlation coefficients for monitored variables;-new manual sections:Batch-mode: Scripts,Tricks,WinBUGS Graphics,Tutorial,andChanging MCMC Defaults.Compound DocumentsContentsWhat is a compound document?Working with compound documentsEditing compound documentsCompound documents and e-mailPrinting compound documents and DoodlesReading in text filesWhat is a compound document?[top|home]A compound document contains various types of information(formatted text,tables,formulae,plots,graphs etc)displayed in a single window and stored in a single file.The tools needed to create and manipulate these information types are always available,so there is no need to continuously move between different programs. The WinBUGS software has been designed so that it produces output directly to a compound document and can get its input directly from a compound document.To see an example of a compound document click here. WinBUGS is written in Component Pascal using the BlackBox development framework:seehttp://www.oberon.ch.In WinBUGS a document is a description of a statistical analysis,the user interface to the software,and the resulting output.Compound documents are stored with the.odc extension.Working with compound documents[top|home]A compound document is like a word-processor document that contains special rectangular embedded regions or elements,each of which can be manipulated by standard word-processing tools--each rectangle behaves like a single large character,and can be focused,selected,moved,copied,deleted etc.If an element is focused the tools to manipulate its interior become available.The WinBUGS software works with many different types of elements,the most interesting of which are Doodles,which allow statistical models to be described in terms of graphs.DoodleBUGS is a specialised graphics editor and is described fully in DoodleBUGS: The Doodle Editor.Other elements are rather simpler and are used to display plots of an analysis.Editing compound documents[top|home]WinBUGS contains a built-in word processor,which can be used to manipulate any output produced by the software.If a more powerful editing tool is needed WinBUGS documents or parts of them can be pasted into a standard OLE enabled word processor.Text is selected by holding down the left mouse button while dragging the mouse over a region of text. Warning:if text is selected and a key pressed the selection will be replaced by the character typed.The selection can be removed by pressing the"Esc"key or clicking the mouse.A single element can be selected by clicking once into it with the left mouse button.A selected element is distinguished by a thin bounding rectangle.If this bounding rectangle contains small solid squares at the corners and mid sides it can be resized by dragging these with the mouse.An element can be focused by clicking twice into it with the left mouse button.A focused element is distinguished by a hairy grey bounding rectangle.A selection can be moved to a new position by dragging it with the mouse.To copy the selection hold down the "control"key while releasing the mouse button.These operations work across windows and across applications,and so the problem specification and the output can both be pasted into a single document,which can then be copied into another word-processor or presentation package.The style,size,font and colour of selected text can be changed using the Attributes menu.The vertical offset of the selection can be changed using the Text menu.The formatting of text can be altered by embedding special elements.The most common format control is the ruler:pick option Show Marks in menu Text to see what rulers look like.The small black up-pointing triangles are tab stops,which can be moved by dragging them with the mouse and removed by dragging them outside the left or right borders of the ruler.The icons above the scale control,for example,centering and page breaks. Vertical lines within tables can be curtailed by inserting a ruler and removing the lines by selecting each tab-stop and then ctrl-left-mouse-click.(Warning:removing the left-most line requires care:there is a tab-stop hidden behind the upper left-most one that can cause a crash if deleted in the usual way-it seems to require a ctrl-right-mouse-click!).Compound documents and e-mail[top|home]WinBUGS compound documents contain non-ascii characters,but the Tools menu contains a command Encode Document which produces an ascii representation of the focus document.The original document can be recovered from this encoded form by using the Decode command of the Tools menu.This allows,for example,Doodles to be sent by e-mail.Printing compound documents and Doodles[top|home]These can be printed directly from the File menu.If postscript versions of Doodles or whole documents are wanted,you could install a driver for a postscript printer(say Apple LaserWriter),but set it up to print to file (checking the paper size is appropriate).Alternatively Doodles or documents could be copied to a presentation or word-processing package and printed from there.Reading in text files[top|home]Open these from the File menu as text files.They can be copied into documents,or stored as documents.Model SpecificationContentsGraphical modelsGraphs as a formal languageThe BUGS language: stochastic nodes Censoring and truncation Constraints on using certain distributions Logical nodes Arrays and indexing Repeated structures Data transformations Nested indexing and mixtures Formatting of dataGraphical models[top |home ]We strongly recommend that the first step in any analysis should be the construction of a directed graphical model .Briefly,this represents all quantities as nodes in a directed graph,in which arrows run into nodes from their direct influences (parents).The model represents the assumption that,given its parent nodes pa[v ],each node v is independent of all other nodes in the graph except descendants of v ,where descendant has the obvious definition.Nodes in the graph are of three types.1.Constants are fixed by the design of the study:they are always founder nodes (i.e.do not have parents),and are denoted as rectangles in the graph.They must be specified in a data file.2.Stochastic node s are variables that are given a distribution,and are denoted as ellipses in the graph;they may be parents or children (or both).Stochastic nodes may be observed in which case they are data ,or may be unobserved and hence be parameters ,which may be unknown quantities underlying a model,observations on an individual case that are unobserved say due to censoring,or simply missing data.3.Deterministic nodes are logical functions of other nodes.Quantities are specified to be data by giving them values in a data file,in which values for constants are also given.Directed links may be of two types:a solid arrow indicates a stochastic dependence while a hollow arrow indicates a logical function.An undirected dashed link may also be drawn to represent an upper or lower bound.Repeated parts of the graph can be represented using a 'plate',as shown below for the range (i in 1:N).A simple graphical model,where Y[i]depends on mu[i]and tau,with mu[i]being a logical function of alpha and beta.The conditional independence assumptions represented by the graph mean that the full joint distribution of all quantities V has a simple factorisation in terms of the conditional distribution p(v |parents[v ])of each nodeindex:i from:1up to:Ngiven its parents,so thatp(V )=Πp(v |parents[v ])v in VThe crucial idea is that we need only provide the parent-child distributions in order to fully specify the model,and WinBUGS then sorts out the necessary sampling methods directly from the expressed graphical structure.Graphs as a formal language[top |home ]A special drawing tool DoodleBUGS has been developed for specifying graphical models,which uses a hyper-diagram approach to add extra information to the graph to give a complete model specification.Each stochastic and logical node in the graph must be given a name using the conventions explained in Creating a node .The shaded node Y[i]is normally distributed with mean mu[i]andprecision tau.The shaded node mu[i]is a logical function of alpha,beta,and theconstants x.(x is not required to be shown in the graph).The value function of a logical node contains all the necessary information to define thelogical node:the logical links in the graph are not strictly necessary.As an alternative to the Doodle representation,the model can be specified using the text-based BUGS language,headed by the model statement:model {text-based description of graph in BUGS language}The BUGS language:stochastic nodes[top|home]In the text-based model description,stochastic nodes are represented by the node name followed by a twiddles symbol followed by the distribution name followed by a comma-separated list of parents enclosed in brackets e.g.r~dbin(p,n)The distributions that can be used in WinBUGS are described in Distributions.Clicking on the name of each distribution should provide a link to an example of its use provided with this release.The parameters of a distribution must be explicit nodes in the graph(scalar parameters can also be numerical constants)and so may not be function expressions.For distributions not featured in Distributions,see Tricks: Advanced Use of the BUGS Language.Censoring and truncation[top|home]Censoring is denoted using the notation I(lower,upper)e.g.x~ddist(theta)I(lower,upper)would denote a quantity x from distribution ddist with parameters theta,which had been observed to lie between lower and upper.Leaving either lower or upper blank corresponds to no limit,e.g.I(lower,)corresponds to an observation known to lie above lower.Whenever censoring is specified the censored node contributes a term to the full conditional distribution of its parents.This structure is only of use if x has not been observed(if x is observed then the constraints will be ignored).It is vital to note that this construct does NOT correspond to a truncated distribution,which generates a likelihood that is a complex function of the basic parameters.Truncated distributions might be handled by working out an algebraic form for the likelihood and using the techniques for arbitrary distributions described in Tricks: Advanced Use of the BUGS Language.It is also important to note that if x,theta,lower and upper are all unobserved,then lower and upper must not be functions of theta.Constraints on using certain distributions[top|home]Contiguous elements:Multivariate nodes must form contiguous elements in an array.Since the final element in an array changes fastest,such nodes must be defined as the final part of any array.For example,to define a set of K*K Wishart variables as a single multidimensional array x[i,j,k],we could write: for(i in1:I){x[i,1:K,1:K]~dwish(R[i,,],3)}where R[i,,]is an array of specified prior parameters.No missing data:Data defined as multinomial or as multivariate Student-t must be complete,in that missing values are not allowed in the data array.We realise this is an unfortunate restriction and we hope to relax it in the future.For multinomial data,it may be possible to get round this problem by re-expressing the multivariate likelihood as a sequence of conditional univariate binomial distributions.Note that multivariate normal data may now be specified with missing values.Conjugate updating:Dirichlet and Wishart distributions can only be used as parents of multinomial and multivariate normal nodes respectively.Parameters you can't learn about and must specify as constants:The parameters of Dirichlet and Wishart distributions and the order(N)of the multinomial distribution must be specified and cannot be given prior distributions.(There is,however,a trick to avoid this constraint for the Dirichlet distribution−see here.)Structured precision matrices for multivariate normals:these can be used in certain circumstances.If a。
使用WinDbg调试入门(内核模式)
使⽤WinDbg调试⼊门(内核模式)windbg是⼀个内核模式和⽤户模式调试器,包含在Windows调试⼯具中。
这⾥我们提供了⼀些实践练习,可以帮助您开始使⽤windbg作为内核模式调试器。
设置内核模式调试内核模式调试环境通常有两台计算机:主机和⽬标计算机。
调试器在主机上运⾏,正在调试的代码在⽬标计算机上运⾏。
主机和⽬标通过调试电缆连接。
Windows调试程序⽀持以下类型的电缆进⾏调试:EthernetUSB 2.0USB 3.01394Serial (also called null modem)如果⽬标计算机运⾏的是Windows8或更⾼版本,则可以使⽤任何类型的调试电缆,包括以太⽹。
此图说明通过以太⽹电缆连接调试的主机和⽬标计算机。
如果⽬标计算机运⾏的Windows版本早于Windows 8,则不能使⽤以太⽹进⾏调试;必须使⽤USB、1394或串⾏。
此图说明了通过USB、1394或串⾏调试电缆连接的主机和⽬标计算机。
建⽴内核模式调试会话在设置好主机和⽬标计算机并⽤调试电缆将它们连接起来之后,您可以按照⽤于设置的同⼀主题中的说明建⽴内核模式调试会话。
例如,如果您决定设置主机和⽬标计算机以通过以太⽹进⾏调试,参考《》。
同样,如果您决定设置主机和⽬标计算机以通过USB 2.0进⾏调试,您可以找到建⽴内核模式调试会话的说明,参考《》开始调试1、在主机上,打开windbg并与⽬标计算机建⽴内核模式调试会话。
2、在windbg中,从帮助菜单中选择内容。
这将打开调试器⽂档chm⽂件。
调试程序⽂档也可以在这⾥在线获得。
3、当建⽴内核模式调试会话时,windbg可能会⾃动进⼊⽬标计算机。
如果windbg尚未插⼊,请从“调试”菜单中选择“中断”。
4、在windbg窗⼝底部附近的命令⾏中,输⼊以下命令:符号搜索路径告诉windbg在哪⾥查找符号(pdb)⽂件。
调试器需要符号⽂件来获取有关代码模块(函数名、变量名等)的信息。
windbg调试函数
windbg调试函数Windbg是一款强大的Windows调试工具,可以用来调试各种类型的问题,包括应用程序崩溃、死锁、性能问题等。
在Windbg中调试函数是非常常见的任务,通过调试函数可以深入了解代码执行的过程,发现问题所在并进行调试和解决。
首先,要调试函数,需要了解如何在Windbg中设置断点。
断点是一种可以让程序在特定条件下停止执行的工具,可以帮助我们跟踪程序的执行过程。
在Windbg中可以通过命令或者图形界面来设置断点,常用的命令有“bp”和“bu”,分别表示设置断点和条件断点。
其次,要调试函数,需要了解如何查看函数的调用堆栈。
调用堆栈是函数调用的过程记录,可以帮助我们了解函数调用的顺序和参数传递的情况。
在Windbg中可以使用命令“kb”或者“kbn”来查看调用堆栈,通过查看调用堆栈可以找到函数的调用关系,定位问题所在。
另外,要调试函数,需要了解如何查看函数的参数和局部变量。
函数的参数和局部变量是函数执行过程中的重要数据,通过查看这些数据可以帮助我们了解函数的执行情况,定位问题所在。
在Windbg中可以使用命令“dv”和“dt”来查看函数的参数和局部变量,通过查看参数和局部变量可以帮助我们定位问题所在,找到解决方案。
最后,要调试函数,需要了解如何单步调试函数的执行过程。
单步调试是一种可以让程序一步一步执行的调试方法,可以帮助我们跟踪函数的执行过程,发现问题所在。
在Windbg中可以使用命令“p”和“t”来单步执行函数,通过单步调试可以深入了解函数的执行过程,找到问题所在,解决问题。
总的来说,调试函数是Windbg中的常见任务,通过设置断点、查看调用堆栈、查看参数和局部变量、单步调试等方法,可以帮助我们深入了解函数的执行过程,找到问题所在,解决问题。
希望以上内容可以帮助您更好地理解和应用Windbg调试函数的方法。
如有任何问题,欢迎随时向我咨询。
WinDbg远程调试配置方法
WinDbg远程调试配置方法1. 调试环境:目标机:VMware 5.5.1 + Windows XP SP2主机:Windows XP SP2 + WinDbg 6.52. 目标机配置(虚拟机)2.1 通过VMware虚拟一个com端口关闭目标机系统,运行 VMware ,点击Edit virtual machine settings -> Add -> Serial Port -> Output to named pipe;第一框里保持默认的 "\\.\pipe\com_1";第二框里选"This end is the server."第三框里选"The other end is an application."选中"Connect at power on";然后点击 "Advanced>>",选中"Yield CPU on poll",然后点完成。
2.2 设置目标机操作系统的boot.ini在目标机操作系统的boot.ini文件加入一行multi(0)disk(0)rdisk(0)partition(1) \WINNT="Microsoft Windows XP Professional - debug" /fastdetect /debug /debugport=com1 /baudrate=115200。
目标机配置完成。
3. 主机配置安装WinDbg并在桌面创建一快捷方式,点右键属性,在快捷方式目标处填写为:(此处WinDbg装在C盘)C:\Program Files\Debugging Tools for Windows\windbg.exe -k com:port=\\.\pipe\com_1, baud=11520, pipe4. 调试顺序(1) 启动目标机,进入调试程序模式(2) 运行主机中桌面的WinDbg快捷方式,就可以连接上目标机5. 附注:5.1 如何单步调试调试驱动程序时,在目标机把驱动安装完成后,需在主机的WinDbg配置Symbol、Source 以及Image的路径,配置完成后,就可以进行驱动程序的源码单步调试。
Windbg 使用教程
详解用法详解第30章WinDBG用法WinDBG是个非常强大的调试器,它设计了极其丰富的功能来支持各种调试任务,包括用户态调试、内核态调试、调试转储文件、远程调试等等。
WinDBG具有非常大的灵活性和可扩展性,用来满足各种各样的调试需求,比如用户可以自由定义调试事件的处理方式,编写调试扩展模块来定制和补充WinDBG的调试功能。
尽管WinDBG是个典型的窗口程序,但是它的大多数调试功能还是以手工输入命令的方式来工作的。
目前版本的WinDBG共提供了20多条标准命令,140多条元命令(Meta-commands),和难以计数的大量扩展命令。
学习和灵活使用这些命令是学习WinDBG的关键,也是难点。
上一章我们从设计的角度分析了WinDBG,本章将从使用(用户)的角度介绍WinDBG。
我们先介绍工作空间的概念和用法(第1节),然后介绍命令的分类和不同种类的命令提示符(第2节)。
第3节介绍不同的调试模式,也就是如何与不同特征的调试目标建立调试会话。
第4节介绍上下文的概念和在调试时应该如何切换和控制上下文。
第5节介绍调试事件和如何定制调试事件的处理方式。
从第6节到第9节我们将分别介绍如何在WinDBG中完成典型的调试操作,比如控制调试目标(第6节)、设置断点(第7节)、观察栈(第8节)以及如何观察和修改数据(第9节)。
30.1 工作空间WinDBG使用工作空间(Workspace)来描述和存储一个调试项目的属性、参数、以及调试器设置等信息。
其功能类似于集成开发环境的项目文件。
分类30.1.1分类WinDBG定义了两种工作空间,一种称为缺省的工作空间(Default Workspace),另一种称为命名的工作空间(Named Workspace)。
当没有明确使用某个命名的工作空间时,WinDBG总是使用缺省的工作空间,因此缺省的工作空间也叫隐含的(implicit)工作空间,命名的工作空间也叫显式的(explicit)工作空间。
WinDbg源码模式调试
WinDbg源码模式调试Debugging Tools for Windows如果可以分析源代码⽽不是反汇编⼆进制代码,调试程序会更加容易⼀些。
当源代码是C、C++或汇编语⾔时,WinDbg、CDB和KD可以在调试中使⽤它们。
编译的要求要进⾏源码调试,必须让编译器或链接器在构建⼆进制⽂件时⽣成符号⽂件(.pdb⽂件)。
这些符号⽂件保存了⼆进制指令和源码⾏之间的对应关系。
另外,调试器必须能够访问源码⽂件,因为符号⽂件中并不包含实际的源代码⽂本。
如果这些都满⾜,编译器和链接器还不能对代码进⾏优化。
如果代码经过优化,在源码调试时访问局部变量会变得很困难,有时候⼏乎是不可能的。
如果使⽤Build 实⽤程序作为编译器和链接器,可以将MSC_OPTIMIZATION 宏设置为/Od /Oi 来避免优化。
定位符号⽂件和源码⽂件在源码模式下调试,调试器必须能够找到源码⽂件和符号⽂件。
更多信息,查看。
开始源码调试只要调试器拥有当前被调试线程的正确的符号和源码⽂件,就可以显⽰源码信息。
如果使⽤调试器启动⼀个新的⽤户模式程序,在Ntdll.dll加载程序时初始断点就会触发。
由于调试器不能访问Ntdll.dll的源码⽂件,所以这时不能访问应⽤程序的源码信息。
要将程序计数器移动到程序的开始位置,可以在⼆进制代码⼊⼝点设置断点。
在输⼊下⾯的命令。
bp maing之后,程序会被加载起来并在进⼊main函数时停⽌。
(当然,可以使⽤任何⼊⼝点,⽽不仅仅是main。
)如果程序抛出⼀个异常,它会中断到调试器中。
这时源码信息是可⽤的。
但是,如果通过、或命令来中断,调试器创建了⼀个新线程,所以不能看到源代码。
当到达具有源码⽂件的线程时,在调试器命令窗⼝中就可以执⾏源码调试命令了。
如果使⽤WinDbg,会出现。
如果已经通过点击File菜单的 Open Source File 打开了源码窗⼝,在WinDbg GUI中进⾏源码调试如果使⽤WinDbg,当程序计数器运⾏到调试器拥有源码信息的代码时,⼀个源码窗⼝会出现。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Debugging Windows Applications with IDA WinDbg PluginCopyright 2011 Hex-Rays SA Quick overview:The Windbg debugger plugin is an IDA Pro debugger plugin that uses Microsoft's debugging engine (dbgeng) that is used by Windbg, Cdb or Kd.To get started, you need to install the latest Debugging Tools from Microsoft website:/whdc/devtools/debugging/installx86.mspxor from the Windows SDK / DDK package.Please make sure you should install the x86 version of the debugging tools which is used by both IDA Pro and IDA Pro 64. The x64 version will NOT work.After installing the debugging tools, make sure you select « Debugger / Switch Debugger » and select the WinDbg debugger.Also make sure you specify the correct settings in the “Debugger specific options” dialog:•User mode: Select this mode for user mode application debugging (default mode)•Kernel mode: Select this mode to attach to a live kernel.•Non Invasive debugging: Select this mode to attach to a process non-invasively•Output flags: These flags tell the debugging engine which kind of output messages to display and which to omit•Kernel mode debugging with reconnect and initial break: Select this option when debugging a kernel and when the connection string contains 'reconnect'. This option will assure that the debugger breaks as soon as possible after a reconnect.To make these settings permanent, please edit the IDA\cfg\dbg_windbg.cfg file.To specify the debugging tools folde r you may add to the PATH environment variable the location of Windbg.exe or edit %IDA%\cfg\ida.cfg and change the value of the DBGTOOLS key.After the debugger is properly configured, edit the process options and leave the connection string value empty because we intend to debug a local user-mode application.Now hit F9 to start debugging:The Windbg plugin is very similar to IDA Pro's Win32 debugger plugin, nonetheless by using the former, one can benefit from the command line facilities and the extensions that ship with the debugging tools.For example, one can type “!chain” to see the registered Windbg extensions:“!gle” is another command to get the last error value of a given Win32 API call.Another benefit of using the Windbg debugger plugin is the use of symbolic information. Normally, if the debugging symbols path is not set, then the module window will only show the exported names. For example kernel32.dll displays 1359 names:Let us configure a symbol source by adding this environment variable before running IDA: set _NT_SYMBOL_PATH=srv*C:\Temp\pdb*/download/symbols It is also possible to set the symbol path directly while debugging:and then typing “.reload /f” to reload the symbols.Now we try again and notice that more symbol names are retrieved from kernel32.dll:Now we have 5818 symbols instead!It is also possible to use the “x” command to quickly search for symbols:(Looking for any symbol in any module that contains the word “continue”)Debugging a remote process:We have seen how to debug a local user mode program, now let us see how to debug a remote process. First let us assume that “pcA” is the target machine (where we will run the debugger server and the debugged program) and “pcB” is the machine where IDA Pro and the debugging tools are installed. To start a remote process:•On “pcA”, type:dbgsrv -t tcp:port=5000(change the port number as needed)•On “pcB”, setup IDA Pro and Windbg debugger plugin:◦“Application/Input file”: these should contain a path to the debuggee residing in “pcA”◦Connection string: tcp:port=5000,server=pcANow run the program and debug it remotely.To attach to a remote process, use the same steps to setup “pcA” and use the same connection string when attaching to the process.More about connection strings and different protocols (other than TCP/IP) can be found in “debugger.chm” in the debugging tools folder.Debugging the kernel with VMWare:We will now demonstrate how to debug the kernel through a virtual machine.In this example we will be using VMWare 6.5 and Windows XP SP3.Configuring the virtual machine:Run the VM and then edit “c:\boot.ini” file and add one more entry (see in bold):[operating systems]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional"/noexecute=optin /fastdetectmulti(0)disk(0)rdisk(0)partition(1)\WINDOWS="Local debug" /noexecute=optin /fastdetect/debug /debugport=com1 /baudrate=115200For MS Windows Vista please see: /en-us/library/ms791527.aspxp Actually the last line is just a copy of the first line but we added the “/debug” switch and some configuration values.Now shutdown the virtual machine and edit its hardware settings and add a new serial port with option “use named pipes”:Press “Finish” and start the VM. At the boot prompt, select “Local debug” from the boot menu:Configuring Windbg debugger plugin:Now run IDA Pro and select Debugger / Attach / WindbgThen configure it to use “Kernel mode” debugging and use the following connection string: com:port=\\.\pipe\com_1,baud=115200,pipeIt is possible to use the 'reconnect' keyword in the connection string:com:port=\\.\pipe\com_1,baud=115200,pipe,reconnectAlso make sure the appropriate option is selected from the debugger specific options.Please note that the connection string (in step 1) refers to the named pipe we set up in the previous steps.Finally, press OK to attach and start debugging.When IDA attaches successfully, it will display something like this:If you do not see named labels then try checking your debugging symbols settings.Note: In kernel mode IDA Pro will display one entry in the threads window for each processor. For example a two processor configuration yields:VMWare configurationThreads in IDAThis screenshot shows how we are debugging the kernel and changing the disassembly listing (renaming stack variables, or using structure offsets):At the end you can detach from the kernel and resume it or detach from the kernel and keep it suspended.To detach and resume, simply select the “Debugger / Detach”, however to detach and keep the kernel suspended select “Debugger / Terminate Process”.Debugging the kernel through kdsrv.exeIn some cases, when debugging a 64bit kernel using a 1394 cable then 64bit drivers are needed, thus dbgeng (32bits) will not work. To workaround this problem we need to run the kernel debugger server from the x64 debugging tools folder and connect to it:•Go to “Debugging Tools (x64)” installation•Run kdsrv.exe (change the port number/transport appropriately):◦kdsrv -t tcp:port=6000•Now run ida64 and specify the following connection string (change the transport value appropriately):◦kdsrv:server=@{tcp:port=6000,server=127.0.0.1},trans=@{com:port=\\.\pipe\com_3,bau d=115200,pipe}。