XDB – Intel® System Debugger 2015
Overview Training
Agenda
1) What is XDB?
2) Debugger startup and device/platform support
3) Debugger usage (Android* an Linux*)
4) System State Inspection
5) Instruction Trace
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
3
Key Features
• Linux* and Windows* host
• JTAG debug for Intel
®
Core™, Xeon
®
& Quark SoC-based platforms
• EFI/UEFI Firmware, bootloader debug, Linux
*
OS awareness
• UEFI debugging, optionally with Agent module
• Dynamically loaded Linux kernel module debug
• JTAG system debug with event tracing (SVEN)
• Full CPU register description and bitfield editor
• Access to page translation and descriptor tables
• LBR, IPT On-Chip instruction trace support, SMP run control support
What is XDB? - Summary
4
Intel® System Debugger for the Internet of Things
Deep Insights into memory and system configuration
Fast issue resolution with low-level system debuggers
The only complete system debug solution for the Intel based Internet of Things
• JTAG based bootloader, OS and device driver debug
• Agent based UEFI debug
• In depth visualization of memory configuration, system state and register sets
• Common debugger front-end for all debug protocols
OpenOCD*
Dfx Abstraction Layer
Example: Galileo,
Intel® Quark SoC X1000
Example: Bayley Bay,
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Intel® System Debugger and Intel® Quark SoC (1)
5
Supported Devices:
Intel® ITP-XDP3
Go to
https://designintools.intel.com/
, select the
Debug Tools
product
category and add
ITP-XDP BR3
to your cart.
TinCanTools* FLYSWATTER2
Go to
http://www.tincantools.com/wiki/Compiling_OpenOCD
Olimex* ARM-USB-OCD-H
Intel® System Debugger and Intel® Quark SoC (2)
Recommended setup for debugging with
OpenOCD*
•
Host System
•
USB 2.0 male-male A-B cable
•
JTAG Probe
•
ARM-JTAG-20-10 Adapter
•
JTAG Port
•
Intel® Galileo Board
•
Serial Cable to view boot process
•
Power Supply
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
7
Supported Formats & Software
Object File formats:
ELF/DWARF from GCC/ICC Compilers
PE/COFF+PDB from Microsoft Compilers
Multiple simultaneous modules / mixed formats
Linux-specific Features:
Auto-detect Kernel Module load/unload
Kernel Data structure viewer
Includes kernel threads, process list, process address space, and more.
EFI-specific Features:
Load sources for PEI, DXE, and SMM modules (by address)
Agent-based debugging without JTAG…
Supported Target Connection Methods
The debugger can connect via multiple methods:
Dfx Abstraction Layer API
for current Intel® Atom™ Processor, Intel® Quark SoC, Intel® Core™ Processors, Intel® Xeon™ Processors
Connect via conventional JTAG using ITP-XDP3 probe
Can be used concurrently with other Intel® ITPII clients
TCI API for older Intel® Atom™ Processors
Connect via conventional JTAG using ITP-XDP3 probe or Macraigor* usb2Demon*
OpenOCD* API for Intel® Quark SoC
Connect via conventional JTAG using low-cost JTAG probe (e.g. Olimex*, Flyswatter*)
Agent-based UEFI Debugger
Debug of UEFI firmware over USB/Serial using a target-side agent
Deployable on production hardware (no JTAG port)
Debug SEC/PEI/DXE with burned-in agent, or soft-load agent for post-shell work
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Starting the Debugger
9
Step 1:
Open the folder where XDB was installed
Step 2:
Select a startup script and launch it,
“start_xdb_2015_products” or
“start_xdb_UEFI_agent” or
“start_xdb_legacy_products” or
“start_xdb_gdb_remote”
Step 3:
Connect to your target using the “Connect” button
(or Ctrl-R)
Intel® System Debugger Launcher
integrated into Eclipse* and Wind River* Workbench*
1. Define which debugger start-up to launch under “Launcher Options …”
2. Launch Debugger
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Standard Debugger Features
11
Breakpoints
Program State
Multiple Source
Files
CPU Structures
Execution Trace
Syntax-highlights
And more!
Linux & EFI
Support
Initial Startup & overview
Assembly Window
Console Window
Displays status messages
(keep it open!)
Command-driven
operation also possible
Toolbars / Menus
Most functions available
from menus & buttons
Connect/Disconnect
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Connecting To Targets
13
Step 2: Select your probe
Step 1: Click the
connect icon
Step 3: Select your target platform
Step 3a (optional): Enter advanced
connection parameters
Target Run Control
ASM step over
ASM step into
Run until caller
Step program until next source line
Restart target
Halt execution
Resume Execution
Step Over function call
Run Control
•Run/stop the CPU
•Step into, over, out
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Multiple HW threads
15
The debugger can display how the multiple logical cores are used and
indicate which logical core is used by the current code displayed.
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Loading the symbols
17
Browse to find the
identical binary file as
Loaded on the target.
Download = download into
Target RAM. Do not tick this if
You will debug SW already
on the target
How to find the sources
The debugger will try to find the source file
which matches the current instruction pointer.
If it cannot find the file it will ask you to do a
manual search.
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Select source files to view
19
With the ‘Source Files’ icon you can open a
window which contains the source tree as found
in the binary file loaded in the debugger.
Just double click on any of the source
Evaluate symbols
Hover the cursor over a variable and the debugger will show you its value
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Local variables
The example above shows part of the ‘rq’ structure
In expression field indicate that this is a compound element and that it has been
Expanded ( > for not expanded)
Local variable window will
display all variables which
are accessible from within
current scope
How did I reach the current location?
Source file:
line number
Current file
Function tree – bottom up
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Create a breakpoint
23
Minimum - code location is required.
Hard option allows you to set a breakpoint
even if the memory location is not
accessible
For Watchpoints the location,
Debugging loadable modules
There is a Linux kernel module [xdbntf] provided with the debugger which you can
build and install – you then can load & debug Linux kernel modules and device drivers
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Inspecting Android* & Linux* Kernel State
25
View all kernel thread with process id, current state, active flags, launch arguments
and call tree dependency.
What happened?
Inspecting System State
XDB presents state in a “Human Readable” format
Relationships: “show the nesting of structure members”
High-level decode: “show the names of bits in a register”
Context: “show the documentation for a register”
Program State:
Memory contents -> “Memory Window”
Program State -> “Locals Window / Eval Window”
CPU State:
General and Extended Registers
Page Tables
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Overview of State Windows:
27
Execution Trace
Linux Kernel State
PCI Topology & Devices
Processor Structures
Page Tables
Callstack & HW Threads
Program Variables
Program State:
“Locals” Window
Program state for the
currently selected callstack
frame
Callstack Window
Show call stack for the currently
selected hardware thread
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
CPU State: Register Windows
29
GP Registers
CPU Registers
CPU State: Detailed Register View
Text Documentation
Bit-level Breakdown
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
What about paging?
31
Double click on a page table/directory
entry and You will have the ability to
modify the attribute bits with the
bit field editor
Virtual -> physical address mapping
Select an address and press Translate to find the address mapping.
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Execution Trace
33
XDB Execution
Trace Viewer
XDB supports execution trace via:
Intel Processor Trace (Intel PT)
Last-Branch Record (LBR)
Trace data is presented as C source
code, view is integrated with other
source debug features
User is not concerned with underlying mechanism, it
“just works”
Trace
Trace
Execution Trace GUI Overview
Execution Trace GUI is fully integrated with source
debug, user can view trace data simultaneously with
source, ASM , callstack…
Execution Trace
history
ASM window
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Execution Trace Features
35
Expand source lines
to reveal assembly
Jump to this line’s
source file or
instruction
Keep source and/or
assembler window
in-sync with trace
window
Execution Trace Features (continued)
Colors indicating how recently
the instruction/line was executed
“+” indicates
multiple hits
Coloring can be configured in Options -> GUI Preferences
Intuitive
following of
execution flow
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
PCI Scan Tool Technology Preview
Scan for devices, display device-specific registers:
SVEN SoC Trace –
low overhead technology for
static instrumentation of key SoC components
Intrumented Software Modules of
Devices & Systems
Event
Recorder
JTAG Device
Device
Kernel
User
•
Event tracing with JTAG
•
Smart breakpoints
•
Interrupt execution on key events
•
Visualize, Analyze and
Debug system event traces
•
Command line interface
•
Graphical interface
SVEN Event:
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
SVEN - A Stethoscope for your System System & SoC trace through JTAG
39
Trace Visualization
Advanced navigation, search & filter
Graphical and textual event display
User controlled trace line grouping
Smart Event Triggers
Live JTAG system debug with event tracing
Smart breakpoints that interrupt execution on trace event calls
Set smart breakpoints for in-depth analysis
For example:
Break on any event from the USB driver
Break on any Debug String that starts with “ERROR”
Break if register X is accessed
Break if register X bits [7-9] have value 0b101
•
Timeline view
•
Search & Filter
•
Smart Event Trigger
definition
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
EFI BIOS Support
41
General EFI Features:
Source-level debug in any phase of EFI,
from reset to OS boot
Load symbols for all or selected modules
Simultaneous debug of MSVC and
GCC-built modules
Passive mode (interrogation-based):
Inspect target memory to locate
modules, load symbols
Can be used on production BIOS
Requires JTAG
Active Mode (agent-based):
Receive notifications from agent as
modules are loaded/unloaded
Break at init of a named module,
regardless of load position
Requires debug agent
Stepping into BIOS code…
Before we can load symbols/source for EFI we need to be in protected mode
Using the Assembly-level Run Control features you can step from the reset
vector to the jump to protected mode:
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
43
Loading Symbols for EFI BIOS
Once in protected mode we can use an XDB function to load symbols for EFI:
“loadthis” command
Key to EFI debug: searches memory for a relocatable EFI module, uses module
metadata to locate debug symbols & sources
Works in all phases of EFI (SEC, PEI, DXE)
Debugging in SEC with sources:
Once XDB has symbols loaded it can locate source code for the current instruction point.
Both Source and ASM-level run control is now possible:
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.
Optimization Notice
Setting a Breakpoint in Source Code
45
Using the context menu: set a breakpoint on a source line
Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others.