AdvancedEmulation07.pdf

64x+ Advanced Emulation Techniques
and Technologies
SDO Applications
December, 2007
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
2
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
3
XDS560 Trace
• What is XDS560 Trace?
– XDS560 Trace is an Emulation Technology that allows real-time,
non-intrusive logging of CPU Address Bus and Data Bus Activity in
a DSP Application
• Which 64x+ Targets is Trace Available on?
– “Full-GEM” Devices
•
•
•
•
C6455
C6488
DM647
DM648
4
XDS560 Trace Architecture
DATA ADDRESS BUSSES
DATA BUSSES
CPU
PROGRAM BUS
Trace & AET Jobs
Comparators
Compressor
Cycle counter
DSP
XDS560T POD
Additional JTAG Emulation Pins
• Current Buffer Size:
224K
• Future: 64 MB
XDS560T POD
RECORDING
UNIT
To/from host PC
5
Required Hardware and Software
•
•
•
•
•
60 Pin emulation header
Target must support Trace (Full-Gem)
Blackhawk USB 560
XDS560T Trace Pod/Cable
CCS 3.30 or higher
6
Trace Example (PC & Timing)
Trace Log
Cycles
PC
0x00897C60
0x00897C64
0x00897C68
0x00897C6C
0x00897C70
0x00897C74
0x00897C78
0x00897C7C
102456
102457
102458
102459
102460
102461
102462
102463
Cycle Count 102456
102457
102460
102461
102463
102458
102459
102462
7
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
8
Advanced Event Triggering (AET)
• What is it?
– A hardware block on 64x+ “Full Gem” Devices use for detecting
application behavior and generating events.
• Why Discuss AET in conjunction with Trace?
– AET is always bundled with Trace. It is the logic that allows us to
smartly turn on trace to capture data that is interesting, and turn off
trace in locations where it is not interesting.
• Eliminates parsing through data that is irrelevant
• More importantly, conserves Trace Buffer for more interesting
information.
9
AET Hardware Overview
10
AET Job Examples
• Trace PC whenever the PC is between location A and B
(PC Trace in Range)
• Trace all writes to memory location 0x12345678 (Data
Trace)
• Halt whenever the application executes the instruction
at location 0x801000, but only after it has executed the
instruction at 0x804060 (Hardware Breakpoint qualified
by a Sequencer State)
• Halt when the value 0x00001234 is written to location
0x80500000 (Halt on Data Write qualified by value)
11
Triggers
• What type of events (triggers) can be generated?
–
–
–
–
–
–
–
–
CPU Halt (with Debugger Connected)
Interrupt
Start/Increment Counter
Stop/Reload Counter
Start Trace
Stop Trace
Store Trace Sample
Toggle Emu 0/1 Pin
12
How much hardware is it?
• 6 Dual Range Comparators (4 PA/DA + 2 PA Only)
• 14 Trigger Builders* (General Use)
– 6 1-Wide Trigger Builders (Halt, Interrupt, Inc. Counter)
– 6 3-Wide Trigger Builders (State Machine State Change, Stop
Trace)
– 2 7-Wide Trigger Builders (Start Trace/ Capture Trace)
• 1 4 State State Machine (Can be split into 2 2-State)
• 2 32-Bit Multiple Mode Counters
* A Trigger Builder is just a lookup table which defines a 13
truth table for the combination of inputs. It is hardwired
to one of 4 events that it can generate.
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
14
AET Target Library
• Target Side Library allowing the user to program and
reprogram AET hardware from within their application.
• Documentation and examples Included
15
AET Target Library
DISCLAIMER
AET Target Library cannot be used
simultaneously with the CCS Event Analysis
Plug-in. There is no means for resource sharing
between the two. The AET hardware is owned
by either the debugger or the application.
16
AET Target Library Pros/Cons
•
Pros
– Allows the user to dynamically
reprogram AET resources,
resulting in more advanced
scenarios
•
Cons
– Requires Code Modification
– Consumes Application Cycles
– Consumes Application Footprint
• TSK Stack Monitor
• Tracing of specific functions
based on context
– Full Symbolic support
• UBM Plug-in will fix this
– Can actually use AET resources
somewhat like an extra peripheral
– Can configure in initialization
routine
– Supports some scenarios that the
AET Plug-in does not
17
AET Target Library – Code Example
Halt on Write to Range
AET_jobParams params;
AET_jobIndex jobNumber;
/* Data Watchpoint Parameter Structure */
/* Job Number returned by AETLIB */
/* Initialize Parameter Structure */
params = AET_JOBPARAMS;
/* Set Parameters to Halt on Access to first 0x15 elements of memArray[] */
params.dataStartAddress = (Uint32) &memArray1[0];
params.dataEndAddress = (Uint32) &memArray1[0x15];
params.triggerType = AET_TRIG_HALT_CPU;
params.readWrite = AET_WATCH_WRITE;
params.refSize = AET_REF_SIZE_WORD;
/* Initialize AET */
AET_init();
/* Claim the AET resource */
if (AET_claim()!=AET_SOK)
return;
/* Setup the AET job with selected parameters */
if (AET_setupJob(AET_JOB_TRIG_ON_DATA_RANGE, &params)!=AET_SOK)
return;
/* Remember the index of this job in the job table */
jobNumber = params.jobIndex;;
/* Enable AET */
if (AET_enable()!=AET_SOK)
return;
18
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
19
Application Analysis with XDS560 Trace
20
Advantages over Traditional Methods
• Profiling on Actual Hardware
– No Modifications necessary for peripherals that aren’t simulated
– Memory/Cache effects inherently captured
– Extremely Fast, results in minutes
21
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
22
Interrupt Profiling Overview
Graphically display interrupt cycle
accurate interrupt servicing
frequency
• Capture Program Address
and Timestamp whenever the
PC is within the Interrupt
Vector Table
• Generate a cycle accurate
picture of when each
interrupt starts executing
23
Trigger Configuration (Using UBM)*
User needs only to specify the
symbol that signifies the start of
the interrupt vector table
24
*This Feature Added to UBM in CCS SR10
Data Captured
Raw Trace Data
Processed Data
25
Results
26
Results - 2
27
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
28
Statistical Profiling Overview
• The Program Address is sampled at regular intervals
• Statistical Analysis is performed on the captured samples
• As in any statistical analysis, the determinations made on
the statistical sample can be related to the general
population
Fxn1
Fxn2
Fxn3
Fxn4
Fxn5
Fxn6
4
4
2
5
3
3
2
2
2
3
3
6
6
4
4
29
Statistical Profiling - 2
• AET contains all of the hardware needed to capture
trace samples at a specified interval
• Interval should be carefully chose so as not to coincide
with a periodic function
• Application instrumentation can switch AET off in
locations that are not of interest
30
Trigger Configuration (Using UBM)*
User needs only to specify the
desired number of cycles
between samples
31
*This Feature Added to UBM in CCS SR9
Statistical Profiling - Results
• Comma Separated Value
Format
• Sorted from most intensive
functions to least
32
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
33
Thread Aware Profiling
GOAL
Generate a cycle accurate
execution graph of a
Thread/Task based
application
34
Time (cycles)
Solution
• Instrument the task/thread switch function to write the
task/thread ID to a well known location (global variable)
– Operating systems typically provide hooks to insert functions in
this location
• Trace all of the writes to that location, and get a
timestamp with each.
35
Trigger Configuration (Using UBM)*
User needs only to specify the address of the thread
value write. This can be a numerical value, or a symbolic
variable name preceded by the address of operator.
Example: &TRACE_thrExecLog
*This Feature Added to UBM in CCS SR10
36
Results
37
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
38
Thread Aware Dynamic Call Graph
65
132
200
200
GOAL
Display a Thread Based
representation of actual
function execution in an
application
68
39
Capturing the Data
• Thread/Task
– Hook function writes address of task
• Function
– Entry/Exit points instrumented with Mark 0/ Mark 1
instructions*
• Mark 0 inlined at each function entry point
• Mark 1 inlined at each function exit point
– Trace captures each of these locations with timestamp
* CGT 6.0.1 enables function hooks
40
Trigger Configuration (Using UBM)*
User needs only to specify the address of the thread
value write. This can be a numerical value, or a symbolic
variable name preceded by the address of operator.
Example: &TRACE_thrExecLog
*This Feature Added to UBM in CCS SR10
Mark 0 is
assumed for
entry, Mark 1 for
exit.
41
Presentation
• Graphical Displays become
impractical as the number of
functions increase
• At right is a sample call graph
displayed by the Guess
graphing package
42
GPROF Like Format
•
•
•
Modeled after Unix
GPROF
Each Thread separated
into it’s own subsection
Each function section
contains only
immediate callers and
callees
43
A Closer Look
Primary
Line Lines
for a Functions
Callers
describes
the function
Callees
which the entry is
about and gives the
overall statistics for this
function
44
Future Display – Tree View
Thread: 0x828194
_DEC_tcp2DeintUnpunctsoft3
_DEC_tcp2QuantizeSoft
Callers
_DEC_tcp2PreProc
Callees
_DEC_tcp2PreProc
Calls = 388/388
_varianceEstim
_COM_spoolTsk
Exclusive Cycles = 14491050
_COM_spoolPost
_DEC_tcp2EdmaIsr
45
Agenda
•
•
•
•
XDS560 Trace Overview
Advanced Event Triggering Overview
AET Target Lib
Application Analysis with Trace
–
–
–
–
Interrupt Profiling
Statistical Profiling
Thread Aware Profiling
Thread Aware Dynamic Callgraph
• What’s Next ?
46
What’s Coming Soon?
• Event Trace
– See where specific events (such as Cache Misses, Stalls, Etc)
occur within execution of your code
• Extended Buffer Memory
– Software update that allows the Trace Pod to use 64MB of
memory, rather than the current 224KB.
• Script access to Binary Trace Data
– Will allow faster processing of data to work with Extended Buffer
Memory
47
Questions ???
Backup Slides
AET Example
Start PC+Data Write + TimingTrace on write to memory location 0x10000-0x10020 with a value of 0x00001234
Program Address
T1 Data Address
T2 Data Address
0x80008040
0x00008080
0x00010010
T1 Read Data
T2 Read Data
T1 Write Data
T2 Write Data
0x08F0347F
0x00001234
7-Wide Trigger
Builder
Trigger Builder Selective ORS
Address
Bus
Multiplexer
0x10000
Dual Range
Comparator
Data
Qualifier
Enable
>=
Data Bus
Multiplexer
A
B
C
D
Start Timing Trace
A&B
Start RTDX Transmit
Start DTDMA
Comparator
0x00001234
Address
Bus
Multiplexer
=
0x10020
Dual Range
Comparator
Data
Qualifier
Enable
A
B
C
D
A&B
Start PC Trace
Store Timing
Stop RTDX Transmit
Stop DTDMA
<=
Address
Bus
Multiplexer
A
B
C
D
0x10000
Dual Range
Comparator
Data
Qualifier
Enable
>=
Data Bus
Multiplexer
Comparator
0x00001234
Address
Bus
Multiplexer
=
0x10020
Dual Range
Comparator
<=
Data
Qualifier
Enable
A
B
C
D
A
B
C
D
A
B
C
D
Auxiliary Events
A
B
C
D
Counter 0 Zero
Counter 1 Zero
Trace Trigger
Start Read Address Trace
Store Read Address
Start RTDX Receive
0
Start Write Address Trace
Store Write Address
Stop RTDX Receive
0
Start Read Data Trace
Store Read Data
0
Start Write Data Trace
Store Write Data
A&B
Start PCTAG Trace
Store PCTAG
0
Multiplexer
OUTPUT
CONTROL = 0
State 0
State 1
State 2
State 3
Multiplexer
50