Skip to content

Commit 93013a0

Browse files
arch/tile: refactor backtracing code
This change is the result of some work to make the backtrace code more shareable between kernel, libc, and gdb. For the kernel, some good effects are to eliminate the hacky "VirtualAddress" typedef in favor of "unsigned long", to eliminate a bunch of spurious kernel doc comments, to remove the dead "bt_read_memory" function, and to use "__tilegx__" in #ifdefs instead of "TILE_CHIP". Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
1 parent 8e10cd7 commit 93013a0

6 files changed

Lines changed: 93 additions & 131 deletions

File tree

‎arch/tile/include/asm/backtrace.h‎

Lines changed: 23 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -12,80 +12,41 @@
1212
* more details.
1313
*/
1414

15-
#ifndef _TILE_BACKTRACE_H
16-
#define _TILE_BACKTRACE_H
17-
18-
15+
#ifndef _ASM_TILE_BACKTRACE_H
16+
#define _ASM_TILE_BACKTRACE_H
1917

2018
#include <linux/types.h>
2119

22-
#include <arch/chip.h>
23-
24-
#if defined(__tile__)
25-
typedef unsigned long VirtualAddress;
26-
#elif CHIP_VA_WIDTH() > 32
27-
typedef unsigned long long VirtualAddress;
28-
#else
29-
typedef unsigned int VirtualAddress;
30-
#endif
31-
32-
33-
/** Reads 'size' bytes from 'address' and writes the data to 'result'.
20+
/* Reads 'size' bytes from 'address' and writes the data to 'result'.
3421
* Returns true if successful, else false (e.g. memory not readable).
3522
*/
3623
typedef bool (*BacktraceMemoryReader)(void *result,
37-
VirtualAddress address,
24+
unsigned long address,
3825
unsigned int size,
3926
void *extra);
4027

4128
typedef struct {
42-
/** Current PC. */
43-
VirtualAddress pc;
29+
/* Current PC. */
30+
unsigned long pc;
4431

45-
/** Current stack pointer value. */
46-
VirtualAddress sp;
32+
/* Current stack pointer value. */
33+
unsigned long sp;
4734

48-
/** Current frame pointer value (i.e. caller's stack pointer) */
49-
VirtualAddress fp;
35+
/* Current frame pointer value (i.e. caller's stack pointer) */
36+
unsigned long fp;
5037

51-
/** Internal use only: caller's PC for first frame. */
52-
VirtualAddress initial_frame_caller_pc;
38+
/* Internal use only: caller's PC for first frame. */
39+
unsigned long initial_frame_caller_pc;
5340

54-
/** Internal use only: callback to read memory. */
41+
/* Internal use only: callback to read memory. */
5542
BacktraceMemoryReader read_memory_func;
5643

57-
/** Internal use only: arbitrary argument to read_memory_func. */
44+
/* Internal use only: arbitrary argument to read_memory_func. */
5845
void *read_memory_func_extra;
5946

6047
} BacktraceIterator;
6148

6249

63-
/** Initializes a backtracer to start from the given location.
64-
*
65-
* If the frame pointer cannot be determined it is set to -1.
66-
*
67-
* @param state The state to be filled in.
68-
* @param read_memory_func A callback that reads memory. If NULL, a default
69-
* value is provided.
70-
* @param read_memory_func_extra An arbitrary argument to read_memory_func.
71-
* @param pc The current PC.
72-
* @param lr The current value of the 'lr' register.
73-
* @param sp The current value of the 'sp' register.
74-
* @param r52 The current value of the 'r52' register.
75-
*/
76-
extern void backtrace_init(BacktraceIterator *state,
77-
BacktraceMemoryReader read_memory_func,
78-
void *read_memory_func_extra,
79-
VirtualAddress pc, VirtualAddress lr,
80-
VirtualAddress sp, VirtualAddress r52);
81-
82-
83-
/** Advances the backtracing state to the calling frame, returning
84-
* true iff successful.
85-
*/
86-
extern bool backtrace_next(BacktraceIterator *state);
87-
88-
8950
typedef enum {
9051

9152
/* We have no idea what the caller's pc is. */
@@ -138,7 +99,7 @@ enum {
13899
};
139100

140101

141-
/** Internal constants used to define 'info' operands. */
102+
/* Internal constants used to define 'info' operands. */
142103
enum {
143104
/* 0 and 1 are reserved, as are all negative numbers. */
144105

@@ -147,13 +108,10 @@ enum {
147108
CALLER_SP_IN_R52_BASE = 4,
148109

149110
CALLER_SP_OFFSET_BASE = 8,
150-
151-
/* Marks the entry point of certain functions. */
152-
ENTRY_POINT_INFO_OP = 16
153111
};
154112

155113

156-
/** Current backtracer state describing where it thinks the caller is. */
114+
/* Current backtracer state describing where it thinks the caller is. */
157115
typedef struct {
158116
/*
159117
* Public fields
@@ -192,7 +150,13 @@ typedef struct {
192150

193151
} CallerLocation;
194152

153+
extern void backtrace_init(BacktraceIterator *state,
154+
BacktraceMemoryReader read_memory_func,
155+
void *read_memory_func_extra,
156+
unsigned long pc, unsigned long lr,
157+
unsigned long sp, unsigned long r52);
195158

196159

160+
extern bool backtrace_next(BacktraceIterator *state);
197161

198-
#endif /* _TILE_BACKTRACE_H */
162+
#endif /* _ASM_TILE_BACKTRACE_H */

‎arch/tile/include/asm/opcode-tile_32.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,5 +1502,12 @@ extern int parse_insn_tile(tile_bundle_bits bits,
15021502
decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]);
15031503

15041504

1505+
/* Given a set of bundle bits and a specific pipe, returns which
1506+
* instruction the bundle contains in that pipe.
1507+
*/
1508+
extern const struct tile_opcode *
1509+
find_opcode(tile_bundle_bits bits, tile_pipeline pipe);
1510+
1511+
15051512

15061513
#endif /* opcode_tile_h */

‎arch/tile/include/asm/opcode-tile_64.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,5 +1502,12 @@ extern int parse_insn_tile(tile_bundle_bits bits,
15021502
decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]);
15031503

15041504

1505+
/* Given a set of bundle bits and a specific pipe, returns which
1506+
* instruction the bundle contains in that pipe.
1507+
*/
1508+
extern const struct tile_opcode *
1509+
find_opcode(tile_bundle_bits bits, tile_pipeline pipe);
1510+
1511+
15051512

15061513
#endif /* opcode_tile_h */

0 commit comments

Comments
 (0)