Add %LR and %LC to get at the current row and columm in skinned lists.
[maemo-rb.git] / lib / unwarminder / backtrace.c
blob4e1609137cd375c0574f343233c0b2521b21dfa2
1 /***************************************************************************
2 * ARM Stack Unwinder, Michael.McTernan.2001@cs.bris.ac.uk
4 * This program is PUBLIC DOMAIN.
5 * This means that there is no copyright and anyone is able to take a copy
6 * for free and use it as they wish, with or without modifications, and in
7 * any context, commercially or otherwise. The only limitation is that I
8 * don't guarantee that the software is fit for any purpose or accept any
9 * liability for it's use or misuse - this software is without warranty.
10 ***************************************************************************
11 * File Description: Unwinder client that reads local memory.
12 * This client reads from local memory and is designed to run on target
13 * along with the unwinder. Memory read requests are implemented by
14 * casting a point to read the memory directly, although checks for
15 * alignment should probably also be made if this is to be used in
16 * production code, as otherwise the ARM may return the memory in a
17 * rotated/rolled format, or the MMU may generate an alignment exception
18 * if present and so configured.
19 **************************************************************************/
21 /***************************************************************************
22 * Includes
23 ***************************************************************************/
25 #include "backtrace.h"
27 /***************************************************************************
28 * Prototypes
29 ***************************************************************************/
31 static Boolean CliReport(void *data, Int32 address);
32 static Boolean CliReadW(Int32 a, Int32 *v);
33 static Boolean CliReadH(Int32 a, Int16 *v);
34 static Boolean CliReadB(Int32 a, Int8 *v);
36 /***************************************************************************
37 * Variables
38 ***************************************************************************/
40 /* Table of function pointers for passing to the unwinder */
41 const UnwindCallbacks cliCallbacks =
43 CliReport,
44 CliReadW,
45 CliReadH,
46 CliReadB
47 #if defined(UNW_DEBUG)
48 ,printf
49 #endif
53 /***************************************************************************
54 * Callbacks
55 ***************************************************************************/
57 /***************************************************************************
59 * Function: CliReport
61 * Parameters: data - Pointer to data passed to UnwindStart()
62 * address - The return address of a stack frame.
64 * Returns: TRUE if unwinding should continue, otherwise FALSE to
65 * indicate that unwinding should stop.
67 * Description: This function is called from the unwinder each time a stack
68 * frame has been unwound. The LSB of address indicates if
69 * the processor is in ARM mode (LSB clear) or Thumb (LSB
70 * set).
72 ***************************************************************************/
73 static Boolean CliReport(void *data, Int32 address)
75 /* CliStack *s = (CliStack *)data; */
76 unsigned *line = (unsigned *)data;
79 lcd_putsf(0, (*line)++, " %c: 0x%08x",
80 (address & 0x1) ? 'T' : 'A',
81 address & (~0x1));
82 lcd_update();
84 return TRUE;
87 static Boolean CliReadW(const Int32 a, Int32 *v)
89 *v = *(Int32 *)a;
90 return TRUE;
93 static Boolean CliReadH(const Int32 a, Int16 *v)
95 *v = *(Int16 *)a;
96 return TRUE;
99 static Boolean CliReadB(const Int32 a, Int8 *v)
101 *v = *(Int8 *)a;
102 return TRUE;
105 Boolean CliInvalidateW(const Int32 a)
107 *(Int32 *)a = 0xdeadbeef;
108 return TRUE;
111 void backtrace(int pcAddr, int spAddr, unsigned *line)
113 UnwResult r;
115 lcd_putsf(0, (*line)++, "bt pc: 0x%08x, sp: 0x%08x", pcAddr, spAddr);
116 lcd_update();
118 r = UnwindStart(pcAddr, spAddr, &cliCallbacks, (void *)line);
120 lcd_puts(0, (*line)++, "bt end");
121 lcd_update();
124 /* END OF FILE */