aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/include
diff options
context:
space:
mode:
authorMatt Fleming <matt@console-pimps.org>2009-08-16 10:44:08 -0400
committerMatt Fleming <matt@console-pimps.org>2009-08-21 08:02:43 -0400
commitfb3f3e7fc6d4afb32f9eba32124beaf40313de3c (patch)
tree69ed6cfbc123a188aabbe4a98209c935680c27a2 /arch/sh/include
parent97f361e2498ada54b48a235619eaf5af8e46427e (diff)
sh: unwinder: Fix memory leak and create our own kmem cache
Plug a memory leak in dwarf_unwinder_dump() where we didn't free the memory that we had previously allocated for the DWARF frames and DWARF registers. Now is also a opportune time to implement our own mempool and kmem cache. It's a good idea to have a certain number of frame and register objects in reserve at all times, so that we are guaranteed to have our allocation satisfied even when memory is scarce. Since we have pools to allocate from we can implement the registers for each frame as a linked list as opposed to a sparsely populated array. Whilst it's true that the lookup time for a linked list is larger than for arrays, there's only usually a maximum of 8 registers per frame. So the overhead isn't that much of a concern. Signed-off-by: Matt Fleming <matt@console-pimps.org>
Diffstat (limited to 'arch/sh/include')
-rw-r--r--arch/sh/include/asm/dwarf.h22
1 files changed, 6 insertions, 16 deletions
diff --git a/arch/sh/include/asm/dwarf.h b/arch/sh/include/asm/dwarf.h
index 2fbe8720411e..a22fbe98303f 100644
--- a/arch/sh/include/asm/dwarf.h
+++ b/arch/sh/include/asm/dwarf.h
@@ -265,10 +265,7 @@ struct dwarf_frame {
265 265
266 unsigned long pc; 266 unsigned long pc;
267 267
268 struct dwarf_reg *regs; 268 struct list_head reg_list;
269 unsigned int num_regs; /* how many regs are allocated? */
270
271 unsigned int depth; /* what level are we in the callstack? */
272 269
273 unsigned long cfa; 270 unsigned long cfa;
274 271
@@ -292,22 +289,15 @@ struct dwarf_frame {
292 * @flags: Describes how to calculate the value of this register 289 * @flags: Describes how to calculate the value of this register
293 */ 290 */
294struct dwarf_reg { 291struct dwarf_reg {
292 struct list_head link;
293
294 unsigned int number;
295
295 unsigned long addr; 296 unsigned long addr;
296 unsigned long flags; 297 unsigned long flags;
297#define DWARF_REG_OFFSET (1 << 0) 298#define DWARF_REG_OFFSET (1 << 0)
298}; 299};
299 300
300/**
301 * dwarf_stack - a DWARF stack contains a collection of DWARF frames
302 * @depth: the number of frames in the stack
303 * @level: an array of DWARF frames, indexed by stack level
304 *
305 */
306struct dwarf_stack {
307 unsigned int depth;
308 struct dwarf_frame **level;
309};
310
311/* 301/*
312 * Call Frame instruction opcodes. 302 * Call Frame instruction opcodes.
313 */ 303 */
@@ -372,7 +362,7 @@ static inline unsigned int DW_CFA_operand(unsigned long insn)
372 362
373extern struct dwarf_frame *dwarf_unwind_stack(unsigned long, 363extern struct dwarf_frame *dwarf_unwind_stack(unsigned long,
374 struct dwarf_frame *); 364 struct dwarf_frame *);
375#endif /* __ASSEMBLY__ */ 365#endif /* !__ASSEMBLY__ */
376 366
377#define CFI_STARTPROC .cfi_startproc 367#define CFI_STARTPROC .cfi_startproc
378#define CFI_ENDPROC .cfi_endproc 368#define CFI_ENDPROC .cfi_endproc