Trace Capture
QT
RACE
-
U
SER
M
ANUAL
© 2018 PDQLogic Ltd.
QTrace User Manual Rev 1.01
Page 30
4.3.1
Problems setting exception handler trigger
Exception handlers will typically be defined as a series of functions in a single source file. The linker will
usually place these functions in contiguous memory, allowing them to be defined as a single memory
range for trace capture. However, if the handlers are not in contiguous memory then the QTrace
Analyser will either be unable to set trace capture for exceptions (range > 8K) or it will generate false
exception triggers when non-exception handler code is executed that has been placed by the linker in
between exception handlers.
Pressing the
toolbar button will display the target exception handlers. Figure 33 below shows
handlers that are not in all in contiguous memory (see highlighted NMI handler address).
Figure 33 Target exception handlers viewer
If the code cannot easily be refactored to achieve sequential addresses then indirect exception handlers
can be implemented in a single section. Each handler will then jump to its respective implementation.
An example is shown below:
/* keep handler functions together in the same section */
void NMI_Handler_ind( void ) __attribute__((section(".exception_handlers")));
void HardFault_Handler_ind( void ) __attribute__((section(".exception_handlers")));
void MemManage_Handler_ind( void ) __attribute__((section(".exception_handlers")));
void BusFault_Handler_ind( void ) __attribute__((section(".exception_handlers")));
void UsageFault_Handler_ind( void ) __attribute__((section(".exception_handlers")));
/* indirect NMI Handler */
void NMI_Handler_ind( void )
{
NMI_Handler();
}
.
.
/* indirect UsageFault Handler */
void UsageFault_Handler_ind( void )
{
UsageFault_Handler();
}
/* the interrupt vector table */
const void * const __vector_table[113] __attribute__((section(".isr_vectors"),used)) =
{
(const void*)STACK_BASE,
(const void*)&Reset_Handler,
(const void*)&NMI_Handler_ind,
(const void*)&HardFault_Handler_ind,
(const void*)&MemManage_Handler_ind,
(const void*)&BusFault_Handler_ind,
(const void*)&UsageFault_Handler_ind,
.
.
}
Figure 34 Indirect exception handlers