1 / 40

Using Advanced Platform Builder Debugger Features

Using Advanced Platform Builder Debugger Features. Chenghui Lian Microsoft China Technology Center. Agenda. Introduction to the PB Kernel Debugger Tools for debugging Remote tools Demo. Desktop. Windows CE Device. cemgr.exe. KITL. kernel (nk.exe). KdStub (kd.dll). Platform Builder

jodie
Download Presentation

Using Advanced Platform Builder Debugger Features

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Advanced Platform Builder Debugger Features Chenghui Lian Microsoft China Technology Center

  2. Agenda • Introduction to the PB Kernel Debugger • Tools for debugging • Remote tools • Demo

  3. Desktop Windows CE Device cemgr.exe KITL kernel (nk.exe) KdStub (kd.dll) Platform Builder Debugger (cepb.exe) foo.exe Debugger Architecture

  4. 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

  5. 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

  6. 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=”

  7. Tools for debugging • System debugging • Hardware-assisted debugging • Kernel profiler

  8. 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

  9. Process Window (run)

  10. Modules Window (run)

  11. Threads Window (run)

  12. 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

  13. 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

  14. 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

  15. Edit \ Breakpoints (ctrl+b)

  16. Edit \ Breakpoints (ctrl+b)

  17. Edit \ Breakpoints (ctrl+b)

  18. 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

  19. Target \ CE Exceptions

  20. 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

  21. Call Stack Window

  22. 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

  23. 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.

  24. 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

  25. Dynamically turn on/off debug zone

  26. 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

  27. 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…

  28. HW Debugging: eXDI eXDI Callbacks OsAxS.dll Debugger (PB) Probe (JTAG,BDM…) or Emulator Driver eXDI Interface Can launch eXDI Callbacks Plug-ins CPU Plug-ins Plug-ins Optional 3rd party interface Plug-ins

  29. 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

  30. 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

  31. 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!

  32. Kernel Profiler • Debugging tool to collect various information • Monte Carlo profiling • System call profiling • Instrumented kernel profiling

  33. Kernel Profiler • Controlling the kernel profiler • Using prof command • Using profiler API • Using keyboard on the target device • Mode of kernel profiler • Buffered • Unbuffered

  34. Remote tools • Remote heap walker • Remote process viewer • Remote spy • Remote call profiler • Remote kernel tracker • Remote performance monitor

  35. Remote tools

  36. Tools & Resources Build Develop Websites msdn.microsoft.com/embedded msdn.microsoft.com/mobility Newsgroups microsoft.public.pocketpc.developer smartphone.developer dotnet.framework.compactframework microsoft.public.windowsxp.embedded windowsce.platbuilder windowsce.embedded.vc Blogs blogs.msdn.com/mikehall blogs.msdn.com/windowsmobilevsdteamnetcfteam Tools Windows CE 5.0 Eval KitWindows XP Embedded Eval Kit Windows Mobile 5.0 Eval Kit

  37. 大会注意事项 请在课程结束后填写课程培训反馈表,参加抽奖。 请填写资料袋内的黄色大会来宾反馈表,到大会接待台领取大会纪念包。 您还可以: 参加Windows Mobile动手实验室; 参观微软及合作伙伴展区; 体验基于 Windows Mobile平台开发的最新硬件产品及解决方案。

More Related