Chinaunix首页 | 论坛 | 博客
  • 博客访问: 33229
  • 博文数量: 15
  • 博客积分: 351
  • 博客等级: 一等列兵
  • 技术积分: 105
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-22 12:34
文章分类

全部博文(15)

文章存档

2011年(15)

我的朋友

分类: LINUX

2011-02-27 21:35:10



From:  Arjan van de Ven
To:  linux-kernel@vger.kernel.org
Subject:  [patch] Add a simple backtrace test module
Date:  Wed, 9 Jan 2008 22:42:08 -0800
Message-ID:  <20080109224208.541a659f@laptopd505.fenrus.org>
Cc:  mingo@elte.hu

Subject: Add a simple backtrace test module
From: Arjan van de Ven

During the work on the x86 32 and 64 bit backtrace code I found it useful
to have a simple test module to test a process and irq context backtrace.
Since the existing backtrace code was buggy, I figure it might be useful
to have such a test module in the kernel so that maybe we can even
detect such bugs earlier..

Signed-off-by: Arjan van de Ven

  1. ---
  2.  kernel/Makefile | 1 +
  3.  kernel/backtracetest.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
  4.  lib/Kconfig.debug | 12 ++++++++++++
  5.  3 files changed, 60 insertions(+)

  6. Index: linux-2.6.24-rc7/kernel/Makefile
  7. ===================================================================
  8. --- linux-2.6.24-rc7.orig/kernel/Makefile
  9. +++ linux-2.6.24-rc7/kernel/Makefile
  10. @@ -52,6 +52,7 @@ obj-$(CONFIG_DETECT_SOFTLOCKUP) += softl
  11.  obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
  12.  obj-$(CONFIG_SECCOMP) += seccomp.o
  13.  obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
  14. +obj-$(BACKTRACE_SELF_TEST) += backtracetest.o
  15.  obj-$(CONFIG_RELAY) += relay.o
  16.  obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
  17.  obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
  18. Index: linux-2.6.24-rc7/kernel/backtracetest.c
  19. ===================================================================
  20. --- /dev/null
  21. +++ linux-2.6.24-rc7/kernel/backtracetest.c
  22. @@ -0,0 +1,47 @@
  23. +/*
  24. + * Simple stack backtrace regression test module
  25. + *
  26. + * (C) Copyright 2008 Intel Corporation
  27. + * Author: Arjan van de Ven
  28. + *
  29. + * This program is free software; you can redistribute it and/or
  30. + * modify it under the terms of the GNU General Public License
  31. + * as published by the Free Software Foundation; version 2
  32. + * of the License.
  33. + */
  34. +
  35. +#include <linux/module.h>
  36. +#include <linux/sched.h>
  37. +
  38. +static struct timer_list backtrace_timer;
  39. +
  40. +static void backtrace_test_timer(unsigned long data)
  41. +{
  42. +    printk("Testing a backtrace from irq context.\n");
  43. +    printk("The following trace is a kernel self test and not a bug!\n");
  44. +    dump_stack();
  45. +}
  46. +static int backtrace_regression_test(void)
  47. +{
  48. +    printk("====[ backtrace testing ]===========\n");
  49. +    printk("Testing a backtrace from process context.\n");
  50. +    printk("The following trace is a kernel self test and not a bug!\n");
  51. +    dump_stack();
  52. +
  53. +    init_timer(&backtrace_timer);
  54. +    backtrace_timer.function = backtrace_test_timer;
  55. +    mod_timer(&backtrace_timer, jiffies + 10);
  56. +
  57. +    msleep(10);
  58. +    printk("====[ end of backtrace testing ]====\n");
  59. +    return 0;
  60. +}
  61. +
  62. +static void exitf(void)
  63. +{
  64. +}
  65. +
  66. +module_init(backtrace_regression_test);
  67. +module_exit(exitf);
  68. +MODULE_LICENSE("GPL");
  69. +MODULE_AUTHOR("Arjan van de Ven ");
  70. Index: linux-2.6.24-rc7/lib/Kconfig.debug
  71. ===================================================================
  72. --- linux-2.6.24-rc7.orig/lib/Kconfig.debug
  73. +++ linux-2.6.24-rc7/lib/Kconfig.debug
  74. @@ -462,6 +462,18 @@ config RCU_TORTURE_TEST
  75.       Say M if you want the RCU torture tests to build as a module.
  76.       Say N if you are unsure.
  77.  
  78. +config BACKTRACE_SELF_TEST
  79. +    tristate "Self test for the backtrace code"
  80. +    depends on DEBUG_KERNEL
  81. +    default n
  82. +    help
  83. +     This option provides a kernel module that can be used to test
  84. +     the kernel stack backtrace code. This option is not useful
  85. +     for distributions or general kernels, but only for kernel
  86. +     developers working on architecture code.
  87. +
  88. +     Say N if you are unsure.
  89. +
  90.  config LKDTM
  91.      tristate "Linux Kernel Dump Test Tool Module"
  92.      depends on DEBUG_KERNEL


--
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings,
visit
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at
Please read the FAQ at


阅读(616) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~