76120498 7579509 TN 182 Design Process Using Adapt Builder Platform
Using Advanced Platform Builder Debugger Features
description
Transcript of Using Advanced Platform Builder Debugger Features
![Page 1: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/1.jpg)
![Page 2: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/2.jpg)
Using Advanced Platform Builder Debugger Features
Chenghui LianMicrosoft China Technology Center
![Page 3: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/3.jpg)
Agenda
• Introduction to the PB Kernel Debugger
• Tools for debugging• Remote tools• Demo
![Page 4: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/4.jpg)
Debugger Architecture
foo.exe
KdStub (kd.dll)
kernel (nk.exe)
Windows CE DeviceDesktop
cemgr.exe
Platform Builder Debugger (cepb.exe)
KITL
![Page 5: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/5.jpg)
PB kernel debugger
• VC++ version 6 roots– Familiar UI– Rich in features
• System Debugger– Exceptions from any process– Stops interrupts while in break state– Uses KITL connections– HW Assist thru 3rd party support
• Debugging Applications– Slightly different from eVC
![Page 6: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/6.jpg)
Debug build vs. retail build
– Debug•Full debugging on by default•Optimizations off can be easier to debug•More messages output
– Retail•Default: IMGNODEBUGGER =1•Optimizations enabled Code Movement •Less messages output
![Page 7: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/7.jpg)
Debug/Retail Build vs. Debugger
• Debug/Retail build– Optimization off/on– Compiler options– Controlled by “set wincedebug=debug”
or “set wincedebug=retail”
• Debugger– Modules included in run time image to
enable debugging– Controlled by “set IMGNODEBUGGER=”
![Page 8: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/8.jpg)
Tools for debugging
• System debugging• Hardware-assisted debugging• Kernel profiler
![Page 9: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/9.jpg)
Target State: Running
• CE Target Control service (shell.exe) populates Data Windows
• Processes• Moduales
– Path to *.pdb for each loaded module– Image Address & Relocated Address– Can Manually Unload symbols
• Threads– Call Stack for each thread only available when
device is in break-state
![Page 10: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/10.jpg)
Process Window (run)
![Page 11: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/11.jpg)
Modules Window (run)
![Page 12: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/12.jpg)
Threads Window (run)
![Page 13: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/13.jpg)
Target State: Halted
• Can set Breakpoints• Threads window includes call stacks• Can set behavior for Exceptions• Call Stack Window• Watches Window • Auto / Locals / this Window• Registers Window• Memory Window• Disassembly Window
![Page 14: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/14.jpg)
What are Breakpoints?
• Replace instruction with trap (ie INT 3)• Requires Write Access to Instruction• Kernel will page-in memory and lock• Source-level stepping is implemented
with breakpoints• Max 256 BP• Can set BP in call stack, source, or
disassembly
![Page 15: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/15.jpg)
Types of Breakpoints• Location Breakpoints• Conditional Breakpoints
– Based on expression (iFoo == 27)• Data Breakpoints
– When iFoo changes, break– Can watch an array, and can limit scope
• Message Breakpoints– Break when window message received in a
specific context• Cond., Data, and Msg Breakpoints are
based on VS6 implementation
![Page 16: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/16.jpg)
Edit \ Breakpoints (ctrl+b)
![Page 17: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/17.jpg)
Edit \ Breakpoints (ctrl+b)
![Page 18: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/18.jpg)
Edit \ Breakpoints (ctrl+b)
![Page 19: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/19.jpg)
Exceptions Control
• KdStub passes all exceptions to debugger (when connected)
• Specify behavior per exception type– Stop Always
•Debugger will break on each instance of an exception
– Stop if not handled •Debugger will return control to application’s
exception handler (first chance).
• Can add custom exception types
![Page 20: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/20.jpg)
Target \ CE Exceptions
![Page 21: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/21.jpg)
Call Stack
• Switch process / thread context easily• Frame Pointer• Parameter values and types• Source file and line number• Can set breakpoints on function
return• Can “go to source” on each frame• Can quickly log entire callstack
output window
![Page 22: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/22.jpg)
Call Stack Window
![Page 23: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/23.jpg)
Disassembly Window
• Essential for debugging retail devices• Can set breakpoints in disassembly• Can be set to “Mixed Source” Mode• Works best with Debug build• Can “Jump to Source”• Can view raw code bytes or
assembler instructions• All CE CPU types supported
![Page 24: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/24.jpg)
![Page 25: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/25.jpg)
Debug Zone
• What is the simplest software debugging technique?– Output debug messages from applications – OutputDebugString API function allows you to
output a debug message
• You can control the output of debug messages using debug zone.– If a debug zone is open, all messages sent on
behalf of this zone will be accepted.– If a debug zone is closed, all debug messages for
this zone will be ignored.
![Page 26: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/26.jpg)
Debug Zone
• Allows you to access the debug zones of any registered module
• Dynamically turn on or off any debug zone on your platform
• Makes it easier to locate a particular debug message in the debug stream
![Page 27: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/27.jpg)
Dynamically turn on/off debug zone
![Page 28: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/28.jpg)
Using Debug Zone in Your Code
• Include DbgApi.h header file in your source code
• Declare a DBGPARAM structure that contains:– Module name– A name for each debug zone– An initial mask for the output status of all debug
zones
• DBGPARAM structure must be called dpCurSettings
• dpCurSettings must be a global variable in your module
![Page 29: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/29.jpg)
Hardware Assisted Debugging
• Can debug device without KdStub!• Requires a 3rd party probe & driver• Same look and feel, tight integration• Can debug *all* code
– Can debug Device Bootup (ie OEMInit())– Interrupt Service Routines– Bootloaders
• Can set breakpoints / step in ROM• Additional features provided by probe
– Tracing, Triggers, etc…
![Page 30: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/30.jpg)
HW Debugging: eXDI
Debugger Debugger (PB)(PB)
Probe Probe ((JTAG,BDM…JTAG,BDM…))or Emulatoror Emulator
CPUCPU
eXDI eXDI CallbacksCallbacks
eXDI eXDI InterfaceInterface
Plug-insPlug-insPlug-insPlug-insPlug-insPlug-insPlug-insPlug-inseXDI eXDI CallbacksCallbacks
DriverDriver
Optional 3Optional 3rdrd party party interfaceinterface
OsAxS.dllOsAxS.dll
Can launchCan launch
![Page 31: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/31.jpg)
Limitations of HW Assist
• Potentially Expensive• Fewer available breakpoints (generally)• Potentially more complicated setup• Because no KdStub…
– No kernel Data Windows (when halted)– Cannot view / edit all memory
• Cannot page-in memory on demand– No Module Load Notifications
• No Deferred Breakpoints• Static (manual refresh) Modules List
![Page 32: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/32.jpg)
HW Debug Probe Vendors
• ARM - ARM cores• EPI - ARM cores, XSCALE, MIPS IV• Hitachi - SH3, SH4• MacGregor/Intel - XSCALE• NEC/Midas – MIPS II, MIPS IV• Special Computing - X86, AMD, NSC
Geode
![Page 33: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/33.jpg)
Just-In-Time Debugging
• Required: Passive KITL• Exception Occurs (“first chance”)
– if(dbgr) passed to Debugger– if(!dbgr) application’s exception handler is
called
• If application does not handle (“second chance”)– if(!dbgr) KdStub halts OS, waiting for debugger
connection
• When Debugger connects, can debug failure!
![Page 34: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/34.jpg)
Kernel Profiler
• Debugging tool to collect various information– Monte Carlo profiling– System call profiling– Instrumented kernel profiling
![Page 35: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/35.jpg)
Kernel Profiler
• Controlling the kernel profiler– Using prof command– Using profiler API– Using keyboard on the target device
• Mode of kernel profiler– Buffered– Unbuffered
![Page 36: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/36.jpg)
Remote tools
• Remote heap walker• Remote process viewer• Remote spy• Remote call profiler• Remote kernel tracker• Remote performance monitor
![Page 37: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/37.jpg)
Remote tools
![Page 38: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/38.jpg)
Tools & Resources
msdn.microsoft.com/msdn.microsoft.com/ embeddedembedded
microsoft.public.microsoft.public. windowsxp.embeddedwindowsxp.embedded windowsce.platbuilderwindowsce.platbuilder windowsce.embedded.vcwindowsce.embedded.vc
blogs.msdn.com/blogs.msdn.com/ mikehallmikehall
Windows CE 5.0 Eval KitWindows CE 5.0 Eval KitWindows XP Embedded Eval KitWindows XP Embedded Eval Kit
msdn.microsoft.com/msdn.microsoft.com/ mobilitymobility
microsoft.public.microsoft.public. pocketpc.developer pocketpc.developer smartphone.developer smartphone.developer dotnet.framework.compactframeworkdotnet.framework.compactframework
blogs.msdn.com/blogs.msdn.com/ windowsmobilewindowsmobile vsdteamvsdteam netcfteamnetcfteam
Windows Mobile 5.0 Eval KitWindows Mobile 5.0 Eval Kit
WebsitesWebsites
NewsgroupsNewsgroups
BlogsBlogs
ToolsTools
BuildBuild DevelopDevelop
![Page 39: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/39.jpg)
请填写资料袋内的黄色大会来宾反馈表 ,到大会接待台领取大会纪念包。
请在课程结束后填写课程培训反馈表,参加抽奖。
您还可以:
参加Windows Mobile 动手实验室;参观微软及合作伙伴展区;体验基于 Windows Mobile 平台开发的最新硬件产品及解决方案。
大会注意事项
![Page 40: Using Advanced Platform Builder Debugger Features](https://reader035.fdocuments.us/reader035/viewer/2022062301/56814dc8550346895dbb1c3f/html5/thumbnails/40.jpg)