~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/kernel/stacktrace.c

Version: ~ [ linux-5.16 ] ~ [ linux-5.15.13 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.90 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.170 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.224 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.261 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.296 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.298 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3  * Copyright (C) 2013 Richard Weinberger <richard@nod.at>
  4  * Copyright (C) 2014 Google Inc., Author: Daniel Walter <dwalter@google.com>
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License version 2 as
  8  * published by the Free Software Foundation.
  9  */
 10 
 11 #include <linux/kallsyms.h>
 12 #include <linux/kernel.h>
 13 #include <linux/sched.h>
 14 #include <linux/stacktrace.h>
 15 #include <linux/module.h>
 16 #include <linux/uaccess.h>
 17 #include <asm/stacktrace.h>
 18 
 19 void dump_trace(struct task_struct *tsk,
 20                 const struct stacktrace_ops *ops,
 21                 void *data)
 22 {
 23         int reliable = 0;
 24         unsigned long *sp, bp, addr;
 25         struct pt_regs *segv_regs = tsk->thread.segv_regs;
 26         struct stack_frame *frame;
 27 
 28         bp = get_frame_pointer(tsk, segv_regs);
 29         sp = get_stack_pointer(tsk, segv_regs);
 30 
 31         frame = (struct stack_frame *)bp;
 32         while (((long) sp & (THREAD_SIZE-1)) != 0) {
 33                 addr = *sp;
 34                 if (__kernel_text_address(addr)) {
 35                         reliable = 0;
 36                         if ((unsigned long) sp == bp + sizeof(long)) {
 37                                 frame = frame ? frame->next_frame : NULL;
 38                                 bp = (unsigned long)frame;
 39                                 reliable = 1;
 40                         }
 41                         ops->address(data, addr, reliable);
 42                 }
 43                 sp++;
 44         }
 45 }
 46 
 47 static void save_addr(void *data, unsigned long address, int reliable)
 48 {
 49         struct stack_trace *trace = data;
 50 
 51         if (!reliable)
 52                 return;
 53         if (trace->nr_entries >= trace->max_entries)
 54                 return;
 55 
 56         trace->entries[trace->nr_entries++] = address;
 57 }
 58 
 59 static const struct stacktrace_ops dump_ops = {
 60         .address = save_addr
 61 };
 62 
 63 static void __save_stack_trace(struct task_struct *tsk, struct stack_trace *trace)
 64 {
 65         dump_trace(tsk, &dump_ops, trace);
 66         if (trace->nr_entries < trace->max_entries)
 67                 trace->entries[trace->nr_entries++] = ULONG_MAX;
 68 }
 69 
 70 void save_stack_trace(struct stack_trace *trace)
 71 {
 72         __save_stack_trace(current, trace);
 73 }
 74 EXPORT_SYMBOL_GPL(save_stack_trace);
 75 
 76 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 77 {
 78         __save_stack_trace(tsk, trace);
 79 }
 80 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
 81 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp